mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-22 23:21:08 +02:00
* use alias for router injection * update @router declarations in engine files * fix remaining pki router imports * dynamically set router based on owner * address replication routers * update markdown docs * use non-deprecated import for getOwner * revert out of scope changes * add transition-to test
40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* 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;
|
|
});
|
|
},
|
|
});
|