From b64d2e948842d42fb885b34fb05843fe8182c1c6 Mon Sep 17 00:00:00 2001 From: Noelle Daley <adriannenoelle@gmail.com> Date: Tue, 21 Apr 2020 17:49:22 -0700 Subject: [PATCH] show error in state card using the same state map in the cluster model --- .../addon/components/replication-primary-card.js | 11 +++++------ .../templates/components/replication-primary-card.hbs | 2 +- .../templates/components/replication-summary.hbs | 1 + 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ui/lib/replication/addon/components/replication-primary-card.js b/ui/lib/replication/addon/components/replication-primary-card.js index d2d0cc83b..0cdc96158 100644 --- a/ui/lib/replication/addon/components/replication-primary-card.js +++ b/ui/lib/replication/addon/components/replication-primary-card.js @@ -15,7 +15,8 @@ import { computed } from '@ember/object'; * ``` * @param {string} [title=null] - The title to be displayed on the top left corner of the card. * @param {string} [description=null] - Helper text to describe the metric on the card. - * @param {object} [glyph=null] - The glyph to display beside the metric. + * @param {string} [glyph=null] - The glyph to display beside the metric. + * @param {boolean} [hasOkState=true] - Whether or not the cluster is in an okay state. This comes from the cluster model. * @param {string} metric=null - The main metric to highlight on the card. */ @@ -25,11 +26,9 @@ export default Component.extend({ description: null, metric: null, glyph: null, - hasError: computed('title', 'metric', function() { - // TODO: can we make a map somewhere in the cluster that keeps track of all the good and bad states - // as well as their glyphs? this could replace the cluster StateDiplay and StateGlyph - // TODO: then add tests to ensure we show the correct error msg - return this.title === 'State' && this.metric !== 'running'; + hasOkState: true, + hasError: computed('hasOkState', 'title', 'metric', function() { + return this.title === 'State' && !this.hasOkState; }), errorMessage: computed('hasError', function() { // TODO figure out if we need another error message diff --git a/ui/lib/replication/addon/templates/components/replication-primary-card.hbs b/ui/lib/replication/addon/templates/components/replication-primary-card.hbs index bfa4a6e56..b62e7ba38 100644 --- a/ui/lib/replication/addon/templates/components/replication-primary-card.hbs +++ b/ui/lib/replication/addon/templates/components/replication-primary-card.hbs @@ -9,7 +9,7 @@ </span> <h3 class="title is-3"> {{metric}} - {{#if glyph}} + {{#if (and glyph (not hasError))}} <Icon @glyph={{glyph}} class="has-text-success" /> {{/if}} </h3> diff --git a/ui/lib/replication/addon/templates/components/replication-summary.hbs b/ui/lib/replication/addon/templates/components/replication-summary.hbs index 394c5619c..f4e64ca06 100644 --- a/ui/lib/replication/addon/templates/components/replication-summary.hbs +++ b/ui/lib/replication/addon/templates/components/replication-summary.hbs @@ -349,6 +349,7 @@ @title='State' @description='Updated every ten seconds.' @glyph={{get cluster (concat replicationMode 'StateGlyph')}} + @hasOkState={{get cluster (concat replicationMode 'HasOkState')}} @metric={{replicationAttrs.state}}/> <ReplicationPrimaryCard @title='Last WAL entry' -- GitLab