Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/prod-beta' into prod-stable
Browse files Browse the repository at this point in the history
  • Loading branch information
dlabrecq committed Jul 19, 2023
2 parents d8cd86a + 66e37c1 commit 7a93bdc
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 60 deletions.
42 changes: 14 additions & 28 deletions locales/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -1881,20 +1881,6 @@
"value": "CPU"
}
],
"cpuUnits": [
{
"type": 0,
"value": "CPU ("
},
{
"type": 1,
"value": "units"
},
{
"type": 0,
"value": ")"
}
],
"create": [
{
"type": 0,
Expand Down Expand Up @@ -9960,20 +9946,6 @@
"value": "Memory"
}
],
"memoryUnits": [
{
"type": 0,
"value": "Memory ("
},
{
"type": 1,
"value": "units"
},
{
"type": 0,
"value": ")"
}
],
"metric": [
{
"type": 0,
Expand Down Expand Up @@ -10676,6 +10648,20 @@
"value": "Optimizations table"
}
],
"optimizationsValueUnits": [
{
"type": 1,
"value": "value"
},
{
"type": 0,
"value": " "
},
{
"type": 1,
"value": "units"
}
],
"optimizationsValues": [
{
"options": {
Expand Down
3 changes: 1 addition & 2 deletions locales/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@
"costTypeUnblended": "Unblended",
"costTypeUnblendedDesc": "Usage cost on the day you are charged",
"cpuTitle": "CPU",
"cpuUnits": "CPU ({units})",
"create": "Create",
"createCostModelConfirmMsg": "Are you sure you want to stop creating a cost model? All settings will be discarded.",
"createCostModelDesc": "A cost model allows you to associate a price to metrics provided by your sources to charge for utilization of resources.",
Expand Down Expand Up @@ -356,7 +355,6 @@
"measurementValues": "{value, select, count {{count, plural, one {Count} other {Count ({units})}}} effective_usage {{count, plural, one {Request} other {Effective-usage ({units})}}} request {{count, plural, one {Request} other {Request ({units})}}} usage {{count, plural, one {Usage} other {Usage ({units})}}} other {}}",
"measurementValuesDesc": "{value, select, count {{units, select, node_month {The distinct number of nodes identified during the month} pvc_month {The distinct number of volume claims identified during the month} cluster_month {The distinct number of clusters identified during the month} other {}}} effective_usage {The greater of usage and request each hour} request {The pod resources requested, as reported by OpenShift} usage {The pod resources used, as reported by OpenShift} other {}}",
"memoryTitle": "Memory",
"memoryUnits": "Memory ({units})",
"metric": "Metric",
"metricPlaceholder": "Filter by metrics",
"metricValues": "{value, select, cpu {CPU} cluster {Cluster} memory {Memory} node {Node} persistent_volume_claims {Persistent volume claims} storage {Storage} other {}}",
Expand Down Expand Up @@ -437,6 +435,7 @@
"optimizationsPerspective": "View optimizations based on",
"optimizationsShortTerm": "Last 24 hrs",
"optimizationsTableAriaLabel": "Optimizations table",
"optimizationsValueUnits": "{value} {units}",
"optimizationsValues": "{value, select, cluster {Cluster name} container {Container name} last_reported {Last reported} project {Project name} workload {Workload name} workload_type {Workload type} other {}}",
"optimizationsViewAll": "View all optimizations for this project",
"optimizationsViewAllDisabled": "This project has not reported data this month.",
Expand Down
105 changes: 85 additions & 20 deletions src/components/drawers/optimzations/optimizationsContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ class OptimizationsContentBase extends React.Component<OptimizationsContentProps
);
};

private getChangeValue = value => {
private getChangeValue = (value, units = '') => {
const { intl } = this.props;

// Show icon opposite of month over month
let iconOverride = 'iconOverride';
if (value !== null && value < 0) {
Expand All @@ -193,17 +195,32 @@ class OptimizationsContentBase extends React.Component<OptimizationsContentProps
<div className={iconOverride}>
{value < 0 ? (
<>
<span style={styles.value}>{formatOptimization(value)}</span>
<span style={styles.value}>
{intl.formatMessage(messages.optimizationsValue, {
value: formatOptimization(value),
units,
})}
</span>
<span className="fa fa-sort-down" />
</>
) : value > 0 ? (
<>
<span style={styles.value}>{formatOptimization(value)}</span>
<span style={styles.value}>
{intl.formatMessage(messages.optimizationsValue, {
value: formatOptimization(value),
units,
})}
</span>
<span className="fa fa-sort-up" />
</>
) : value === 0 ? (
<>
<span style={styles.value}>{formatOptimization(value)}</span>
<span style={styles.value}>
{intl.formatMessage(messages.optimizationsValue, {
value: formatOptimization(value),
units,
})}
</span>
<span className="fa fa-equals" />
</>
) : (
Expand Down Expand Up @@ -236,12 +253,16 @@ class OptimizationsContentBase extends React.Component<OptimizationsContentProps
const cpuConfigAmount = hasConfigLimitsCpu ? term.config.limits.cpu.amount : undefined;
const cpuConfigUnits = hasConfigLimitsCpu ? term.config.limits.cpu.format : undefined;
const cpuCurrentAmount = hasCurrentLimitsCpu ? term.current.limits.cpu.amount : undefined;
const cpuCurrentUnits = hasCurrentLimitsCpu ? term.current.limits.cpu.format : undefined;
const cpuVariation = hasVariationLimitsCpu ? term.variation.limits.cpu.amount : undefined;
const cpuVariationUnits = hasVariationLimitsCpu ? term.variation.limits.cpu.format : undefined;

const memConfigAmount = hasConfigLimitsMemory ? term.config.limits.memory.amount : undefined;
const memConfigUnits = hasConfigLimitsMemory ? term.config.limits.memory.format : undefined;
const memCurrentAmount = hasCurrentLimitsMemory ? term.current.limits.memory.amount : undefined;
const memCurrentUnits = hasCurrentLimitsMemory ? term.current.limits.memory.format : undefined;
const memVariation = hasVariationLimitsMemory ? term.variation.limits.memory.amount : undefined;
const memVariationUnits = hasVariationLimitsMemory ? term.variation.limits.memory.format : undefined;

return (
<TableComposable
Expand All @@ -260,16 +281,36 @@ class OptimizationsContentBase extends React.Component<OptimizationsContentProps
</Thead>
<Tbody>
<Tr>
<Td style={styles.firstColumn}>{intl.formatMessage(messages.cpuUnits, { units: cpuConfigUnits })}</Td>
<Td>{this.getFormattedValue(cpuCurrentAmount)}</Td>
<Td hasRightBorder>{this.getFormattedValue(cpuConfigAmount)}</Td>
<Td>{this.getChangeValue(cpuVariation)}</Td>
<Td style={styles.firstColumn}>{intl.formatMessage(messages.cpuTitle)}</Td>
<Td>
{intl.formatMessage(messages.optimizationsValue, {
value: this.getFormattedValue(cpuCurrentAmount),
units: cpuCurrentUnits,
})}
</Td>
<Td hasRightBorder>
{intl.formatMessage(messages.optimizationsValue, {
value: this.getFormattedValue(cpuConfigAmount),
units: cpuConfigUnits,
})}
</Td>
<Td>{this.getChangeValue(cpuVariation, cpuVariationUnits)}</Td>
</Tr>
<Tr>
<Td style={styles.firstColumn}>{intl.formatMessage(messages.memoryUnits, { units: memConfigUnits })}</Td>
<Td>{this.getFormattedValue(memCurrentAmount)}</Td>
<Td hasRightBorder>{this.getFormattedValue(memConfigAmount)}</Td>
<Td>{this.getChangeValue(memVariation)}</Td>
<Td style={styles.firstColumn}>{intl.formatMessage(messages.memoryTitle)}</Td>
<Td>
{intl.formatMessage(messages.optimizationsValue, {
value: this.getFormattedValue(memCurrentAmount),
units: memCurrentUnits,
})}
</Td>
<Td hasRightBorder>
{intl.formatMessage(messages.optimizationsValue, {
value: this.getFormattedValue(memConfigAmount),
units: memConfigUnits,
})}
</Td>
<Td>{this.getChangeValue(memVariation, memVariationUnits)}</Td>
</Tr>
</Tbody>
</TableComposable>
Expand Down Expand Up @@ -324,12 +365,16 @@ class OptimizationsContentBase extends React.Component<OptimizationsContentProps
const cpuConfigAmount = hasConfigRequestsCpu ? term.config.requests.cpu.amount : undefined;
const cpuConfigUnits = hasConfigRequestsCpu ? term.config.requests.cpu.format : undefined;
const cpuCurrentAmount = hasCurrentLimitsCpu ? term.current.requests.cpu.amount : undefined;
const cpuCurrentUnits = hasCurrentLimitsCpu ? term.current.requests.cpu.format : undefined;
const cpuVariation = hasVariationRequestsCpu ? term.variation.requests.cpu.amount : undefined;
const cpuVariationUnits = hasVariationRequestsCpu ? term.variation.requests.cpu.format : undefined;

const memConfigAmount = hasConfigRequestsMemory ? term.config.requests.memory.amount : undefined;
const memConfigUnits = hasConfigRequestsMemory ? term.config.requests.memory.format : undefined;
const memCurrentAmount = hasCurrentLimitsMemory ? term.current.requests.memory.amount : undefined;
const memCurrentUnits = hasCurrentLimitsMemory ? term.current.requests.memory.format : undefined;
const memVariation = hasVariationRequestsMemory ? term.variation.requests.memory.amount : undefined;
const memVariationUnits = hasVariationRequestsMemory ? term.variation.requests.memory.format : undefined;

return (
<TableComposable
Expand All @@ -348,16 +393,36 @@ class OptimizationsContentBase extends React.Component<OptimizationsContentProps
</Thead>
<Tbody>
<Tr>
<Td style={styles.firstColumn}>{intl.formatMessage(messages.cpuUnits, { units: cpuConfigUnits })}</Td>
<Td>{this.getFormattedValue(cpuCurrentAmount)}</Td>
<Td hasRightBorder>{this.getFormattedValue(cpuConfigAmount)}</Td>
<Td>{this.getChangeValue(cpuVariation)}</Td>
<Td style={styles.firstColumn}>{intl.formatMessage(messages.cpuTitle)}</Td>
<Td>
{intl.formatMessage(messages.optimizationsValue, {
value: this.getFormattedValue(cpuCurrentAmount),
units: cpuCurrentUnits,
})}
</Td>
<Td hasRightBorder>
{intl.formatMessage(messages.optimizationsValue, {
value: this.getFormattedValue(cpuConfigAmount),
units: cpuConfigUnits,
})}
</Td>
<Td>{this.getChangeValue(cpuVariation, cpuVariationUnits)}</Td>
</Tr>
<Tr>
<Td style={styles.firstColumn}>{intl.formatMessage(messages.memoryUnits, { units: memConfigUnits })}</Td>
<Td>{this.getFormattedValue(memCurrentAmount)}</Td>
<Td hasRightBorder>{this.getFormattedValue(memConfigAmount)}</Td>
<Td>{this.getChangeValue(memVariation)}</Td>
<Td style={styles.firstColumn}>{intl.formatMessage(messages.memoryTitle)}</Td>
<Td>
{intl.formatMessage(messages.optimizationsValue, {
value: this.getFormattedValue(memCurrentAmount),
units: memCurrentUnits,
})}
</Td>
<Td hasRightBorder>
{intl.formatMessage(messages.optimizationsValue, {
value: this.getFormattedValue(memConfigAmount),
units: memConfigUnits,
})}
</Td>
<Td>{this.getChangeValue(memVariation, memVariationUnits)}</Td>
</Tr>
</Tbody>
</TableComposable>
Expand Down
15 changes: 5 additions & 10 deletions src/locales/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -952,11 +952,6 @@ export default defineMessages({
description: 'CPU',
id: 'cpuTitle',
},
cpuUnits: {
defaultMessage: 'CPU ({units})',
description: 'CPU (mCores)',
id: 'cpuUnits',
},
create: {
defaultMessage: 'Create',
description: 'Create',
Expand Down Expand Up @@ -2306,11 +2301,6 @@ export default defineMessages({
description: 'Memory',
id: 'memoryTitle',
},
memoryUnits: {
defaultMessage: 'Memory ({units})',
description: 'Memory (MB)',
id: 'memoryUnits',
},
metric: {
defaultMessage: 'Metric',
description: 'Metric',
Expand Down Expand Up @@ -2748,6 +2738,11 @@ export default defineMessages({
description: 'Optimizations table',
id: 'optimizationsTableAriaLabel',
},
optimizationsValue: {
defaultMessage: '{value} {units}',
description: '2 GiB',
id: 'optimizationsValueUnits',
},
optimizationsValues: {
defaultMessage:
'{value, select, ' +
Expand Down

0 comments on commit 7a93bdc

Please sign in to comment.