From b359d1c012dd26191955cb1fdcbeac868671c17c Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Mon, 11 May 2020 21:49:05 -0400 Subject: [PATCH] fix(graphCardHelpers): issues/180 tooltip show data facets (#282) * graphCardHelpers, update tooltip to display all data facets * graphCardSelectors, pass has_data and has_infinite to graphCard * i18n, strings updated --- public/locales/en-US.json | 4 +- .../graphCardHelpers.test.js.snap | 241 ++++++++++++++++- .../__tests__/graphCardHelpers.test.js | 98 ++++++- src/components/graphCard/graphCardHelpers.js | 19 +- .../__tests__/__snapshots__/i18n.test.js.snap | 13 +- .../graphCardSelectors.test.js.snap | 248 +++++++++++++----- .../__tests__/graphCardSelectors.test.js | 15 +- src/redux/selectors/graphCardSelectors.js | 11 +- 8 files changed, 555 insertions(+), 94 deletions(-) diff --git a/public/locales/en-US.json b/public/locales/en-US.json index 77448ad92..6ebee62df 100644 --- a/public/locales/en-US.json +++ b/public/locales/en-US.json @@ -13,7 +13,9 @@ "dropdownMonthly": "Monthly", "dropdownQuarterly": "Quarterly", "dropdownPlaceholder": "Select date range", - "noDataLabel": "No data", + "infiniteThresholdLabel": "unlimited", + "noDataLabel": "no data", + "noDataErrorLabel": "No data", "dateLabel": "Date", "coresLabel": "Cores", "socketsLabel": "Sockets", diff --git a/src/components/graphCard/__tests__/__snapshots__/graphCardHelpers.test.js.snap b/src/components/graphCard/__tests__/__snapshots__/graphCardHelpers.test.js.snap index 967f29243..5d9b0b7b3 100644 --- a/src/components/graphCard/__tests__/__snapshots__/graphCardHelpers.test.js.snap +++ b/src/components/graphCard/__tests__/__snapshots__/graphCardHelpers.test.js.snap @@ -18,33 +18,246 @@ Object { } `; -exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: granularity data display 1`] = ` +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: data display > 0 and NOT hasData on report 1`] = ` +Object { + "daily": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: data display > 0 and UNDEFINED hasData on report 1`] = ` +Object { + "daily": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 50 +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 50 +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 50 +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 50 +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: data display > 0 and hasData on report 1`] = ` +Object { + "daily": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 50 +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 50 +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 50 +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 50 +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: data display for null and NOT hasData on report 1`] = ` +Object { + "daily": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: data display for null and UNDEFINED hasData on report 1`] = ` +Object { + "daily": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: data display for null and hasData on report 1`] = ` +Object { + "daily": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: data display for zero and NOT hasData on report 1`] = ` +Object { + "daily": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: data display for zero and UNDEFINED hasData on report 1`] = ` +Object { + "daily": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: data display for zero and hasData on report 1`] = ` +Object { + "daily": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 0 +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: no data granularity data display 1`] = ` +Object { + "daily": "t(curiosity-graph.noDataErrorLabel)", + "monthly": "t(curiosity-graph.noDataErrorLabel)", + "quarterly": "t(curiosity-graph.noDataErrorLabel)", + "weekly": "t(curiosity-graph.noDataErrorLabel)", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: threshold display for > 0 and NOT hasInfinite on threshold 1`] = ` Object { "daily": "t(curiosity-graph.thresholdLabel): 100 -t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 50 -t(curiosity-graph.physicalSocketsLabel, [object Object]): 50 t(curiosity-graph.dateLabel): June 1", "monthly": "t(curiosity-graph.thresholdLabel): 100 -t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 50 -t(curiosity-graph.physicalSocketsLabel, [object Object]): 50 t(curiosity-graph.dateLabel): June 2019", "quarterly": "t(curiosity-graph.thresholdLabel): 100 -t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 50 -t(curiosity-graph.physicalSocketsLabel, [object Object]): 50 t(curiosity-graph.dateLabel): June 2019", "weekly": "t(curiosity-graph.thresholdLabel): 100 -t(curiosity-graph.hypervisorSocketsLabel, [object Object]): 50 -t(curiosity-graph.physicalSocketsLabel, [object Object]): 50 t(curiosity-graph.dateLabel): June 1", } `; -exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: no data granularity data display 1`] = ` +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: threshold display for > 0 and UNDEFINED hasInfinite on threshold 1`] = ` +Object { + "daily": "t(curiosity-graph.thresholdLabel): 100 +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.thresholdLabel): 100 +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.thresholdLabel): 100 +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.thresholdLabel): 100 +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: threshold display for > 0 and hasInfinite on threshold 1`] = ` +Object { + "daily": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.infiniteThresholdLabel) +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.infiniteThresholdLabel) +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.infiniteThresholdLabel) +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.infiniteThresholdLabel) +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: threshold display for null and NOT hasInfinite on threshold 1`] = ` Object { - "daily": "t(curiosity-graph.noDataLabel)", - "monthly": "t(curiosity-graph.noDataLabel)", - "quarterly": "t(curiosity-graph.noDataLabel)", - "weekly": "t(curiosity-graph.noDataLabel)", + "daily": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: threshold display for null and UNDEFINED hasInfinite on threshold 1`] = ` +Object { + "daily": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.noDataLabel) +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: threshold display for null and hasInfinite on threshold 1`] = ` +Object { + "daily": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.infiniteThresholdLabel) +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.infiniteThresholdLabel) +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.infiniteThresholdLabel) +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.infiniteThresholdLabel) +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: threshold display for zero and NOT hasInfinite on threshold 1`] = ` +Object { + "daily": "t(curiosity-graph.thresholdLabel): 0 +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.thresholdLabel): 0 +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.thresholdLabel): 0 +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.thresholdLabel): 0 +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: threshold display for zero and UNDEFINED hasInfinite on threshold 1`] = ` +Object { + "daily": "t(curiosity-graph.thresholdLabel): 0 +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.thresholdLabel): 0 +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.thresholdLabel): 0 +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.thresholdLabel): 0 +t(curiosity-graph.dateLabel): June 1", +} +`; + +exports[`GraphCardHelpers getTooltips should return a formatted tooltip based on data and granularity: threshold display for zero and hasInfinite on threshold 1`] = ` +Object { + "daily": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.infiniteThresholdLabel) +t(curiosity-graph.dateLabel): June 1", + "monthly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.infiniteThresholdLabel) +t(curiosity-graph.dateLabel): June 2019", + "quarterly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.infiniteThresholdLabel) +t(curiosity-graph.dateLabel): June 2019", + "weekly": "t(curiosity-graph.thresholdLabel): t(curiosity-graph.infiniteThresholdLabel) +t(curiosity-graph.dateLabel): June 1", } `; diff --git a/src/components/graphCard/__tests__/graphCardHelpers.test.js b/src/components/graphCard/__tests__/graphCardHelpers.test.js index 0ff74f592..6611493d7 100644 --- a/src/components/graphCard/__tests__/graphCardHelpers.test.js +++ b/src/components/graphCard/__tests__/graphCardHelpers.test.js @@ -45,12 +45,102 @@ describe('GraphCardHelpers', () => { 'no data granularity data display' ); - itemsByKey.hypervisorSockets = { x: 0, y: 50, date: '2019-06-01T00:00:00Z' }; - itemsByKey.physicalSockets = { x: 0, y: 50, date: '2019-06-01T00:00:00Z' }; - itemsByKey.threshold = { x: 0, y: 100, date: '2019-06-01T00:00:00Z' }; + // report value > 0 + itemsByKey.hypervisorSockets = { x: 0, y: 50, date: '2019-06-01T00:00:00Z', hasData: undefined }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'data display > 0 and UNDEFINED hasData on report' + ); + + itemsByKey.hypervisorSockets = { x: 0, y: 50, date: '2019-06-01T00:00:00Z', hasData: false }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'data display > 0 and NOT hasData on report' + ); + + itemsByKey.hypervisorSockets = { x: 0, y: 50, date: '2019-06-01T00:00:00Z', hasData: true }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'data display > 0 and hasData on report' + ); + + // report value = 0 + itemsByKey.hypervisorSockets = { x: 0, y: 0, date: '2019-06-01T00:00:00Z', hasData: undefined }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'data display for zero and UNDEFINED hasData on report' + ); + + itemsByKey.hypervisorSockets = { x: 0, y: 0, date: '2019-06-01T00:00:00Z', hasData: false }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'data display for zero and NOT hasData on report' + ); + + itemsByKey.hypervisorSockets = { x: 0, y: 0, date: '2019-06-01T00:00:00Z', hasData: true }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'data display for zero and hasData on report' + ); + + // report value = null + itemsByKey.hypervisorSockets = { x: 0, y: null, date: '2019-06-01T00:00:00Z', hasData: undefined }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'data display for null and UNDEFINED hasData on report' + ); + + itemsByKey.hypervisorSockets = { x: 0, y: null, date: '2019-06-01T00:00:00Z', hasData: false }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'data display for null and NOT hasData on report' + ); + + itemsByKey.hypervisorSockets = { x: 0, y: null, date: '2019-06-01T00:00:00Z', hasData: true }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'data display for null and hasData on report' + ); + + delete itemsByKey.hypervisorSockets; + + // threshold value > 0 + itemsByKey.threshold = { x: 0, y: 100, date: '2019-06-01T00:00:00Z', hasInfinite: undefined }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'threshold display for > 0 and UNDEFINED hasInfinite on threshold' + ); + + itemsByKey.threshold = { x: 0, y: 100, date: '2019-06-01T00:00:00Z', hasInfinite: false }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'threshold display for > 0 and NOT hasInfinite on threshold' + ); + + itemsByKey.threshold = { x: 0, y: 100, date: '2019-06-01T00:00:00Z', hasInfinite: true }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'threshold display for > 0 and hasInfinite on threshold' + ); + + // threshold value = 0 + itemsByKey.threshold = { x: 0, y: 0, date: '2019-06-01T00:00:00Z', hasInfinite: undefined }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'threshold display for zero and UNDEFINED hasInfinite on threshold' + ); + + itemsByKey.threshold = { x: 0, y: 0, date: '2019-06-01T00:00:00Z', hasInfinite: false }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'threshold display for zero and NOT hasInfinite on threshold' + ); + + itemsByKey.threshold = { x: 0, y: 0, date: '2019-06-01T00:00:00Z', hasInfinite: true }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'threshold display for zero and hasInfinite on threshold' + ); + + // threshold value = null + itemsByKey.threshold = { x: 0, y: null, date: '2019-06-01T00:00:00Z', hasInfinite: undefined }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'threshold display for null and UNDEFINED hasInfinite on threshold' + ); + + itemsByKey.threshold = { x: 0, y: null, date: '2019-06-01T00:00:00Z', hasInfinite: false }; + expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( + 'threshold display for null and NOT hasInfinite on threshold' + ); + itemsByKey.threshold = { x: 0, y: null, date: '2019-06-01T00:00:00Z', hasInfinite: true }; expect({ daily: daily(), weekly: weekly(), monthly: monthly(), quarterly: quarterly() }).toMatchSnapshot( - 'granularity data display' + 'threshold display for null and hasInfinite on threshold' ); }); diff --git a/src/components/graphCard/graphCardHelpers.js b/src/components/graphCard/graphCardHelpers.js index f92767499..37beed355 100644 --- a/src/components/graphCard/graphCardHelpers.js +++ b/src/components/graphCard/graphCardHelpers.js @@ -78,18 +78,23 @@ const getTooltips = ({ itemsByKey, granularity, product = '' }) => { })}`; } - if (itemsByKey[key].y) { - if (/^threshold/.test(key)) { - thresholdString = `${translate(`curiosity-graph.thresholdLabel`)}: ${itemsByKey[key].y}\n`; - } else { - dataFacets.push(`${translate(`curiosity-graph.${key}Label`, { product })}: ${itemsByKey[key].y}\n`); - } + if (/^threshold/.test(key)) { + const thresholdStringValue = + (itemsByKey[key].hasInfinite && translate('curiosity-graph.infiniteThresholdLabel')) || + (itemsByKey[key].y ?? translate('curiosity-graph.noDataLabel')); + + thresholdString = `${translate(`curiosity-graph.thresholdLabel`)}: ${thresholdStringValue}\n`; + } else { + const dataFactsValue = + (itemsByKey[key].hasData === false && translate('curiosity-graph.noDataLabel')) || itemsByKey[key].y || 0; + + dataFacets.push(`${translate(`curiosity-graph.${key}Label`, { product })}: ${dataFactsValue}\n`); } }); return ( ((thresholdString || dataFacets.length) && `${thresholdString}${dataFacets.join('')}${dateString}`.trim()) || - translate('curiosity-graph.noDataLabel') + translate('curiosity-graph.noDataErrorLabel') ); }; diff --git a/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap b/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap index b250976e6..67d3eaf63 100644 --- a/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap +++ b/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap @@ -49,7 +49,16 @@ msgstr \\"\\" msgid \\"curiosity-graph.dropdownWeekly\\" msgstr \\"\\" -#: src/components/graphCard/graphCardHelpers.js:92 +#: src/components/graphCard/graphCardHelpers.js:83 +msgid \\"curiosity-graph.infiniteThresholdLabel\\" +msgstr \\"\\" + +#: src/components/graphCard/graphCardHelpers.js:97 +msgid \\"curiosity-graph.noDataErrorLabel\\" +msgstr \\"\\" + +#: src/components/graphCard/graphCardHelpers.js:84 +#: src/components/graphCard/graphCardHelpers.js:89 msgid \\"curiosity-graph.noDataLabel\\" msgstr \\"\\" @@ -58,7 +67,7 @@ msgid \\"curiosity-graph.socketsHeading\\" msgstr \\"\\" #: src/components/graphCard/graphCard.js:134 -#: src/components/graphCard/graphCardHelpers.js:83 +#: src/components/graphCard/graphCardHelpers.js:86 msgid \\"curiosity-graph.thresholdLabel\\" msgstr \\"\\" diff --git a/src/redux/selectors/__tests__/__snapshots__/graphCardSelectors.test.js.snap b/src/redux/selectors/__tests__/__snapshots__/graphCardSelectors.test.js.snap index 022a15d88..f5c4a3ee6 100644 --- a/src/redux/selectors/__tests__/__snapshots__/graphCardSelectors.test.js.snap +++ b/src/redux/selectors/__tests__/__snapshots__/graphCardSelectors.test.js.snap @@ -18,16 +18,19 @@ Object { "cloudCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": true, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": true, "x": 2, "y": 0, }, @@ -35,16 +38,19 @@ Object { "cloudInstanceCount": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": true, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": true, "x": 2, "y": 0, }, @@ -52,16 +58,19 @@ Object { "cloudSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": true, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": true, "x": 2, "y": 0, }, @@ -69,50 +78,39 @@ Object { "cores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 2, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": true, "x": 1, "y": 2, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": true, "x": 2, "y": 4, }, ], - "hasData": Array [ - Object { - "date": 2019-09-04T00:00:00.000Z, - "x": 0, - "y": 0, - }, - Object { - "date": 2019-09-05T00:00:00.000Z, - "x": 1, - "y": 0, - }, - Object { - "date": 2019-09-06T00:00:00.000Z, - "x": 2, - "y": 0, - }, - ], "hypervisorCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": true, "x": 1, "y": 1, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": true, "x": 2, "y": 2, }, @@ -120,16 +118,19 @@ Object { "hypervisorSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": true, "x": 1, "y": 1, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": true, "x": 2, "y": 2, }, @@ -137,16 +138,19 @@ Object { "physicalCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": true, "x": 1, "y": 1, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": true, "x": 2, "y": 2, }, @@ -154,16 +158,19 @@ Object { "physicalSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": true, "x": 1, "y": 1, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": true, "x": 2, "y": null, }, @@ -171,16 +178,19 @@ Object { "sockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 2, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": true, "x": 1, "y": 2, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": true, "x": 2, "y": 4, }, @@ -188,16 +198,19 @@ Object { "thresholdCloudCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": true, "x": 1, "y": null, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": true, "x": 2, "y": null, }, @@ -205,16 +218,19 @@ Object { "thresholdCloudInstanceCount": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": true, "x": 1, "y": null, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": true, "x": 2, "y": null, }, @@ -222,16 +238,19 @@ Object { "thresholdCloudSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": true, "x": 1, "y": null, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": true, "x": 2, "y": null, }, @@ -239,16 +258,19 @@ Object { "thresholdCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": true, "x": 1, "y": null, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": true, "x": 2, "y": null, }, @@ -256,16 +278,19 @@ Object { "thresholdHypervisorCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": true, "x": 1, "y": null, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": true, "x": 2, "y": null, }, @@ -273,16 +298,19 @@ Object { "thresholdHypervisorSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 50, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": true, "x": 1, "y": null, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": true, "x": 2, "y": null, }, @@ -290,16 +318,19 @@ Object { "thresholdPhysicalCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": true, "x": 1, "y": null, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": true, "x": 2, "y": null, }, @@ -307,16 +338,19 @@ Object { "thresholdPhysicalSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 50, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": true, "x": 1, "y": null, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": true, "x": 2, "y": null, }, @@ -324,16 +358,19 @@ Object { "thresholdSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 100, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": true, "x": 1, "y": null, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": true, "x": 2, "y": null, }, @@ -382,6 +419,7 @@ Object { "cloudCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 0, }, @@ -389,6 +427,7 @@ Object { "cloudInstanceCount": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 0, }, @@ -396,6 +435,7 @@ Object { "cloudSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 0, }, @@ -403,20 +443,15 @@ Object { "cores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 2, }, ], - "hasData": Array [ - Object { - "date": 2019-09-04T00:00:00.000Z, - "x": 0, - "y": 0, - }, - ], "hypervisorCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, @@ -424,6 +459,7 @@ Object { "hypervisorSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, @@ -431,6 +467,7 @@ Object { "physicalCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, @@ -438,6 +475,7 @@ Object { "physicalSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, @@ -445,6 +483,7 @@ Object { "sockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 2, }, @@ -452,6 +491,7 @@ Object { "thresholdCloudCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -459,6 +499,7 @@ Object { "thresholdCloudInstanceCount": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -466,6 +507,7 @@ Object { "thresholdCloudSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -473,13 +515,7 @@ Object { "thresholdCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, - "x": 0, - "y": 0, - }, - ], - "thresholdHasInfiniteQuantity": Array [ - Object { - "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -487,6 +523,7 @@ Object { "thresholdHypervisorCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -494,6 +531,7 @@ Object { "thresholdHypervisorSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 50, }, @@ -501,6 +539,7 @@ Object { "thresholdPhysicalCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -508,6 +547,7 @@ Object { "thresholdPhysicalSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 50, }, @@ -515,6 +555,7 @@ Object { "thresholdSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 100, }, @@ -533,6 +574,7 @@ Object { "cloudCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 0, }, @@ -540,6 +582,7 @@ Object { "cloudInstanceCount": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 0, }, @@ -547,6 +590,7 @@ Object { "cloudSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 0, }, @@ -554,20 +598,15 @@ Object { "cores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 2, }, ], - "hasData": Array [ - Object { - "date": 2019-09-04T00:00:00.000Z, - "x": 0, - "y": 0, - }, - ], "hypervisorCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, @@ -575,6 +614,7 @@ Object { "hypervisorSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, @@ -582,6 +622,7 @@ Object { "physicalCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, @@ -589,6 +630,7 @@ Object { "physicalSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, @@ -596,6 +638,7 @@ Object { "sockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 2, }, @@ -603,6 +646,7 @@ Object { "thresholdCloudCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -610,6 +654,7 @@ Object { "thresholdCloudInstanceCount": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -617,6 +662,7 @@ Object { "thresholdCloudSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -624,13 +670,7 @@ Object { "thresholdCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, - "x": 0, - "y": 0, - }, - ], - "thresholdHasInfiniteQuantity": Array [ - Object { - "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -638,6 +678,7 @@ Object { "thresholdHypervisorCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -645,6 +686,7 @@ Object { "thresholdHypervisorSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 50, }, @@ -652,6 +694,7 @@ Object { "thresholdPhysicalCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -659,6 +702,7 @@ Object { "thresholdPhysicalSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 50, }, @@ -666,6 +710,7 @@ Object { "thresholdSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 100, }, @@ -684,6 +729,7 @@ Object { "cloudCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 0, }, @@ -691,6 +737,7 @@ Object { "cloudInstanceCount": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 0, }, @@ -698,6 +745,7 @@ Object { "cloudSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 0, }, @@ -705,20 +753,15 @@ Object { "cores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 2, }, ], - "hasData": Array [ - Object { - "date": 2019-09-04T00:00:00.000Z, - "x": 0, - "y": 0, - }, - ], "hypervisorCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, @@ -726,6 +769,7 @@ Object { "hypervisorSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, @@ -733,6 +777,7 @@ Object { "physicalCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, @@ -740,6 +785,7 @@ Object { "physicalSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 1, }, @@ -747,6 +793,7 @@ Object { "sockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": true, "x": 0, "y": 2, }, @@ -754,6 +801,7 @@ Object { "thresholdCloudCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -761,6 +809,7 @@ Object { "thresholdCloudInstanceCount": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -768,6 +817,7 @@ Object { "thresholdCloudSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -775,13 +825,7 @@ Object { "thresholdCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, - "x": 0, - "y": 0, - }, - ], - "thresholdHasInfiniteQuantity": Array [ - Object { - "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -789,6 +833,7 @@ Object { "thresholdHypervisorCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -796,6 +841,7 @@ Object { "thresholdHypervisorSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 50, }, @@ -803,6 +849,7 @@ Object { "thresholdPhysicalCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 0, }, @@ -810,6 +857,7 @@ Object { "thresholdPhysicalSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 50, }, @@ -817,6 +865,7 @@ Object { "thresholdSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": false, "x": 0, "y": 100, }, @@ -835,16 +884,19 @@ Object { "cloudCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": undefined, "x": 2, "y": 0, }, @@ -852,16 +904,19 @@ Object { "cloudInstanceCount": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": undefined, "x": 2, "y": 0, }, @@ -869,16 +924,19 @@ Object { "cloudSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": undefined, "x": 2, "y": 0, }, @@ -886,16 +944,19 @@ Object { "cores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": undefined, "x": 2, "y": 0, }, @@ -903,16 +964,19 @@ Object { "hasData": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": undefined, "x": 2, "y": 0, }, @@ -920,16 +984,19 @@ Object { "hypervisorCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": undefined, "x": 2, "y": 0, }, @@ -937,16 +1004,19 @@ Object { "hypervisorSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": undefined, "x": 1, "y": 1, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": undefined, "x": 2, "y": 0, }, @@ -954,16 +1024,19 @@ Object { "physicalCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": undefined, "x": 2, "y": 0, }, @@ -971,16 +1044,19 @@ Object { "physicalSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 1, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": undefined, "x": 2, "y": 2, }, @@ -988,16 +1064,19 @@ Object { "sockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 2, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasData": undefined, "x": 1, "y": 2, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasData": undefined, "x": 2, "y": 4, }, @@ -1005,16 +1084,19 @@ Object { "thresholdCloudCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": undefined, "x": 2, "y": 0, }, @@ -1022,16 +1104,19 @@ Object { "thresholdCloudInstanceCount": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": undefined, "x": 2, "y": 0, }, @@ -1039,16 +1124,19 @@ Object { "thresholdCloudSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": undefined, "x": 2, "y": 0, }, @@ -1056,16 +1144,19 @@ Object { "thresholdCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": undefined, "x": 2, "y": 0, }, @@ -1073,16 +1164,19 @@ Object { "thresholdHasInfiniteQuantity": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": undefined, "x": 2, "y": 0, }, @@ -1090,16 +1184,19 @@ Object { "thresholdHypervisorCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": undefined, "x": 2, "y": 0, }, @@ -1107,16 +1204,19 @@ Object { "thresholdHypervisorSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 50, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": undefined, "x": 2, "y": 50, }, @@ -1124,16 +1224,19 @@ Object { "thresholdPhysicalCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": undefined, "x": 2, "y": 0, }, @@ -1141,16 +1244,19 @@ Object { "thresholdPhysicalSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 50, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": undefined, "x": 2, "y": 50, }, @@ -1158,16 +1264,19 @@ Object { "thresholdSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 100, }, Object { "date": 2019-09-05T00:00:00.000Z, + "hasInfinite": undefined, "x": 1, "y": 0, }, Object { "date": 2019-09-06T00:00:00.000Z, + "hasInfinite": undefined, "x": 2, "y": 100, }, @@ -1186,6 +1295,7 @@ Object { "cloudCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 0, }, @@ -1193,6 +1303,7 @@ Object { "cloudInstanceCount": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 0, }, @@ -1200,6 +1311,7 @@ Object { "cloudSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 0, }, @@ -1207,6 +1319,7 @@ Object { "cores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 2, }, @@ -1214,6 +1327,7 @@ Object { "hasData": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 0, }, @@ -1221,6 +1335,7 @@ Object { "hypervisorCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 1, }, @@ -1228,6 +1343,7 @@ Object { "hypervisorSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 1, }, @@ -1235,6 +1351,7 @@ Object { "physicalCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 1, }, @@ -1242,6 +1359,7 @@ Object { "physicalSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 1, }, @@ -1249,6 +1367,7 @@ Object { "sockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasData": undefined, "x": 0, "y": 2, }, @@ -1256,6 +1375,7 @@ Object { "thresholdCloudCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, @@ -1263,6 +1383,7 @@ Object { "thresholdCloudInstanceCount": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, @@ -1270,6 +1391,7 @@ Object { "thresholdCloudSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, @@ -1277,6 +1399,7 @@ Object { "thresholdCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, @@ -1284,6 +1407,7 @@ Object { "thresholdDate": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, @@ -1291,6 +1415,7 @@ Object { "thresholdHasInfiniteQuantity": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, @@ -1298,6 +1423,7 @@ Object { "thresholdHypervisorCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, @@ -1305,6 +1431,7 @@ Object { "thresholdHypervisorSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, @@ -1312,6 +1439,7 @@ Object { "thresholdPhysicalCores": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, @@ -1319,6 +1447,7 @@ Object { "thresholdPhysicalSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, @@ -1326,6 +1455,7 @@ Object { "thresholdSockets": Array [ Object { "date": 2019-09-04T00:00:00.000Z, + "hasInfinite": undefined, "x": 0, "y": 0, }, diff --git a/src/redux/selectors/__tests__/graphCardSelectors.test.js b/src/redux/selectors/__tests__/graphCardSelectors.test.js index 35174e77a..8723ddc8b 100644 --- a/src/redux/selectors/__tests__/graphCardSelectors.test.js +++ b/src/redux/selectors/__tests__/graphCardSelectors.test.js @@ -217,7 +217,8 @@ describe('GraphCardSelectors', () => { [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.HYPERVISOR_CORES]: 1, [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.HYPERVISOR_SOCKETS]: 1, [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.PHYSICAL_CORES]: 1, - [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.PHYSICAL_SOCKETS]: 1 + [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.PHYSICAL_SOCKETS]: 1, + [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.HAS_DATA]: true }, { [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.DATE]: '2019-09-05T00:00:00.000Z', @@ -226,7 +227,8 @@ describe('GraphCardSelectors', () => { [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.HYPERVISOR_CORES]: 1, [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.HYPERVISOR_SOCKETS]: 1, [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.PHYSICAL_CORES]: 1, - [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.PHYSICAL_SOCKETS]: 1 + [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.PHYSICAL_SOCKETS]: 1, + [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.HAS_DATA]: true }, { [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.DATE]: '2019-09-06T00:00:00.000Z', @@ -235,7 +237,8 @@ describe('GraphCardSelectors', () => { [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.HYPERVISOR_CORES]: 2, [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.HYPERVISOR_SOCKETS]: 2, [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.PHYSICAL_CORES]: 2, - [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.PHYSICAL_SOCKETS]: null + [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.PHYSICAL_SOCKETS]: null, + [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.HAS_DATA]: true } ] }, @@ -298,7 +301,8 @@ describe('GraphCardSelectors', () => { [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.HYPERVISOR_CORES]: 1, [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.HYPERVISOR_SOCKETS]: 1, [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.PHYSICAL_CORES]: 1, - [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.PHYSICAL_SOCKETS]: 1 + [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.PHYSICAL_SOCKETS]: 1, + [rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.HAS_DATA]: true } ] }, @@ -308,7 +312,8 @@ describe('GraphCardSelectors', () => { [rhsmApiTypes.RHSM_API_RESPONSE_CAPACITY_DATA_TYPES.DATE]: '2019-09-04T00:00:00.000Z', [rhsmApiTypes.RHSM_API_RESPONSE_CAPACITY_DATA_TYPES.SOCKETS]: 100, [rhsmApiTypes.RHSM_API_RESPONSE_CAPACITY_DATA_TYPES.HYPERVISOR_SOCKETS]: 50, - [rhsmApiTypes.RHSM_API_RESPONSE_CAPACITY_DATA_TYPES.PHYSICAL_SOCKETS]: 50 + [rhsmApiTypes.RHSM_API_RESPONSE_CAPACITY_DATA_TYPES.PHYSICAL_SOCKETS]: 50, + [rhsmApiTypes.RHSM_API_RESPONSE_CAPACITY_DATA_TYPES.HAS_INFINITE]: false } ] } diff --git a/src/redux/selectors/graphCardSelectors.js b/src/redux/selectors/graphCardSelectors.js index 2e9cd1c23..8fcb7aa8e 100644 --- a/src/redux/selectors/graphCardSelectors.js +++ b/src/redux/selectors/graphCardSelectors.js @@ -81,11 +81,18 @@ const graphCardSelector = createSelector([graphResponse], response => { rhsmApiTypes.RHSM_API_RESPONSE_CAPACITY_DATA_TYPES ]); + // Apply "display logic" then return a custom value for Reporting graph entries + const customReportValue = (data, key, presetData) => ({ + ...presetData, + hasData: data[rhsmApiTypes.RHSM_API_RESPONSE_PRODUCTS_DATA_TYPES.HAS_DATA] + }); + // Apply "display logic" then return a custom value for Capacity graph entries const customCapacityValue = (data, key, { date, x, y }) => ({ date, x, - y: data[rhsmApiTypes.RHSM_API_RESPONSE_CAPACITY_DATA_TYPES.HAS_INFINITE] === true ? null : y + y: data[rhsmApiTypes.RHSM_API_RESPONSE_CAPACITY_DATA_TYPES.HAS_INFINITE] === true ? null : y, + hasInfinite: data[rhsmApiTypes.RHSM_API_RESPONSE_CAPACITY_DATA_TYPES.HAS_INFINITE] }); // Generate reflected graph data for number, undefined, and null @@ -130,7 +137,7 @@ const graphCardSelector = createSelector([graphResponse], response => { }); }; - generateGraphData({ graphDataObj: { ...tallySchema, ...value } }); + generateGraphData({ graphDataObj: { ...tallySchema, ...value }, customValue: customReportValue }); generateGraphData({ graphDataObj: { ...capacitySchema, ...capacityData[index] }, keyPrefix: 'threshold',