mirror of
https://github.com/hashicorp/vault.git
synced 2025-12-03 00:21:11 +01:00
* remove .get() from cluster and vault route * replace .get() use in adapters * remove .get() from components part 1 * remove .get() from string-list * remaining components * controller .get() removal * remove .get() use in mixins * routes/cluster/access* .get() replacement * policy index route * routes/secrets/backend* * route/cluster* * serializers * is-active-route * remaining top-level addon gets * replication get() * revery change that broke things * woops, revert other store service change * revert some controller changes * revert get on URLSearchParams class * remove .sortBy ember method * small cleanup items * small cleanups from PR review
52 lines
1.6 KiB
JavaScript
52 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 { 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({
|
|
router: service(),
|
|
store: service(),
|
|
model() {
|
|
const store = this.store;
|
|
const model = this.modelFor('mode');
|
|
|
|
const replicationMode = this.paramsFor('mode').replication_mode;
|
|
const clusterMode = model[replicationMode].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.canUpdate);
|
|
});
|
|
})
|
|
).then(() => {
|
|
return model;
|
|
});
|
|
},
|
|
|
|
beforeModel() {
|
|
const model = this.modelFor('mode');
|
|
const replicationMode = this.paramsFor('mode').replication_mode;
|
|
const modeModel = model[replicationMode];
|
|
if (modeModel.replicationDisabled || modeModel.replicationUnsupported) {
|
|
this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
|
}
|
|
},
|
|
});
|