vault/ui/lib/replication/addon/routes/mode/secondaries.js
Vault Automation 0c6c13dd38
license: update headers to IBM Corp. (#10229) (#10233)
* license: update headers to IBM Corp.
* `make proto`
* update offset because source file changed

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
2025-10-21 15:20:20 -06:00

40 lines
1.3 KiB
JavaScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
import { setProperties } from '@ember/object';
import { hash } from 'rsvp';
import Route from '@ember/routing/route';
import { service } from '@ember/service';
export default Route.extend({
router: service('app-router'),
store: service(),
model() {
const replicationMode = this.paramsFor('mode').replication_mode;
return hash({
cluster: this.modelFor('mode'),
canAddSecondary: this.store
.findRecord('capabilities', `sys/replication/${replicationMode}/primary/secondary-token`)
.then((c) => c.canUpdate),
canRevokeSecondary: this.store
.findRecord('capabilities', `sys/replication/${replicationMode}/primary/revoke-secondary`)
.then((c) => c.canUpdate),
}).then(({ cluster, canAddSecondary, canRevokeSecondary }) => {
setProperties(cluster, {
canRevokeSecondary,
canAddSecondary,
});
return cluster;
});
},
afterModel(model) {
const replicationMode = this.paramsFor('mode').replication_mode;
const modeModel = model[replicationMode];
if (!modeModel.isPrimary || modeModel.replicationDisabled || modeModel.replicationUnsupported) {
this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
}
},
});