vault/ui/lib/replication/addon/routes/application.js
Vault Automation 2eb6905459
UI: remove cluster route and model boundary route mixins (#11873) (#12025)
* 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>
2026-01-29 11:02:04 -06:00

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;
}
}