mirror of https://github.com/rancher/ui.git
75 lines
2.0 KiB
JavaScript
75 lines
2.0 KiB
JavaScript
import { alias } from '@ember/object/computed';
|
|
import { inject as service } from '@ember/service';
|
|
// import { all as PromiseAll } from 'rsvp';
|
|
import Component from '@ember/component';
|
|
// import NewOrEdit from 'ui/mixins/new-or-edit';
|
|
import layout from './template';
|
|
import { get, set, computed/* , setProperties */} from '@ember/object';
|
|
import NewOrEdit from 'ui/mixins/new-or-edit';
|
|
import ChildHook from 'shared/mixins/child-hook';
|
|
|
|
const M_CONFIG = {
|
|
type: 'projectRoleTemplateBinding',
|
|
subjectKind: '',
|
|
userId: '',
|
|
projectRoleTemplateId: '',
|
|
projectId: '',
|
|
};
|
|
|
|
export default Component.extend(NewOrEdit, ChildHook, {
|
|
layout,
|
|
intl: service(),
|
|
router: service(),
|
|
globalStore: service(),
|
|
memberConfig: M_CONFIG,
|
|
model: null,
|
|
primaryResource: alias('model.project'),
|
|
secPolicy: alias('model.project.defaultPodSecurityPolicyTemplateId'),
|
|
policies: alias('model.policies'),
|
|
creator: computed('primaryResource.creatorId', function() {
|
|
let cid = get(this, 'primaryResource.creatorId');
|
|
let creator = null;
|
|
|
|
if (get(this, 'editing')) {
|
|
let users = get(this, 'model.users');
|
|
creator = users.findBy('id', cid)||users.findBy('username', cid); //TODO 2.0 must do because first clusters and projects are given admin as the creator id which is not the admins userid
|
|
} else {
|
|
creator = get(this, 'model.me');
|
|
}
|
|
return creator;
|
|
}),
|
|
|
|
actions: {
|
|
cancel() {
|
|
this.goBack();
|
|
},
|
|
|
|
expandFn() {
|
|
},
|
|
},
|
|
|
|
init() {
|
|
this._super(...arguments);
|
|
let bindings = (get(this,'model.project.projectRoleTemplateBindings')||[]).slice();
|
|
bindings = bindings.filter(x =>get(x, 'name') !== 'creator');
|
|
set(this, 'memberArray', bindings);
|
|
},
|
|
|
|
goBack() {
|
|
get(this, 'router').transitionTo('authenticated.cluster.projects.index');
|
|
},
|
|
|
|
didSave() {
|
|
const pr = get(this, 'primaryResource');
|
|
return pr.waitForCondition('BackingNamespaceCreated').then(() => {
|
|
return this.applyHooks().then(() => {
|
|
return pr;
|
|
});
|
|
});
|
|
},
|
|
|
|
doneSaving() {
|
|
this.goBack();
|
|
},
|
|
});
|