Skip to content

Commit e9b15fe

Browse files
committed
Stubbed-out historical layout for network and storage features
1 parent 77480c7 commit e9b15fe

File tree

9 files changed

+111
-4
lines changed

9 files changed

+111
-4
lines changed

locales/data.json

+8
Original file line numberDiff line numberDiff line change
@@ -9799,6 +9799,14 @@
97999799
}
98009800
]
98019801
},
9802+
"network": {
9803+
"value": [
9804+
{
9805+
"type": 0,
9806+
"value": "Network usage comparison"
9807+
}
9808+
]
9809+
},
98029810
"other": {
98039811
"value": []
98049812
},

locales/translations.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@
339339
"groupByValuesTitleCase": "{value, select, account {{count, plural, one {Account} other {Accounts}}} aws_category {{count, plural, one {Cost category} other {Cost categories}}} cluster {{count, plural, one {Cluster} other {Clusters}}} gcp_project {{count, plural, one {GCP project} other {GCP projects}}} node {{count, plural, one {Node} other {Node}}} org_unit_id {{count, plural, one {Organizational unit} other {Organizational units}}} payer_tenant_id {{count, plural, one {Account} other {Accounts}}} product_service {{count, plural, one {Service} other {Services}}} project {{count, plural, one {Project} other {Projects}}} region {{count, plural, one {Region} other {Regions}}} resource_location {{count, plural, one {Region} other {Regions}}} service {{count, plural, one {Service} other {Services}}} service_name {{count, plural, one {Service} other {Services}}} subscription_guid {{count, plural, one {Account} other {Accounts}}} tag {{count, plural, one {Tag} other {Tags}}} other {}}",
340340
"historicalChartCostLabel": "Cost ({units})",
341341
"historicalChartDayOfMonthLabel": "Day of Month",
342-
"historicalChartTitle": "{value, select, cost {Cost comparison} cpu {CPU usage, request, and limit comparison} instance_type {Compute usage comparison}memory {Memory usage, request, and limit comparison} modal {{name} daily usage comparison} storage {Storage usage comparison} virtual_machine {Virtual machine usage comparison}other {}}",
342+
"historicalChartTitle": "{value, select, cost {Cost comparison} cpu {CPU usage, request, and limit comparison} instance_type {Compute usage comparison}memory {Memory usage, request, and limit comparison} modal {{name} daily usage comparison} network {Network usage comparison} storage {Storage usage comparison} virtual_machine {Virtual machine usage comparison}other {}}",
343343
"historicalChartUsageLabel": "{value, select, instance_type {hrs} storage {gb-mo} other {}}",
344344
"ibm": "IBM Cloud",
345345
"ibmComputeTitle": "Compute instances usage",

src/api/reports/ocpReports.ts

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ export const ReportTypePaths: Partial<Record<ReportType, string>> = {
6161
[ReportType.cost]: 'reports/openshift/costs/',
6262
[ReportType.cpu]: 'reports/openshift/compute/',
6363
[ReportType.memory]: 'reports/openshift/memory/',
64+
[ReportType.network]: 'reports/openshift/volumes/', // TBD: Use "network" when API is available
6465
[ReportType.volume]: 'reports/openshift/volumes/',
6566
};
6667

src/locales/messages.ts

