mirror of
https://github.com/status-im/consul.git
synced 2025-01-12 06:44:41 +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>
58 lines
1.4 KiB
JavaScript
58 lines
1.4 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Service, { inject as service } from '@ember/service';
|
|
import builderFactory from 'consul-ui/utils/form/builder';
|
|
|
|
import kv from 'consul-ui/forms/kv';
|
|
import token from 'consul-ui/forms/token';
|
|
import policy from 'consul-ui/forms/policy';
|
|
import role from 'consul-ui/forms/role';
|
|
import intention from 'consul-ui/forms/intention';
|
|
|
|
const builder = builderFactory();
|
|
|
|
const forms = {
|
|
kv: kv,
|
|
token: token,
|
|
policy: policy,
|
|
role: role,
|
|
intention: intention,
|
|
};
|
|
|
|
export default class FormService extends Service {
|
|
// a `get` method is added via the form initializer
|
|
// see initializers/form.js
|
|
|
|
// TODO: Temporarily add these here until something else needs
|
|
// dynamic repos
|
|
@service('repository/role') role;
|
|
@service('repository/policy') policy;
|
|
//
|
|
forms = [];
|
|
|
|
build(obj, name) {
|
|
return builder(...arguments);
|
|
}
|
|
|
|
form(name) {
|
|
let form = this.forms[name];
|
|
if (typeof form === 'undefined') {
|
|
form = this.forms[name] = forms[name](this);
|
|
// only do special things for our new things for the moment
|
|
if (name === 'role' || name === 'policy') {
|
|
const repo = this[name];
|
|
form.clear(function (obj) {
|
|
return repo.create(obj);
|
|
});
|
|
form.submit(function (obj) {
|
|
return repo.persist(obj);
|
|
});
|
|
}
|
|
}
|
|
return form;
|
|
}
|
|
}
|