Skip to content

Commit

Permalink
feat(productViewOpenShiftDedicated): ent-3324 base view (#590)
Browse files Browse the repository at this point in the history
* i18n, locale strings for OpenShift
* inventoryList, Subscriptions, console confirmation for sorting
* inventoryListHelpers, allow for missing data
* productView, product label context
* productViewOpenShiftDedicated, base view
* routerConfig, OpenShift dedicated route
* rhsmServices, mock API response, core hours
* rhsmApiTypes, product IDs, core hours for sorting and inventory
  • Loading branch information
cdcabrera committed Apr 13, 2021
1 parent 1e93aae commit a768f57
Show file tree
Hide file tree
Showing 22 changed files with 801 additions and 75 deletions.
13 changes: 13 additions & 0 deletions public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@
"cardHeading": "CPU usage",
"cardHeading_cores": "CPU core usage",
"cardHeading_sockets": "CPU socket usage",
"cardHeading_OpenShift-dedicated-metrics": "Flexible subscriptions",
"cardHeading_RHEL": "CPU socket usage",
"cardHeading_Satellite": "CPU socket usage",
"infiniteThresholdLabel": "unlimited",
"noLabel": "Data",
"noDataLabel": "no data",
"noDataErrorLabel": "No data",
"dateLabel": "Date",
"coresLabel": "Cores",
"coresLegendTooltip": "{{product}} CPU usage, per CPU core.",
"coreHoursLabel": "Core Hours",
"coreHoursLegendTooltip": "{{product}} core hours usage.",
"coreHoursLegendTooltip_OpenShift-dedicated-metrics": "OpenShift Dedicated core hours usage.",
"socketsLabel": "Sockets",
"socketsLegendTooltip": "{{product}} CPU usage, per CPU socket pair.",
"cloudSocketsLabel": "Public cloud",
Expand Down Expand Up @@ -67,13 +73,18 @@
"hardwareType_virtualized": "Virtual",
"header": "{{context}}",
"header_cores": "Subscribed cores",
"header_cores_OpenShift Container Platform": "Cores",
"header_cores_OpenShift-metrics": "Cores",
"header_cores_OpenShift-dedicated-metrics": "Cores",
"header_coreHours": "Hours used",
"header_displayName": "Name",
"header_guestsDisplayName": "Guest name",
"header_hardwareType": "Type",
"header_measurementType": "Type",
"header_inventoryId": "UUID",
"header_sockets": "Subscribed sockets",
"header_lastSeen": "Last seen",
"header_lastSeen_OpenShift-dedicated-metrics": "Last check-in",
"header_productName": "Product",
"header_serviceLevel": "Service level",
"header_upcomingEventDate": "Next renewal",
Expand Down Expand Up @@ -143,6 +154,8 @@
"subtitle": "Monitor your usage based on your subscription terms. <0>Learn more about {{appName}} reporting</0>",
"title_OpenShift Container Platform": "Red Hat OpenShift",
"subtitle_OpenShift Container Platform": "Monitor your Red Hat OpenShift usage by socket or core usage, based on your subscription terms. <0>Learn more about {{appName}} reporting</0>",
"title_OpenShift-dedicated-metrics": "OpenShift Dedicated",
"subtitle_OpenShift-dedicated-metrics": "Monitor your OpenShift Dedicated usage for flexible capacity subscriptions. <0>Learn more about {{appName}} reporting</0>",
"title_RHEL": "Red Hat Enterprise Linux",
"subtitle_RHEL": "Monitor your Red Hat Enterprise Linux usage by physical, virtual, and public cloud sockets. <0>Learn more about {{appName}} reporting</0>",
"title_Satellite": "Red Hat Satellite"
Expand Down
23 changes: 22 additions & 1 deletion src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ Array [
"key": "curiosity-inventory.header",
"match": "translate('curiosity-inventory.header', { context: key })",
},
Object {
"key": "curiosity-inventory.header",
"match": "translate('curiosity-inventory.header', { context: id })",
},
],
},
Object {
Expand Down Expand Up @@ -274,7 +278,7 @@ Array [
},
Object {
"key": "curiosity-graph.cardHeading",
"match": "t('curiosity-graph.cardHeading', { context: 'sockets' })",
"match": "t('curiosity-graph.cardHeading', { context: productLabel })",
},
Object {
"key": "curiosity-inventory.tab",
Expand All @@ -286,6 +290,19 @@ Array [
},
],
},
Object {
"file": "./src/components/productView/productViewOpenShiftDedicated.js",
"keys": Array [
Object {
"key": "curiosity-inventory.label",
"match": "translate('curiosity-inventory.label', { context: 'numberOfGuests', count: numberOfGuests.value }, [ <PfLabel color=\\"blue\\" /> ])",
},
Object {
"key": "curiosity-inventory.header",
"match": "translate('curiosity-inventory.header', { context: 'lastSeen_OpenShift-dedicated-metrics' })",
},
],
},
Object {
"file": "./src/components/productView/productViewRhel.js",
"keys": Array [
Expand Down Expand Up @@ -550,6 +567,10 @@ Array [
"file": "./src/components/productView/productView.js",
"key": "curiosity-inventory.tab",
},
Object {
"file": "./src/components/productView/productViewOpenShiftDedicated.js",
"key": "curiosity-inventory.label",
},
Object {
"file": "./src/components/productView/productViewRhel.js",
"key": "curiosity-inventory.label",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ Object {
}
`;

exports[`InventoryListHelpers applySortFilters should apply and return updated filters for table sorting: sortable, set a default field 1`] = `
Object {
"id": "lorem",
"isSortDefault": true,
"isSortable": true,
"onSort": [Function],
"sortActive": true,
"sortDefaultInitialDirection": "lorem",
"sortDirection": "lorem",
}
`;

exports[`InventoryListHelpers applyWrappableFilters should apply and return updated filters for table header wrapping: NOT wrappable header 1`] = `
Array [
Object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ describe('InventoryListHelpers', () => {
}
})
).toMatchSnapshot('sortable, active column');

expect(
applySortFilters({
filter: { ...filter, sortActive: false, sortDefaultInitialDirection: 'lorem', isSortDefault: true },
onSort: () => {}
})
).toMatchSnapshot('sortable, set a default field');
});