+1
Original file line numberDiff line numberDiff line change
@@ -2222,6 +2222,7 @@ export default defineMessages({
22222222
'instance_type {Compute usage comparison}' +
22232223
'memory {Memory usage, request, and limit comparison} ' +
22242224
'modal {{name} daily usage comparison} ' +
2225+
'network {Network usage comparison} ' +
22252226
'storage {Storage usage comparison} ' +
22262227
'virtual_machine {Virtual machine usage comparison}' +
22272228
'other {}}',

src/routes/details/components/historicalData/historicalDataBase.tsx

+63-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ interface HistoricalDataOwnProps {
1818
}
1919

2020
export interface HistoricalDataStateProps {
21+
isOcpCloudNetworkingToggleEnabled?: boolean;
22+
isOcpProjectStorageToggleEnabled?: boolean;
2123
selectWidgets?: Record<number, any>;
2224
widgets: number[];
2325
}
@@ -26,7 +28,9 @@ type HistoricalDataProps = HistoricalDataOwnProps & HistoricalDataStateProps & W
2628

2729
class HistoricalDatasBase extends React.Component<HistoricalDataProps, any> {
2830
private getTitleKey = (reportPathsType, reportType) => {
29-
if (reportPathsType === ReportPathsType.azure) {
31+
if (reportPathsType === ReportPathsType.ocp) {
32+
return reportType === ReportType.volume ? 'storage' : reportType;
33+
} else if (reportPathsType === ReportPathsType.azure) {
3034
return reportType === ReportType.instanceType ? 'virtual_machine' : reportType;
3135
}
3236
return reportType === ReportType.instanceType ? 'instance_type' : reportType;
@@ -59,6 +63,60 @@ class HistoricalDatasBase extends React.Component<HistoricalDataProps, any> {
5963
);
6064
};
6165

66+
// Returns network chart
67+
private getNetworkChart = (widget: HistoricalDataWidget) => {
68+
const { intl, isOcpCloudNetworkingToggleEnabled } = this.props;
69+
70+
if (widget.reportPathsType === ReportPathsType.ocp && !isOcpCloudNetworkingToggleEnabled) {
71+
return null;
72+
}
73+
return (
74+
<Card>
75+
<CardTitle>
76+
<Title headingLevel="h2" size={TitleSizes.lg}>
77+
{intl.formatMessage(messages.historicalChartTitle, {
78+
value: this.getTitleKey(widget.reportPathsType, widget.reportType),
79+
})}
80+
</Title>
81+
</CardTitle>
82+
<CardBody>
83+
<HistoricalDataUsageChart
84+
chartName={widget.chartName}
85+
reportPathsType={widget.reportPathsType}
86+
reportType={widget.reportType}
87+
/>
88+
</CardBody>
89+
</Card>
90+
);
91+
};
92+
93+
// Returns storage chart
94+
private getStorageChart = (widget: HistoricalDataWidget) => {
95+
const { intl, isOcpProjectStorageToggleEnabled } = this.props;
96+
97+
if (widget.reportPathsType === ReportPathsType.ocp && !isOcpProjectStorageToggleEnabled) {
98+
return null;
99+
}
100+
return (
101+
<Card>
102+
<CardTitle>
103+
<Title headingLevel="h2" size={TitleSizes.lg}>
104+
{intl.formatMessage(messages.historicalChartTitle, {
105+
value: this.getTitleKey(widget.reportPathsType, widget.reportType),
106+
})}
107+
</Title>
108+
</CardTitle>
109+
<CardBody>
110+
<HistoricalDataUsageChart
111+
chartName={widget.chartName}
112+
reportPathsType={widget.reportPathsType}
113+
reportType={widget.reportType}
114+
/>
115+
</CardBody>
116+
</Card>
117+
);
118+
};
119+
62120
// Returns trend chart
63121
private getTrendChart = (widget: HistoricalDataWidget) => {
64122
const { costType, currency, intl } = this.props;
@@ -114,6 +172,10 @@ class HistoricalDatasBase extends React.Component<HistoricalDataProps, any> {
114172
switch (widget.type) {
115173
case HistoricalDataWidgetType.cost:
116174
return this.getCostChart(widget);
175+
case HistoricalDataWidgetType.network:
176+
return this.getNetworkChart(widget);
177+
case HistoricalDataWidgetType.storage:
178+
return this.getStorageChart(widget);
117179
case HistoricalDataWidgetType.trend:
118180
return this.getTrendChart(widget);
119181
case HistoricalDataWidgetType.usage:

src/routes/details/ocpBreakdown/historicalData.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { HistoricalDataStateProps } from 'routes/details/components/histori
33
import { HistoricalDataBase } from 'routes/details/components/historicalData';
44
import { ocpHistoricalDataSelectors } from 'store/breakdown/historicalData/ocpHistoricalData';
55
import { createMapStateToProps } from 'store/common';
6+
import { FeatureToggleSelectors } from 'store/featureToggle';
67

78
interface OcpHistoricalDataOwnProps {
89
// TBD...
@@ -11,6 +12,8 @@ interface OcpHistoricalDataOwnProps {
1112
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1213
const mapStateToProps = createMapStateToProps<OcpHistoricalDataOwnProps, HistoricalDataStateProps>((state, props) => {
1314
return {
15+
isOcpCloudNetworkingToggleEnabled: FeatureToggleSelectors.selectIsOcpCloudNetworkingToggleEnabled(state),
16+
isOcpProjectStorageToggleEnabled: FeatureToggleSelectors.selectIsOcpProjectStorageToggleEnabled(state),
1417
selectWidgets: ocpHistoricalDataSelectors.selectWidgets(state),
1518
widgets: ocpHistoricalDataSelectors.selectCurrentWidgets(state),
1619
};

src/store/breakdown/historicalData/common/historicalDataCommon.ts

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import type { ReportPathsType, ReportType } from 'api/reports/report';
33
// eslint-disable-next-line no-shadow
44
export const enum HistoricalDataWidgetType {
55
cost = 'cost', // This type displays historical cost chart
6+
network = 'network', // This type displays historical network chart
7+
storage = 'storage', // This type displays historical storage chart
68
trend = 'trend', // This type displays historical trend chart
79
usage = 'usage', // This type displays historical usage chart
810
}

src/store/breakdown/historicalData/ocpHistoricalData/ocpHistoricalDataReducer.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
import type { OcpHistoricalDataWidget } from './ocpHistoricalDataCommon';
2-
import { costWidget, cpuUsageWidget, memoryUsageWidget } from './ocpHistoricalDataWidgets';
2+
import {
3+
costWidget,
4+
cpuUsageWidget,
5+
memoryUsageWidget,
6+
networkUsageWidget,
7+
storageUsageWidget,
8+
} from './ocpHistoricalDataWidgets';
39

410
export type OcpHistoricalDataState = Readonly<{
511
widgets: Record<number, OcpHistoricalDataWidget>;
612
currentWidgets: number[];
713
}>;
814

915
export const defaultState: OcpHistoricalDataState = {
10-
currentWidgets: [costWidget.id, cpuUsageWidget.id, memoryUsageWidget.id],
16+
currentWidgets: [
17+
costWidget.id,
18+
cpuUsageWidget.id,
19+
memoryUsageWidget.id,
20+
networkUsageWidget.id,
21+
storageUsageWidget.id,
22+
],
1123
widgets: {
1224
[costWidget.id]: costWidget,
1325
[cpuUsageWidget.id]: cpuUsageWidget,
1426
[memoryUsageWidget.id]: memoryUsageWidget,
27+
[networkUsageWidget.id]: networkUsageWidget,
28+
[storageUsageWidget.id]: storageUsageWidget,
1529
},
1630
};
1731

src/store/breakdown/historicalData/ocpHistoricalData/ocpHistoricalDataWidgets.ts

+16
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,19 @@ export const memoryUsageWidget: OcpHistoricalDataWidget = {
2929
reportType: ReportType.memory,
3030
type: HistoricalDataWidgetType.usage,
3131
};
32+
33+
export const networkUsageWidget: OcpHistoricalDataWidget = {
34+
chartName: 'ocpNetworkChart',
35+
id: getId(),
36+
reportPathsType: ReportPathsType.ocp,
37+
reportType: ReportType.network,
38+
type: HistoricalDataWidgetType.network,
39+
};
40+
41+
export const storageUsageWidget: OcpHistoricalDataWidget = {
42+
chartName: 'ocpStorageChart',
43+
id: getId(),
44+
reportPathsType: ReportPathsType.ocp,
45+
reportType: ReportType.volume,
46+
type: HistoricalDataWidgetType.storage,
47+
};

0 commit comments

Comments
 (0)