Skip to content

Commit

Permalink
fix(locale): ent-4045 threshold graph legend strings (#733)
Browse files Browse the repository at this point in the history
* locale, threshold strings
* graphCardChartLegend, context, string refs
* graphCardChartTooltip, context, string refs
* productViewOpenShiftContainer, productLabel to product group
  • Loading branch information
cdcabrera committed Jul 26, 2021
1 parent ca59ea8 commit f5cd3a7
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 27 deletions.
10 changes: 5 additions & 5 deletions public/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@
"physicalSocketsLabel": "Physical {{product}}",
"physicalSocketsLegendTooltip": "{{product}} CPU socket usage, per socket pair.",
"physicalSocketsLegendTooltip_RHEL": "Physical {{product}} CPU usage, per socket pair. Each system's socket count is rounded upwards to the next even number.",
"thresholdLabel": "Subscription threshold",
"thresholdLegendTooltip": "Maximum capacity, based on total {{product}} subscriptions in this account.",
"thresholdLegendTooltip_RHEL": "Maximum capacity, as CPU sockets, based on total {{product}} subscriptions in this account.",
"thresholdCoresLegendTooltip_OpenShift Container Platform": "Maximum capacity, as CPU cores, based on total {{product}} subscriptions in this account.",
"thresholdSocketsLegendTooltip_OpenShift Container Platform": "Maximum capacity, as CPU sockets, based on total {{product}} subscriptions in this account.",
"label_threshold": "Subscription threshold",
"legendTooltip_threshold": "Maximum capacity, based on total {{product}} subscriptions in this account.",
"legendTooltip_threshold_thresholdSockets_RHEL": "Maximum capacity, as CPU sockets, based on total {{product}} subscriptions in this account.",
"legendTooltip_threshold_thresholdCores_OpenShift Container Platform": "Maximum capacity, as CPU cores, based on total {{product}} Annual subscriptions in this account.",
"legendTooltip_threshold_thresholdSockets_OpenShift Container Platform": "Maximum capacity, as CPU sockets, based on total {{product}} Annual subscriptions in this account.",
"tooltipSummary": "Your subscription data facets. With one level of column and row headers."
},
"curiosity-inventory": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ exports[`GraphCardChartLegend Component should render basic data: data 1`] = `
<Tooltip
content={
<p>
t(curiosity-graph.dolorSitLegendTooltip,curiosity-graph.thresholdLegendTooltip, {"product":"test","context":"test"})
t(curiosity-graph.legendTooltip_threshold, {"product":"test","context":"dolorSit_test"})
</p>
}
distance={5}
Expand Down Expand Up @@ -313,13 +313,13 @@ exports[`GraphCardChartLegend Component should render basic data: data 1`] = `
tabIndex={0}
variant="link"
>
t(curiosity-graph.dolorSitLabel,curiosity-graph.thresholdLabel, {"product":"test","context":"test"})
t(curiosity-graph.label_threshold, {"product":"test","context":"dolorSit_test"})
</Button>
</Tooltip>
<Tooltip
content={
<p>
t(curiosity-graph.nonCursusLegendTooltip,curiosity-graph.thresholdLegendTooltip, {"product":"test","context":"test"})
t(curiosity-graph.legendTooltip_threshold, {"product":"test","context":"nonCursus_test"})
</p>
}
distance={5}
Expand Down Expand Up @@ -350,7 +350,7 @@ exports[`GraphCardChartLegend Component should render basic data: data 1`] = `
tabIndex={0}
variant="link"
>
t(curiosity-graph.nonCursusLabel,curiosity-graph.thresholdLabel, {"product":"test","context":"test"})
t(curiosity-graph.label_threshold, {"product":"test","context":"nonCursus_test"})
</Button>
</Tooltip>
</Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ describe('GraphCardChartLegend Component', () => {
}
]
},
productId: 'test id',
productLabel: 'test'
};

Expand Down Expand Up @@ -79,6 +80,7 @@ describe('GraphCardChartLegend Component', () => {
legend: {
'test-dolorSit': true
},
productId: 'test id',
productLabel: 'test',
viewId: 'test'
};
Expand Down Expand Up @@ -119,6 +121,7 @@ describe('GraphCardChartLegend Component', () => {
}
]
},
productId: 'test id',
productLabel: 'test'
};

Expand Down
15 changes: 8 additions & 7 deletions src/components/graphCard/graphCardChartLegend.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ class GraphCardChartLegend extends React.Component {

const labelContent =
(isThreshold &&
t([`curiosity-graph.${id}Label`, `curiosity-graph.thresholdLabel`], {
t('curiosity-graph.label_threshold', {
product: productLabel,
context: productLabel
context: [id, productLabel]
})) ||
t([`curiosity-graph.${id}Label`, `curiosity-graph.noLabel`], {
product: productLabel,
Expand All @@ -126,9 +126,9 @@ class GraphCardChartLegend extends React.Component {

const tooltipContent =
(isThreshold &&
t([`curiosity-graph.${id}LegendTooltip`, `curiosity-graph.thresholdLegendTooltip`], {
t('curiosity-graph.legendTooltip_threshold', {
product: productLabel,
context: productLabel
context: [id, productLabel]
})) ||
t(`curiosity-graph.${id}LegendTooltip`, { product: productLabel, context: productLabel });

Expand All @@ -149,7 +149,8 @@ class GraphCardChartLegend extends React.Component {
/**
* Prop types.
*
* @type {{datum, productLabel: string, t: Function, legend: object, chart: object}}
* @type {{datum: object, productLabel: string, viewId: string, t: Function, legend: object,
* chart: object}}
*/
GraphCardChartLegend.propTypes = {
chart: PropTypes.shape({
Expand All @@ -175,8 +176,8 @@ GraphCardChartLegend.propTypes = {
/**
* Default props.
*
* @type {{datum: {dataSets: Array}, productLabel: string, viewId: string, t: translate, legend: object,
* chart: {hide: Function, toggle: Function, isToggled: Function}}}
* @type {{datum: object, productLabel: string, viewId: string, t: translate, legend: object,
* chart: object}}
*/
GraphCardChartLegend.defaultProps = {
chart: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/graphCard/graphCardChartTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const GraphCardChartTooltip = ({ datum, granularity, productLabel, t }) => {
}
}

tempDataFacet.label = t(`curiosity-graph.thresholdLabel`);
tempDataFacet.label = t('curiosity-graph.label', { context: 'threshold' });
tempDataFacet.value = thresholdStringValue;
} else {
const dataFactsValue =
Expand Down
16 changes: 10 additions & 6 deletions src/components/i18n/__tests__/__snapshots__/i18n.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ Array [
"file": "./src/components/graphCard/graphCardChartLegend.js",
"keys": Array [
Object {
"key": "",
"match": "t([\`curiosity-graph.\${id}Label\`, \`curiosity-graph.thresholdLabel\`], { product: productLabel, context: productLabel })",
"key": "curiosity-graph.label_threshold",
"match": "t('curiosity-graph.label_threshold', { product: productLabel, context: [id, productLabel] })",
},
Object {
"key": "",
"match": "t([\`curiosity-graph.\${id}Label\`, \`curiosity-graph.noLabel\`], { product: productLabel, context: productLabel })",
},
Object {
"key": "",
"match": "t([\`curiosity-graph.\${id}LegendTooltip\`, \`curiosity-graph.thresholdLegendTooltip\`], { product: productLabel, context: productLabel })",
"key": "curiosity-graph.legendTooltip_threshold",
"match": "t('curiosity-graph.legendTooltip_threshold', { product: productLabel, context: [id, productLabel] })",
},
Object {
"key": "",
Expand All @@ -90,8 +90,8 @@ Array [
"match": "t('curiosity-graph.infiniteThresholdLabel')",
},
Object {
"key": "curiosity-graph.thresholdLabel",
"match": "t(\`curiosity-graph.thresholdLabel\`)",
"key": "curiosity-graph.label",
"match": "t('curiosity-graph.label', { context: 'threshold' })",
},
Object {
"key": "curiosity-graph.noDataLabel",
Expand Down Expand Up @@ -585,6 +585,10 @@ Array [

exports[`I18n Component should have locale keys that exist in the default language JSON: missing locale keys 1`] = `
Array [
Object {
"file": "./src/components/graphCard/graphCardChartTooltip.js",
"key": "curiosity-graph.label",
},
Object {
"file": "./src/components/inventoryList/inventoryList.js",
"key": "curiosity-inventory.tab",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ exports[`ProductViewOpenShiftContainer Component should render a non-connected c
}
key="graph_OpenShift Container Platform"
productId="OpenShift Container Platform"
productLabel="OpenShift"
productLabel="OpenShift Container Platform"
query={
Object {
"beginning": "2019-06-20T00:00:00.000Z",
Expand Down Expand Up @@ -306,7 +306,7 @@ exports[`ProductViewOpenShiftContainer Component should render a non-connected c
}
key="graph_OpenShift-metrics"
productId="OpenShift-metrics"
productLabel="OpenShift Metric"
productLabel="OpenShift-metrics"
query={
Object {
"beginning": "2019-07-01T00:00:00.000Z",
Expand Down
4 changes: 2 additions & 2 deletions src/components/productView/productViewOpenShiftContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ ProductViewOpenShiftContainer.defaultProps = {
id: RHSM_API_QUERY_TYPES.SLA
}
],
productLabel: 'OpenShift',
productLabel: RHSM_API_PATH_ID_TYPES.OPENSHIFT,
productId: RHSM_API_PATH_ID_TYPES.OPENSHIFT,
viewId: 'viewOpenShift'
},
Expand Down Expand Up @@ -501,7 +501,7 @@ ProductViewOpenShiftContainer.defaultProps = {
}
],
initialToolbarFilters: undefined,
productLabel: 'OpenShift Metric',
productLabel: RHSM_API_PATH_ID_TYPES.OPENSHIFT_METRICS,
productId: RHSM_API_PATH_ID_TYPES.OPENSHIFT_METRICS,
viewId: 'viewOpenShiftMetric'
}
Expand Down

0 comments on commit f5cd3a7

Please sign in to comment.