it('applyWrappableFilters should apply and return updated filters for table header wrapping', () => {
Expand Down
3 changes: 3 additions & 0 deletions src/components/inventoryList/inventoryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class InventoryList extends React.Component {
let updatedDirection;

if (!updatedSortColumn) {
if (helpers.DEV_MODE || helpers.REVIEW_MODE) {
console.warn(`Sorting can only be performed on select fields, confirm field ${id} is allowed.`);
}
return;
}

Expand Down
20 changes: 13 additions & 7 deletions src/components/inventoryList/inventoryListHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
* Apply sort filter to filters.
*
* @param {object} params
* @param {object} params.filter
* @param {{ onSort: Function, sortActive: boolean, sortDirection: string, isSortDefault: boolean,
* sortDefaultInitialDirection: string }} params.filter
* @param {Function} params.onSort
* @param {object} params.query
* @returns {object}
Expand Down Expand Up @@ -136,6 +137,9 @@ const parseRowCellsListData = ({ filters = [], cellData = {}, session = {} }) =>
if (allCells[id]) {
headerUpdated = allCells[id]?.title ?? id;
cellUpdated = allCells[id]?.value ?? '';
} else if (id) {
headerUpdated = translate('curiosity-inventory.header', { context: id });
cellUpdated = '';
}

// set table header cell filter params
Expand All @@ -153,14 +157,16 @@ const parseRowCellsListData = ({ filters = [], cellData = {}, session = {} }) =>
};
}

headerUpdated.transforms = [];
if (headerUpdated) {
headerUpdated.transforms = [];

if (Array.isArray(transforms)) {
headerUpdated.transforms = headerUpdated.transforms.concat([...transforms]);
}
if (Array.isArray(transforms)) {
headerUpdated.transforms = headerUpdated.transforms.concat([...transforms]);
}

if (typeof cellWidth === 'number') {
headerUpdated.transforms.push(PfCellWidth(cellWidth));
if (typeof cellWidth === 'number') {
headerUpdated.transforms.push(PfCellWidth(cellWidth));
}
}

if (typeof onSort === 'function') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class InventorySubscriptions extends React.Component {
let updatedDirection;

if (!updatedSortColumn) {
if (helpers.DEV_MODE || helpers.REVIEW_MODE) {
console.warn(`Sorting can only be performed on select fields, confirm field ${id} is allowed.`);
}
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ exports[`ProductView Component should allow custom toolbar components: custom to
className=""
>
<Connect(GraphCard)
cardTitle="t(curiosity-graph.cardHeading, {\\"context\\":\\"sockets\\"})"
cardTitle="t(curiosity-graph.cardHeading, {\\"context\\":\\"lorem ipsum product label\\"})"
key="graph_lorem ipsum"
productId="lorem ipsum"
productLabel="lorem ipsum product label"
Expand Down Expand Up @@ -98,7 +98,7 @@ exports[`ProductView Component should allow custom toolbar components: custom to
className=""
>
<Connect(GraphCard)
cardTitle="t(curiosity-graph.cardHeading, {\\"context\\":\\"sockets\\"})"
cardTitle="t(curiosity-graph.cardHeading, {\\"context\\":\\"lorem ipsum product label\\"})"
key="graph_lorem ipsum"
productId="lorem ipsum"
productLabel="lorem ipsum product label"
Expand Down Expand Up @@ -173,7 +173,7 @@ exports[`ProductView Component should render a non-connected component: non-conn
className=""
>
<Connect(GraphCard)
cardTitle="t(curiosity-graph.cardHeading, {\\"context\\":\\"sockets\\"})"
cardTitle="t(curiosity-graph.cardHeading, {\\"context\\":\\"lorem ipsum product label\\"})"
key="graph_lorem ipsum"
productId="lorem ipsum"
productLabel="lorem ipsum product label"
Expand Down
Loading

0 comments on commit a768f57

Please sign in to comment.