From 61253fbaf0c1aa76d643a006fe624f2f8f79c640 Mon Sep 17 00:00:00 2001 From: Joel Myers Date: Tue, 21 Sep 2021 13:12:55 -0400 Subject: [PATCH] feat(inventorySubscriptions): ent-3352 activate subs table (#795) * dotenv, productViews, RHEL, OpenShift, activate subs * locales, subs table column headers --- .env.production | 1 - public/locales/en-US.json | 3 + .../__tests__/__snapshots__/i18n.test.js.snap | 8 ++ .../__snapshots__/productView.test.js.snap | 124 +++++++++++++----- ...productViewOpenShiftContainer.test.js.snap | 16 ++- .../productView/__tests__/productView.test.js | 10 ++ src/components/productView/productView.js | 2 +- .../productViewOpenShiftContainer.js | 2 +- .../__snapshots__/redirect.test.js.snap | 16 ++- .../product.openshiftContainer.test.js.snap | 36 +++++ .../__snapshots__/product.rhel.test.js.snap | 36 +++++ src/config/product.openshiftContainer.js | 16 ++- src/config/product.rhel.js | 18 ++- .../selectors/subscriptionsListSelectors.js | 2 + 14 files changed, 247 insertions(+), 43 deletions(-) diff --git a/.env.production b/.env.production index 92d66b836..8d892e935 100644 --- a/.env.production +++ b/.env.production @@ -2,4 +2,3 @@ REACT_APP_ENV=production REACT_APP_UI_VERSION=${UI_VERSION} REACT_APP_UI_DISABLED_TOOLBAR=false -REACT_APP_UI_DISABLED_TABLE_SUBSCRIPTIONS=true diff --git a/public/locales/en-US.json b/public/locales/en-US.json index 6074d346c..656c42d0f 100644 --- a/public/locales/en-US.json +++ b/public/locales/en-US.json @@ -112,6 +112,9 @@ "header_productName": "Product", "header_quantity": "Quantity", "header_serviceLevel": "Service level", + "header_subscriptions": "Sockets", + "header_subscriptions_cores": "Cores", + "header_subscriptions_sockets": "Sockets", "measurementType": "{{context}}", "measurementType_cloud": "Public cloud", "measurementType_alibaba": "Public cloud", diff --git a/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap b/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap index 9a184789b..20280ef58 100644 --- a/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap +++ b/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap @@ -498,6 +498,10 @@ Array [ "key": "curiosity-inventory.header", "match": "translate('curiosity-inventory.header', { context: ['cores', 'OpenShift Container Platform'] })", }, + Object { + "key": "curiosity-inventory.header", + "match": "translate('curiosity-inventory.header', { context: ['subscriptions', data?.uom?.value] })", + }, ], }, Object { @@ -545,6 +549,10 @@ Array [ "key": "curiosity-inventory.cloudProvider", "match": "translate('curiosity-inventory.cloudProvider', { context: cloudProvider.value })", }, + Object { + "key": "curiosity-inventory.header", + "match": "translate('curiosity-inventory.header', { context: ['subscriptions', data?.uom?.value] })", + }, ], }, Object { diff --git a/src/components/productView/__tests__/__snapshots__/productView.test.js.snap b/src/components/productView/__tests__/__snapshots__/productView.test.js.snap index 975cef8a9..715d74760 100644 --- a/src/components/productView/__tests__/__snapshots__/productView.test.js.snap +++ b/src/components/productView/__tests__/__snapshots__/productView.test.js.snap @@ -97,6 +97,93 @@ exports[`ProductView Component should allow custom product views: custom graphCa /> + + + + + + + + +`; + +exports[`ProductView Component should allow custom product views: custom tabs, subscriptions table 1`] = ` + + + t(curiosity-view.title, {"appName":"Subscriptions","context":"lorem ipsum product label"}) + + + + + + dolor sit + + + + t(curiosity-graph.cardHeading, {"context":"lorem ipsum"}) + + t(curiosity-graph.cardHeadingDescription, {"context":"lorem ipsum"}) +

+ } + distance={5} + enableFlip={false} + entryDelay={100} + exitDelay={0} + position="top" + > + + + +
+ + } + key="graph_lorem ipsum" + productId="lorem ipsum" + productLabel="lorem ipsum product label" + query={Object {}} + viewId="dolor sit" + /> +
@@ -122,6 +209,7 @@ exports[`ProductView Component should allow custom product views: custom graphCa title="t(curiosity-inventory.tabSubscriptions, {\\"context\\":\\"lorem ipsum\\"})" > - - -
@@ -270,18 +346,6 @@ exports[`ProductView Component should allow custom product views: custom toolbar viewId="dolor sit" /> - - - @@ -381,18 +445,6 @@ exports[`ProductView Component should render a non-connected component: non-conn viewId="dolor sit" /> - - - diff --git a/src/components/productView/__tests__/__snapshots__/productViewOpenShiftContainer.test.js.snap b/src/components/productView/__tests__/__snapshots__/productViewOpenShiftContainer.test.js.snap index b805b3464..9f758ddc8 100644 --- a/src/components/productView/__tests__/__snapshots__/productViewOpenShiftContainer.test.js.snap +++ b/src/components/productView/__tests__/__snapshots__/productViewOpenShiftContainer.test.js.snap @@ -228,7 +228,8 @@ exports[`ProductViewOpenShiftContainer Component should render a non-connected c Array [ Object { "id": "productName", - "isSortable": true, + "isSortable": false, + "isWrappable": true, }, Object { "cellWidth": 15, @@ -236,6 +237,19 @@ exports[`ProductViewOpenShiftContainer Component should render a non-connected c "isSortable": true, "isWrappable": true, }, + Object { + "cellWidth": 20, + "id": "quantity", + "isSortable": true, + "isWrappable": true, + }, + Object { + "cellWidth": 15, + "header": [Function], + "id": "totalCapacity", + "isSortable": false, + "isWrappable": true, + }, Object { "cell": [Function], "cellWidth": 15, diff --git a/src/components/productView/__tests__/productView.test.js b/src/components/productView/__tests__/productView.test.js index e0d61b354..79c652b36 100644 --- a/src/components/productView/__tests__/productView.test.js +++ b/src/components/productView/__tests__/productView.test.js @@ -61,5 +61,15 @@ describe('ProductView Component', () => { }); expect(component).toMatchSnapshot('custom toolbar, toolbarProduct'); + + component.setProps({ + ...props, + routeDetail: { + ...props.routeDetail, + productConfig: [{ lorem: 'ipsum', initialSubscriptionsInventoryFilters: [] }] + } + }); + + expect(component).toMatchSnapshot('custom tabs, subscriptions table'); }); }); diff --git a/src/components/productView/productView.js b/src/components/productView/productView.js index 7b7fd1fe4..0ddeb477d 100644 --- a/src/components/productView/productView.js +++ b/src/components/productView/productView.js @@ -162,7 +162,7 @@ const ProductView = ({ routeDetail, t, toolbarGraph, toolbarGraphDescription, to viewId={viewId} /> - {!helpers.UI_DISABLED_TABLE_SUBSCRIPTIONS && ( + {initialSubscriptionsInventoryFilters && ( { viewId={viewId} /> - {!helpers.UI_DISABLED_TABLE_SUBSCRIPTIONS && initialSubscriptionsInventoryFilters && ( + {initialSubscriptionsInventoryFilters && ( translate('curiosity-inventory.header', { context: ['subscriptions', data?.uom?.value] }), + isSortable: false, + cellWidth: 15, + isWrappable: true + }, { id: 'nextEventDate', cell: data => diff --git a/src/config/product.rhel.js b/src/config/product.rhel.js index 0a10057ca..d5a4641c8 100644 --- a/src/config/product.rhel.js +++ b/src/config/product.rhel.js @@ -16,6 +16,7 @@ import { RHSM_API_QUERY_SORT_TYPES, RHSM_API_QUERY_SUBSCRIPTIONS_SORT_TYPES, RHSM_API_QUERY_TYPES, + RHSM_API_QUERY_UOM_TYPES, RHSM_API_PATH_ID_TYPES } from '../types/rhsmApiTypes'; import { dateHelpers, helpers } from '../common'; @@ -35,6 +36,7 @@ const config = { productId, viewId: `view${productGroup}`, query: { + [RHSM_API_QUERY_TYPES.UOM]: RHSM_API_QUERY_UOM_TYPES.SOCKETS, [RHSM_API_QUERY_TYPES.START_DATE]: dateHelpers.getRangedDateTime(GRANULARITY_TYPES.DAILY).startDate.toISOString(), [RHSM_API_QUERY_TYPES.END_DATE]: dateHelpers.getRangedDateTime(GRANULARITY_TYPES.DAILY).endDate.toISOString() }, @@ -188,7 +190,8 @@ const config = { initialSubscriptionsInventoryFilters: [ { id: 'productName', - isSortable: true + isSortable: false, + isWrappable: true }, { id: 'serviceLevel', @@ -196,6 +199,19 @@ const config = { isWrappable: true, cellWidth: 15 }, + { + id: 'quantity', + isSortable: true, + cellWidth: 10, + isWrappable: true + }, + { + id: 'totalCapacity', + header: data => translate('curiosity-inventory.header', { context: ['subscriptions', data?.uom?.value] }), + isSortable: false, + cellWidth: 10, + isWrappable: true + }, { id: 'nextEventDate', cell: data => diff --git a/src/redux/selectors/subscriptionsListSelectors.js b/src/redux/selectors/subscriptionsListSelectors.js index 8e619fd3e..8ba2370a0 100644 --- a/src/redux/selectors/subscriptionsListSelectors.js +++ b/src/redux/selectors/subscriptionsListSelectors.js @@ -110,6 +110,8 @@ const selector = createDeepEqualSelector([statePropsFilter, queryFilter], (respo switch (key) { case rhsmApiTypes.RHSM_API_RESPONSE_INVENTORY_SUBSCRIPTIONS_DATA_TYPES.NEXT_EVENT_DATE: return (value && new Date(value)) || null; + case rhsmApiTypes.RHSM_API_RESPONSE_INVENTORY_SUBSCRIPTIONS_DATA_TYPES.UOM: + return value?.toLowerCase() || null; default: return value ?? null; }