From 349e449d49fef4fcc836d29b84ec7c1336bdb9ca Mon Sep 17 00:00:00 2001 From: Chelsea Shaw <82459713+hashishaw@users.noreply.github.com> Date: Mon, 15 Apr 2024 15:30:33 -0500 Subject: [PATCH] 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> --- ui/app/adapters/cluster.js | 2 +- .../core/addon/mixins/replication-actions.js | 25 +- .../components/enable-replication-form.hbs | 178 +++++++++++ .../components/enable-replication-form.js | 126 ++++++++ .../addon/components/replication-summary.js | 66 +--- .../addon/controllers/application.js | 2 +- ui/lib/replication/addon/controllers/index.js | 7 +- ui/lib/replication/addon/controllers/mode.js | 4 +- .../addon/controllers/mode/index.js | 4 +- .../addon/controllers/mode/manage.js | 4 +- .../addon/controllers/mode/secondaries.js | 4 +- .../addon/controllers/replication-mode.js | 82 +++-- .../components/replication-summary.hbs | 283 ----------------- ui/lib/replication/addon/templates/index.hbs | 89 +++++- .../addon/templates/mode/index.hbs | 52 ++- .../acceptance/enterprise-replication-test.js | 9 +- ui/tests/acceptance/oidc-provider-test.js | 4 +- ui/tests/helpers/replication.js | 12 +- .../enable-replication-form-test.js | 298 ++++++++++++++++++ 19 files changed, 829 insertions(+), 422 deletions(-) create mode 100644 ui/lib/replication/addon/components/enable-replication-form.hbs create mode 100644 ui/lib/replication/addon/components/enable-replication-form.js create mode 100644 ui/tests/integration/components/enable-replication-form-test.js diff --git a/ui/app/adapters/cluster.js b/ui/app/adapters/cluster.js index 2552a72a68..5a8984ec33 100644 --- a/ui/app/adapters/cluster.js +++ b/ui/app/adapters/cluster.js @@ -169,7 +169,7 @@ export default ApplicationAdapter.extend({ urlFor(endpoint) { if (!ENDPOINTS.includes(endpoint)) { throw new Error( - `Calls to a ${endpoint} endpoint are not currently allowed in the vault cluster adapater` + `Calls to a ${endpoint} endpoint are not currently allowed in the vault cluster adapter` ); } return `${this.buildURL()}/${endpoint}`; diff --git a/ui/lib/core/addon/mixins/replication-actions.js b/ui/lib/core/addon/mixins/replication-actions.js index 10ab7e2ff4..26fe1effef 100644 --- a/ui/lib/core/addon/mixins/replication-actions.js +++ b/ui/lib/core/addon/mixins/replication-actions.js @@ -13,7 +13,6 @@ export default Mixin.create({ store: service(), router: service(), loading: or('save.isRunning', 'submitSuccess.isRunning'), - onEnable() {}, onDisable() {}, onPromote() {}, submitHandler: task(function* (action, clusterMode, data, event) { @@ -53,10 +52,9 @@ export default Mixin.create({ return yield this.submitSuccess.perform(resp, action, clusterMode); }).drop(), - submitSuccess: task(function* (resp, action, mode) { + submitSuccess: task(function* (resp, action) { + // enable action is handled separately in EnableReplicationForm component const cluster = this.cluster; - const replicationMode = this.selectedReplicationMode || this.replicationMode; - const store = this.store; if (!cluster) { return; } @@ -75,20 +73,6 @@ export default Mixin.create({ if (this.reset) { this.reset(); } - if (action === 'enable') { - // do something to show model is pending - cluster.set( - replicationMode, - store.createRecord('replication-attributes', { - mode: 'bootstrapping', - }) - ); - if (mode === 'secondary' && replicationMode === 'performance') { - // if we're enabing a secondary, there could be mount filtering, - // so we should unload all of the backends - store.unloadAll('secret-engine'); - } - } try { yield cluster.reload(); } catch (e) { @@ -101,11 +85,6 @@ export default Mixin.create({ if (action === 'promote') { yield this.onPromote(); } - if (action === 'enable') { - /// onEnable is a method available only to route vault.cluster.replication.index - // if action 'enable' is called from vault.cluster.replication.mode.index this method is not called - yield this.onEnable(replicationMode, mode); - } }).drop(), submitError(e) { diff --git a/ui/lib/replication/addon/components/enable-replication-form.hbs b/ui/lib/replication/addon/components/enable-replication-form.hbs new file mode 100644 index 0000000000..8f95d7ae69 --- /dev/null +++ b/ui/lib/replication/addon/components/enable-replication-form.hbs @@ -0,0 +1,178 @@ +{{! + Copyright (c) HashiCorp, Inc. + SPDX-License-Identifier: BUSL-1.1 +~}} + +
+ + +
+ +
+
+ +
+ {{#if (eq this.data.mode "secondary")}} + + {{/if}} +
+ {{#if (eq this.data.mode "primary")}} + {{#if @canEnablePrimary}} +
+ +
+ +
+

+ Overrides the cluster address that the primary gives to secondary nodes. +

+
+ {{else}} +

+ The token you are using is not authorized to enable primary replication. +

+ {{/if}} + {{else}} + {{#if @canEnableSecondary}} + {{#if (and (eq @replicationMode "dr") this.performanceReplicationEnabled (has-feature "Performance Replication"))}} +
+ + {{#if this.showExplanation}} +

+ When running as a DR Secondary Vault is read only. For this reason, we don't allow other Replication modes to + operate at the same time. This cluster is also currently operating as a Performance + {{capitalize @performanceMode}}. +

+ {{/if}} +
+ {{else}} +
+ +
+