vault/ui/lib/replication/addon/routes/mode.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

39 lines
1.1 KiB
JavaScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
import { service } from '@ember/service';
import { hash } from 'rsvp';
import { setProperties } from '@ember/object';
import Route from '@ember/routing/route';
const SUPPORTED_REPLICATION_MODES = ['dr', 'performance'];
export default Route.extend({
replicationMode: service(),
router: service('app-router'),
store: service(),
beforeModel() {
const replicationMode = this.paramsFor(this.routeName).replication_mode;
if (!SUPPORTED_REPLICATION_MODES.includes(replicationMode)) {
this.router.transitionTo('vault.cluster.replication.index');
}
},
model() {
const replicationMode = this.paramsFor(this.routeName).replication_mode;
this.replicationMode.setMode(replicationMode);
return this.modelFor('application');
},
afterModel(model) {
return hash({
// set new property on model to compare if the drMode changes when you are demoting the cluster
drModeInit: model.drMode,
}).then(({ drModeInit }) => {
setProperties(model, {
drModeInit,
});
return model;
});
},
});