From 9df7b4ed53f0d3fa0b62888c49fe7d36ec69f035 Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Mon, 29 Aug 2022 12:24:09 -0400 Subject: [PATCH] fix(rhacs): sw-479 Core-hours to Cores metric (#965) --- public/locales/en-US.json | 29 ++++++++++++------- .../graphCardChartTooltip.test.js.snap | 8 ++--- .../graphCard/graphCardChartTooltip.js | 4 +-- .../__tests__/__snapshots__/i18n.test.js.snap | 10 ++----- .../inventoryCardContext.test.js.snap | 1 - .../__snapshots__/product.rhacs.test.js.snap | 18 ++++++------ src/config/__tests__/product.rhacs.test.js | 2 +- src/config/product.rhacs.js | 8 ++--- .../__snapshots__/rhsmConstants.test.js.snap | 8 ----- src/services/rhsm/rhsmConstants.js | 5 ++-- 10 files changed, 44 insertions(+), 49 deletions(-) diff --git a/public/locales/en-US.json b/public/locales/en-US.json index 1a18b0b40..49c753914 100644 --- a/public/locales/en-US.json +++ b/public/locales/en-US.json @@ -12,8 +12,11 @@ "cardActionTotal": "{{total}} used", "cardActionTotal_coreHours": "{{total}} core hours used", "cardHeading": "CPU usage", - "cardHeading_Core-hours": "vCPU hours", "cardHeading_cores": "CPU core usage", + "cardHeading_cores_OpenShift Container Platform": "CPU core usage", + "cardHeading_cores_OpenShift-metrics": "CPU core usage", + "cardHeading_cores_OpenShift-dedicated-metrics": "CPU core usage", + "cardHeading_Cores": "vCPU hours", "cardHeading_sockets": "CPU socket usage", "cardHeading_Instance-hours": "Instance hours", "cardHeading_Storage-gibibytes": "Data storage", @@ -31,7 +34,7 @@ "cardHeading_Satellite Capsule": "CPU socket usage", "cardHeading_Satellite Server": "CPU socket usage", "cardHeadingDescription": "...", - "cardHeadingDescription_Core-hours": "vCPU hours usage in hours", + "cardHeadingDescription_Cores": "vCPU hours usage in hours", "cardHeadingDescription_Instance-hours": "Instance hours usage in hours", "cardHeadingDescription_Storage-gibibytes": "Data storage usage in binary gigabyte hours", "cardHeadingDescription_Storage-gibibyte-months": "Data storage usage in binary gigabyte months", @@ -40,32 +43,35 @@ "cardHeadingDescription_OpenShift-metrics": "A subscription model that offers purchasing options to match your usage patterns.", "cardHeadingDescription_OpenShift-dedicated-metrics": "A subscription model that offers purchasing options to match your usage patterns.", "cardHeadingMetric_dailyTotal": "Daily total", - "cardHeadingMetric_dailyTotal_Core-hours": "Daily vCPU hours", + "cardHeadingMetric_dailyTotal_Cores": "Daily vCPU hours", "cardHeadingMetric_dailyTotal_Instance-hours": "Daily instance hours", "cardHeadingMetric_dailyTotal_Storage-gibibytes": "Daily data storage", "cardHeadingMetric_dailyTotal_Storage-gibibyte-months": "Daily data storage", "cardHeadingMetric_dailyTotal_Transfer-gibibytes": "Daily data transfer", "cardHeadingMetric_monthlyTotal": "Monthly total", - "cardHeadingMetric_monthlyTotal_Core-hours": "Monthly vCPU hours", + "cardHeadingMetric_monthlyTotal_Cores": "Monthly vCPU hours", "cardHeadingMetric_monthlyTotal_Instance-hours": "Monthly instance hours", "cardHeadingMetric_monthlyTotal_Storage-gibibytes": "Monthly data storage", "cardHeadingMetric_monthlyTotal_Storage-gibibyte-months": "Monthly data storage", "cardHeadingMetric_monthlyTotal_Transfer-gibibytes": "Monthly data transfer", "cardBodyMetric_total": "No data", - "cardBodyMetric_total_Core-hours": "<0>{{total}} vCPU hours", + "cardBodyMetric_total_Cores": "<0>{{total}} vCPU hours", "cardBodyMetric_total_Instance-hours": "<0>{{total}} Instance hours", "cardBodyMetric_total_Storage-gibibytes": "<0>{{total}} Binary gigabyte hours", "cardBodyMetric_total_Storage-gibibyte-months": "<0>{{total}} Binary gigabyte months", "cardBodyMetric_total_Transfer-gibibytes": "<0>{{total}} Binary gigabytes", "cardFooterMetric": "Last update {{date}}", "label_axisX_Daily": "Day of the month", - "label_axisY_Core-hours": "vCPU hours", + "label_axisY_Cores": "vCPU hours", "label_axisY_Instance-hours": "Instance hours", "label_axisY_Storage-gibibytes": "Binary gigabyte hours", "label_axisY_Storage-gibibyte-months": "Binary gigabyte months", "label_axisY_Transfer-gibibytes": "Binary gigabytes", - "label_Core-hours": "vCPU hours", "label_cores": "Cores", + "label_cores_OpenShift Container Platform": "Cores", + "label_cores_OpenShift-metrics": "Cores", + "label_cores_OpenShift-dedicated-metrics": "Cores", + "label_Cores": "vCPU hours", "label_coreHours": "Core hours", "label_instanceHours": "Instance hours", "label_Instance-hours": "Instance hours", @@ -83,8 +89,11 @@ "label_threshold": "Subscription threshold", "label_threshold_infinite": "unlimited", "label_Transfer-gibibytes": "Data transfer", - "legendTooltip_Core-hours": "vCPU hours usage", "legendTooltip_cores": "{{product}} CPU usage, per CPU core.", + "legendTooltip_cores_OpenShift Container Platform": "{{product}} CPU usage, per CPU core.", + "legendTooltip_cores_OpenShift-metrics": "{{product}} CPU usage, per CPU core.", + "legendTooltip_cores_OpenShift-dedicated-metrics": "{{product}} CPU usage, per CPU core.", + "legendTooltip_Cores": "vCPU hours usage", "legendTooltip_coreHours": "{{product}} core hours usage.", "legendTooltip_coreHours_OpenShift-dedicated-metrics": "OpenShift Dedicated <0>On-Demand core hour usage.", "legendTooltip_Instance-hours": "Instance hours usage", @@ -146,7 +155,7 @@ "header_cores_OpenShift Container Platform": "Cores", "header_cores_OpenShift-metrics": "Cores", "header_cores_OpenShift-dedicated-metrics": "Cores", - "header_Core-hours": "vCPU hours", + "header_Cores": "vCPU hours", "header_coreHours": "Core hours", "header_displayName": "Name", "header_display_name": "Name", @@ -183,7 +192,7 @@ "measurement_billing_provider_none": "None", "measurement_billing_provider_oracle": "Oracle", "measurement_billing_provider_red hat": "Red Hat", - "measurement_Core-hours": "{{total}} hours", + "measurement_Cores": "{{total}} hours", "measurement_Instance-hours": "{{total}} hours", "measurement_Storage-gibibytes": "{{total}} GB hours", "measurement_Storage-gibibyte-months": "{{total}} GB months", diff --git a/src/components/graphCard/__tests__/__snapshots__/graphCardChartTooltip.test.js.snap b/src/components/graphCard/__tests__/__snapshots__/graphCardChartTooltip.test.js.snap index 506dcb91a..6fb321422 100644 --- a/src/components/graphCard/__tests__/__snapshots__/graphCardChartTooltip.test.js.snap +++ b/src/components/graphCard/__tests__/__snapshots__/graphCardChartTooltip.test.js.snap @@ -29,7 +29,7 @@ exports[`GraphCardChartTooltip Component should render basic data: data 1`] = ` - t(curiosity-graph.label, {"context":"dolorSit"}) + t(curiosity-graph.label_dolorSit, {}) 1 - t(curiosity-graph.label, {"context":"loremIpsum"}) + t(curiosity-graph.label_loremIpsum, {}) 0 diff --git a/src/components/graphCard/graphCardChartTooltip.js b/src/components/graphCard/graphCardChartTooltip.js index 6b9a9bf2a..1cda6ba32 100644 --- a/src/components/graphCard/graphCardChartTooltip.js +++ b/src/components/graphCard/graphCardChartTooltip.js @@ -22,7 +22,7 @@ const GraphCardChartTooltip = ({ useProduct: useAliasProduct, useProductGraphTallyQuery: useAliasProductGraphTallyQuery }) => { - const { productLabel } = useAliasProduct(); + const { productId, productLabel } = useAliasProduct(); const { [RHSM_API_QUERY_SET_TYPES.GRANULARITY]: granularity } = useAliasProductGraphTallyQuery(); let header = null; @@ -68,7 +68,7 @@ const GraphCardChartTooltip = ({ itemsByKey[key]?.data.y || 0; - tempDataFacet.label = t('curiosity-graph.label', { context: key, product: productLabel }); + tempDataFacet.label = t(`curiosity-graph.label_${key}`, { context: productId, product: productLabel }); tempDataFacet.value = dataFactsValue; } diff --git a/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap b/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap index cda35e813..ac4d80607 100644 --- a/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap +++ b/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap @@ -121,8 +121,8 @@ Array [ "match": "t('curiosity-graph.label_noData')", }, Object { - "key": "curiosity-graph.label", - "match": "t('curiosity-graph.label', { context: key, product: productLabel })", + "key": "", + "match": "t(\`curiosity-graph.label_\${key}\`, { context: productId, product: productLabel })", }, Object { "key": "curiosity-graph.tooltipSummary", @@ -619,7 +619,7 @@ Array [ }, Object { "key": "curiosity-inventory.measurement", - "match": "translate('curiosity-inventory.measurement', { context: RHSM_API_PATH_METRIC_TYPES.CORE_HOURS, total: helpers.numberDisplay(total?.value)", + "match": "translate('curiosity-inventory.measurement', { context: RHSM_API_PATH_METRIC_TYPES.CORES, total: helpers.numberDisplay(total?.value)", }, Object { "key": "", @@ -752,10 +752,6 @@ Array [ exports[`I18n Component should have locale keys that exist in the default language JSON: missing locale keys 1`] = ` Array [ - Object { - "file": "./src/components/graphCard/graphCardChartTooltip.js", - "key": "curiosity-graph.label", - }, Object { "file": "./src/components/inventoryCard/inventoryCard.js", "key": "curiosity-inventory.tab", diff --git a/src/components/inventoryCard/__tests__/__snapshots__/inventoryCardContext.test.js.snap b/src/components/inventoryCard/__tests__/__snapshots__/inventoryCardContext.test.js.snap index f141c9d68..875683cc4 100644 --- a/src/components/inventoryCard/__tests__/__snapshots__/inventoryCardContext.test.js.snap +++ b/src/components/inventoryCard/__tests__/__snapshots__/inventoryCardContext.test.js.snap @@ -4,7 +4,6 @@ exports[`InventoryCardContext should expect specific sort properties: sort prope Object { "BILLING_PROVIDER": "billing_provider", "CORES": "Cores", - "CORE_HOURS": "Core-hours", "CORE_SECONDS": "Core-seconds", "INSTANCE_HOURS": "Instance-hours", "LAST_SEEN": "last_seen", diff --git a/src/config/__tests__/__snapshots__/product.rhacs.test.js.snap b/src/config/__tests__/__snapshots__/product.rhacs.test.js.snap index 8230dc962..6218c0ca6 100644 --- a/src/config/__tests__/__snapshots__/product.rhacs.test.js.snap +++ b/src/config/__tests__/__snapshots__/product.rhacs.test.js.snap @@ -10,7 +10,7 @@ Object { "title": "t(curiosity-inventory.measurement_billing_provider, {\\"context\\":\\"none\\"})", }, Object { - "title": "t(curiosity-inventory.measurement, {\\"context\\":\\"Core-hours\\",\\"total\\":\\"200\\"})", + "title": "t(curiosity-inventory.measurement, {\\"context\\":\\"Cores\\",\\"total\\":\\"200\\"})", }, Object { "title": { const inventoryData = { [INVENTORY_TYPES.DISPLAY_NAME]: 'lorem ipsum', - [RHSM_API_PATH_METRIC_TYPES.CORE_HOURS]: 200, + [RHSM_API_PATH_METRIC_TYPES.CORES]: 200, [INVENTORY_TYPES.LAST_SEEN]: '2022-01-01T00:00:00.000Z' }; diff --git a/src/config/product.rhacs.js b/src/config/product.rhacs.js index 29bc80242..a53d457c2 100644 --- a/src/config/product.rhacs.js +++ b/src/config/product.rhacs.js @@ -60,7 +60,7 @@ const config = { }, initialGraphFilters: [ { - id: RHSM_API_PATH_METRIC_TYPES.CORE_HOURS, + id: RHSM_API_PATH_METRIC_TYPES.CORES, fill: chartColorBlueLight.value, stroke: chartColorBlueDark.value, color: chartColorBlueDark.value, @@ -129,10 +129,10 @@ const config = { cellWidth: 15 }, { - id: RHSM_API_PATH_METRIC_TYPES.CORE_HOURS, - cell: ({ [RHSM_API_PATH_METRIC_TYPES.CORE_HOURS]: total }) => + id: RHSM_API_PATH_METRIC_TYPES.CORES, + cell: ({ [RHSM_API_PATH_METRIC_TYPES.CORES]: total }) => translate('curiosity-inventory.measurement', { - context: RHSM_API_PATH_METRIC_TYPES.CORE_HOURS, + context: RHSM_API_PATH_METRIC_TYPES.CORES, total: helpers.numberDisplay(total?.value)?.format({ mantissa: 5, trimMantissa: true }) || 0 }), isSortable: true, diff --git a/src/services/rhsm/__tests__/__snapshots__/rhsmConstants.test.js.snap b/src/services/rhsm/__tests__/__snapshots__/rhsmConstants.test.js.snap index 4a6d02479..b8950e1fc 100644 --- a/src/services/rhsm/__tests__/__snapshots__/rhsmConstants.test.js.snap +++ b/src/services/rhsm/__tests__/__snapshots__/rhsmConstants.test.js.snap @@ -4,7 +4,6 @@ exports[`RHSM Constants should have specific properties: all exported constants Object { "RHSM_API_PATH_METRIC_TYPES": Object { "CORES": "Cores", - "CORE_HOURS": "Core-hours", "CORE_SECONDS": "Core-seconds", "INSTANCE_HOURS": "Instance-hours", "SOCKETS": "Sockets", @@ -48,7 +47,6 @@ Object { "RHSM_API_QUERY_INVENTORY_SORT_TYPES": Object { "BILLING_PROVIDER": "billing_provider", "CORES": "Cores", - "CORE_HOURS": "Core-hours", "CORE_SECONDS": "Core-seconds", "INSTANCE_HOURS": "Instance-hours", "LAST_SEEN": "last_seen", @@ -226,7 +224,6 @@ Object { "default": Object { "RHSM_API_PATH_METRIC_TYPES": Object { "CORES": "Cores", - "CORE_HOURS": "Core-hours", "CORE_SECONDS": "Core-seconds", "INSTANCE_HOURS": "Instance-hours", "SOCKETS": "Sockets", @@ -270,7 +267,6 @@ Object { "RHSM_API_QUERY_INVENTORY_SORT_TYPES": Object { "BILLING_PROVIDER": "billing_provider", "CORES": "Cores", - "CORE_HOURS": "Core-hours", "CORE_SECONDS": "Core-seconds", "INSTANCE_HOURS": "Instance-hours", "LAST_SEEN": "last_seen", @@ -449,7 +445,6 @@ Object { "rhsmConstants": Object { "RHSM_API_PATH_METRIC_TYPES": Object { "CORES": "Cores", - "CORE_HOURS": "Core-hours", "CORE_SECONDS": "Core-seconds", "INSTANCE_HOURS": "Instance-hours", "SOCKETS": "Sockets", @@ -493,7 +488,6 @@ Object { "RHSM_API_QUERY_INVENTORY_SORT_TYPES": Object { "BILLING_PROVIDER": "billing_provider", "CORES": "Cores", - "CORE_HOURS": "Core-hours", "CORE_SECONDS": "Core-seconds", "INSTANCE_HOURS": "Instance-hours", "LAST_SEEN": "last_seen", @@ -676,7 +670,6 @@ exports[`RHSM Constants should have specific properties: specific constants 1`] Object { "RHSM_API_PATH_METRIC_TYPES": Object { "CORES": "Cores", - "CORE_HOURS": "Core-hours", "CORE_SECONDS": "Core-seconds", "INSTANCE_HOURS": "Instance-hours", "SOCKETS": "Sockets", @@ -720,7 +713,6 @@ Object { "RHSM_API_QUERY_INVENTORY_SORT_TYPES": Object { "BILLING_PROVIDER": "billing_provider", "CORES": "Cores", - "CORE_HOURS": "Core-hours", "CORE_SECONDS": "Core-seconds", "INSTANCE_HOURS": "Instance-hours", "LAST_SEEN": "last_seen", diff --git a/src/services/rhsm/rhsmConstants.js b/src/services/rhsm/rhsmConstants.js index ba90ac21b..9bb3cabfd 100644 --- a/src/services/rhsm/rhsmConstants.js +++ b/src/services/rhsm/rhsmConstants.js @@ -34,13 +34,12 @@ const RHSM_API_PATH_PRODUCT_TYPES = { /** * RHSM path IDs for metrics. * - * @type {{CORES: string, CORE_HOURS: string, STORAGE_GIBIBYTES: string, SOCKETS: string, INSTANCE_HOURS: string, + * @type {{CORES: string, STORAGE_GIBIBYTES: string, SOCKETS: string, INSTANCE_HOURS: string, * TRANSFER_GIBIBYTES: string, CORE_SECONDS: string, STORAGE_GIBIBYTE_MONTHS: string}} */ const RHSM_API_PATH_METRIC_TYPES = { CORES: 'Cores', SOCKETS: 'Sockets', - CORE_HOURS: 'Core-hours', CORE_SECONDS: 'Core-seconds', INSTANCE_HOURS: 'Instance-hours', STORAGE_GIBIBYTES: 'Storage-gibibytes', @@ -380,7 +379,7 @@ const RHSM_INTERNAL_PRODUCT_DISPLAY_TYPES = { * * @type {{RHSM_API_QUERY_SET_TALLY_CAPACITY_TYPES: {GRANULARITY: string, USAGE: string, END_DATE: string, SLA: string, START_DATE: string, * BILLING_PROVIDER: string}, RHSM_API_RESPONSE_DATA: string, RHSM_API_RESPONSE_SUBSCRIPTIONS_META_TYPES: {PRODUCT: string, - * SUBSCRIPTION_TYPE: string, COUNT: string}, RHSM_API_PATH_METRIC_TYPES: {CORES: string, CORE_HOURS: string, STORAGE_GIBIBYTES: string, + * SUBSCRIPTION_TYPE: string, COUNT: string}, RHSM_API_PATH_METRIC_TYPES: {CORES: string, STORAGE_GIBIBYTES: string, * SOCKETS: string, INSTANCE_HOURS: string, TRANSFER_GIBIBYTES: string, CORE_SECONDS: string, STORAGE_GIBIBYTE_MONTHS: string}, * RHSM_API_RESPONSE_TALLY_DATA_TYPES: {DATE: string, HAS_DATA: string, VALUE: string}, * RHSM_API_RESPONSE_INSTANCES_META_TYPES: {MEASUREMENTS: string, PRODUCT: string, COUNT: string},