mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
UI: Glimmerize replication enable form (#26417)
* Glimmerize replication controllers * Add enable-replication-form component with tests * use EnableReplicationForm in index and mode routes * clean up enable action from replication-actions mixin * fix test failure for structuredClone * stabilize tests, remove enable action from replication-actions and replication-summary * Update ui/lib/replication/addon/controllers/replication-mode.js Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com> * address PR comments * stabilize oidc test? --------- Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
This commit is contained in:
@@ -3,36 +3,74 @@
|
||||
* SPDX-License-Identifier: BUSL-1.1
|
||||
*/
|
||||
|
||||
import { alias } from '@ember/object/computed';
|
||||
import { service } from '@ember/service';
|
||||
import Controller from '@ember/controller';
|
||||
import { task, timeout } from 'ember-concurrency';
|
||||
import { waitFor } from '@ember/test-waiters';
|
||||
import { action } from '@ember/object';
|
||||
|
||||
export default Controller.extend({
|
||||
router: service(),
|
||||
rm: service('replication-mode'),
|
||||
replicationMode: alias('rm.mode'),
|
||||
waitForNewClusterToInit: task(
|
||||
waitFor(function* (replicationMode) {
|
||||
// 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
|
||||
yield timeout(1000);
|
||||
this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||
})
|
||||
),
|
||||
actions: {
|
||||
onEnable(replicationMode, mode) {
|
||||
if (replicationMode == 'dr' && mode === 'secondary') {
|
||||
export default class ReplicationModeBaseController extends Controller {
|
||||
@service('replication-mode') rm;
|
||||
@service router;
|
||||
@service store;
|
||||
|
||||
get replicationMode() {
|
||||
return this.rm.mode;
|
||||
}
|
||||
|
||||
get replicationForMode() {
|
||||
if (!this.replicationMode || !this.model) return null;
|
||||
return this.model[this.replicationMode];
|
||||
}
|
||||
|
||||
@task
|
||||
@waitFor
|
||||
*waitForNewClusterToInit(replicationMode) {
|
||||
// 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
|
||||
yield timeout(1000);
|
||||
this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||
}
|
||||
|
||||
@action
|
||||
onDisable() {
|
||||
this.router.transitionTo('vault.cluster.replication.index');
|
||||
}
|
||||
|
||||
@action
|
||||
async onEnableSuccess(resp, replicationMode, clusterMode, doTransition = false) {
|
||||
// this is extrapolated from the replication-actions mixin "submitSuccess"
|
||||
const cluster = this.model;
|
||||
if (!cluster) {
|
||||
return;
|
||||
}
|
||||
// do something to show model is pending
|
||||
cluster.set(
|
||||
replicationMode,
|
||||
this.store.createRecord('replication-attributes', {
|
||||
mode: 'bootstrapping',
|
||||
})
|
||||
);
|
||||
if (clusterMode === 'secondary' && replicationMode === 'performance') {
|
||||
// if we're enabing a secondary, there could be mount filtering,
|
||||
// so we should unload all of the backends
|
||||
this.store.unloadAll('secret-engine');
|
||||
}
|
||||
try {
|
||||
await cluster.reload();
|
||||
} catch (e) {
|
||||
// no error handling here
|
||||
}
|
||||
cluster.rollbackAttributes();
|
||||
// we should only do the transitions if called from vault.cluster.replication.index
|
||||
if (doTransition) {
|
||||
if (replicationMode == 'dr' && clusterMode === 'secondary') {
|
||||
this.router.transitionTo('vault.cluster');
|
||||
} else if (replicationMode === 'dr') {
|
||||
this.router.transitionTo('vault.cluster.replication.mode', replicationMode);
|
||||
} else {
|
||||
this.waitForNewClusterToInit.perform(replicationMode);
|
||||
}
|
||||
},
|
||||
onDisable() {
|
||||
this.router.transitionTo('vault.cluster.replication.index');
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user