mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-10-30 18:17:55 +00:00
UI: Ember deprecations - replication engine transitionTo (#25686)
* Replace transitionToRoute on replication-mode controller (tests passing) * Fix create config toolbar link * Replace transitionToRoute in replication controllers * Replace some transitionTo in routes * replace route transitionTo + stabilize tests * Last transition + test fixes * stabilize DR primary test
This commit is contained in:
@@ -10,6 +10,7 @@ import Controller from '@ember/controller';
|
|||||||
import { copy } from 'ember-copy';
|
import { copy } from 'ember-copy';
|
||||||
import { resolve } from 'rsvp';
|
import { resolve } from 'rsvp';
|
||||||
import decodeConfigFromJWT from 'replication/utils/decode-config-from-jwt';
|
import decodeConfigFromJWT from 'replication/utils/decode-config-from-jwt';
|
||||||
|
import { buildWaiter } from '@ember/test-waiters';
|
||||||
|
|
||||||
const DEFAULTS = {
|
const DEFAULTS = {
|
||||||
token: null,
|
token: null,
|
||||||
@@ -23,11 +24,13 @@ const DEFAULTS = {
|
|||||||
paths: [],
|
paths: [],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
const waiter = buildWaiter('replication-actions');
|
||||||
|
|
||||||
export default Controller.extend(copy(DEFAULTS, true), {
|
export default Controller.extend(copy(DEFAULTS, true), {
|
||||||
isModalActive: false,
|
isModalActive: false,
|
||||||
isTokenCopied: false,
|
isTokenCopied: false,
|
||||||
expirationDate: null,
|
expirationDate: null,
|
||||||
|
router: service(),
|
||||||
store: service(),
|
store: service(),
|
||||||
rm: service('replication-mode'),
|
rm: service('replication-mode'),
|
||||||
replicationMode: alias('rm.mode'),
|
replicationMode: alias('rm.mode'),
|
||||||
@@ -87,6 +90,7 @@ export default Controller.extend(copy(DEFAULTS, true), {
|
|||||||
},
|
},
|
||||||
|
|
||||||
submitHandler(action, clusterMode, data, event) {
|
submitHandler(action, clusterMode, data, event) {
|
||||||
|
const waiterToken = waiter.beginAsync();
|
||||||
const replicationMode = this.replicationMode;
|
const replicationMode = this.replicationMode;
|
||||||
if (event && event.preventDefault) {
|
if (event && event.preventDefault) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -116,7 +120,10 @@ export default Controller.extend(copy(DEFAULTS, true), {
|
|||||||
},
|
},
|
||||||
(...args) => this.submitError(...args)
|
(...args) => this.submitError(...args)
|
||||||
)
|
)
|
||||||
.finally(() => this.set('secondaryToRevoke', null));
|
.finally(() => {
|
||||||
|
this.set('secondaryToRevoke', null);
|
||||||
|
waiter.endAsync(waiterToken);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
@@ -125,7 +132,7 @@ export default Controller.extend(copy(DEFAULTS, true), {
|
|||||||
},
|
},
|
||||||
closeTokenModal() {
|
closeTokenModal() {
|
||||||
this.toggleProperty('isModalActive');
|
this.toggleProperty('isModalActive');
|
||||||
this.transitionToRoute('mode.secondaries');
|
this.router.transitionTo('vault.cluster.replication.mode.secondaries');
|
||||||
this.set('isTokenCopied', false);
|
this.set('isTokenCopied', false);
|
||||||
},
|
},
|
||||||
onCopy() {
|
onCopy() {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import Controller from '@ember/controller';
|
|||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
flashMessages: service(),
|
flashMessages: service(),
|
||||||
|
router: service(),
|
||||||
rm: service('replication-mode'),
|
rm: service('replication-mode'),
|
||||||
replicationMode: alias('rm.mode'),
|
replicationMode: alias('rm.mode'),
|
||||||
actions: {
|
actions: {
|
||||||
@@ -29,14 +30,15 @@ export default Controller.extend({
|
|||||||
const flash = this.flashMessages;
|
const flash = this.flashMessages;
|
||||||
const id = config.id;
|
const id = config.id;
|
||||||
const redirectArgs = isDelete
|
const redirectArgs = isDelete
|
||||||
? ['mode.secondaries', this.replicationMode]
|
? ['vault.cluster.replication.mode.secondaries', this.replicationMode]
|
||||||
: ['mode.secondaries.config-show', id];
|
: ['vault.cluster.replication.mode.secondaries.config-show', id];
|
||||||
const modelMethod = isDelete ? config.destroyRecord : config.save;
|
const modelMethod = isDelete ? config.destroyRecord : config.save;
|
||||||
|
|
||||||
modelMethod
|
modelMethod
|
||||||
.call(config)
|
.call(config)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.transitionToRoute(...redirectArgs)
|
this.router
|
||||||
|
.transitionTo(...redirectArgs)
|
||||||
.followRedirects()
|
.followRedirects()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
flash.success(
|
flash.success(
|
||||||
|
|||||||
@@ -9,26 +9,27 @@ import Controller from '@ember/controller';
|
|||||||
import { task, timeout } from 'ember-concurrency';
|
import { task, timeout } from 'ember-concurrency';
|
||||||
|
|
||||||
export default Controller.extend({
|
export default Controller.extend({
|
||||||
|
router: service(),
|
||||||
rm: service('replication-mode'),
|
rm: service('replication-mode'),
|
||||||
replicationMode: alias('rm.mode'),
|
replicationMode: alias('rm.mode'),
|
||||||
waitForNewClusterToInit: task(function* (replicationMode) {
|
waitForNewClusterToInit: task(function* (replicationMode) {
|
||||||
// waiting for the newly enabled cluster to init
|
// waiting for the newly enabled cluster to init
|
||||||
// this ensures we don't hit a capabilities-self error, called in the model of the mode/index route
|
// this ensures we don't hit a capabilities-self error, called in the model of the mode/index route
|
||||||
yield timeout(1000);
|
yield timeout(1000);
|
||||||
return this.transitionToRoute('mode', replicationMode);
|
this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
onEnable(replicationMode, mode) {
|
onEnable(replicationMode, mode) {
|
||||||
if (replicationMode == 'dr' && mode === 'secondary') {
|
if (replicationMode == 'dr' && mode === 'secondary') {
|
||||||
return this.transitionToRoute('vault.cluster');
|
this.router.transitionTo('vault.cluster');
|
||||||
} else if (replicationMode === 'dr') {
|
} else if (replicationMode === 'dr') {
|
||||||
return this.transitionToRoute('mode', replicationMode);
|
this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||||
} else {
|
} else {
|
||||||
this.waitForNewClusterToInit.perform(replicationMode);
|
this.waitForNewClusterToInit.perform(replicationMode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onDisable() {
|
onDisable() {
|
||||||
return this.transitionToRoute('index');
|
this.router.transitionTo('vault.cluster.replication.index');
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,11 +12,12 @@ const SUPPORTED_REPLICATION_MODES = ['dr', 'performance'];
|
|||||||
|
|
||||||
export default Route.extend({
|
export default Route.extend({
|
||||||
replicationMode: service(),
|
replicationMode: service(),
|
||||||
|
router: service(),
|
||||||
store: service(),
|
store: service(),
|
||||||
beforeModel() {
|
beforeModel() {
|
||||||
const replicationMode = this.paramsFor(this.routeName).replication_mode;
|
const replicationMode = this.paramsFor(this.routeName).replication_mode;
|
||||||
if (!SUPPORTED_REPLICATION_MODES.includes(replicationMode)) {
|
if (!SUPPORTED_REPLICATION_MODES.includes(replicationMode)) {
|
||||||
return this.transitionTo('index');
|
this.router.transitionTo('vault.cluster.replication.index');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
model() {
|
model() {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import Route from '@ember/routing/route';
|
|||||||
import { service } from '@ember/service';
|
import { service } from '@ember/service';
|
||||||
|
|
||||||
export default Route.extend({
|
export default Route.extend({
|
||||||
|
router: service(),
|
||||||
store: service(),
|
store: service(),
|
||||||
model() {
|
model() {
|
||||||
const replicationMode = this.paramsFor('mode').replication_mode;
|
const replicationMode = this.paramsFor('mode').replication_mode;
|
||||||
@@ -29,14 +30,12 @@ export default Route.extend({
|
|||||||
return cluster;
|
return cluster;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
afterModel(model) {
|
afterModel(model) {
|
||||||
const replicationMode = this.paramsFor('mode').replication_mode;
|
const replicationMode = this.paramsFor('mode').replication_mode;
|
||||||
if (
|
const cluster = model[replicationMode];
|
||||||
!model.get(`${replicationMode}.isPrimary`) ||
|
if (!cluster.isPrimary || cluster.replicationDisabled || cluster.replicationUnsupported) {
|
||||||
model.get(`${replicationMode}.replicationDisabled`) ||
|
return this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||||
model.get(`${replicationMode}.replicationUnsupported`)
|
|
||||||
) {
|
|
||||||
return this.transitionTo('mode', replicationMode);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const pathForAction = (action, replicationMode, clusterMode) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default Route.extend({
|
export default Route.extend({
|
||||||
|
router: service(),
|
||||||
store: service(),
|
store: service(),
|
||||||
model() {
|
model() {
|
||||||
const store = this.store;
|
const store = this.store;
|
||||||
@@ -46,7 +47,7 @@ export default Route.extend({
|
|||||||
model.get(replicationMode).get('replicationDisabled') ||
|
model.get(replicationMode).get('replicationDisabled') ||
|
||||||
model.get(replicationMode).get('replicationUnsupported')
|
model.get(replicationMode).get('replicationUnsupported')
|
||||||
) {
|
) {
|
||||||
return this.transitionTo('mode', replicationMode);
|
this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import Route from '@ember/routing/route';
|
|||||||
import { service } from '@ember/service';
|
import { service } from '@ember/service';
|
||||||
|
|
||||||
export default Route.extend({
|
export default Route.extend({
|
||||||
|
router: service(),
|
||||||
store: service(),
|
store: service(),
|
||||||
model() {
|
model() {
|
||||||
const replicationMode = this.paramsFor('mode').replication_mode;
|
const replicationMode = this.paramsFor('mode').replication_mode;
|
||||||
@@ -36,7 +37,7 @@ export default Route.extend({
|
|||||||
model.get(`${replicationMode}.replicationDisabled`) ||
|
model.get(`${replicationMode}.replicationDisabled`) ||
|
||||||
model.get(`${replicationMode}.replicationUnsupported`)
|
model.get(`${replicationMode}.replicationUnsupported`)
|
||||||
) {
|
) {
|
||||||
return this.transitionTo('mode', replicationMode);
|
this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export default Base.extend({
|
|||||||
redirect(model) {
|
redirect(model) {
|
||||||
const replicationMode = this.paramsFor('mode').replication_mode;
|
const replicationMode = this.paramsFor('mode').replication_mode;
|
||||||
if (!model.get(`${replicationMode}.isPrimary`) || !model.get('canAddSecondary')) {
|
if (!model.get(`${replicationMode}.isPrimary`) || !model.get('canAddSecondary')) {
|
||||||
return this.transitionTo('mode', replicationMode);
|
return this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import Base from '../../replication-base';
|
|||||||
|
|
||||||
export default Base.extend({
|
export default Base.extend({
|
||||||
flashMessages: service(),
|
flashMessages: service(),
|
||||||
|
router: service(),
|
||||||
|
|
||||||
modelPath: 'model.config',
|
modelPath: 'model.config',
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ export default Base.extend({
|
|||||||
!cluster.get(`${replicationMode}.isPrimary`) ||
|
!cluster.get(`${replicationMode}.isPrimary`) ||
|
||||||
!cluster.get('canAddSecondary')
|
!cluster.get('canAddSecondary')
|
||||||
) {
|
) {
|
||||||
return this.transitionTo('mode', replicationMode);
|
return this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import Route from '@ember/routing/route';
|
|||||||
import UnloadModelRouteMixin from 'vault/mixins/unload-model-route';
|
import UnloadModelRouteMixin from 'vault/mixins/unload-model-route';
|
||||||
|
|
||||||
export default Route.extend(UnloadModelRouteMixin, {
|
export default Route.extend(UnloadModelRouteMixin, {
|
||||||
|
router: service(),
|
||||||
store: service(),
|
store: service(),
|
||||||
version: service(),
|
version: service(),
|
||||||
rm: service('replication-mode'),
|
rm: service('replication-mode'),
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
{{else}}
|
{{else}}
|
||||||
<ToolbarLink
|
<ToolbarLink
|
||||||
@route="mode.secondaries.config-create"
|
@route="mode.secondaries.config-create"
|
||||||
@params={{this.model.config.id}}
|
@model={{this.model.config.id}}
|
||||||
data-test-replication-link="create-mount-config"
|
data-test-replication-link="create-mount-config"
|
||||||
>
|
>
|
||||||
Create config
|
Create config
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
import { module, test } from 'qunit';
|
import { module, test } from 'qunit';
|
||||||
import { setupApplicationTest } from 'ember-qunit';
|
import { setupApplicationTest } from 'ember-qunit';
|
||||||
import { setupMirage } from 'ember-cli-mirage/test-support';
|
import { setupMirage } from 'ember-cli-mirage/test-support';
|
||||||
import { click, visit } from '@ember/test-helpers';
|
import { click, currentURL, settled, visit } from '@ember/test-helpers';
|
||||||
import authPage from 'vault/tests/pages/auth';
|
import authPage from 'vault/tests/pages/auth';
|
||||||
import { STATUS_DISABLED_RESPONSE, mockReplicationBlock } from 'vault/tests/helpers/replication';
|
import { STATUS_DISABLED_RESPONSE, mockReplicationBlock } from 'vault/tests/helpers/replication';
|
||||||
|
|
||||||
@@ -57,6 +57,8 @@ module('Acceptance | Enterprise | replication modes', function (hooks) {
|
|||||||
assert.dom(s.navLink('Disaster Recovery')).exists('shows dr link');
|
assert.dom(s.navLink('Disaster Recovery')).exists('shows dr link');
|
||||||
|
|
||||||
await click(s.navLink('Performance'));
|
await click(s.navLink('Performance'));
|
||||||
|
assert.strictEqual(currentURL(), '/vault/replication/performance', 'it navigates to the correct page');
|
||||||
|
await settled();
|
||||||
assert.dom(s.title).hasText('Enable Performance Replication', 'it shows the enable view for performance');
|
assert.dom(s.title).hasText('Enable Performance Replication', 'it shows the enable view for performance');
|
||||||
|
|
||||||
await click(s.navLink('Disaster Recovery'));
|
await click(s.navLink('Disaster Recovery'));
|
||||||
@@ -80,6 +82,8 @@ module('Acceptance | Enterprise | replication modes', function (hooks) {
|
|||||||
assert.dom(s.navLink('Disaster Recovery')).exists('shows dr link');
|
assert.dom(s.navLink('Disaster Recovery')).exists('shows dr link');
|
||||||
|
|
||||||
await click(s.navLink('Performance'));
|
await click(s.navLink('Performance'));
|
||||||
|
assert.strictEqual(currentURL(), `/vault/replication/performance`, `goes to correct URL`);
|
||||||
|
await settled();
|
||||||
assert.dom(s.title).hasText(`Performance ${mode}`, `it shows the performance title`);
|
assert.dom(s.title).hasText(`Performance ${mode}`, `it shows the performance title`);
|
||||||
assert.dom(s.dashboard).exists(`it shows the replication dashboard`);
|
assert.dom(s.dashboard).exists(`it shows the replication dashboard`);
|
||||||
|
|
||||||
@@ -104,6 +108,8 @@ module('Acceptance | Enterprise | replication modes', function (hooks) {
|
|||||||
assert.dom(s.navLink('Disaster Recovery')).exists('shows dr link');
|
assert.dom(s.navLink('Disaster Recovery')).exists('shows dr link');
|
||||||
|
|
||||||
await click(s.navLink('Performance'));
|
await click(s.navLink('Performance'));
|
||||||
|
assert.strictEqual(currentURL(), `/vault/replication/performance`, `goes to correct URL`);
|
||||||
|
await settled();
|
||||||
assert.dom(s.title).hasText(`Enable Performance Replication`, `it shows the performance title`);
|
assert.dom(s.title).hasText(`Enable Performance Replication`, `it shows the performance title`);
|
||||||
assert.dom(s.enableForm).exists('it shows the enable view for performance');
|
assert.dom(s.enableForm).exists('it shows the enable view for performance');
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { clickTrigger } from 'ember-power-select/test-support/helpers';
|
import { clickTrigger } from 'ember-power-select/test-support/helpers';
|
||||||
import { click, fillIn, findAll, currentURL, find, visit, settled, waitUntil } from '@ember/test-helpers';
|
import {
|
||||||
|
click,
|
||||||
|
fillIn,
|
||||||
|
findAll,
|
||||||
|
currentURL,
|
||||||
|
find,
|
||||||
|
visit,
|
||||||
|
settled,
|
||||||
|
waitUntil,
|
||||||
|
waitFor,
|
||||||
|
} from '@ember/test-helpers';
|
||||||
import { module, test } from 'qunit';
|
import { module, test } from 'qunit';
|
||||||
import { setupApplicationTest } from 'ember-qunit';
|
import { setupApplicationTest } from 'ember-qunit';
|
||||||
import authPage from 'vault/tests/pages/auth';
|
import authPage from 'vault/tests/pages/auth';
|
||||||
@@ -249,12 +259,11 @@ module('Acceptance | Enterprise | replication', function (hooks) {
|
|||||||
|
|
||||||
await pollCluster(this.owner);
|
await pollCluster(this.owner);
|
||||||
await settled();
|
await settled();
|
||||||
const modalDefaultTtl = document.querySelector('[data-test-row-value="TTL"]').innerText;
|
|
||||||
|
|
||||||
// checks on secondary token modal
|
// checks on secondary token modal
|
||||||
assert.dom('#replication-copy-token-modal').exists();
|
assert.dom('#replication-copy-token-modal').exists();
|
||||||
assert.dom('[data-test-inline-error-message]').hasText('Copy token to dismiss modal');
|
assert.dom('[data-test-inline-error-message]').hasText('Copy token to dismiss modal');
|
||||||
assert.strictEqual(modalDefaultTtl, '1800s', 'shows the correct TTL of 1800s');
|
assert.dom('[data-test-row-value="TTL"]').hasText('1800s', 'shows the correct TTL of 1800s');
|
||||||
// click off the modal to make sure you don't just have to click on the copy-close button to copy the token
|
// click off the modal to make sure you don't just have to click on the copy-close button to copy the token
|
||||||
assert.dom('[data-test-modal-close]').isDisabled('cancel is disabled');
|
assert.dom('[data-test-modal-close]').isDisabled('cancel is disabled');
|
||||||
await click('[data-test-modal-copy]');
|
await click('[data-test-modal-copy]');
|
||||||
@@ -272,8 +281,7 @@ module('Acceptance | Enterprise | replication', function (hooks) {
|
|||||||
|
|
||||||
await pollCluster(this.owner);
|
await pollCluster(this.owner);
|
||||||
await settled();
|
await settled();
|
||||||
const modalTtl = document.querySelector('[data-test-row-value="TTL"]').innerText;
|
assert.dom('[data-test-row-value="TTL"]').hasText('180s', 'shows the correct TTL of 180s');
|
||||||
assert.strictEqual(modalTtl, '180s', 'shows the correct TTL of 180s');
|
|
||||||
await click('[data-test-modal-copy]');
|
await click('[data-test-modal-copy]');
|
||||||
await click('[data-test-modal-close]');
|
await click('[data-test-modal-close]');
|
||||||
|
|
||||||
@@ -351,13 +359,15 @@ module('Acceptance | Enterprise | replication', function (hooks) {
|
|||||||
// Click confirm button
|
// Click confirm button
|
||||||
await click('[data-test-confirm-button="Demote to secondary?"]');
|
await click('[data-test-confirm-button="Demote to secondary?"]');
|
||||||
|
|
||||||
await click('[data-test-replication-link="details"]');
|
await pollCluster(this.owner);
|
||||||
|
await settled();
|
||||||
|
|
||||||
|
await click('[data-test-replication-link="details"]');
|
||||||
|
await waitFor('[data-test-replication-dashboard]');
|
||||||
assert.dom('[data-test-replication-dashboard]').exists();
|
assert.dom('[data-test-replication-dashboard]').exists();
|
||||||
assert.dom('[data-test-selectable-card-container="secondary"]').exists();
|
assert.dom('[data-test-selectable-card-container="secondary"]').exists();
|
||||||
assert.ok(
|
assert
|
||||||
find('[data-test-replication-mode-display]').textContent.includes('secondary'),
|
.dom('[data-test-replication-mode-display]')
|
||||||
'it displays the cluster mode correctly'
|
.hasText('secondary', 'it displays the cluster mode correctly in header');
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user