81f209d71e
Adds support for ACL Roles and Service Identities CRUD, along with necessary changes to Tokens, and the CSS improvements required. Also includes refinements/improvements for easier testing of deeply nested components. 1. ember-data adapter/serializer/model triplet for Roles 2. repository, form/validations and searching filter for Roles 3. Moves potentially, repeated, or soon to to repeated functionality into a mixin (mainly for 'many policy' relationships) 4. A few styling tweaks for little edge cases around roles 5. Router additions, Route, Controller and templates for Roles Also see: * UI: ACL Roles cont. plus Service Identities (#5661 and #5720)
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
import FormComponent from './form-component';
|
|
import { inject as service } from '@ember/service';
|
|
import { get, set } from '@ember/object';
|
|
|
|
export default FormComponent.extend({
|
|
repo: service('repository/policy/component'),
|
|
datacenterRepo: service('repository/dc/component'),
|
|
type: 'policy',
|
|
name: 'policy',
|
|
classNames: ['policy-form'],
|
|
|
|
isScoped: false,
|
|
init: function() {
|
|
this._super(...arguments);
|
|
set(this, 'isScoped', get(this, 'item.Datacenters.length') > 0);
|
|
set(this, 'datacenters', get(this, 'datacenterRepo').findAll());
|
|
this.templates = [
|
|
{
|
|
name: 'Policy',
|
|
template: '',
|
|
},
|
|
{
|
|
name: 'Service Identity',
|
|
template: 'service-identity',
|
|
},
|
|
];
|
|
},
|
|
actions: {
|
|
change: function(e) {
|
|
try {
|
|
this._super(...arguments);
|
|
} catch (err) {
|
|
const scoped = get(this, 'isScoped');
|
|
const name = err.target.name;
|
|
switch (name) {
|
|
case 'policy[isScoped]':
|
|
if (scoped) {
|
|
set(this, 'previousDatacenters', get(this.item, 'Datacenters'));
|
|
set(this.item, 'Datacenters', null);
|
|
} else {
|
|
set(this.item, 'Datacenters', get(this, 'previousDatacenters'));
|
|
set(this, 'previousDatacenters', null);
|
|
}
|
|
set(this, 'isScoped', !scoped);
|
|
break;
|
|
default:
|
|
this.onerror(err);
|
|
}
|
|
this.onchange({ target: get(this, 'form') });
|
|
}
|
|
},
|
|
},
|
|
});
|