Skip to content

Commit

Permalink
feat(config): sw-922 product custom card metrics (#1077)
Browse files Browse the repository at this point in the history
* config, rhacs, rhods, rhosak, card metrics to display
* helpers, setImmutableData
* graphCard, move isMetricDisplay check to totals comp
* graphCardHelpers, set, or determine, isMetricDisplay
* graphCardMetricTotals, passthrough, call card callbacks
* pageColumns, adjust children isRequired
  • Loading branch information
cdcabrera committed Mar 21, 2023
1 parent a242cbc commit c979301
Show file tree
Hide file tree
Showing 35 changed files with 917 additions and 320 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
'!src/app.js',
'!src/bootstrap.js',
'!src/entry.js',
'!src/index.js',
'!src/index*.js',
'!src/components/**/index.js',
'!src/common/index.js',
'!src/redux/index.js',
Expand Down
19 changes: 19 additions & 0 deletions src/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ Download the debug log file.
* [General](#Helpers.module_General)
* [~noop](#Helpers.module_General..noop)
* [~noopPromise](#Helpers.module_General..noopPromise) : <code>Promise.&lt;{}&gt;</code>
* [~setImmutableData](#Helpers.module_General..setImmutableData) ⇒ <code>\*</code>
* [~DEV_MODE](#Helpers.module_General..DEV_MODE) : <code>boolean</code>
* [~PROD_MODE](#Helpers.module_General..PROD_MODE) : <code>boolean</code>
* [~REVIEW_MODE](#Helpers.module_General..REVIEW_MODE) : <code>boolean</code>
Expand Down Expand Up @@ -222,6 +223,24 @@ An empty promise.
Typically used as a default prop, or during testing.

**Kind**: inner constant of [<code>General</code>](#Helpers.module_General)
<a name="Helpers.module_General..setImmutableData"></a>

### General~setImmutableData ⇒ <code>\*</code>
Quick set data as "immutable-like". Used to pass object and array data through configuration callbacks.

**Kind**: inner constant of [<code>General</code>](#Helpers.module_General)
<table>
<thead>
<tr>
<th>Param</th><th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>data</td><td><code>*</code></td>
</tr> </tbody>
</table>

<a name="Helpers.module_General..DEV_MODE"></a>

### General~DEV\_MODE : <code>boolean</code>
Expand Down
3 changes: 3 additions & 0 deletions src/common/__tests__/__snapshots__/helpers.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ exports[`Helpers should expose a window object: limited window object 1`] = `
"noopPromise": Promise {},
"numberDisplay": [Function],
"objFreeze": [Function],
"setImmutableData": [Function],
}
`;

Expand Down Expand Up @@ -91,6 +92,7 @@ exports[`Helpers should expose a window object: window object 1`] = `
"noopPromise": Promise {},
"numberDisplay": [Function],
"objFreeze": [Function],
"setImmutableData": [Function],
}
`;

Expand Down Expand Up @@ -146,6 +148,7 @@ exports[`Helpers should have specific functions: helpers 1`] = `
"noopPromise": Promise {},
"numberDisplay": [Function],
"objFreeze": [Function],
"setImmutableData": [Function],
}
`;

Expand Down
9 changes: 9 additions & 0 deletions src/common/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,14 @@ const objFreeze = obj => {
return obj;
};

/**
* Quick set data as "immutable-like". Used to pass object and array data through configuration callbacks.
*
* @param {*} data
* @returns {*}
*/
const setImmutableData = memo(data => objFreeze(data));

/**
* Is dev mode active.
* Associated with using the NPM script "start". See dotenv config files for activation.
Expand Down Expand Up @@ -413,6 +421,7 @@ const helpers = {
noopPromise,
numberDisplay,
objFreeze,
setImmutableData,
DEV_MODE,
PROD_MODE,
REVIEW_MODE,
Expand Down
2 changes: 1 addition & 1 deletion src/components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2602,7 +2602,7 @@ Display totals for a single metric.
</tr><tr>
<td>props.children</td><td><code>React.ReactNode</code></td>
</tr><tr>
<td>props.t</td><td><code>function</code></td>
<td>props.useGraphCardContext</td><td><code>function</code></td>
</tr><tr>
<td>props.useMetricsSelector</td><td><code>function</code></td>
</tr><tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ exports[`GraphCard Component should setup basic settings: settings, grouped 1`]
value={
{
"settings": {
"cards": [
{
"body": "ipsum",
"footer": "dolor sit",
"header": "lorem",
},
],
"isMetricDisplay": true,
"loremIpsum": false,
"metric": undefined,
Expand All @@ -29,7 +36,7 @@ exports[`GraphCard Component should setup basic settings: settings, grouped 1`]
}
>
<GraphCardMetricTotals
t={[Function]}
useGraphCardContext={[Function]}
useMetricsSelector={[Function]}
useProductGraphTallyQuery={[Function]}
>
Expand Down Expand Up @@ -75,12 +82,18 @@ exports[`GraphCard Component should setup basic settings: settings, standalone 1
}
}
>
<GraphCardChart
t={[Function]}
useGetMetrics={[Function]}
useGraphCardActions={[Function]}
<GraphCardMetricTotals
useGraphCardContext={[Function]}
useMetricsSelector={[Function]}
useProductGraphTallyQuery={[Function]}
/>
>
<GraphCardChart
t={[Function]}
useGetMetrics={[Function]}
useGraphCardActions={[Function]}
useGraphCardContext={[Function]}
useProductGraphTallyQuery={[Function]}
/>
</GraphCardMetricTotals>
</ContextProvider>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ exports[`GraphCardContext should parse configuration: configuration, grouped 1`]
"filtersSettings": [
{
"settings": {
"groupMetric": [
"Core-seconds",
],
"isMetricDisplay": false,
"isMultiMetric": false,
"isStandalone": undefined,
"metric": undefined,
Expand Down Expand Up @@ -152,6 +156,10 @@ exports[`GraphCardContext should parse configuration: configuration, standalone
"filtersSettings": [
{
"settings": {
"groupMetric": [
"Core-seconds",
],
"isMetricDisplay": false,
"isMultiMetric": false,
"isStandalone": undefined,
"loremIpsum": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ exports[`GraphCardHelpers generateChartSettings should return base graph setting
{
"settings": {
"dolor": "sit",
"groupMetric": [
"dolorSit",
],
"isMetricDisplay": false,
"isMultiMetric": false,
"isStandalone": undefined,
"metric": undefined,
Expand Down
Loading

0 comments on commit c979301

Please sign in to comment.