vault/ui/lib/replication/addon/routes/application.js
claire bontempo 918642bd9c
UI: Ember deprecation prep for 5.0: ember-data:deprecate-array-like (#26170)
* remove .get() from cluster and vault route

* replace .get() use in adapters

* remove .get() from components part 1

* remove .get() from string-list

* remaining components

* controller .get() removal

* remove .get() use in mixins

* routes/cluster/access* .get() replacement

* policy index route

* routes/secrets/backend*

* route/cluster*

* serializers

* is-active-route

* remaining top-level addon gets

* replication get()

* revery change that broke things

* woops, revert other store service change

* revert some controller changes

* revert get on URLSearchParams class

* remove .sortBy ember method

* small cleanup items

* small cleanups from PR review
2024-03-28 12:13:33 -07:00

54 lines
1.3 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { service } from '@ember/service';
import { setProperties } from '@ember/object';
import { hash } from 'rsvp';
import Route from '@ember/routing/route';
import ClusterRoute from 'vault/mixins/cluster-route';
export default Route.extend(ClusterRoute, {
version: service(),
store: service(),
auth: service(),
router: service(),
beforeModel() {
if (this.auth.activeCluster.replicationRedacted) {
// disallow replication access if endpoints are redacted
return this.router.transitionTo('vault.cluster');
}
return this.version.fetchFeatures().then(() => {
return this._super(...arguments);
});
},
model() {
return this.auth.activeCluster;
},
afterModel(model) {
return hash({
canEnablePrimary: this.store
.findRecord('capabilities', 'sys/replication/primary/enable')
.then((c) => c.canUpdate),
canEnableSecondary: this.store
.findRecord('capabilities', 'sys/replication/secondary/enable')
.then((c) => c.canUpdate),
}).then(({ canEnablePrimary, canEnableSecondary }) => {
setProperties(model, {
canEnablePrimary,
canEnableSecondary,
});
return model;
});
},
actions: {
refresh() {
this.refresh();
},
},
});