diff --git a/public/locales/en-US.json b/public/locales/en-US.json index a7b9f3015..439f5de86 100644 --- a/public/locales/en-US.json +++ b/public/locales/en-US.json @@ -157,6 +157,7 @@ "tabHosts_OpenShift-dedicated-metrics_other": "{{count}} instances", "tabInstances": "Current monthly instances", "tabInstances_RHEL": "Current systems", + "tabInstances_Satellite": "Current systems", "tabSubscriptions": "Current subscriptions", "tab_disabled": "The inventory display is currently disabled.", "tableAriaLabel": "{{appName}} systems inventory table.", diff --git a/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap b/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap index 8c08fea02..5c27b4f27 100644 --- a/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap +++ b/src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap @@ -744,15 +744,11 @@ exports[`I18n Component should generate a predictable locale key output snapshot }, { "key": "curiosity-inventory.label", - "match": "translate('curiosity-inventory.label', { context: 'numberOfGuests', count: numberOfGuests.value }, [ ])", - }, - { - "key": "curiosity-inventory.measurementType", - "match": "translate('curiosity-inventory.measurementType', { context: measurementType?.value })", + "match": "translate('curiosity-inventory.label', { context: [INVENTORY_TYPES.CATEGORY, category?.value] })", }, { - "key": "curiosity-inventory.cloudProvider", - "match": "translate('curiosity-inventory.cloudProvider', { context: cloudProvider?.value })", + "key": "curiosity-inventory.label", + "match": "translate('curiosity-inventory.label', { context: [INVENTORY_TYPES.CLOUD_PROVIDER, cloudProvider?.value] })", }, ], }, @@ -954,6 +950,10 @@ exports[`I18n Component should have locale keys that exist in the default langua "file": "./src/config/product.satellite.js", "key": "curiosity-inventory.label", }, + { + "file": "./src/config/product.satellite.js", + "key": "curiosity-inventory.label", + }, ] `; diff --git a/src/components/router/__tests__/__snapshots__/router.test.js.snap b/src/components/router/__tests__/__snapshots__/router.test.js.snap index 72321cae5..9334c1647 100644 --- a/src/components/router/__tests__/__snapshots__/router.test.js.snap +++ b/src/components/router/__tests__/__snapshots__/router.test.js.snap @@ -2374,15 +2374,23 @@ exports[`Router Component should render a basic component: basic 1`] = ` "id": "display_name", "isSortable": true, }, + { + "cell": [Function], + "cellWidth": 15, + "id": "number_of_guests", + "isSortable": true, + "isWrappable": true, + }, { "cell": [Function], "cellWidth": 20, - "id": "measurement_type", + "id": "category", "isSortable": true, }, { + "cell": [Function], "cellWidth": 15, - "id": "sockets", + "id": "Sockets", "isSortable": true, "isWrappable": true, }, @@ -2422,7 +2430,7 @@ exports[`Router Component should render a basic component: basic 1`] = ` "offset": 0, "sort": "next_event_date", }, - "productDisplay": "partial", + "productDisplay": "capacity", "productGroup": "Satellite", "productId": "Satellite", "productLabel": "Satellite", diff --git a/src/config/__tests__/__snapshots__/product.satellite.test.js.snap b/src/config/__tests__/__snapshots__/product.satellite.test.js.snap index c274a0f73..543162882 100644 --- a/src/config/__tests__/__snapshots__/product.satellite.test.js.snap +++ b/src/config/__tests__/__snapshots__/product.satellite.test.js.snap @@ -1,90 +1,23 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Product Satellite config should apply graph configuration: filters 1`] = ` +exports[`Product Satellite config should apply an inventory configuration: filtered 1`] = ` { - "groupedFiltersSettings": { - "settings": { - "isStandalone": false, - "metric": undefined, - "metrics": [ - { - "chartType": "area", - "color": "#06c", - "fill": "#8bc1f7", - "id": "Sockets_physical", - "isCapacity": false, - "isStacked": true, - "isStandalone": false, - "isThreshold": false, - "isToolbarFilter": true, - "metric": "Sockets", - "query": { - "category": "physical", - }, - "stroke": "#06c", - "strokeWidth": 2, - }, - { - "chartType": "area", - "color": "#009596", - "fill": "#a2d9d9", - "id": "Sockets_virtual", - "isCapacity": false, - "isStacked": true, - "isStandalone": false, - "isThreshold": false, - "isToolbarFilter": true, - "metric": "Sockets", - "query": { - "category": "virtual", - }, - "stroke": "#009596", - "strokeWidth": 2, - }, - { - "chartType": "area", - "color": "#5752d1", - "fill": "#b2b0ea", - "id": "Sockets_cloud", - "isCapacity": false, - "isStacked": true, - "isStandalone": false, - "isThreshold": false, - "isToolbarFilter": true, - "metric": "Sockets", - "query": { - "category": "cloud", - }, - "stroke": "#5752d1", - "strokeWidth": 2, - }, - ], + "cells": [ + { + "title": "lorem ipsum", }, - }, - "standaloneFiltersSettings": [], -} -`; - -exports[`Product Satellite config should apply graph configuration: settings 1`] = ` -{ - "actions": [ { - "id": "granularity", - "position": "right", + "title": "--", }, - ], - "isDisabledLegendClick": true, -} -`; - -exports[`Product Satellite config should apply guest inventory configuration: filtered 1`] = ` -{ - "cells": [ { - "title": "lorem", + "title": + t(curiosity-inventory.label, {"context":"category"}) + + + , }, { - "title": "lorem inventory id", + "title": 200, }, { "title": - lorem + lorem ipsum , }, { - "title": "lorem inventory id", + "title": "--", + }, + { + "title": + t(curiosity-inventory.label, {"context":"category"}) + + + , + }, + { + "title": 200, }, { "title": , + "title": + t(curiosity-inventory.label, {"context":"category"}) + + + , + }, + { + "title": 200, + }, + { + "title": "", }, ], "columnHeaders": [ { - "title": "t(curiosity-inventory.header, {"context":"guestsDisplayName"})", + "title": "t(curiosity-inventory.header_display, {"context":"name"})", "transforms": [], }, { - "title": "t(curiosity-inventory.header, {"context":"inventoryId"})", + "title": "t(curiosity-inventory.header_number_of, {"context":"guests"})", "transforms": [ [Function], ], }, { - "title": "t(curiosity-inventory.header, {"context":"lastSeen"})", + "title": "t(curiosity-inventory.header, {"context":"category"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header, {"context":"Sockets"})", + "transforms": [ + [Function], + ], + }, + { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", "transforms": [ [Function], ], }, ], "data": { - "displayName": { - "title": "t(curiosity-inventory.header, {"context":"displayName"})", - "value": "lorem", + "Sockets": { + "title": "t(curiosity-inventory.header, {"context":"Sockets"})", + "value": 200, }, - "inventoryId": { - "title": "t(curiosity-inventory.header, {"context":"inventoryId"})", - "value": "", + "cloud_provider": { + "title": "t(curiosity-inventory.header_cloud, {"context":"provider"})", + "value": "dolor sit", }, - "lastSeen": { - "title": "t(curiosity-inventory.header, {"context":"lastSeen"})", - "value": "2022-01-01T00:00:00.000Z", + "display_name": { + "title": "t(curiosity-inventory.header_display, {"context":"name"})", + "value": "lorem ipsum", }, - "loremIpsum": { - "title": "t(curiosity-inventory.header, {"context":"loremIpsum"})", - "value": "hello world", + "instance_id": { + "title": "t(curiosity-inventory.header_instance, {"context":"id"})", + "value": null, }, - "subscriptionManagerId": { - "title": "t(curiosity-inventory.header, {"context":"subscriptionManagerId"})", - "value": "lorem subscription id", + "last_seen": { + "title": "t(curiosity-inventory.header_last, {"context":"seen"})", + "value": null, }, }, } `; -exports[`Product Satellite config should apply hosts inventory configuration: filtered 1`] = ` +exports[`Product Satellite config should apply an inventory configuration: filtered, infinite 1`] = ` { "cells": [ { - "title": "lorem", + "title": "lorem ipsum", + }, + { + "title": "--", }, { "title": - t(curiosity-inventory.measurementType, {"context":null}) + t(curiosity-inventory.label, {"context":"category"}) , }, { - "title": 10, + "title": 200, }, { "title": - - - t(curiosity-inventory.label, {"context":"numberOfGuests","count":3}, [object Object]) - , + "id": "granularity", + "position": "right", }, + ], + "isDisabledLegendClick": true, +} +`; + +exports[`Product Satellite config should apply guest inventory configuration: filtered 1`] = ` +{ + "cells": [ { - "title": - t(curiosity-inventory.measurementType, {"context":null}) - - - , + "title": "lorem", }, { - "title": 10, + "title": "lorem inventory id", }, { "title": - - - t(curiosity-inventory.label, {"context":"numberOfGuests","count":3}, [object Object]) - , - }, - { - "title": - t(curiosity-inventory.measurementType, {"context":null}) - - - , + "title": , }, { - "title": 10, + "title": "lorem inventory id", }, { "title": - t(curiosity-inventory.measurementType, {"context":null}) - - - , - }, - { - "title": 10, + "title": "", }, { - "title": "", + "title": , }, ], "columnHeaders": [ { - "title": "t(curiosity-inventory.header_display_name, {"context":"Satellite"})", + "title": "t(curiosity-inventory.header, {"context":"guestsDisplayName"})", "transforms": [], }, { - "title": "t(curiosity-inventory.header_measurement_type, {"context":"Satellite"})", - "transforms": [ - [Function], - ], - }, - { - "title": "t(curiosity-inventory.header_sockets, {"context":"Satellite"})", + "title": "t(curiosity-inventory.header, {"context":"inventoryId"})", "transforms": [ [Function], ], }, { - "title": "t(curiosity-inventory.header_last_seen, {"context":"Satellite"})", + "title": "t(curiosity-inventory.header, {"context":"lastSeen"})", "transforms": [ [Function], ], }, ], "data": { - "cloud_provider": { - "title": "t(curiosity-inventory.header_cloud_provider, {"context":"Satellite"})", - "value": "dolor sit", - }, - "cores": { - "title": "t(curiosity-inventory.header_cores, {"context":"Satellite"})", - "value": 12, - }, - "display_name": { - "title": "t(curiosity-inventory.header_display_name, {"context":"Satellite"})", + "displayName": { + "title": "t(curiosity-inventory.header, {"context":"displayName"})", "value": "lorem", }, - "hardware_type": { - "title": "t(curiosity-inventory.header_hardware_type, {"context":"Satellite"})", - "value": "ipsum", - }, - "inventory_id": { - "title": "t(curiosity-inventory.header_inventory_id, {"context":"Satellite"})", - "value": null, + "inventoryId": { + "title": "t(curiosity-inventory.header, {"context":"inventoryId"})", + "value": "", }, - "last_seen": { - "title": "t(curiosity-inventory.header_last_seen, {"context":"Satellite"})", - "value": null, + "lastSeen": { + "title": "t(curiosity-inventory.header, {"context":"lastSeen"})", + "value": "2022-01-01T00:00:00.000Z", }, "loremIpsum": { - "title": "t(curiosity-inventory.header_loremIpsum, {"context":"Satellite"})", + "title": "t(curiosity-inventory.header, {"context":"loremIpsum"})", "value": "hello world", }, - "measurement_type": { - "title": "t(curiosity-inventory.header_measurement_type, {"context":"Satellite"})", - "value": null, - }, - "number_of_guests": { - "title": "t(curiosity-inventory.header_number_of_guests, {"context":"Satellite"})", - "value": 3, - }, - "sockets": { - "title": "t(curiosity-inventory.header_sockets, {"context":"Satellite"})", - "value": 10, + "subscriptionManagerId": { + "title": "t(curiosity-inventory.header, {"context":"subscriptionManagerId"})", + "value": "lorem subscription id", }, }, } diff --git a/src/config/__tests__/product.satellite.test.js b/src/config/__tests__/product.satellite.test.js index 5dfb5400a..15efa1e36 100644 --- a/src/config/__tests__/product.satellite.test.js +++ b/src/config/__tests__/product.satellite.test.js @@ -2,9 +2,11 @@ import { config } from '../product.satellite'; import { generateChartSettings } from '../../components/graphCard/graphCardHelpers'; import { parseRowCellsListData } from '../../components/inventoryCard/inventoryCardHelpers'; import { + RHSM_API_PATH_METRIC_TYPES, RHSM_API_QUERY_INVENTORY_SORT_DIRECTION_TYPES as SORT_DIRECTION_TYPES, RHSM_API_QUERY_SET_TYPES, - RHSM_API_RESPONSE_HOSTS_DATA_TYPES as INVENTORY_TYPES + RHSM_API_RESPONSE_INSTANCES_DATA_TYPES as INVENTORY_TYPES, + RHSM_API_RESPONSE_SUBSCRIPTIONS_DATA_TYPES as SUBSCRIPTIONS_INVENTORY_TYPES } from '../../services/rhsm/rhsmConstants'; describe('Product Satellite config', () => { @@ -15,40 +17,30 @@ describe('Product Satellite config', () => { expect(initialGraphSettings).toMatchSnapshot('settings'); }); - it('should apply hosts inventory configuration', () => { - const { initialInventoryFilters: initialFilters, inventoryHostsQuery: inventoryQuery, productId } = config; + it('should apply an inventory configuration', () => { + const { initialInventoryFilters: initialFilters, inventoryHostsQuery: inventoryQuery } = config; const inventoryData = { - [INVENTORY_TYPES.DISPLAY_NAME]: 'lorem', - [INVENTORY_TYPES.INVENTORY_ID]: undefined, - [INVENTORY_TYPES.HARDWARE_TYPE]: 'ipsum', - [INVENTORY_TYPES.MEASUREMENT_TYPE]: null, - [INVENTORY_TYPES.NUMBER_OF_GUESTS]: 3, - [INVENTORY_TYPES.SOCKETS]: 10, - [INVENTORY_TYPES.CORES]: 12, - [INVENTORY_TYPES.LAST_SEEN]: '2022-01-01T00:00:00.000Z', - loremIpsum: 'hello world' + [INVENTORY_TYPES.DISPLAY_NAME]: 'lorem ipsum', + [RHSM_API_PATH_METRIC_TYPES.SOCKETS]: 200, + [INVENTORY_TYPES.LAST_SEEN]: '2022-01-01T00:00:00.000Z' }; const filteredInventoryData = parseRowCellsListData({ filters: initialFilters, - cellData: inventoryData, - productId + cellData: inventoryData }); expect(filteredInventoryData).toMatchSnapshot('filtered'); - const fallbackInventoryData = { - ...inventoryData, - [INVENTORY_TYPES.INVENTORY_ID]: null, - [INVENTORY_TYPES.LAST_SEEN]: null, - [INVENTORY_TYPES.CLOUD_PROVIDER]: 'dolor sit' - }; - const fallbackFilteredInventoryData = parseRowCellsListData({ filters: initialFilters, - cellData: fallbackInventoryData, - productId + cellData: { + ...inventoryData, + [INVENTORY_TYPES.INSTANCE_ID]: null, + [INVENTORY_TYPES.LAST_SEEN]: null, + [INVENTORY_TYPES.CLOUD_PROVIDER]: 'dolor sit' + } }); expect(fallbackFilteredInventoryData).toMatchSnapshot('filtered, fallback display'); @@ -57,13 +49,23 @@ describe('Product Satellite config', () => { filters: initialFilters, cellData: { ...inventoryData, - [INVENTORY_TYPES.INVENTORY_ID]: 'XXXX-XXXX-XXXXX-XXXXX' + [INVENTORY_TYPES.INSTANCE_ID]: 'XXXX-XXXX-XXXXX-XXXXX' }, session: { authorized: { inventory: true } } }); expect(filteredInventoryDataAuthorized).toMatchSnapshot('filtered, authorized'); + const filteredInventoryDataInfinite = parseRowCellsListData({ + filters: initialFilters, + cellData: { + ...inventoryData, + [SUBSCRIPTIONS_INVENTORY_TYPES.HAS_INFINITE_QUANTITY]: false + } + }); + + expect(filteredInventoryDataInfinite).toMatchSnapshot('filtered, infinite'); + expect(inventoryQuery[RHSM_API_QUERY_SET_TYPES.DIRECTION] === SORT_DIRECTION_TYPES.DESCENDING).toBe(true); }); diff --git a/src/config/product.satellite.js b/src/config/product.satellite.js index 771d6f89d..56c1a4971 100644 --- a/src/config/product.satellite.js +++ b/src/config/product.satellite.js @@ -19,7 +19,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_RESPONSE_HOSTS_DATA_TYPES as INVENTORY_TYPES, + RHSM_API_RESPONSE_INSTANCES_DATA_TYPES as INVENTORY_TYPES, RHSM_INTERNAL_PRODUCT_DISPLAY_TYPES as DISPLAY_TYPES } from '../services/rhsm/rhsmConstants'; import { dateHelpers, helpers } from '../common'; @@ -51,7 +51,7 @@ const config = { productId, productLabel, productPath: productGroup.toLowerCase(), - productDisplay: DISPLAY_TYPES.PARTIAL, + productDisplay: DISPLAY_TYPES.CAPACITY, viewId: `view${productGroup}`, productVariants: [...Object.values(RHSM_API_PATH_PRODUCT_VARIANT_SATELLITE_TYPES)], query: { @@ -155,20 +155,16 @@ const config = { { id: INVENTORY_TYPES.DISPLAY_NAME, cell: ( - { - [INVENTORY_TYPES.DISPLAY_NAME]: displayName = {}, - [INVENTORY_TYPES.INVENTORY_ID]: inventoryId = {}, - [INVENTORY_TYPES.NUMBER_OF_GUESTS]: numberOfGuests = {} - } = {}, + { [INVENTORY_TYPES.DISPLAY_NAME]: displayName = {}, [INVENTORY_TYPES.INSTANCE_ID]: instanceId = {} }, session ) => { const { inventory: authorized } = session?.authorized || {}; - if (!inventoryId.value) { + if (!instanceId.value) { return displayName.value; } - let updatedDisplayName = displayName.value || inventoryId.value; + let updatedDisplayName = displayName.value || instanceId.value; if (authorized) { updatedDisplayName = ( @@ -176,37 +172,34 @@ const config = { isInline component="a" variant="link" - href={`${helpers.UI_DEPLOY_PATH_PREFIX}/insights/inventory/${inventoryId.value}/`} + href={`${helpers.UI_DEPLOY_PATH_PREFIX}/insights/inventory/${instanceId.value}/`} > - {displayName.value || inventoryId.value} + {displayName.value || instanceId.value} ); } - return ( - - {updatedDisplayName}{' '} - {(numberOfGuests.value && - translate('curiosity-inventory.label', { context: 'numberOfGuests', count: numberOfGuests.value }, [ - - ])) || - ''} - - ); + return updatedDisplayName; }, isSortable: true }, { - id: INVENTORY_TYPES.MEASUREMENT_TYPE, - cell: ({ - [INVENTORY_TYPES.CLOUD_PROVIDER]: cloudProvider, - [INVENTORY_TYPES.MEASUREMENT_TYPE]: measurementType - } = {}) => ( + id: INVENTORY_TYPES.NUMBER_OF_GUESTS, + cell: ({ [INVENTORY_TYPES.NUMBER_OF_GUESTS]: numberOfGuests } = {}) => numberOfGuests?.value || '--', + isSortable: true, + isWrappable: true, + cellWidth: 15 + }, + { + id: INVENTORY_TYPES.CATEGORY, + cell: ({ [INVENTORY_TYPES.CLOUD_PROVIDER]: cloudProvider, [INVENTORY_TYPES.CATEGORY]: category } = {}) => ( - {translate('curiosity-inventory.measurementType', { context: measurementType?.value })}{' '} + {translate('curiosity-inventory.label', { context: [INVENTORY_TYPES.CATEGORY, category?.value] })}{' '} {(cloudProvider?.value && ( - {translate('curiosity-inventory.cloudProvider', { context: cloudProvider?.value })} + {translate('curiosity-inventory.label', { + context: [INVENTORY_TYPES.CLOUD_PROVIDER, cloudProvider?.value] + })} )) || ''} @@ -216,14 +209,15 @@ const config = { cellWidth: 20 }, { - id: INVENTORY_TYPES.SOCKETS, + id: RHSM_API_PATH_METRIC_TYPES.SOCKETS, + cell: ({ [RHSM_API_PATH_METRIC_TYPES.SOCKETS]: sockets } = {}) => sockets?.value || '--', isSortable: true, isWrappable: true, cellWidth: 15 }, { id: INVENTORY_TYPES.LAST_SEEN, - cell: ({ [INVENTORY_TYPES.LAST_SEEN]: lastSeen }) => + cell: ({ [INVENTORY_TYPES.LAST_SEEN]: lastSeen } = {}) => (lastSeen?.value && ) || '', isSortable: true, isWrappable: true,