mirror of
https://github.com/hashicorp/vault.git
synced 2026-05-28 04:10:44 -04:00
* remove cluster route and model boundary route mixins * add copyright header * remove old unit test * change replication/application route * don't use cluster route in replication * why have a base class at all? * test tweaks * remove afterModel redirect in replication * refactor targetRouteName to use derived state * Update route class name on replication-dr-promote.js --------- Co-authored-by: Matthew Irish <39469+meirish@users.noreply.github.com> Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
/**
|
|
* Copyright IBM Corp. 2016, 2025
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import { service } from '@ember/service';
|
|
import Route from '@ember/routing/route';
|
|
|
|
export default class ApplicationRoute extends Route {
|
|
@service version;
|
|
@service store;
|
|
@service auth;
|
|
@service('app-router') router;
|
|
@service capabilities;
|
|
|
|
async fetchCapabilities() {
|
|
const enablePath = (type, cluster) => `sys/replication/${type}/${cluster}/enable`;
|
|
const perms = await this.capabilities.fetch([
|
|
enablePath('dr', 'primary'),
|
|
enablePath('dr', 'primary'),
|
|
enablePath('performance', 'secondary'),
|
|
enablePath('performance', 'secondary'),
|
|
]);
|
|
return {
|
|
canEnablePrimaryDr: perms[enablePath('dr', 'primary')].canUpdate,
|
|
canEnableSecondaryDr: perms[enablePath('dr', 'primary')].canUpdate,
|
|
canEnablePrimaryPerformance: perms[enablePath('performance', 'secondary')].canUpdate,
|
|
canEnableSecondaryPerformance: perms[enablePath('performance', 'secondary')].canUpdate,
|
|
};
|
|
}
|
|
|
|
beforeModel() {
|
|
if (this.auth.activeCluster.replicationRedacted) {
|
|
// disallow replication access if endpoints are redacted
|
|
return this.router.transitionTo('vault.cluster');
|
|
}
|
|
return this.version.fetchFeatures();
|
|
}
|
|
|
|
model() {
|
|
return this.auth.activeCluster;
|
|
}
|
|
|
|
async afterModel(model) {
|
|
const {
|
|
canEnablePrimaryDr,
|
|
canEnableSecondaryDr,
|
|
canEnablePrimaryPerformance,
|
|
canEnableSecondaryPerformance,
|
|
} = await this.fetchCapabilities();
|
|
|
|
model.canEnablePrimaryDr = canEnablePrimaryDr;
|
|
model.canEnableSecondaryDr = canEnableSecondaryDr;
|
|
model.canEnablePrimaryPerformance = canEnablePrimaryPerformance;
|
|
model.canEnableSecondaryPerformance = canEnableSecondaryPerformance;
|
|
return model;
|
|
}
|
|
}
|