Skip to content

Commit

Permalink
fix(rhosak): ent-5022 subscription type column activated (#939)
Browse files Browse the repository at this point in the history
* locale, subscription type strings
* config, rhosak, replace total capacity with subs type
* rhsmServices, schemas, constants, subs types and mock
  • Loading branch information
cdcabrera committed May 26, 2022
1 parent 120c065 commit 91f8a03
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 76 deletions.
4 changes: 4 additions & 0 deletions public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@
"label_hasInfiniteQuantity_sockets": "Unlimited sockets",
"label_numberOfGuests_one": "<0>{{count}} guest</0>",
"label_numberOfGuests_other": "<0>{{count}} guests</0>",
"label_subscriptionType": "{{context}}",
"label_subscriptionType_Annual": "Annual",
"label_subscriptionType_On-demand": "On-Demand",
"cloudProvider": "{{context}}",
"cloudProvider_alibaba": "Alibaba",
"cloudProvider_aws": "AWS",
Expand Down Expand Up @@ -150,6 +153,7 @@
"header_subscriptions": "Sockets",
"header_subscriptions_cores": "Cores",
"header_subscriptions_sockets": "Sockets",
"header_subscriptionType": "Subscription type",
"header_Transfer-gibibytes": "Data transfer",
"header_tooltip_Storage-gibibytes": "Measurements in binary gigabyte months",
"header_tooltip_Transfer-gibibytes": "Measurements in binary gigabytes",
Expand Down
12 changes: 2 additions & 10 deletions src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -675,12 +675,8 @@ Array [
"match": "translate('curiosity-inventory.measurement', { context: RHSM_API_PATH_METRIC_TYPES.INSTANCE_HOURS, total: helpers.numberDisplay(total?.value)",
},
Object {
"key": "curiosity-inventory.header",
"match": "translate('curiosity-inventory.header', { context: ['subscriptions', data?.uom?.value] })",
},
Object {
"key": "curiosity-inventory.label",
"match": "translate('curiosity-inventory.label', { context: ['hasInfiniteQuantity', uom?.value] })",
"key": "curiosity-inventory.label_subscriptionType",
"match": "translate('curiosity-inventory.label_subscriptionType', { context: meta?.subscriptionType || EMPTY_CONTEXT })",
},
],
},
Expand Down Expand Up @@ -815,10 +811,6 @@ Array [
"file": "./src/config/product.rhosak.js",
"key": "curiosity-inventory.measurement",
},
Object {
"file": "./src/config/product.rhosak.js",
"key": "curiosity-inventory.label",
},
Object {
"file": "./src/config/product.satellite.js",
"key": "curiosity-inventory.label",
Expand Down
40 changes: 4 additions & 36 deletions src/config/__tests__/__snapshots__/product.rhosak.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -286,23 +286,7 @@ Object {
"title": "",
},
Object {
"title": <Tooltip
content="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
distance={5}
enableFlip={false}
entryDelay={100}
exitDelay={0}
isNoWrap={false}
position="top"
>
<ChartIcon
aria-label="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
fill={null}
size="sm"
symbol="infinity"
title={null}
/>
</Tooltip>,
"title": "t(curiosity-inventory.label_subscriptionType, {\\"context\\":\\"dolor\\"})",
},
Object {
"title": "2022-01-01T00:00:00.000Z",
Expand All @@ -326,7 +310,7 @@ Object {
],
},
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"subscriptions\\"})",
"title": "t(curiosity-inventory.header, {\\"context\\":\\"subscriptionType\\"})",
"transforms": Array [
[Function],
],
Expand Down Expand Up @@ -376,23 +360,7 @@ Object {
"title": "",
},
Object {
"title": <Tooltip
content="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
distance={5}
enableFlip={false}
entryDelay={100}
exitDelay={0}
isNoWrap={false}
position="top"
>
<ChartIcon
aria-label="t(curiosity-inventory.label, {\\"context\\":\\"hasInfiniteQuantity\\"})"
fill={null}
size="sm"
symbol="infinity"
title={null}
/>
</Tooltip>,
"title": "t(curiosity-inventory.label_subscriptionType, {\\"context\\":\\" \\"})",
},
Object {
"title": "",
Expand All @@ -416,7 +384,7 @@ Object {
],
},
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"subscriptions\\"})",
"title": "t(curiosity-inventory.header, {\\"context\\":\\"subscriptionType\\"})",
"transforms": Array [
[Function],
],
Expand Down
10 changes: 8 additions & 2 deletions src/config/__tests__/product.rhosak.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,14 @@ describe('Product RHOSAK config', () => {
hasInfiniteQuantity: true
};

const inventoryMeta = {
subscriptionType: 'dolor'
};

const filteredInventoryData = parseRowCellsListData({
filters: initialFilters,
cellData: inventoryData
cellData: inventoryData,
meta: inventoryMeta
});

expect(filteredInventoryData).toMatchSnapshot('filtered');
Expand All @@ -109,7 +114,8 @@ describe('Product RHOSAK config', () => {

const fallbackFilteredInventoryData = parseRowCellsListData({
filters: initialFilters,
cellData: fallbackInventoryData
cellData: fallbackInventoryData,
meta: {}
});

expect(fallbackFilteredInventoryData).toMatchSnapshot('filtered, fallback display');
Expand Down
27 changes: 8 additions & 19 deletions src/config/product.rhosak.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import {
RHSM_API_PATH_METRIC_TYPES
} from '../services/rhsm/rhsmConstants';
import { dateHelpers, helpers } from '../common';
import { Tooltip } from '../components/tooltip/tooltip';
import { ChartIcon } from '../components/chart/chartIcon';
import { translate } from '../components/i18n/i18n';
import { translate, EMPTY_CONTEXT } from '../components/i18n/i18n';

/**
* ToDo: evaluate separating products/product tags into individual configs...
Expand Down Expand Up @@ -223,22 +221,13 @@ const config = {
isWrappable: true
},
{
id: 'totalCapacity',
header: data => translate('curiosity-inventory.header', { context: ['subscriptions', data?.uom?.value] }),
cell: (data = {}) => {
const { hasInfiniteQuantity, totalCapacity, uom } = data;
if (hasInfiniteQuantity?.value === true) {
const content = translate('curiosity-inventory.label', { context: ['hasInfiniteQuantity', uom?.value] });
return (
<Tooltip content={content}>
<ChartIcon symbol="infinity" aria-label={content} />
</Tooltip>
);
}
return totalCapacity?.value;
},
isSortable: true,
cellWidth: 10,
id: 'subscriptionType',
cell: (data, session, meta) =>
translate('curiosity-inventory.label_subscriptionType', {
context: meta?.subscriptionType || EMPTY_CONTEXT
}),
isSortable: false,
cellWidth: 15,
isWrappable: true
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ Object {
"SELF": "Self-Support",
"STANDARD": "Standard",
},
"RHSM_API_RESPONSE_SUBSCRIPTION_TYPES": Object {
"ANNUAL": "Annual",
"ON_DEMAND": "On-demand",
},
"RHSM_API_RESPONSE_TALLY_DATA_TYPES": Object {
"DATE": "date",
"HAS_DATA": "has_data",
Expand Down Expand Up @@ -351,6 +355,10 @@ Object {
"SELF": "Self-Support",
"STANDARD": "Standard",
},
"RHSM_API_RESPONSE_SUBSCRIPTION_TYPES": Object {
"ANNUAL": "Annual",
"ON_DEMAND": "On-demand",
},
"RHSM_API_RESPONSE_TALLY_DATA_TYPES": Object {
"DATE": "date",
"HAS_DATA": "has_data",
Expand Down Expand Up @@ -540,6 +548,10 @@ Object {
"SELF": "Self-Support",
"STANDARD": "Standard",
},
"RHSM_API_RESPONSE_SUBSCRIPTION_TYPES": Object {
"ANNUAL": "Annual",
"ON_DEMAND": "On-demand",
},
"RHSM_API_RESPONSE_TALLY_DATA_TYPES": Object {
"DATE": "date",
"HAS_DATA": "has_data",
Expand Down Expand Up @@ -733,6 +745,10 @@ Object {
"SELF": "Self-Support",
"STANDARD": "Standard",
},
"RHSM_API_RESPONSE_SUBSCRIPTION_TYPES": Object {
"ANNUAL": "Annual",
"ON_DEMAND": "On-demand",
},
"RHSM_API_RESPONSE_TALLY_DATA_TYPES": Object {
"DATE": "date",
"HAS_DATA": "has_data",
Expand Down
27 changes: 20 additions & 7 deletions src/services/rhsm/rhsmConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ const RHSM_API_RESPONSE_SLA_TYPES = {
NONE: ''
};

/**
* RHSM response, general parameters for subscription types
*
* @type {{ANNUAL: string, ON_DEMAND: string}}
*/
const RHSM_API_RESPONSE_SUBSCRIPTION_TYPES = {
ANNUAL: 'Annual',
ON_DEMAND: 'On-demand'
};

/**
* RHSM response, query parameters for UOM.
*
Expand Down Expand Up @@ -336,13 +346,14 @@ const RHSM_API_QUERY_SET_TYPES = {
* RHSM_API_RESPONSE_META_TYPES: {PRODUCT: string, COUNT: string}, RHSM_API_RESPONSE_ERRORS_CODE_TYPES: {GENERIC: string,
* OPTIN: string}, RHSM_API_QUERY_GRANULARITY_TYPES: {WEEKLY: string, QUARTERLY: string, DAILY: string, MONTHLY: string},
* RHSM_API_RESPONSE_UOM_TYPES: {CORES: string, SOCKETS: string}, RHSM_API_QUERY_INVENTORY_SORT_DIRECTION_TYPES: {ASCENDING: string,
* DESCENDING: string}, RHSM_API_QUERY_INVENTORY_SORT_TYPES: {CORES: string, STORAGE_GIBIBYTES: string, SOCKETS: string,
* INSTANCE_HOURS: string, TRANSFER_GIBIBYTES: string, BILLING_PROVIDER: string, CORE_SECONDS: string, LAST_SEEN: string,
* NAME: string}, RHSM_API_PATH_PRODUCT_TYPES: {RHEL_ARM: string, OPENSHIFT_METRICS: string, SATELLITE: string,
* RHEL_WORKSTATION: string, RHOSAK: string, RHEL_COMPUTE_NODE: string, RHEL_X86: string, OPENSHIFT: string,
* SATELLITE_SERVER: string, OPENSHIFT_DEDICATED_METRICS: string, RHEL_DESKTOP: string, RHEL: string, SATELLITE_CAPSULE: string,
* RHEL_SERVER: string, RHEL_IBM_Z: string, RHEL_IBM_POWER: string}, RHSM_API_RESPONSE_BILLING_PROVIDER_TYPES: {AZURE: string,
* GCP: string, RED_HAT: string, NONE: string, AWS: string, ORACLE: string}, RHSM_API_RESPONSE_ERRORS_TYPES: {CODE: string},
* DESCENDING: string}, RHSM_API_RESPONSE_SUBSCRIPTION_TYPES: {ANNUAL: string, ON_DEMAND: string},
* RHSM_API_QUERY_INVENTORY_SORT_TYPES: {CORES: string, STORAGE_GIBIBYTES: string, SOCKETS: string, INSTANCE_HOURS: string,
* TRANSFER_GIBIBYTES: string, BILLING_PROVIDER: string, CORE_SECONDS: string, LAST_SEEN: string, NAME: string},
* RHSM_API_PATH_PRODUCT_TYPES: {RHEL_ARM: string, OPENSHIFT_METRICS: string, SATELLITE: string, RHEL_WORKSTATION: string,
* RHOSAK: string, RHEL_COMPUTE_NODE: string, RHEL_X86: string, OPENSHIFT: string, SATELLITE_SERVER: string,
* OPENSHIFT_DEDICATED_METRICS: string, RHEL_DESKTOP: string, RHEL: string, SATELLITE_CAPSULE: string, RHEL_SERVER: string,
* RHEL_IBM_Z: string, RHEL_IBM_POWER: string}, RHSM_API_RESPONSE_BILLING_PROVIDER_TYPES: {AZURE: string, GCP: string,
* RED_HAT: string, NONE: string, AWS: string, ORACLE: string}, RHSM_API_RESPONSE_ERRORS_TYPES: {CODE: string},
* RHSM_API_QUERY_BILLING_PROVIDER_TYPES: {AZURE: string, GCP: string, RED_HAT: string, NONE: string, AWS: string, ORACLE: string},
* RHSM_API_QUERY_USAGE_TYPES: {UNSPECIFIED: string, DISASTER: string, DEVELOPMENT: string, PRODUCTION: string},
* RHSM_API_QUERY_SLA_TYPES: {PREMIUM: string, SELF: string, NONE: string, STANDARD: string},
Expand Down Expand Up @@ -374,6 +385,7 @@ const rhsmConstants = {
RHSM_API_RESPONSE_GRANULARITY_TYPES,
RHSM_API_RESPONSE_BILLING_PROVIDER_TYPES,
RHSM_API_RESPONSE_SLA_TYPES,
RHSM_API_RESPONSE_SUBSCRIPTION_TYPES,
RHSM_API_RESPONSE_UOM_TYPES,
RHSM_API_RESPONSE_USAGE_TYPES,
RHSM_API_QUERY_GRANULARITY_TYPES,
Expand Down Expand Up @@ -407,6 +419,7 @@ export {
RHSM_API_RESPONSE_GRANULARITY_TYPES,
RHSM_API_RESPONSE_BILLING_PROVIDER_TYPES,
RHSM_API_RESPONSE_SLA_TYPES,
RHSM_API_RESPONSE_SUBSCRIPTION_TYPES,
RHSM_API_RESPONSE_UOM_TYPES,
RHSM_API_RESPONSE_USAGE_TYPES,
RHSM_API_QUERY_GRANULARITY_TYPES,
Expand Down
6 changes: 5 additions & 1 deletion src/services/rhsm/rhsmSchemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ const instancesResponseSchema = Joi.object().keys({
*
* @type {*} Joi schema
*/
const subscriptionsMetaSchema = metaResponseSchema;
const subscriptionsMetaSchema = metaResponseSchema
.keys({
subscription_type: Joi.string().valid(null, ...Object.values(rhsmConstants.RHSM_API_RESPONSE_SUBSCRIPTION_TYPES))
})
.unknown(true);

/**
* Subscriptions response item.
Expand Down
3 changes: 2 additions & 1 deletion src/services/rhsm/rhsmServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -2348,7 +2348,8 @@ const getInstancesInventory = (id, params = {}, options = {}) => {
* ],
* "links": {},
* "meta": {
* "count": 3
* "count": 3,
* "subscription_type": "On-demand"
* }
* }
*
Expand Down

0 comments on commit 91f8a03

Please sign in to comment.