Files
vault/ui/lib/replication/addon/routes/mode/manage.js
hashicorp-copywrite[bot] 0b12cdcfd1 [COMPLIANCE] License changes (#22290)
* 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 https://hashi.co/bsl-blog, 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 BUS-1.1

* Fix test that expected exact offset on hcl file

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Sarah Thompson <sthompson@hashicorp.com>
Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
2023-08-10 18:14:03 -07:00

53 lines
1.6 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { camelize } from '@ember/string';
import { all } from 'rsvp';
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import { replicationActionForMode } from 'replication/helpers/replication-action-for-mode';
const pathForAction = (action, replicationMode, clusterMode) => {
let path;
if (action === 'reindex' || action === 'recover') {
path = `sys/replication/${action}`;
} else {
path = `sys/replication/${replicationMode}/${clusterMode}/${action}`;
}
return path;
};
export default Route.extend({
store: service(),
model() {
const store = this.store;
const model = this.modelFor('mode');
const replicationMode = this.paramsFor('mode').replication_mode;
const clusterMode = model.get(replicationMode).get('modeForUrl');
const actions = replicationActionForMode([replicationMode, clusterMode]);
return all(
actions.map((action) => {
return store.findRecord('capabilities', pathForAction(action)).then((capability) => {
model.set(`can${camelize(action)}`, capability.get('canUpdate'));
});
})
).then(() => {
return model;
});
},
beforeModel() {
const model = this.modelFor('mode');
const replicationMode = this.paramsFor('mode').replication_mode;
if (
model.get(replicationMode).get('replicationDisabled') ||
model.get(replicationMode).get('replicationUnsupported')
) {
return this.transitionTo('mode', replicationMode);
}
},
});