From 49c7ed1a2dab95f907d6a265546dca7a0ed04eb5 Mon Sep 17 00:00:00 2001 From: CD Cabrera Date: Tue, 19 Mar 2024 11:34:18 -0400 Subject: [PATCH] refactor(config): sw-2319 separate cores, sockets display (#1297) --- public/locales/en-US.json | 8 +- .../__tests__/__snapshots__/i18n.test.js.snap | 34 ++- .../productViewContext.test.js.snap | 108 ++++--- .../__snapshots__/product.config.test.js.snap | 275 +++++++++++------- src/config/__tests__/product.config.test.js | 4 +- src/config/product.openshiftContainer.js | 113 ++++--- src/config/product.rhel.js | 28 +- .../rhsmTransformers.test.js.snap | 16 + src/services/rhsm/rhsmTransformers.js | 30 +- 9 files changed, 394 insertions(+), 222 deletions(-) diff --git a/public/locales/en-US.json b/public/locales/en-US.json index b8ca50471..a99670f01 100644 --- a/public/locales/en-US.json +++ b/public/locales/en-US.json @@ -9,7 +9,7 @@ "cardActionTotal_Cores": "{{total}} core hours used", "cardHeading": "Usage", "cardHeading_Cores": "vCPU hours", - "cardHeading_Cores_OpenShift Container Platform": "Annual subscriptions", + "cardHeading_Cores_OpenShift Container Platform": "Core usage", "cardHeading_Cores_OpenShift-dedicated-metrics": "On-Demand subscriptions", "cardHeading_Cores_OpenShift-metrics": "Core hours", "cardHeading_Cores_rosa": "vCPU hour usage", @@ -19,7 +19,7 @@ "cardHeading_Storage-gibibyte-months": "Data storage", "cardHeading_Transfer-gibibytes": "Data transfer", "cardHeading_Sockets": "CPU socket usage", - "cardHeading_Sockets_OpenShift Container Platform": "$t(curiosity-graph.cardHeading_Cores_OpenShift Container Platform)", + "cardHeading_Sockets_OpenShift Container Platform": "Socket usage", "cardHeading_vCPUs": "$t(curiosity-graph.cardHeading_Cores)", "cardHeadingDescription": "...", "cardHeadingDescription_Cores": "vCPU hours usage in hours", @@ -216,8 +216,8 @@ "label_cloud_provider_gcp": "GCP", "label_cloud_provider_ibm": "IBM", "label_cloud_provider_oracle": "Oracle", - "label_has_infinite_quantity_cores": "Unlimited cores", - "label_has_infinite_quantity_sockets": "Unlimited sockets", + "label_has_infinite_quantity_Cores": "Unlimited cores", + "label_has_infinite_quantity_Sockets": "Unlimited sockets", "label_number_of_guests": "{{context}}", "label_number_of_guests_one": "<0>{{count}} guest", "label_number_of_guests_other": "<0>{{count}} guests", diff --git a/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap b/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap index 205c13172..9f2fe2c5f 100644 --- a/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap +++ b/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap @@ -513,8 +513,8 @@ exports[`I18n Component should generate a predictable locale key output snapshot "match": "translate('curiosity-inventory.label', { context: 'numberOfGuests', count: numberOfGuests }, [ ])", }, { - "key": "curiosity-inventory.header", - "match": "translate('curiosity-inventory.header', { context: [uom, productId] })", + "key": "curiosity-inventory.measurement", + "match": "translate('curiosity-inventory.measurement', { context: (total && 'value')", }, { "key": "curiosity-inventory.measurement", @@ -526,11 +526,23 @@ exports[`I18n Component should generate a predictable locale key output snapshot }, { "key": "curiosity-inventory.header", - "match": "translate('curiosity-inventory.header', { context: ['subscriptions', uom] })", + "match": "translate('curiosity-inventory.header', { context: ['subscriptions', RHSM_API_PATH_METRIC_TYPES.CORES] })", }, { "key": "curiosity-inventory.label", - "match": "translate(\`curiosity-inventory.label\`, { context: [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY, uom] })", + "match": "translate(\`curiosity-inventory.label\`, { context: [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY, RHSM_API_PATH_METRIC_TYPES.CORES] })", + }, + { + "key": "curiosity-inventory.measurement", + "match": "translate('curiosity-inventory.measurement', { context: (total && 'value')", + }, + { + "key": "curiosity-inventory.header", + "match": "translate('curiosity-inventory.header', { context: ['subscriptions', RHSM_API_PATH_METRIC_TYPES.SOCKETS] })", + }, + { + "key": "curiosity-inventory.label", + "match": "translate(\`curiosity-inventory.label\`, { context: [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY, RHSM_API_PATH_METRIC_TYPES.SOCKETS] })", }, { "key": "curiosity-inventory.measurement", @@ -730,11 +742,11 @@ exports[`I18n Component should generate a predictable locale key output snapshot }, { "key": "curiosity-inventory.header", - "match": "translate('curiosity-inventory.header', { context: ['subscriptions', uom] })", + "match": "translate('curiosity-inventory.header', { context: ['subscriptions', RHSM_API_PATH_METRIC_TYPES.SOCKETS] })", }, { - "key": "", - "match": "translate( \`curiosity-inventory.label_\${SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY}\`, { context: uom } )", + "key": "curiosity-inventory.label", + "match": "translate(\`curiosity-inventory.label\`, { context: [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY, RHSM_API_PATH_METRIC_TYPES.SOCKETS] })", }, { "key": "curiosity-inventory.measurement", @@ -1060,6 +1072,10 @@ exports[`I18n Component should have locale keys that exist in the default langua "file": "src/config/product.openshiftContainer.js", "key": "curiosity-inventory.label", }, + { + "file": "src/config/product.openshiftContainer.js", + "key": "curiosity-inventory.label", + }, { "file": "src/config/product.openshiftDedicated.js", "key": "curiosity-graph.label_axisY", @@ -1124,6 +1140,10 @@ exports[`I18n Component should have locale keys that exist in the default langua "file": "src/config/product.rhel.js", "key": "curiosity-inventory.label", }, + { + "file": "src/config/product.rhel.js", + "key": "curiosity-inventory.label", + }, { "file": "src/config/product.rhelElsPayg.js", "key": "curiosity-graph.label_axisY", diff --git a/src/components/productView/__tests__/__snapshots__/productViewContext.test.js.snap b/src/components/productView/__tests__/__snapshots__/productViewContext.test.js.snap index 6cf7c0cd9..9425981a9 100644 --- a/src/components/productView/__tests__/__snapshots__/productViewContext.test.js.snap +++ b/src/components/productView/__tests__/__snapshots__/productViewContext.test.js.snap @@ -40,30 +40,31 @@ exports[`ProductViewContext should apply a hook for retrieving product context: { "color": "#06c", "fill": "#8bc1f7", - "isOptional": true, "metric": "Cores", "stroke": "#06c", }, { "chartType": "threshold", - "isOptional": true, "metric": "Cores", }, ], - "isOptional": false, + }, + { + "filters": [ + { + "color": "#06c", + "fill": "#8bc1f7", + "metric": "Sockets", + "stroke": "#06c", + }, + { + "chartType": "threshold", + "metric": "Sockets", + }, + ], }, ], "initialGraphSettings": { - "actions": [ - { - "id": "uom", - "position": "right", - }, - { - "id": "granularity", - "position": "right", - }, - ], "isCardTitleDescription": true, }, "initialGuestsFilters": [ @@ -90,12 +91,18 @@ exports[`ProductViewContext should apply a hook for retrieving product context: }, { "cell": [Function], - "header": [Function], "isSort": true, "isWrap": true, "metric": "Cores", "width": 15, }, + { + "cell": [Function], + "isSort": true, + "isWrap": true, + "metric": "Sockets", + "width": 15, + }, { "cell": [Function], "isSort": true, @@ -112,7 +119,6 @@ exports[`ProductViewContext should apply a hook for retrieving product context: ], "guestContent": [Function], }, - "initialOption": "cores", "initialSubscriptionsInventoryFilters": [ { "isSort": true, @@ -130,15 +136,21 @@ exports[`ProductViewContext should apply a hook for retrieving product context: "isSort": true, "isWrap": true, "metric": "quantity", - "width": 20, + "width": 10, }, { "cell": [Function], "header": [Function], - "isSort": true, "isWrap": true, "metric": "total_capacity", - "width": 15, + "width": 10, + }, + { + "cell": [Function], + "header": [Function], + "isWrap": true, + "metric": "total_capacity", + "width": 10, }, { "cell": [Function], @@ -152,6 +164,11 @@ exports[`ProductViewContext should apply a hook for retrieving product context: { "id": "sla", }, + { + "id": "granularity", + "isSecondary": true, + "position": "right", + }, ], "inventoryGuestsQuery": { "limit": 100, @@ -177,7 +194,6 @@ exports[`ProductViewContext should apply a hook for retrieving product context: "query": { "beginning": "2019-06-20T00:00:00.000Z", "ending": "2019-07-20T23:59:59.999Z", - "uom": "cores", }, "viewId": "viewopenshift", } @@ -201,30 +217,31 @@ exports[`ProductViewContext should apply a hook for retrieving product context: { "color": "#06c", "fill": "#8bc1f7", - "isOptional": true, + "metric": "Cores", + "stroke": "#06c", + }, + { + "chartType": "threshold", + "metric": "Cores", + }, + ], + }, + { + "filters": [ + { + "color": "#06c", + "fill": "#8bc1f7", "metric": "Sockets", "stroke": "#06c", }, { "chartType": "threshold", - "isOptional": true, "metric": "Sockets", }, ], - "isOptional": false, }, ], "initialGraphSettings": { - "actions": [ - { - "id": "uom", - "position": "right", - }, - { - "id": "granularity", - "position": "right", - }, - ], "isCardTitleDescription": true, }, "initialGuestsFilters": [ @@ -251,12 +268,18 @@ exports[`ProductViewContext should apply a hook for retrieving product context: }, { "cell": [Function], - "header": [Function], "isSort": true, "isWrap": true, "metric": "Cores", "width": 15, }, + { + "cell": [Function], + "isSort": true, + "isWrap": true, + "metric": "Sockets", + "width": 15, + }, { "cell": [Function], "isSort": true, @@ -273,7 +296,6 @@ exports[`ProductViewContext should apply a hook for retrieving product context: ], "guestContent": [Function], }, - "initialOption": "cores", "initialSubscriptionsInventoryFilters": [ { "isSort": true, @@ -291,15 +313,21 @@ exports[`ProductViewContext should apply a hook for retrieving product context: "isSort": true, "isWrap": true, "metric": "quantity", - "width": 20, + "width": 10, }, { "cell": [Function], "header": [Function], - "isSort": true, "isWrap": true, "metric": "total_capacity", - "width": 15, + "width": 10, + }, + { + "cell": [Function], + "header": [Function], + "isWrap": true, + "metric": "total_capacity", + "width": 10, }, { "cell": [Function], @@ -313,6 +341,11 @@ exports[`ProductViewContext should apply a hook for retrieving product context: { "id": "sla", }, + { + "id": "granularity", + "isSecondary": true, + "position": "right", + }, ], "inventoryGuestsQuery": { "limit": 100, @@ -338,7 +371,6 @@ exports[`ProductViewContext should apply a hook for retrieving product context: "query": { "beginning": "2019-06-20T00:00:00.000Z", "ending": "2019-07-20T23:59:59.999Z", - "uom": "cores", }, "viewId": "viewopenshift", } diff --git a/src/config/__tests__/__snapshots__/product.config.test.js.snap b/src/config/__tests__/__snapshots__/product.config.test.js.snap index e3279aa36..f6513d5f3 100644 --- a/src/config/__tests__/__snapshots__/product.config.test.js.snap +++ b/src/config/__tests__/__snapshots__/product.config.test.js.snap @@ -1549,26 +1549,14 @@ exports[`Product specific configurations should apply graph filters and settings "filtersSettings": [ { "settings": { - "actions": [ - { - "id": "uom", - "position": "right", - }, - { - "id": "granularity", - "position": "right", - }, - ], "color": "#06c", "fill": "#8bc1f7", "groupMetric": [ "Cores", - "Sockets", ], "isCardTitleDescription": true, "isMetricDisplay": false, "isMultiMetric": true, - "isOptional": true, "isStandalone": undefined, "metric": undefined, "metrics": [ @@ -1578,7 +1566,6 @@ exports[`Product specific configurations should apply graph filters and settings "fill": "#8bc1f7", "id": "Cores_OpenShift Container Platform", "isCapacity": false, - "isOptional": true, "isStacked": true, "isThreshold": false, "isToolbarFilter": false, @@ -1586,13 +1573,43 @@ exports[`Product specific configurations should apply graph filters and settings "stroke": "#06c", "strokeWidth": 2, }, + { + "chartType": "threshold", + "id": "threshold_Cores_OpenShift Container Platform", + "isCapacity": true, + "isStacked": false, + "isThreshold": true, + "isToolbarFilter": false, + "metric": "Cores", + "stroke": "#4cb140", + "strokeDasharray": "4,3", + "strokeWidth": 3, + }, + ], + "productId": "OpenShift Container Platform", + "stringId": "Cores_OpenShift Container Platform", + "stroke": "#06c", + }, + }, + { + "settings": { + "color": "#06c", + "fill": "#8bc1f7", + "groupMetric": [ + "Sockets", + ], + "isCardTitleDescription": true, + "isMetricDisplay": false, + "isMultiMetric": true, + "isStandalone": undefined, + "metric": undefined, + "metrics": [ { "chartType": "area", "color": "#06c", "fill": "#8bc1f7", "id": "Sockets_OpenShift Container Platform", "isCapacity": false, - "isOptional": true, "isStacked": true, "isThreshold": false, "isToolbarFilter": false, @@ -1604,7 +1621,6 @@ exports[`Product specific configurations should apply graph filters and settings "chartType": "threshold", "id": "threshold_Sockets_OpenShift Container Platform", "isCapacity": true, - "isOptional": true, "isStacked": false, "isThreshold": true, "isToolbarFilter": false, @@ -1613,22 +1629,9 @@ exports[`Product specific configurations should apply graph filters and settings "strokeDasharray": "4,3", "strokeWidth": 3, }, - { - "chartType": "threshold", - "id": "threshold_Cores_OpenShift Container Platform", - "isCapacity": true, - "isOptional": true, - "isStacked": false, - "isThreshold": true, - "isToolbarFilter": false, - "metric": "Cores", - "stroke": "#4cb140", - "strokeDasharray": "4,3", - "strokeWidth": 3, - }, ], "productId": "OpenShift Container Platform", - "stringId": "Cores_Sockets_OpenShift Container Platform", + "stringId": "Sockets_OpenShift Container Platform", "stroke": "#06c", }, }, @@ -2463,12 +2466,14 @@ exports[`Product specific configurations should apply query parameters: product "limit": 100, "offset": 0, "sort": "last_seen", + "uom": "sockets", }, "inventorySubscriptionsQuery": { "dir": "desc", "limit": 100, "offset": 0, "sort": "next_event_date", + "uom": "sockets", }, }, }, @@ -3460,7 +3465,7 @@ exports[`Product specific configurations should apply variations in inventory fi }, { "cell": [Function], - "content": "t(curiosity-inventory.header, {"context":"OpenShift Container Platform"})", + "content": "t([curiosity-inventory.header_Cores,curiosity-inventory.guestsHeader_Cores], {"context":"OpenShift Container Platform"})", "info": undefined, "isSort": true, "isWrap": true, @@ -3469,6 +3474,17 @@ exports[`Product specific configurations should apply variations in inventory fi "modifier": "wrap", "width": 15, }, + { + "cell": [Function], + "content": "t([curiosity-inventory.header_Sockets,curiosity-inventory.guestsHeader_Sockets], {"context":"OpenShift Container Platform"})", + "info": undefined, + "isSort": true, + "isWrap": true, + "label": [Function], + "metric": "Sockets", + "modifier": "wrap", + "width": 15, + }, { "cell": [Function], "content": "t([curiosity-inventory.header_last_seen,curiosity-inventory.guestsHeader_last_seen], {"context":"OpenShift Container Platform"})", @@ -3504,14 +3520,23 @@ exports[`Product specific configurations should apply variations in inventory fi "width": undefined, }, { - "content": "t(curiosity-inventory.measurement, {"testId":{"type":"span","key":null,"ref":null,"props":{"data-test":"instances-cell-undefined","data-value":"undefined"},"_owner":null,"_store":{}}})", - "dataLabel": "t(curiosity-inventory.header, {"context":"OpenShift Container Platform"})", + "content": "t(curiosity-inventory.measurement, {"testId":{"type":"span","key":null,"ref":null,"props":{"data-test":"instances-cell-Cores","data-value":"undefined"},"_owner":null,"_store":{}}})", + "dataLabel": "t([curiosity-inventory.header_Cores,curiosity-inventory.guestsHeader_Cores], {"context":"OpenShift Container Platform"})", "header": [Function], "isSort": true, "isWrap": true, "metric": "Cores", "width": 15, }, + { + "content": "t(curiosity-inventory.measurement, {"testId":{"type":"span","key":null,"ref":null,"props":{"data-test":"instances-cell-Sockets","data-value":"undefined"},"_owner":null,"_store":{}}})", + "dataLabel": "t([curiosity-inventory.header_Sockets,curiosity-inventory.guestsHeader_Sockets], {"context":"OpenShift Container Platform"})", + "header": [Function], + "isSort": true, + "isWrap": true, + "metric": "Sockets", + "width": 15, + }, { "content": , - "dataLabel": "t(curiosity-inventory.header, {"context":"subscriptions"})", + "dataLabel": "t(curiosity-inventory.header_subscriptions, {"context":"Cores"})", "header": [Function], - "isSort": true, "isWrap": true, "metric": "total_capacity", - "width": 15, + "width": 10, + }, + { + "content": "t(curiosity-inventory.measurement, {"testId":{"type":"span","key":null,"ref":null,"props":{"data-test":"subscriptions-cell-total_capacity-Sockets","data-value":"undefined"},"_owner":null,"_store":{}}})", + "dataLabel": "t(curiosity-inventory.header_subscriptions, {"context":"Sockets"})", + "header": [Function], + "isWrap": true, + "metric": "total_capacity", + "width": 10, }, { "content": "2022-01-01", @@ -5530,8 +5591,9 @@ exports[`Product specific configurations should apply variations in inventory fi ], "expandedContent": undefined, "row": { + "Cores": 2000, "billing_provider": "dolor sit", - "has_infinite_quantity": true, + "hasInfiniteCores": true, "loremIpsum": "hello world", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", @@ -5676,8 +5738,9 @@ exports[`Product specific configurations should apply variations in inventory fi ], "expandedContent": undefined, "row": { + "Cores": 2000, "billing_provider": "dolor sit", - "has_infinite_quantity": true, + "hasInfiniteCores": true, "loremIpsum": "hello world", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", @@ -5731,14 +5794,14 @@ exports[`Product specific configurations should apply variations in inventory fi }, { "cell": [Function], - "content": "t(curiosity-inventory.header, {"context":"subscriptions"})", + "content": "t(curiosity-inventory.header_subscriptions, {"context":"Sockets"})", "info": undefined, "isSort": true, "isWrap": true, "label": [Function], "metric": "total_capacity", "modifier": "wrap", - "width": 10, + "width": undefined, }, { "cell": [Function], @@ -5783,29 +5846,13 @@ exports[`Product specific configurations should apply variations in inventory fi "width": 10, }, { - "content": - - , - "dataLabel": "t(curiosity-inventory.header, {"context":"subscriptions"})", + "content": "t(curiosity-inventory.measurement, {"testId":{"type":"span","key":null,"ref":null,"props":{"data-test":"subscriptions-cell-total_capacity-Sockets","data-value":"undefined"},"_owner":null,"_store":{}}})", + "dataLabel": "t(curiosity-inventory.header_subscriptions, {"context":"Sockets"})", "header": [Function], "isSort": true, "isWrap": true, "metric": "total_capacity", - "width": 10, + "width": undefined, }, { "content": "2022-01-01", @@ -5819,8 +5866,9 @@ exports[`Product specific configurations should apply variations in inventory fi ], "expandedContent": undefined, "row": { + "Cores": 2000, "billing_provider": "dolor sit", - "has_infinite_quantity": true, + "hasInfiniteCores": true, "loremIpsum": "hello world", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", @@ -5965,8 +6013,9 @@ exports[`Product specific configurations should apply variations in inventory fi ], "expandedContent": undefined, "row": { + "Cores": 2000, "billing_provider": "dolor sit", - "has_infinite_quantity": true, + "hasInfiniteCores": true, "loremIpsum": "hello world", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", @@ -6111,8 +6160,9 @@ exports[`Product specific configurations should apply variations in inventory fi ], "expandedContent": undefined, "row": { + "Cores": 2000, "billing_provider": "dolor sit", - "has_infinite_quantity": true, + "hasInfiniteCores": true, "loremIpsum": "hello world", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", @@ -6198,8 +6248,9 @@ exports[`Product specific configurations should apply variations in inventory fi ], "expandedContent": undefined, "row": { + "Cores": 2000, "billing_provider": "dolor sit", - "has_infinite_quantity": true, + "hasInfiniteCores": true, "loremIpsum": "hello world", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", @@ -6265,18 +6316,27 @@ exports[`Product specific configurations should apply variations in inventory fi "label": [Function], "metric": "quantity", "modifier": "wrap", - "width": 20, + "width": 10, }, { "cell": [Function], - "content": "t(curiosity-inventory.header, {"context":"subscriptions"})", + "content": "t(curiosity-inventory.header_subscriptions, {"context":"Cores"})", "info": undefined, - "isSort": true, "isWrap": true, "label": [Function], "metric": "total_capacity", "modifier": "wrap", - "width": 15, + "width": 10, + }, + { + "cell": [Function], + "content": "t(curiosity-inventory.header_subscriptions, {"context":"Sockets"})", + "info": undefined, + "isWrap": true, + "label": [Function], + "metric": "total_capacity", + "modifier": "wrap", + "width": 10, }, { "cell": [Function], @@ -6318,11 +6378,11 @@ exports[`Product specific configurations should apply variations in inventory fi "isSort": true, "isWrap": true, "metric": "quantity", - "width": 20, + "width": 10, }, { "content": , - "dataLabel": "t(curiosity-inventory.header, {"context":"subscriptions"})", + "dataLabel": "t(curiosity-inventory.header_subscriptions, {"context":"Cores"})", "header": [Function], - "isSort": true, "isWrap": true, "metric": "total_capacity", - "width": 15, + "width": 10, + }, + { + "content": "t(curiosity-inventory.measurement, {"testId":{"type":"span","key":null,"ref":null,"props":{"data-test":"subscriptions-cell-total_capacity-Sockets","data-value":"undefined"},"_owner":null,"_store":{}}})", + "dataLabel": "t(curiosity-inventory.header_subscriptions, {"context":"Sockets"})", + "header": [Function], + "isWrap": true, + "metric": "total_capacity", + "width": 10, }, { "content": "2022-01-01", @@ -6357,8 +6424,9 @@ exports[`Product specific configurations should apply variations in inventory fi ], "expandedContent": undefined, "row": { + "Cores": 2000, "billing_provider": "dolor sit", - "has_infinite_quantity": true, + "hasInfiniteCores": true, "loremIpsum": "hello world", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", @@ -6503,8 +6571,9 @@ exports[`Product specific configurations should apply variations in inventory fi ], "expandedContent": undefined, "row": { + "Cores": 2000, "billing_provider": "dolor sit", - "has_infinite_quantity": true, + "hasInfiniteCores": true, "loremIpsum": "hello world", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", @@ -6558,14 +6627,14 @@ exports[`Product specific configurations should apply variations in inventory fi }, { "cell": [Function], - "content": "t(curiosity-inventory.header, {"context":"subscriptions"})", + "content": "t(curiosity-inventory.header_subscriptions, {"context":"Sockets"})", "info": undefined, "isSort": true, "isWrap": true, "label": [Function], "metric": "total_capacity", "modifier": "wrap", - "width": 10, + "width": undefined, }, { "cell": [Function], @@ -6610,29 +6679,13 @@ exports[`Product specific configurations should apply variations in inventory fi "width": 10, }, { - "content": - - , - "dataLabel": "t(curiosity-inventory.header, {"context":"subscriptions"})", + "content": "t(curiosity-inventory.measurement, {"testId":{"type":"span","key":null,"ref":null,"props":{"data-test":"subscriptions-cell-total_capacity-Sockets","data-value":"undefined"},"_owner":null,"_store":{}}})", + "dataLabel": "t(curiosity-inventory.header_subscriptions, {"context":"Sockets"})", "header": [Function], "isSort": true, "isWrap": true, "metric": "total_capacity", - "width": 10, + "width": undefined, }, { "content": "2022-01-01", @@ -6646,8 +6699,9 @@ exports[`Product specific configurations should apply variations in inventory fi ], "expandedContent": undefined, "row": { + "Cores": 2000, "billing_provider": "dolor sit", - "has_infinite_quantity": true, + "hasInfiniteCores": true, "loremIpsum": "hello world", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", @@ -6792,8 +6846,9 @@ exports[`Product specific configurations should apply variations in inventory fi ], "expandedContent": undefined, "row": { + "Cores": 2000, "billing_provider": "dolor sit", - "has_infinite_quantity": true, + "hasInfiniteCores": true, "loremIpsum": "hello world", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", @@ -6938,8 +6993,9 @@ exports[`Product specific configurations should apply variations in inventory fi ], "expandedContent": undefined, "row": { + "Cores": 2000, "billing_provider": "dolor sit", - "has_infinite_quantity": true, + "hasInfiniteCores": true, "loremIpsum": "hello world", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", @@ -7025,8 +7081,9 @@ exports[`Product specific configurations should apply variations in inventory fi ], "expandedContent": undefined, "row": { + "Cores": 2000, "billing_provider": "dolor sit", - "has_infinite_quantity": true, + "hasInfiniteCores": true, "loremIpsum": "hello world", "next_event_date": "2022-01-01T00:00:00.000Z", "product_name": "lorem", diff --git a/src/config/__tests__/product.config.test.js b/src/config/__tests__/product.config.test.js index 2a9fbba5f..2f2b163df 100644 --- a/src/config/__tests__/product.config.test.js +++ b/src/config/__tests__/product.config.test.js @@ -1,6 +1,7 @@ import { products } from '../products'; import { generateChartSettings } from '../../components/graphCard/graphCardHelpers'; import { + RHSM_API_PATH_METRIC_TYPES, RHSM_API_RESPONSE_INSTANCES_DATA_TYPES as INVENTORY_TYPES, RHSM_API_RESPONSE_SUBSCRIPTIONS_DATA_TYPES as SUBSCRIPTIONS_INVENTORY_TYPES } from '../../services/rhsm/rhsmConstants'; @@ -244,12 +245,13 @@ describe('Product specific configurations', () => { { [SUBSCRIPTIONS_INVENTORY_TYPES.PRODUCT_NAME]: 'lorem', [SUBSCRIPTIONS_INVENTORY_TYPES.BILLING_PROVIDER]: 'dolor sit', - [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY]: true, [SUBSCRIPTIONS_INVENTORY_TYPES.NEXT_EVENT_DATE]: '2022-01-01T00:00:00.000Z', [SUBSCRIPTIONS_INVENTORY_TYPES.QUANTITY]: 1, [SUBSCRIPTIONS_INVENTORY_TYPES.SERVICE_LEVEL]: 'hello world', [SUBSCRIPTIONS_INVENTORY_TYPES.TOTAL_CAPACITY]: 2000, [SUBSCRIPTIONS_INVENTORY_TYPES.UOM]: 'cores', + [RHSM_API_PATH_METRIC_TYPES.CORES]: 2000, + [`hasInfinite${RHSM_API_PATH_METRIC_TYPES.CORES}`]: true, loremIpsum: 'hello world' } ] diff --git a/src/config/product.openshiftContainer.js b/src/config/product.openshiftContainer.js index fb44e500d..e612d0e94 100644 --- a/src/config/product.openshiftContainer.js +++ b/src/config/product.openshiftContainer.js @@ -14,9 +14,7 @@ import { RHSM_API_QUERY_INVENTORY_SORT_TYPES as INVENTORY_SORT_TYPES, RHSM_API_QUERY_INVENTORY_SUBSCRIPTIONS_SORT_TYPES as SUBSCRIPTIONS_SORT_TYPES, RHSM_API_QUERY_SET_TYPES, - RHSM_API_QUERY_UOM_TYPES, RHSM_API_RESPONSE_INSTANCES_DATA_TYPES as INVENTORY_TYPES, - RHSM_API_RESPONSE_INSTANCES_META_TYPES as INVENTORY_META_TYPES, RHSM_API_RESPONSE_SUBSCRIPTIONS_DATA_TYPES as SUBSCRIPTIONS_INVENTORY_TYPES, RHSM_INTERNAL_PRODUCT_DISPLAY_TYPES as DISPLAY_TYPES } from '../services/rhsm/rhsmConstants'; @@ -75,9 +73,8 @@ const config = { productPath: productGroup.toLowerCase(), productDisplay: DISPLAY_TYPES.CAPACITY, viewId: `view${productGroup}`, - productContextFilterUom: true, + productContextFilterUom: false, query: { - [RHSM_API_QUERY_SET_TYPES.UOM]: RHSM_API_QUERY_UOM_TYPES.CORES, [RHSM_API_QUERY_SET_TYPES.START_DATE]: dateHelpers .getRangedDateTime(GRANULARITY_TYPES.DAILY) .startDate.toISOString(), @@ -102,49 +99,38 @@ const config = { [RHSM_API_QUERY_SET_TYPES.LIMIT]: 100, [RHSM_API_QUERY_SET_TYPES.OFFSET]: 0 }, - initialOption: RHSM_API_QUERY_UOM_TYPES.CORES, initialGraphFilters: [ { filters: [ { metric: RHSM_API_PATH_METRIC_TYPES.CORES, - isOptional: true, fill: chartColorBlueLight.value, stroke: chartColorBlueDark.value, color: chartColorBlueDark.value }, + { + metric: RHSM_API_PATH_METRIC_TYPES.CORES, + chartType: ChartTypeVariant.threshold + } + ] + }, + { + filters: [ { metric: RHSM_API_PATH_METRIC_TYPES.SOCKETS, - isOptional: true, fill: chartColorBlueLight.value, stroke: chartColorBlueDark.value, color: chartColorBlueDark.value }, { metric: RHSM_API_PATH_METRIC_TYPES.SOCKETS, - chartType: ChartTypeVariant.threshold, - isOptional: true - }, - { - metric: RHSM_API_PATH_METRIC_TYPES.CORES, - chartType: ChartTypeVariant.threshold, - isOptional: true + chartType: ChartTypeVariant.threshold } ] } ], initialGraphSettings: { - isCardTitleDescription: true, - actions: [ - { - id: RHSM_API_QUERY_SET_TYPES.UOM, - position: SelectPosition.right - }, - { - id: RHSM_API_QUERY_SET_TYPES.GRANULARITY, - position: SelectPosition.right - } - ] + isCardTitleDescription: true }, initialGuestsFilters: [ { @@ -235,16 +221,24 @@ const config = { }, { metric: RHSM_API_PATH_METRIC_TYPES.CORES, - header: (data, session, { [INVENTORY_META_TYPES.UOM]: uom } = {}) => - translate('curiosity-inventory.header', { context: [uom, productId] }), - cell: (data = {}, session, { [INVENTORY_META_TYPES.UOM]: uom } = {}) => { - const total = data?.[uom]; - return translate('curiosity-inventory.measurement', { + cell: ({ [RHSM_API_PATH_METRIC_TYPES.CORES]: total } = {}) => + translate('curiosity-inventory.measurement', { context: (total && 'value') || undefined, total, - testId: - }); - }, + testId: + }), + isSort: true, + isWrap: true, + width: 15 + }, + { + metric: RHSM_API_PATH_METRIC_TYPES.SOCKETS, + cell: ({ [RHSM_API_PATH_METRIC_TYPES.SOCKETS]: total } = {}) => + translate('curiosity-inventory.measurement', { + context: (total && 'value') || undefined, + total, + testId: + }), isSort: true, isWrap: true, width: 15 @@ -292,20 +286,16 @@ const config = { }), isSort: true, isWrap: true, - width: 20 + width: 10 }, { metric: SUBSCRIPTIONS_INVENTORY_TYPES.TOTAL_CAPACITY, - header: (data, session, { [INVENTORY_META_TYPES.UOM]: uom } = {}) => - translate('curiosity-inventory.header', { context: ['subscriptions', uom] }), - cell: ({ - [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY]: hasInfiniteQuantity, - [SUBSCRIPTIONS_INVENTORY_TYPES.TOTAL_CAPACITY]: total, - [SUBSCRIPTIONS_INVENTORY_TYPES.UOM]: uom - } = {}) => { + header: () => + translate('curiosity-inventory.header', { context: ['subscriptions', RHSM_API_PATH_METRIC_TYPES.CORES] }), + cell: ({ hasInfiniteCores: hasInfiniteQuantity, [RHSM_API_PATH_METRIC_TYPES.CORES]: total } = {}) => { if (hasInfiniteQuantity === true) { const content = translate(`curiosity-inventory.label`, { - context: [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY, uom] + context: [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY, RHSM_API_PATH_METRIC_TYPES.CORES] }); return ( @@ -318,15 +308,43 @@ const config = { total, testId: ( ) }); }, - isSort: true, isWrap: true, - width: 15 + width: 10 + }, + { + metric: SUBSCRIPTIONS_INVENTORY_TYPES.TOTAL_CAPACITY, + header: () => + translate('curiosity-inventory.header', { context: ['subscriptions', RHSM_API_PATH_METRIC_TYPES.SOCKETS] }), + cell: ({ hasInfiniteSockets: hasInfiniteQuantity, [RHSM_API_PATH_METRIC_TYPES.SOCKETS]: total } = {}) => { + if (hasInfiniteQuantity === true) { + const content = translate(`curiosity-inventory.label`, { + context: [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY, RHSM_API_PATH_METRIC_TYPES.SOCKETS] + }); + return ( + + + + ); + } + return translate('curiosity-inventory.measurement', { + context: (total && 'value') || undefined, + total, + testId: ( + + ) + }); + }, + isWrap: true, + width: 10 }, { metric: SUBSCRIPTIONS_INVENTORY_TYPES.NEXT_EVENT_DATE, @@ -340,6 +358,11 @@ const config = { initialToolbarFilters: [ { id: RHSM_API_QUERY_SET_TYPES.SLA + }, + { + id: RHSM_API_QUERY_SET_TYPES.GRANULARITY, + isSecondary: true, + position: SelectPosition.right } ] }; diff --git a/src/config/product.rhel.js b/src/config/product.rhel.js index 50f660519..03d49b5bb 100644 --- a/src/config/product.rhel.js +++ b/src/config/product.rhel.js @@ -25,8 +25,7 @@ import { RHSM_API_QUERY_UOM_TYPES, RHSM_API_RESPONSE_INSTANCES_DATA_TYPES as INVENTORY_TYPES, RHSM_API_RESPONSE_SUBSCRIPTIONS_DATA_TYPES as SUBSCRIPTIONS_INVENTORY_TYPES, - RHSM_INTERNAL_PRODUCT_DISPLAY_TYPES as DISPLAY_TYPES, - RHSM_API_RESPONSE_INSTANCES_META_TYPES as INVENTORY_META_TYPES + RHSM_INTERNAL_PRODUCT_DISPLAY_TYPES as DISPLAY_TYPES } from '../services/rhsm/rhsmConstants'; import { dateHelpers, helpers } from '../common'; import { Tooltip } from '../components/tooltip/tooltip'; @@ -83,7 +82,6 @@ const config = { viewId: `view${productGroup}`, productVariants: [...Object.values(RHSM_API_PATH_PRODUCT_VARIANT_RHEL_TYPES)], query: { - [RHSM_API_QUERY_SET_TYPES.UOM]: RHSM_API_QUERY_UOM_TYPES.SOCKETS, [RHSM_API_QUERY_SET_TYPES.START_DATE]: dateHelpers .getRangedDateTime(GRANULARITY_TYPES.DAILY) .startDate.toISOString(), @@ -97,12 +95,14 @@ const config = { [RHSM_API_QUERY_SET_TYPES.OFFSET]: 0 }, inventoryHostsQuery: { + [RHSM_API_QUERY_SET_TYPES.UOM]: RHSM_API_QUERY_UOM_TYPES.SOCKETS, [RHSM_API_QUERY_SET_TYPES.SORT]: INVENTORY_SORT_TYPES.LAST_SEEN, [RHSM_API_QUERY_SET_TYPES.DIRECTION]: SORT_DIRECTION_TYPES.DESCENDING, [RHSM_API_QUERY_SET_TYPES.LIMIT]: 100, [RHSM_API_QUERY_SET_TYPES.OFFSET]: 0 }, inventorySubscriptionsQuery: { + [RHSM_API_QUERY_SET_TYPES.UOM]: RHSM_API_QUERY_UOM_TYPES.SOCKETS, [RHSM_API_QUERY_SET_TYPES.SORT]: SUBSCRIPTIONS_SORT_TYPES.NEXT_EVENT_DATE, [RHSM_API_QUERY_SET_TYPES.DIRECTION]: SORT_DIRECTION_TYPES.DESCENDING, [RHSM_API_QUERY_SET_TYPES.LIMIT]: 100, @@ -323,18 +323,13 @@ const config = { }, { metric: SUBSCRIPTIONS_INVENTORY_TYPES.TOTAL_CAPACITY, - header: (data, session, { [INVENTORY_META_TYPES.UOM]: uom } = {}) => - translate('curiosity-inventory.header', { context: ['subscriptions', uom] }), - cell: ({ - [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY]: hasInfiniteQuantity, - [SUBSCRIPTIONS_INVENTORY_TYPES.TOTAL_CAPACITY]: total, - [SUBSCRIPTIONS_INVENTORY_TYPES.UOM]: uom - } = {}) => { + header: () => + translate('curiosity-inventory.header', { context: ['subscriptions', RHSM_API_PATH_METRIC_TYPES.SOCKETS] }), + cell: ({ hasInfiniteSockets: hasInfiniteQuantity, [RHSM_API_PATH_METRIC_TYPES.SOCKETS]: total } = {}) => { if (hasInfiniteQuantity === true) { - const content = translate( - `curiosity-inventory.label_${SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY}`, - { context: uom } - ); + const content = translate(`curiosity-inventory.label`, { + context: [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY, RHSM_API_PATH_METRIC_TYPES.SOCKETS] + }); return ( @@ -346,15 +341,14 @@ const config = { total, testId: ( ) }); }, isSort: true, - isWrap: true, - width: 10 + isWrap: true }, { metric: SUBSCRIPTIONS_INVENTORY_TYPES.NEXT_EVENT_DATE, diff --git a/src/services/rhsm/__tests__/__snapshots__/rhsmTransformers.test.js.snap b/src/services/rhsm/__tests__/__snapshots__/rhsmTransformers.test.js.snap index 9b6632241..0367034e7 100644 --- a/src/services/rhsm/__tests__/__snapshots__/rhsmTransformers.test.js.snap +++ b/src/services/rhsm/__tests__/__snapshots__/rhsmTransformers.test.js.snap @@ -414,6 +414,10 @@ exports[`RHSM Transformers should attempt to parse a subscriptions response: sub { "data": [ { + "Cores": undefined, + "hasInfiniteCores": undefined, + "has_infinite_quantity": undefined, + "total_capacity": undefined, "uom": "Cores", }, ], @@ -429,6 +433,10 @@ exports[`RHSM Transformers should attempt to parse a subscriptions response: sub { "data": [ { + "Cores": undefined, + "hasInfiniteCores": undefined, + "has_infinite_quantity": undefined, + "total_capacity": undefined, "uom": "Cores", }, ], @@ -444,9 +452,17 @@ exports[`RHSM Transformers should attempt to parse a subscriptions response: sub { "data": [ { + "Cores": undefined, + "hasInfiniteCores": undefined, + "has_infinite_quantity": undefined, + "total_capacity": undefined, "uom": "Cores", }, { + "Sockets": undefined, + "hasInfiniteSockets": undefined, + "has_infinite_quantity": undefined, + "total_capacity": undefined, "uom": "Sockets", }, ], diff --git a/src/services/rhsm/rhsmTransformers.js b/src/services/rhsm/rhsmTransformers.js index 6a09ad898..8dc8aa9d4 100644 --- a/src/services/rhsm/rhsmTransformers.js +++ b/src/services/rhsm/rhsmTransformers.js @@ -136,7 +136,35 @@ const rhsmSubscriptions = (response, { params } = {}) => { const { [rhsmConstants.RHSM_API_RESPONSE_DATA]: data = [], [rhsmConstants.RHSM_API_RESPONSE_META]: meta = {} } = response || {}; - updatedResponse.data = data; + updatedResponse.data = data.map( + ({ + [SUBSCRIPTIONS_DATA_TYPES.UOM]: uom, + [SUBSCRIPTIONS_DATA_TYPES.TOTAL_CAPACITY]: totalCapacity, + [SUBSCRIPTIONS_DATA_TYPES.HAS_INFINITE_QUANTITY]: hasInfiniteQuantity, + ...dataResponse + }) => { + const updatedData = { + [SUBSCRIPTIONS_DATA_TYPES.TOTAL_CAPACITY]: totalCapacity, + [SUBSCRIPTIONS_DATA_TYPES.HAS_INFINITE_QUANTITY]: hasInfiniteQuantity, + ...dataResponse + }; + + let normalizedUomValue; + if (new RegExp(RHSM_API_PATH_METRIC_TYPES.SOCKETS, 'i').test(uom)) { + normalizedUomValue = RHSM_API_PATH_METRIC_TYPES.SOCKETS; + } + + if (new RegExp(RHSM_API_PATH_METRIC_TYPES.CORES, 'i').test(uom)) { + normalizedUomValue = RHSM_API_PATH_METRIC_TYPES.CORES; + } + + updatedData[normalizedUomValue] = totalCapacity; + updatedData[SUBSCRIPTIONS_DATA_TYPES.UOM] = normalizedUomValue; + updatedData[`hasInfinite${normalizedUomValue}`] = hasInfiniteQuantity; + + return updatedData; + } + ); let normalizedUom = params?.[RHSM_API_QUERY_SET_TYPES.UOM];