From 4e73f1b93e121cfe792c3dd8bf0bf1aa040c7627 Mon Sep 17 00:00:00 2001 From: Angel Garbarino Date: Tue, 7 Jul 2020 13:09:01 -0600 Subject: [PATCH] Ui/small replication action fixes (#9387) * fix issue where if dr is not enabled, the breadcrumb link did not work. Now if DR not enabled, the breadcrumb says replication and links back to rep index. * show black nav when cluster is not initialized and is loading, no need for menu items and because NavHeader component and the icon live in the app and not addons I cannot access them without moving them. I figured the black bar was enough, and it wasn't worth moving just for that * conditional change the breadcrumb link in Disaster Recovery based on what page they are currently on (details or manage). Before the breadcrumb link didn't do anything if they were on the manage page * fix slow modal loading after demoting a dr secondary. due to shamir modal not being in the addon engine and erroring out. * to prevent confusing transition state during dr demotion, set new property on cluster and compare the mode of the dr which changes from primary to secondary during demotion. If dr mode changes, showing loading status * get more specific about conditional so loader does not some on disabling, but only on demote * remove concurrency from onSubmit * revert all concurency, I think this is solved by the removal of shamir in the dom * reverse order * cleanup * forgot that tricky layout, hopefull this will fix test * remove page container, it's not needed * remove breadcrumbs if DR secondary * remove pageType no now longer using * remove conditional that is no longer hit --- ui/app/models/cluster.js | 1 + .../core/addon}/components/shamir-flow.js | 2 + .../addon}/components/shamir-modal-flow.js | 0 .../components/replication-header.hbs | 6 +- .../templates/components/replication-page.hbs | 1 + .../templates/components/shamir-flow.hbs | 0 .../components/shamir-modal-flow.hbs | 0 ui/lib/core/app/components/shamir-flow.js | 1 + .../core/app/components/shamir-modal-flow.js | 1 + ui/lib/replication/addon/routes/mode.js | 13 +++ ui/lib/replication/addon/templates/index.hbs | 1 + ui/lib/replication/addon/templates/mode.hbs | 95 ++++++++++--------- 12 files changed, 73 insertions(+), 48 deletions(-) rename ui/{app => lib/core/addon}/components/shamir-flow.js (98%) rename ui/{app => lib/core/addon}/components/shamir-modal-flow.js (100%) rename ui/{app => lib/core/addon}/templates/components/shamir-flow.hbs (100%) rename ui/{app => lib/core/addon}/templates/components/shamir-modal-flow.hbs (100%) create mode 100644 ui/lib/core/app/components/shamir-flow.js create mode 100644 ui/lib/core/app/components/shamir-modal-flow.js diff --git a/ui/app/models/cluster.js b/ui/app/models/cluster.js index dea9ae2317..6090d149fc 100644 --- a/ui/app/models/cluster.js +++ b/ui/app/models/cluster.js @@ -53,6 +53,7 @@ export default DS.Model.extend({ // this service exposes what mode the UI is currently viewing // replicationAttrs will then return the relevant `replication-attributes` fragment rm: service('replication-mode'), + drMode: alias('dr.mode'), replicationMode: alias('rm.mode'), replicationModeForDisplay: computed('replicationMode', function() { return this.replicationMode === 'dr' ? 'Disaster Recovery' : 'Performance'; diff --git a/ui/app/components/shamir-flow.js b/ui/lib/core/addon/components/shamir-flow.js similarity index 98% rename from ui/app/components/shamir-flow.js rename to ui/lib/core/addon/components/shamir-flow.js index 8e89f4db95..11ff4f787c 100644 --- a/ui/app/components/shamir-flow.js +++ b/ui/lib/core/addon/components/shamir-flow.js @@ -3,6 +3,7 @@ import { gt } from '@ember/object/computed'; import { camelize } from '@ember/string'; import Component from '@ember/component'; import { get, computed } from '@ember/object'; +import layout from '../templates/components/shamir-flow'; const DEFAULTS = { key: null, @@ -26,6 +27,7 @@ export default Component.extend(DEFAULTS, { buttonText: 'Submit', thresholdPath: 'required', generateAction: false, + layout, init() { this._super(...arguments); diff --git a/ui/app/components/shamir-modal-flow.js b/ui/lib/core/addon/components/shamir-modal-flow.js similarity index 100% rename from ui/app/components/shamir-modal-flow.js rename to ui/lib/core/addon/components/shamir-modal-flow.js diff --git a/ui/lib/core/addon/templates/components/replication-header.hbs b/ui/lib/core/addon/templates/components/replication-header.hbs index 47c28c5a4a..bd03a24218 100644 --- a/ui/lib/core/addon/templates/components/replication-header.hbs +++ b/ui/lib/core/addon/templates/components/replication-header.hbs @@ -15,7 +15,7 @@ {{/if}} - {{#if (not isSummaryDashboard) }} + {{#if (not (or isSummaryDashboard isSecondary)) }} {{#key-value-header baseKey=baseKey path="vault.cluster.replication-dr-promote" @@ -25,8 +25,8 @@ / - {{#link-to "vault.cluster.replication-dr-promote"}} - Disaster Recovery + {{#link-to "vault.cluster.replication.index"}} + Replication {{/link-to}} {{/key-value-header}} diff --git a/ui/lib/core/addon/templates/components/replication-page.hbs b/ui/lib/core/addon/templates/components/replication-page.hbs index 4a07bcd12b..b3beefa11a 100644 --- a/ui/lib/core/addon/templates/components/replication-page.hbs +++ b/ui/lib/core/addon/templates/components/replication-page.hbs @@ -10,6 +10,7 @@ isSecondary=isSecondary secondaryId=replicationDetails.secondaryId isSummaryDashboard=isSummaryDashboard + isDisabled=isDisabled ) dashboard=(component 'replication-dashboard' diff --git a/ui/app/templates/components/shamir-flow.hbs b/ui/lib/core/addon/templates/components/shamir-flow.hbs similarity index 100% rename from ui/app/templates/components/shamir-flow.hbs rename to ui/lib/core/addon/templates/components/shamir-flow.hbs diff --git a/ui/app/templates/components/shamir-modal-flow.hbs b/ui/lib/core/addon/templates/components/shamir-modal-flow.hbs similarity index 100% rename from ui/app/templates/components/shamir-modal-flow.hbs rename to ui/lib/core/addon/templates/components/shamir-modal-flow.hbs diff --git a/ui/lib/core/app/components/shamir-flow.js b/ui/lib/core/app/components/shamir-flow.js new file mode 100644 index 0000000000..e7ef071bb7 --- /dev/null +++ b/ui/lib/core/app/components/shamir-flow.js @@ -0,0 +1 @@ +export { default } from 'core/components/shamir-flow'; diff --git a/ui/lib/core/app/components/shamir-modal-flow.js b/ui/lib/core/app/components/shamir-modal-flow.js new file mode 100644 index 0000000000..16669241c4 --- /dev/null +++ b/ui/lib/core/app/components/shamir-modal-flow.js @@ -0,0 +1 @@ +export { default } from 'core/components/shamir-modal-flow'; diff --git a/ui/lib/replication/addon/routes/mode.js b/ui/lib/replication/addon/routes/mode.js index c996ec97ae..abf970c1a4 100644 --- a/ui/lib/replication/addon/routes/mode.js +++ b/ui/lib/replication/addon/routes/mode.js @@ -1,4 +1,6 @@ import { inject as service } from '@ember/service'; +import { hash } from 'rsvp'; +import { setProperties } from '@ember/object'; import Route from '@ember/routing/route'; const SUPPORTED_REPLICATION_MODES = ['dr', 'performance']; @@ -17,4 +19,15 @@ export default Route.extend({ this.replicationMode.setMode(replicationMode); return this.modelFor('application'); }, + afterModel(model) { + return hash({ + // set new property on model to compare if the drMode changes when you are demoting the cluster + drModeInit: model.drMode, + }).then(({ drModeInit }) => { + setProperties(model, { + drModeInit, + }); + return model; + }); + }, }); diff --git a/ui/lib/replication/addon/templates/index.hbs b/ui/lib/replication/addon/templates/index.hbs index f4e5553819..a8b208a224 100644 --- a/ui/lib/replication/addon/templates/index.hbs +++ b/ui/lib/replication/addon/templates/index.hbs @@ -1,6 +1,7 @@
{{#if model.replicationIsInitializing }} + {{else}} {{#if (eq model.mode 'unsupported')}} diff --git a/ui/lib/replication/addon/templates/mode.hbs b/ui/lib/replication/addon/templates/mode.hbs index 9ca811ef34..75901bb3a5 100644 --- a/ui/lib/replication/addon/templates/mode.hbs +++ b/ui/lib/replication/addon/templates/mode.hbs @@ -1,57 +1,62 @@
- {{#if model.replicationAttrs.replicationEnabled}} - - -