From 3db6705ddc3a5b40a7530c1e3da150ada3342978 Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Thu, 12 Nov 2020 16:28:54 -0500 Subject: [PATCH] feat(appMessagesSelectors): issues/502 cloud meter messaging (#503) * build, dotenv flag for recommendations link * locale, cloud meter related banner message strings * appMessagesSelectors, apply tally cloud meter data, mismatch * bannerMessages, cloud meter mismatch message * graphCardSelectors, expose cloud meter flags * helpers, ui link for recommendations * rhsmApiTypes, cloud meter data and mismatch flags * rhsmServices, mock update for cloud meter data --- .env | 1 + public/locales/en-US.json | 5 + .../__snapshots__/helpers.test.js.snap | 3 + src/common/helpers.js | 8 + .../bannerMessages/bannerMessages.js | 30 +- .../__tests__/__snapshots__/i18n.test.js.snap | 13 + .../appMessagesSelectors.test.js.snap | 48 ++- .../graphCardSelectors.test.js.snap | 278 ++++++++++++++++++ .../__tests__/appMessagesSelectors.test.js | 195 +++++++++++- .../__tests__/graphCardSelectors.test.js | 20 +- src/redux/selectors/appMessagesSelectors.js | 27 +- src/redux/selectors/graphCardSelectors.js | 4 +- src/services/rhsmServices.js | 2 + .../__snapshots__/index.test.js.snap | 8 + src/types/rhsmApiTypes.js | 33 ++- 15 files changed, 644 insertions(+), 31 deletions(-) diff --git a/.env b/.env index 3d232a414..15d74a91b 100644 --- a/.env +++ b/.env @@ -8,6 +8,7 @@ PUBLIC_URL=${UI_DEPLOY_PATH_PREFIX}/apps/subscriptions/ REACT_APP_UI_LINK_CONTACT_US=https://access.redhat.com/account-team REACT_APP_UI_LINK_LEARN_MORE=https://access.redhat.com/documentation/en-us/subscription_central/2020-10/html/getting_started_with_subscription_watch/con-how-does-subscriptionwatch-show-data_assembly-opening-subscriptionwatch-ctxt/ +REACT_APP_UI_LINK_REPORT_ACCURACY_RECOMMENDATIONS= REACT_APP_UI_DISABLED=false REACT_APP_UI_DISABLED_TOOLBAR=false diff --git a/public/locales/en-US.json b/public/locales/en-US.json index e841109d2..cfd36ad64 100644 --- a/public/locales/en-US.json +++ b/public/locales/en-US.json @@ -3,6 +3,11 @@ "pending": "Authenticating...", "maintenanceCopy": "We are currently undergoing scheduled maintenance and will be back shortly. Thank you for your patience." }, + "curiosity-banner": { + "dataMismatchTitle": "Improve reporting accuracy", + "dataMismatchMessage": "Action required in order to improve {{appName}} reporting.", + "dataMismatchMessage_cloudigradeMismatch": "<0>View recommmend actions to take in order to improve {{appName}} reporting." + }, "curiosity-graph": { "cardHeading": "CPU usage", "coresHeading": "CPU core usage", diff --git a/src/common/__tests__/__snapshots__/helpers.test.js.snap b/src/common/__tests__/__snapshots__/helpers.test.js.snap index bdf19c59e..c938059c8 100644 --- a/src/common/__tests__/__snapshots__/helpers.test.js.snap +++ b/src/common/__tests__/__snapshots__/helpers.test.js.snap @@ -16,6 +16,7 @@ Object { "UI_DISPLAY_START_NAME": "Subscription Watch", "UI_LINK_CONTACT_US": "https://access.redhat.com/account-team", "UI_LINK_LEARN_MORE": "https://access.redhat.com/documentation/en-us/subscription_central/2020-10/html/getting_started_with_subscription_watch/con-how-does-subscriptionwatch-show-data_assembly-opening-subscriptionwatch-ctxt/", + "UI_LINK_REPORT_ACCURACY_RECOMMENDATIONS": "", "UI_LOCALE_DEFAULT": "en-US", "UI_LOCALE_DEFAULT_DESC": "English", "UI_LOGGER_ID": "curiosity", @@ -50,6 +51,7 @@ Object { "UI_DISPLAY_START_NAME": "Subscription Watch", "UI_LINK_CONTACT_US": "https://access.redhat.com/account-team", "UI_LINK_LEARN_MORE": "https://access.redhat.com/documentation/en-us/subscription_central/2020-10/html/getting_started_with_subscription_watch/con-how-does-subscriptionwatch-show-data_assembly-opening-subscriptionwatch-ctxt/", + "UI_LINK_REPORT_ACCURACY_RECOMMENDATIONS": "", "UI_LOCALE_DEFAULT": "en-US", "UI_LOCALE_DEFAULT_DESC": "English", "UI_LOGGER_ID": "curiosity", @@ -84,6 +86,7 @@ Object { "UI_DISPLAY_START_NAME": "Subscription Watch", "UI_LINK_CONTACT_US": "https://access.redhat.com/account-team", "UI_LINK_LEARN_MORE": "https://access.redhat.com/documentation/en-us/subscription_central/2020-10/html/getting_started_with_subscription_watch/con-how-does-subscriptionwatch-show-data_assembly-opening-subscriptionwatch-ctxt/", + "UI_LINK_REPORT_ACCURACY_RECOMMENDATIONS": "", "UI_LOCALE_DEFAULT": "en-US", "UI_LOCALE_DEFAULT_DESC": "English", "UI_LOGGER_ID": "curiosity", diff --git a/src/common/helpers.js b/src/common/helpers.js index e278467b9..981fb44f2 100644 --- a/src/common/helpers.js +++ b/src/common/helpers.js @@ -161,6 +161,13 @@ const UI_LINK_CONTACT_US = process.env.REACT_APP_UI_LINK_CONTACT_US; */ const UI_LINK_LEARN_MORE = process.env.REACT_APP_UI_LINK_LEARN_MORE; +/** + * A url, or uri, for "recommend actions" + * + * @type {string} + */ +const UI_LINK_REPORT_ACCURACY_RECOMMENDATIONS = process.env.REACT_APP_UI_LINK_REPORT_ACCURACY_RECOMMENDATIONS; + /** * UI locale default. * @@ -252,6 +259,7 @@ const helpers = { UI_DISPLAY_START_NAME, UI_LINK_CONTACT_US, UI_LINK_LEARN_MORE, + UI_LINK_REPORT_ACCURACY_RECOMMENDATIONS, UI_LOCALE_DEFAULT, UI_LOCALE_DEFAULT_DESC, UI_LOGGER_ID, diff --git a/src/components/bannerMessages/bannerMessages.js b/src/components/bannerMessages/bannerMessages.js index 1af3f2bdc..90e19cb3a 100644 --- a/src/components/bannerMessages/bannerMessages.js +++ b/src/components/bannerMessages/bannerMessages.js @@ -1,7 +1,10 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { Alert, AlertActionCloseButton, AlertVariant } from '@patternfly/react-core'; +import { Alert, AlertActionCloseButton, AlertVariant, Button } from '@patternfly/react-core'; +import { ExternalLinkAltIcon } from '@patternfly/react-icons'; import { connect, reduxSelectors } from '../../redux'; +import { translate } from '../i18n/i18n'; +import { helpers } from '../../common'; /** * Render banner messages. @@ -86,7 +89,30 @@ BannerMessages.propTypes = { * @type {{messages: Array}} */ BannerMessages.defaultProps = { - messages: [] + messages: [ + { + id: 'cloudigradeMismatch', + title: translate('curiosity-banner.dataMismatchTitle'), + message: translate( + 'curiosity-banner.dataMismatchMessage', + { + context: helpers.UI_LINK_REPORT_ACCURACY_RECOMMENDATIONS !== '' && 'cloudigradeMismatch', + appName: helpers.UI_DISPLAY_NAME + }, + [ +