refactor global resource memeber access

pass the access types down rather that own the access types and manipulate

rancher/rancher#18938
This commit is contained in:
Westly Wright 2019-03-25 11:55:59 -07:00
parent 25e54fae82
commit ff1d1e56c4
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
6 changed files with 34 additions and 33 deletions

View File

@ -26,6 +26,7 @@ export default Controller.extend(ViewNewEdit, {
scope: service(),
queryParams: ['id'],
memberAccessTypes: ['owner'],
id: null,
errros: null,

View File

@ -187,7 +187,7 @@
expand=(action expandFn)
}}
{{form-members-global-access
excludeMember=true
optionsForAccessType=memberAccessTypes
readOnly=false
resource=model.globaldns
addAuthorizedPrincipal=(action "addAuthorizedPrincipal")

View File

@ -11,6 +11,7 @@ export default Controller.extend(ViewNewEdit, {
globalStore: service(),
queryParams: ['id', 'activeProvider'],
memberAccessTypes: ['owner', 'read-only'],
id: null,
activeProvider: 'route53',

View File

@ -54,7 +54,7 @@
expand=(action expandFn)
}}
{{form-members-global-access
excludeMember=true
optionsForAccessType=memberAccessTypes
readOnly=false
resource=model
addAuthorizedPrincipal=(action "addAuthorizedPrincipal")

View File

@ -22,18 +22,18 @@ const MEMBERS_HEADERS = [
];
export default Component.extend({
globalStore: service(),
globalStore: service(),
layout,
membersHeaders: MEMBERS_HEADERS,
sortBy: '',
descending: false,
excludeMember: false,
resource: null,
gotError: null,
removeMember: null,
optionsForAccessType: null,
membersHeaders: MEMBERS_HEADERS,
sortBy: '',
descending: false,
excludeMember: false,
resource: null,
gotError: null,
removeMember: null,
optionsForAccessType: null,
init() {
this._super(...arguments);
@ -69,13 +69,8 @@ export default Component.extend({
},
initOptionsForMembersAccessType() {
let accessTypes = this.globalStore.getById('schema', 'member').optionsFor('accessType') || [];
let accessTypes = this.optionsForAccessType || this.globalStore.getById('schema', 'member').optionsFor('accessType');
if (this.excludeMember) {
accessTypes = accessTypes.without('member');
}
set(this, 'optionsForAccessType', accessTypes);
return;
return set(this, 'optionsForAccessType', accessTypes);
},
});

View File

@ -30,21 +30,25 @@
{{member.displayType}}
</td>
<td data-title="{{dt.accessType}}:">
<select
class="form-control"
onchange={{action (mut member.accessType) value="target.value"}}
>
{{#unless (eq member.accessType "")}}
<option value="" selected=true>
{{t "formMembersGlobalAccess.table.prompt"}}
</option>
{{/unless}}
{{#each optionsForAccessType as |choice|}}
<option value="{{choice}}" selected={{eq choice member.accessType}}>
{{choice}}
</option>
{{/each}}
</select>
{{#if (gt optionsForAccessType.length 1)}}
<select
class="form-control"
onchange={{action (mut member.accessType) value="target.value"}}
>
{{#unless (eq member.accessType "")}}
<option value="" selected=true>
{{t "formMembersGlobalAccess.table.prompt"}}
</option>
{{/unless}}
{{#each optionsForAccessType as |choice|}}
<option value="{{choice}}" selected={{eq choice member.accessType}}>
{{choice}}
</option>
{{/each}}
</select>
{{else}}
{{member.accessType}}
{{/if}}
</td>
<td data-title="{{t "generic.actions"}}:" class="actions">
<div class="p-5">