mirror of
https://github.com/status-im/consul.git
synced 2025-01-25 05:00:32 +00:00
5fb9df1640
* Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at <Blog URL>, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 * Update copyright file headers to BUSL-1.1 --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
78 lines
2.0 KiB
JavaScript
78 lines
2.0 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import ChildSelectorComponent from '../child-selector/index';
|
|
import { set } from '@ember/object';
|
|
import { inject as service } from '@ember/service';
|
|
|
|
const ERROR_PARSE_RULES = 'Failed to parse ACL rules';
|
|
const ERROR_INVALID_POLICY = 'Invalid service policy';
|
|
const ERROR_NAME_EXISTS = 'Invalid Policy: A Policy with Name';
|
|
|
|
export default ChildSelectorComponent.extend({
|
|
repo: service('repository/policy'),
|
|
name: 'policy',
|
|
type: 'policy',
|
|
allowIdentity: true,
|
|
classNames: ['policy-selector'],
|
|
init: function () {
|
|
this._super(...arguments);
|
|
const source = this.source;
|
|
if (source) {
|
|
this._listeners.add(source, {
|
|
save: (e) => {
|
|
this.save.perform(...e.data);
|
|
},
|
|
});
|
|
}
|
|
},
|
|
reset: function (e) {
|
|
this._super(...arguments);
|
|
set(this, 'isScoped', false);
|
|
},
|
|
refreshCodeEditor: function (e, target) {
|
|
const selector = '.code-editor';
|
|
this.dom.component(selector, target).didAppear();
|
|
},
|
|
error: function (e) {
|
|
const item = this.item;
|
|
const err = e.error;
|
|
if (typeof err.errors !== 'undefined') {
|
|
const error = err.errors[0];
|
|
let prop = 'Rules';
|
|
let message = error.detail;
|
|
switch (true) {
|
|
case message.indexOf(ERROR_PARSE_RULES) === 0:
|
|
case message.indexOf(ERROR_INVALID_POLICY) === 0:
|
|
prop = 'Rules';
|
|
message = error.detail;
|
|
break;
|
|
case message.indexOf(ERROR_NAME_EXISTS) === 0:
|
|
prop = 'Name';
|
|
message = message.substr(ERROR_NAME_EXISTS.indexOf(':') + 1);
|
|
break;
|
|
}
|
|
if (prop) {
|
|
item.addError(prop, message);
|
|
}
|
|
} else {
|
|
// TODO: Conponents can't throw, use onerror
|
|
throw err;
|
|
}
|
|
},
|
|
openModal: function () {
|
|
const { modal } = this;
|
|
|
|
if (modal) {
|
|
modal.open();
|
|
}
|
|
},
|
|
actions: {
|
|
open: function (e) {
|
|
this.refreshCodeEditor(e, e.target.parentElement);
|
|
},
|
|
},
|
|
});
|