c98130cc08
* ui: Add the most basic workspace root in /ui * We already have a LICENSE file in the repository root * Change directory path in build scripts ui-v2 -> ui * Make yarn install flags configurable from elsewhere * Minimal workspace root makefile * Call the new docker specific target * Update yarn in the docker build image * Reconfigure the netlify target and move to the higher makefile * Move ui-v2 -> ui/packages/consul-ui * Change repo root to refleect new folder structure * Temporarily don't hoist consul-api-double * Fixup CI configuration * Fixup lint errors * Fixup Netlify target
55 lines
1.4 KiB
JavaScript
55 lines
1.4 KiB
JavaScript
import FormComponent from '../form-component/index';
|
|
import { get, set } from '@ember/object';
|
|
|
|
export default FormComponent.extend({
|
|
type: 'policy',
|
|
name: 'policy',
|
|
allowIdentity: true,
|
|
classNames: ['policy-form'],
|
|
|
|
isScoped: false,
|
|
init: function() {
|
|
this._super(...arguments);
|
|
set(this, 'isScoped', get(this, 'item.Datacenters.length') > 0);
|
|
this.templates = [
|
|
{
|
|
name: 'Policy',
|
|
template: '',
|
|
},
|
|
{
|
|
name: 'Service Identity',
|
|
template: 'service-identity',
|
|
},
|
|
{
|
|
name: 'Node Identity',
|
|
template: 'node-identity',
|
|
},
|
|
];
|
|
},
|
|
actions: {
|
|
change: function(e) {
|
|
try {
|
|
this._super(...arguments);
|
|
} catch (err) {
|
|
const scoped = 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', this.previousDatacenters);
|
|
set(this, 'previousDatacenters', null);
|
|
}
|
|
set(this, 'isScoped', !scoped);
|
|
break;
|
|
default:
|
|
this.onerror(err);
|
|
}
|
|
this.onchange({ target: this.form });
|
|
}
|
|
},
|
|
},
|
|
});
|