mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 02:57:59 +00:00
* Update browserslist * Add browserslistrc * ember-cli-update --to 3.26, fix conflicts * Run codemodes that start with ember-* * More codemods - before cp* * More codemods (curly data-test-*) * WIP ember-basic-dropdown template errors * updates ember-basic-dropdown and related deps to fix build issues * updates basic dropdown instances to new version API * updates more deps -- ember-template-lint is working again * runs no-implicit-this codemod * creates and runs no-quoteless-attributes codemod * runs angle brackets codemod * updates lint:hbs globs to only touch hbs files * removes yield only templates * creates and runs deprecated args transform * supresses lint error for invokeAction on LinkTo component * resolves remaining ambiguous path lint errors * resolves simple-unless lint errors * adds warnings for deprecated tagName arg on LinkTo components * adds warnings for remaining curly component invocation * updates global template lint rules * resolves remaining template lint errors * disables some ember specfic lint rules that target pre octane patterns * js lint fix run * resolves remaining js lint errors * fixes test run * adds npm-run-all dep * fixes test attribute issues * fixes console acceptance tests * fixes tests * adds yield only wizard/tutorial-active template * fixes more tests * attempts to fix more flaky tests * removes commented out settled in transit test * updates deprecations workflow and adds initializer to filter by version * updates flaky policies acl old test * updates to flaky transit test * bumps ember deps down to LTS version * runs linters after main merge * fixes client count tests after bad merge conflict fixes * fixes client count history test * more updates to lint config * another round of hbs lint fixes after extending stylistic rule * updates lint-staged commands * removes indent eslint rule since it seems to break things * fixes bad attribute in transform-edit-form template * test fixes * fixes enterprise tests * adds changelog * removes deprecated ember-concurrency-test-waiters dep and adds @ember/test-waiters * flaky test fix Co-authored-by: hashishaw <cshaw@hashicorp.com>
143 lines
4.8 KiB
JavaScript
143 lines
4.8 KiB
JavaScript
import Component from '@ember/component';
|
|
import { computed } from '@ember/object';
|
|
import layout from '../templates/components/replication-page';
|
|
import { inject as service } from '@ember/service';
|
|
import { task } from 'ember-concurrency';
|
|
|
|
/**
|
|
* @module ReplicationPage
|
|
* The `ReplicationPage` component is the parent contextual component that holds the replication-dashboard, and various replication-<name>-card components.
|
|
* It is the top level component on routes displaying replication dashboards.
|
|
*
|
|
* @example
|
|
* ```js
|
|
* <ReplicationPage
|
|
@model={{cluster}}
|
|
/>
|
|
* ```
|
|
* @param {Object} cluster=null - An Ember data object that is pulled from the Ember Cluster Model.
|
|
*/
|
|
|
|
const MODE = {
|
|
dr: 'Disaster Recovery',
|
|
performance: 'Performance',
|
|
};
|
|
|
|
export default Component.extend({
|
|
layout,
|
|
store: service(),
|
|
router: service(),
|
|
reindexingDetails: null,
|
|
didReceiveAttrs() {
|
|
this._super(arguments);
|
|
this.getReplicationModeStatus.perform();
|
|
},
|
|
getReplicationModeStatus: task(function* () {
|
|
let resp;
|
|
const { replicationMode } = this.model;
|
|
|
|
if (this.isSummaryDashboard) {
|
|
// the summary dashboard is not mode specific and will error
|
|
// while running replication/null/status in the replication-mode adapter
|
|
return;
|
|
}
|
|
|
|
try {
|
|
resp = yield this.store.adapterFor('replication-mode').fetchStatus(replicationMode);
|
|
} catch (e) {
|
|
// do not handle error
|
|
}
|
|
this.set('reindexingDetails', resp);
|
|
}),
|
|
isSummaryDashboard: computed('model.{performance.mode,dr.mode}', function () {
|
|
const router = this.router;
|
|
const currentRoute = router.get('currentRouteName');
|
|
|
|
// we only show the summary dashboard in the replication index route
|
|
if (currentRoute === 'vault.cluster.replication.index') {
|
|
const drMode = this.model.dr.mode;
|
|
const performanceMode = this.model.performance.mode;
|
|
return drMode === 'primary' && performanceMode === 'primary';
|
|
}
|
|
return '';
|
|
}),
|
|
formattedReplicationMode: computed('model.replicationMode', 'isSummaryDashboard', function () {
|
|
// dr or performance 🤯
|
|
const { isSummaryDashboard } = this;
|
|
if (isSummaryDashboard) {
|
|
return 'Disaster Recovery & Performance';
|
|
}
|
|
const mode = this.model.replicationMode;
|
|
return MODE[mode];
|
|
}),
|
|
clusterMode: computed('model.replicationAttrs', 'isSummaryDashboard', function () {
|
|
// primary or secondary
|
|
const { model } = this;
|
|
const { isSummaryDashboard } = this;
|
|
if (isSummaryDashboard) {
|
|
// replicationAttrs does not exist when summaryDashboard
|
|
return 'primary';
|
|
}
|
|
return model.replicationAttrs.mode;
|
|
}),
|
|
isLoadingData: computed('clusterMode', 'model.replicationAttrs', function () {
|
|
const { clusterMode } = this;
|
|
const { model } = this;
|
|
const { isSummaryDashboard } = this;
|
|
if (isSummaryDashboard) {
|
|
return false;
|
|
}
|
|
const clusterId = model.replicationAttrs.clusterId;
|
|
const replicationDisabled = model.replicationAttrs.replicationDisabled;
|
|
if (clusterMode === 'bootstrapping' || (!clusterId && !replicationDisabled)) {
|
|
// if clusterMode is bootstrapping
|
|
// if no clusterId, the data hasn't loaded yet, wait for another status endpoint to be called
|
|
return true;
|
|
}
|
|
return false;
|
|
}),
|
|
isSecondary: computed('clusterMode', function () {
|
|
const { clusterMode } = this;
|
|
return clusterMode === 'secondary';
|
|
}),
|
|
replicationDetailsSummary: computed('isSummaryDashboard', function () {
|
|
const { model } = this;
|
|
const { isSummaryDashboard } = this;
|
|
if (!isSummaryDashboard) {
|
|
return;
|
|
}
|
|
if (isSummaryDashboard) {
|
|
let combinedObject = {};
|
|
combinedObject.dr = model['dr'];
|
|
combinedObject.performance = model['performance'];
|
|
return combinedObject;
|
|
}
|
|
return {};
|
|
}),
|
|
replicationDetails: computed('model.replicationMode', 'isSummaryDashboard', function () {
|
|
const { model } = this;
|
|
const { isSummaryDashboard } = this;
|
|
if (isSummaryDashboard) {
|
|
// Cannot return null
|
|
return {};
|
|
}
|
|
const replicationMode = model.replicationMode;
|
|
return model[replicationMode];
|
|
}),
|
|
isDisabled: computed('replicationDetails.mode', function () {
|
|
if (this.replicationDetails.mode === 'disabled' || this.replicationDetails.mode === 'primary') {
|
|
return true;
|
|
}
|
|
return false;
|
|
}),
|
|
message: computed('model.anyReplicationEnabled', 'formattedReplicationMode', function () {
|
|
let msg;
|
|
if (this.model.anyReplicationEnabled) {
|
|
msg = `This ${this.formattedReplicationMode} secondary has not been enabled. You can do so from the ${this.formattedReplicationMode} Primary.`;
|
|
} else {
|
|
msg = `This cluster has not been enabled as a ${this.formattedReplicationMode} Secondary. You can do so by enabling replication and adding a secondary from the ${this.formattedReplicationMode} Primary.`;
|
|
}
|
|
return msg;
|
|
}),
|
|
});
|