From cb1873b336a1951fc34c6e2c5f7770ac2d80480c Mon Sep 17 00:00:00 2001 From: Noelle Daley Date: Tue, 2 Jun 2020 17:41:05 -0700 Subject: [PATCH 1/7] do not show replication mode or id when replication isn't enabled --- .../core/addon/components/replication-header.js | 1 + ui/lib/core/addon/components/replication-page.js | 7 +++++-- .../templates/components/replication-header.hbs | 14 ++++++++------ .../components/replication-header-test.js | 15 +++++++++++++++ 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/ui/lib/core/addon/components/replication-header.js b/ui/lib/core/addon/components/replication-header.js index 1c6b4aa44c46..f34a1ac4db54 100644 --- a/ui/lib/core/addon/components/replication-header.js +++ b/ui/lib/core/addon/components/replication-header.js @@ -22,6 +22,7 @@ import layout from '../templates/components/replication-header'; export default Component.extend({ layout, + data: null, classNames: ['replication-header'], isSecondary: null, secondaryId: null, diff --git a/ui/lib/core/addon/components/replication-page.js b/ui/lib/core/addon/components/replication-page.js index 5d5e3ad2de2a..10876f744cf3 100644 --- a/ui/lib/core/addon/components/replication-page.js +++ b/ui/lib/core/addon/components/replication-page.js @@ -131,9 +131,12 @@ export default Component.extend({ return false; }), message: computed('model.{anyReplicationEnabled}', 'formattedReplicationMode', function() { + let msg; if (this.model.anyReplicationEnabled) { - return `This ${this.formattedReplicationMode} secondary has not been enabled. You can do so from the ${this.formattedReplicationMode} Primary.`; + 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 `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; }), }); diff --git a/ui/lib/core/addon/templates/components/replication-header.hbs b/ui/lib/core/addon/templates/components/replication-header.hbs index 70653fac34c1..a26f1a74098d 100644 --- a/ui/lib/core/addon/templates/components/replication-header.hbs +++ b/ui/lib/core/addon/templates/components/replication-header.hbs @@ -35,12 +35,14 @@

{{title}} - - {{if isSecondary 'secondary' 'primary'}} - - - {{secondaryId}} - + {{#if data.anyReplicationEnabled}} + + {{if isSecondary 'secondary' 'primary'}} + + + {{secondaryId}} + + {{/if}}

diff --git a/ui/tests/integration/components/replication-header-test.js b/ui/tests/integration/components/replication-header-test.js index 7da66af93d33..356b67c01b8b 100644 --- a/ui/tests/integration/components/replication-header-test.js +++ b/ui/tests/integration/components/replication-header-test.js @@ -4,6 +4,7 @@ import { render } from '@ember/test-helpers'; import hbs from 'htmlbars-inline-precompile'; const DATA = { + anyReplicationEnabled: true, dr: { mode: 'secondary', rm: { @@ -41,6 +42,20 @@ module('Integration | Enterprise | Component | replication-header', function(hoo assert.dom('[data-test-mode]').includesText('secondary', `shows the correct mode value`); }); + test('it does not render mode or secondaryId when replication is not enabled', async function(assert) { + const notEnabled = { anyReplicationEnabled: false }; + const noId = null; + this.set('data', notEnabled); + this.set('secondaryId', noId); + + await render( + hbs`` + ); + + assert.dom('[data-test-secondaryId]').doesNotExist(); + assert.dom('[data-test-mode]').doesNotExist(); + }); + test('it does not show tabs when showTabs is not set', async function(assert) { await render(hbs``); From 6e935aca20cb54e65b3430a9771106ebc728a819 Mon Sep 17 00:00:00 2001 From: Noelle Daley Date: Wed, 3 Jun 2020 09:17:52 -0700 Subject: [PATCH 2/7] fix broken tag --- .../components/replication-header.hbs | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/ui/lib/core/addon/templates/components/replication-header.hbs b/ui/lib/core/addon/templates/components/replication-header.hbs index a26f1a74098d..baab9aa44596 100644 --- a/ui/lib/core/addon/templates/components/replication-header.hbs +++ b/ui/lib/core/addon/templates/components/replication-header.hbs @@ -51,24 +51,25 @@