Skip to content

Commit

Permalink
feat(rhosak): ent-4499 activate subs table (#863)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera authored Jan 11, 2022
1 parent 3db8cf1 commit f565c92
Show file tree
Hide file tree
Showing 4 changed files with 216 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,10 @@ Array [
"key": "curiosity-inventory.measurement",
"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 {
Expand Down
132 changes: 132 additions & 0 deletions src/config/__tests__/__snapshots__/product.rhosak.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,138 @@ Object {
}
`;

exports[`Product RHOSAK config should apply subscriptions inventory configuration: filtered 1`] = `
Object {
"cells": Array [
Object {
"title": "lorem",
},
Object {
"title": "hello world",
},
Object {
"title": "",
},
Object {
"title": "",
},
Object {
"title": "",
},
],
"columnHeaders": Array [
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"productName\\"})",
"transforms": Array [],
},
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"serviceLevel\\"})",
"transforms": Array [
[Function],
],
},
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"quantity\\"})",
"transforms": Array [
[Function],
],
},
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"subscriptions\\"})",
"transforms": Array [
[Function],
],
},
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"nextEventDate\\"})",
"transforms": Array [
[Function],
],
},
],
"data": Object {
"nextEventDate": Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"nextEventDate\\"})",
"value": "lorem date obj",
},
"productName": Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"productName\\"})",
"value": "lorem",
},
"serviceLevel": Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"serviceLevel\\"})",
"value": "hello world",
},
},
}
`;

exports[`Product RHOSAK config should apply subscriptions inventory configuration: filtered, fallback display 1`] = `
Object {
"cells": Array [
Object {
"title": "lorem",
},
Object {
"title": "",
},
Object {
"title": "",
},
Object {
"title": "",
},
Object {
"title": "",
},
],
"columnHeaders": Array [
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"productName\\"})",
"transforms": Array [],
},
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"serviceLevel\\"})",
"transforms": Array [
[Function],
],
},
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"quantity\\"})",
"transforms": Array [
[Function],
],
},
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"subscriptions\\"})",
"transforms": Array [
[Function],
],
},
Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"nextEventDate\\"})",
"transforms": Array [
[Function],
],
},
],
"data": Object {
"nextEventDate": Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"nextEventDate\\"})",
"value": null,
},
"productName": Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"productName\\"})",
"value": "lorem",
},
"serviceLevel": Object {
"title": "t(curiosity-inventory.header, {\\"context\\":\\"serviceLevel\\"})",
"value": null,
},
},
}
`;

exports[`Product RHOSAK config should handle a custom yAxisTickFormat for floating points: yAxisTickFormat 1`] = `
Object {
"0.00001345": "0.00001",
Expand Down
35 changes: 35 additions & 0 deletions src/config/__tests__/product.rhosak.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,39 @@ describe('Product RHOSAK config', () => {

expect(inventoryQuery[RHSM_API_QUERY_SET_TYPES.DIRECTION] === SORT_DIRECTION_TYPES.DESCENDING).toBe(true);
});

it('should apply subscriptions inventory configuration', () => {
const {
initialSubscriptionsInventoryFilters: initialFilters,
inventorySubscriptionsQuery: inventoryQuery
} = config;

const inventoryData = {
productName: 'lorem',
serviceLevel: 'hello world',
nextEventDate: 'lorem date obj'
};

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

expect(filteredInventoryData).toMatchSnapshot('filtered');

const fallbackInventoryData = {
...inventoryData,
serviceLevel: null,
nextEventDate: null
};

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

expect(fallbackFilteredInventoryData).toMatchSnapshot('filtered, fallback display');

expect(inventoryQuery[RHSM_API_QUERY_SET_TYPES.DIRECTION] === SORT_DIRECTION_TYPES.DESCENDING).toBe(true);
});
});
46 changes: 45 additions & 1 deletion src/config/product.rhosak.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import {
} from '@patternfly/react-tokens';
import { Button } from '@patternfly/react-core';
import { DateFormat } from '@redhat-cloud-services/frontend-components/DateFormat';
import moment from 'moment';
import { RHSM_API_QUERY_SUBSCRIPTIONS_SORT_TYPES } from '../types/rhsmApiTypes';
import {
RHSM_API_QUERY_INVENTORY_SORT_DIRECTION_TYPES as SORT_DIRECTION_TYPES,
RHSM_API_QUERY_INVENTORY_SORT_TYPES,
Expand Down Expand Up @@ -50,7 +52,12 @@ const config = {
[RHSM_API_QUERY_SET_TYPES.LIMIT]: 100,
[RHSM_API_QUERY_SET_TYPES.OFFSET]: 0
},
inventorySubscriptionsQuery: {},
inventorySubscriptionsQuery: {
[RHSM_API_QUERY_SET_TYPES.SORT]: RHSM_API_QUERY_SUBSCRIPTIONS_SORT_TYPES.NEXT_EVENT_DATE,
[RHSM_API_QUERY_SET_TYPES.DIRECTION]: SORT_DIRECTION_TYPES.DESCENDING,
[RHSM_API_QUERY_SET_TYPES.LIMIT]: 100,
[RHSM_API_QUERY_SET_TYPES.OFFSET]: 0
},
initialGraphFilters: [
{
id: RHSM_API_PATH_METRIC_TYPES.TRANSFER_GIBIBYTES,
Expand Down Expand Up @@ -173,6 +180,43 @@ const config = {
cellWidth: 15
}
],
initialSubscriptionsInventoryFilters: [
{
id: 'productName',
isSortable: false,
isWrappable: true
},
{
id: 'serviceLevel',
isSortable: true,
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 =>
(data?.nextEventDate?.value &&
helpers.isDate(data?.nextEventDate?.value) &&
moment.utc(data?.nextEventDate?.value).format('YYYY-DD-MM')) ||
'',
isSortable: true,
isWrappable: true,
cellWidth: 15
}
],
initialToolbarFilters: [
{
id: 'rangedMonthly'
Expand Down

0 comments on commit f565c92

Please sign in to comment.