Skip to content

Commit ff1b0ba

Browse files
committed
Refactored storage historical chart to be visible when grouped by cluster, node, and project
Fixed storage card title in OCP breakdown for isPlatformProject flag https://issues.redhat.com/browse/COST-4856
1 parent c0bcf3f commit ff1b0ba

File tree

12 files changed

+79
-92
lines changed

12 files changed

+79
-92
lines changed

src/routes/details/components/costOverview/costOverviewBase.tsx

+13-10
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class CostOverviewsBase extends React.Component<CostOverviewProps, any> {
5959
const { groupBy, intl, report, title } = this.props;
6060

6161
let showWidget = false;
62-
for (const groupById of widget.cluster.showWidgetOnGroupBy) {
62+
for (const groupById of widget.showWidgetOnGroupBy) {
6363
if (groupById === groupBy || (groupById === tagPrefix && groupBy && groupBy.indexOf(tagPrefix) !== -1)) {
6464
showWidget = true;
6565
break;
@@ -210,8 +210,8 @@ class CostOverviewsBase extends React.Component<CostOverviewProps, any> {
210210
const { groupBy, intl } = this.props;
211211

212212
let showWidget = false;
213-
if (widget.pvc.showWidgetOnGroupBy) {
214-
for (const groupById of widget.pvc.showWidgetOnGroupBy) {
213+
if (widget.showWidgetOnGroupBy) {
214+
for (const groupById of widget.showWidgetOnGroupBy) {
215215
if (groupById === groupBy) {
216216
showWidget = true;
217217
break;
@@ -242,20 +242,23 @@ class CostOverviewsBase extends React.Component<CostOverviewProps, any> {
242242
const groupByCostCategory = getGroupByCostCategory(query);
243243
const groupByOrg = getGroupByOrgValue(query);
244244
const groupByTag = getGroupByTagKey(query);
245+
245246
let showWidget = false;
247+
let showPlatformCosts = false;
246248

247-
if (widget.reportSummary.showWidgetOnGroupBy) {
248-
for (const groupById of widget.reportSummary.showWidgetOnGroupBy) {
249+
if (widget.showWidgetOnGroupBy) {
250+
for (const groupById of widget.showWidgetOnGroupBy) {
249251
if (groupById === groupBy || groupByCostCategory || groupByOrg || groupByTag) {
250252
showWidget = true;
251253
break;
252254
}
253255
}
254256
}
255-
if (!showWidget && widget.reportSummary.showWidgetOnPlatformCategory) {
256-
for (const categoryId of widget.reportSummary.showWidgetOnPlatformCategory) {
257+
if (!showWidget && widget.showWidgetOnPlatformCategory) {
258+
for (const categoryId of widget.showWidgetOnPlatformCategory) {
257259
if (isPlatformCosts && categoryId === platformCategoryKey) {
258260
showWidget = true;
261+
showPlatformCosts = true;
259262
break;
260263
}
261264
}
@@ -267,7 +270,7 @@ class CostOverviewsBase extends React.Component<CostOverviewProps, any> {
267270
costDistribution={!isVolumeWidget ? costDistribution : undefined}
268271
costType={!isVolumeWidget ? costType : undefined}
269272
currency={currency}
270-
isPlatformCosts={isPlatformCosts}
273+
isPlatformCosts={showPlatformCosts}
271274
reportGroupBy={widget.reportSummary.reportGroupBy}
272275
reportPathsType={widget.reportPathsType}
273276
reportType={widget.reportType}
@@ -285,8 +288,8 @@ class CostOverviewsBase extends React.Component<CostOverviewProps, any> {
285288

286289
let showWidget = false;
287290

288-
if (widget.volume.showWidgetOnGroupBy) {
289-
for (const groupById of widget.volume.showWidgetOnGroupBy) {
291+
if (widget.showWidgetOnGroupBy) {
292+
for (const groupById of widget.showWidgetOnGroupBy) {
290293
if (groupById === groupBy || (groupById === tagPrefix && groupBy && groupBy.indexOf(tagPrefix) !== -1)) {
291294
showWidget = true;
292295
break;

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

+34-22
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ class HistoricalDatasBase extends React.Component<HistoricalDataProps, any> {
7171
const { groupBy, intl } = this.props;
7272

7373
let showWidget = false;
74-
if (widget.network?.showWidgetOnGroupBy) {
75-
for (const groupById of widget.network.showWidgetOnGroupBy) {
74+
if (widget?.showWidgetOnGroupBy) {
75+
for (const groupById of widget.showWidgetOnGroupBy) {
7676
if (groupById === groupBy) {
7777
showWidget = true;
7878
break;
@@ -102,28 +102,40 @@ class HistoricalDatasBase extends React.Component<HistoricalDataProps, any> {
102102
return null;
103103
};
104104

105-
// Returns volume chart
105+
// Returns storage summary
106106
private getVolumeChart = (widget: HistoricalDataWidget) => {
107-
const { intl } = this.props;
107+
const { groupBy, intl } = this.props;
108108

109-
return (
110-
<Card>
111-
<CardTitle>
112-
<Title headingLevel="h2" size={TitleSizes.lg}>
113-
{intl.formatMessage(messages.historicalChartTitle, {
114-
value: this.getTitleKey(widget.reportPathsType, widget.reportType),
115-
})}
116-
</Title>
117-
</CardTitle>
118-
<CardBody>
119-
<HistoricalDataVolumeChart
120-
chartName={widget.chartName}
121-
reportPathsType={widget.reportPathsType}
122-
reportType={widget.reportType}
123-
/>
124-
</CardBody>
125-
</Card>
126-
);
109+
let showWidget = false;
110+
if (widget?.showWidgetOnGroupBy) {
111+
for (const groupById of widget.showWidgetOnGroupBy) {
112+
if (groupById === groupBy) {
113+
showWidget = true;
114+
break;
115+
}
116+
}
117+
}
118+
if (showWidget) {
119+
return (
120+
<Card>
121+
<CardTitle>
122+
<Title headingLevel="h2" size={TitleSizes.lg}>
123+
{intl.formatMessage(messages.historicalChartTitle, {
124+
value: this.getTitleKey(widget.reportPathsType, widget.reportType),
125+
})}
126+
</Title>
127+
</CardTitle>
128+
<CardBody>
129+
<HistoricalDataVolumeChart
130+
chartName={widget.chartName}
131+
reportPathsType={widget.reportPathsType}
132+
reportType={widget.reportType}
133+
/>
134+
</CardBody>
135+
</Card>
136+
);
137+
}
138+
return null;
127139
};
128140

129141
// Returns trend chart

src/store/breakdown/costOverview/awsCostOverview/awsCostOverviewWidgets.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@ export const accountSummaryWidget: AwsCostOverviewWidget = {
1919
id: getId(),
2020
reportSummary: {
2121
reportGroupBy: 'account',
22-
showWidgetOnGroupBy: ['region', 'service', tagPrefix],
2322
},
2423
reportPathsType: ReportPathsType.aws,
2524
reportType: ReportType.cost,
25+
showWidgetOnGroupBy: ['region', 'service', tagPrefix],
2626
type: CostOverviewWidgetType.reportSummary,
2727
};
2828

2929
export const regionSummaryWidget: AwsCostOverviewWidget = {
3030
id: getId(),
3131
reportSummary: {
3232
reportGroupBy: 'region',
33-
showWidgetOnGroupBy: ['account', 'service', tagPrefix],
3433
},
3534
reportPathsType: ReportPathsType.aws,
3635
reportType: ReportType.cost,
36+
showWidgetOnGroupBy: ['account', 'service', tagPrefix],
3737
type: CostOverviewWidgetType.reportSummary,
3838
};
3939

4040
export const serviceSummaryWidget: AwsCostOverviewWidget = {
4141
id: getId(),
4242
reportSummary: {
4343
reportGroupBy: 'service',
44-
showWidgetOnGroupBy: ['region', 'account', tagPrefix],
4544
},
4645
reportPathsType: ReportPathsType.aws,
4746
reportType: ReportType.cost,
47+
showWidgetOnGroupBy: ['region', 'account', tagPrefix],
4848
type: CostOverviewWidgetType.reportSummary,
4949
};

src/store/breakdown/costOverview/azureCostOverview/azureCostOverviewWidgets.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,31 @@ export const accountSummaryWidget: AzureCostOverviewWidget = {
1818
id: getId(),
1919
reportSummary: {
2020
reportGroupBy: 'subscription_guid',
21-
showWidgetOnGroupBy: ['resource_location', 'service_name', tagPrefix],
2221
},
2322
reportPathsType: ReportPathsType.azure,
2423
reportType: ReportType.cost,
24+
showWidgetOnGroupBy: ['resource_location', 'service_name', tagPrefix],
2525
type: CostOverviewWidgetType.reportSummary,
2626
};
2727

2828
export const regionSummaryWidget: AzureCostOverviewWidget = {
2929
id: getId(),
3030
reportSummary: {
3131
reportGroupBy: 'resource_location',
32-
showWidgetOnGroupBy: ['subscription_guid', 'service_name', tagPrefix],
3332
},
3433
reportPathsType: ReportPathsType.azure,
3534
reportType: ReportType.cost,
35+
showWidgetOnGroupBy: ['subscription_guid', 'service_name', tagPrefix],
3636
type: CostOverviewWidgetType.reportSummary,
3737
};
3838

3939
export const serviceSummaryWidget: AzureCostOverviewWidget = {
4040
id: getId(),
4141
reportSummary: {
4242
reportGroupBy: 'service_name',
43-
showWidgetOnGroupBy: ['resource_location', 'subscription_guid', tagPrefix],
4443
},
4544
reportPathsType: ReportPathsType.azure,
4645
reportType: ReportType.cost,
46+
showWidgetOnGroupBy: ['resource_location', 'subscription_guid', tagPrefix],
4747
type: CostOverviewWidgetType.reportSummary,
4848
};

src/store/breakdown/costOverview/common/costOverviewCommon.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,14 @@ export interface CostOverviewWidget {
1717
id: number;
1818
cluster?: {
1919
reportGroupBy: string; // Report group_by
20-
showWidgetOnGroupBy?: string[]; // Show cluster card when group_by is matched
21-
};
22-
pvc?: {
23-
showWidgetOnGroupBy?: string[]; // Show pvc chart when group_by is matched
24-
};
25-
usage?: {
26-
showCapacityOnGroupBy?: string[]; // Show capacity when group_by is matched
2720
};
2821
reportSummary?: {
2922
reportGroupBy: string; // Report group_by
30-
showWidgetOnPlatformCategory?: string[];
31-
showWidgetOnGroupBy?: string[]; // Show summary card when group_by is matched
3223
usePlaceholder?: boolean; // Use placeholder to keep card placement when widget is not shown
3324
};
3425
reportPathsType: ReportPathsType; // Report URL path
3526
reportType: ReportType; // Report type; cost, storage, etc.
27+
showWidgetOnGroupBy?: string[]; // Show widget when group_by is matched
28+
showWidgetOnPlatformCategory?: string[]; // Show widget when platform category is matched
3629
type: CostOverviewWidgetType;
37-
volume?: {
38-
showWidgetOnGroupBy?: string[]; // Show volume usage chart when group_by is matched
39-
};
4030
}

src/store/breakdown/costOverview/gcpCostOverview/gcpCostOverviewWidgets.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,42 +18,42 @@ export const accountSummaryWidget: GcpCostOverviewWidget = {
1818
id: getId(),
1919
reportSummary: {
2020
reportGroupBy: 'account',
21-
showWidgetOnGroupBy: ['gcp_project', 'region', 'service', tagPrefix],
2221
},
2322
reportPathsType: ReportPathsType.gcp,
2423
reportType: ReportType.cost,
24+
showWidgetOnGroupBy: ['gcp_project', 'region', 'service', tagPrefix],
2525
type: CostOverviewWidgetType.reportSummary,
2626
};
2727

2828
export const projectSummaryWidget: GcpCostOverviewWidget = {
2929
id: getId(),
3030
reportSummary: {
3131
reportGroupBy: 'gcp_project',
32-
showWidgetOnGroupBy: ['account', 'region', 'service', tagPrefix],
3332
},
3433
reportPathsType: ReportPathsType.gcp,
3534
reportType: ReportType.cost,
35+
showWidgetOnGroupBy: ['account', 'region', 'service', tagPrefix],
3636
type: CostOverviewWidgetType.reportSummary,
3737
};
3838

3939
export const regionSummaryWidget: GcpCostOverviewWidget = {
4040
id: getId(),
4141
reportSummary: {
4242
reportGroupBy: 'region',
43-
showWidgetOnGroupBy: ['account', 'gcp_project', 'service', tagPrefix],
4443
},
4544
reportPathsType: ReportPathsType.gcp,
4645
reportType: ReportType.cost,
46+
showWidgetOnGroupBy: ['account', 'gcp_project', 'service', tagPrefix],
4747
type: CostOverviewWidgetType.reportSummary,
4848
};
4949

5050
export const serviceSummaryWidget: GcpCostOverviewWidget = {
5151
id: getId(),
5252
reportSummary: {
5353
reportGroupBy: 'service',
54-
showWidgetOnGroupBy: ['gcp_project', 'region', 'account', tagPrefix],
5554
},
5655
reportPathsType: ReportPathsType.gcp,
5756
reportType: ReportType.cost,
57+
showWidgetOnGroupBy: ['gcp_project', 'region', 'account', tagPrefix],
5858
type: CostOverviewWidgetType.reportSummary,
5959
};

src/store/breakdown/costOverview/ibmCostOverview/ibmCostOverviewWidgets.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,42 +19,42 @@ export const accountSummaryWidget: IbmCostOverviewWidget = {
1919
id: getId(),
2020
reportSummary: {
2121
reportGroupBy: 'account',
22-
showWidgetOnGroupBy: ['project', 'region', 'service', tagPrefix],
2322
},
2423
reportPathsType: ReportPathsType.ibm,
2524
reportType: ReportType.cost,
25+
showWidgetOnGroupBy: ['project', 'region', 'service', tagPrefix],
2626
type: CostOverviewWidgetType.reportSummary,
2727
};
2828

2929
export const projectSummaryWidget: IbmCostOverviewWidget = {
3030
id: getId(),
3131
reportSummary: {
3232
reportGroupBy: 'project',
33-
showWidgetOnGroupBy: ['account', 'region', 'service', tagPrefix],
3433
},
3534
reportPathsType: ReportPathsType.ibm,
3635
reportType: ReportType.cost,
36+
showWidgetOnGroupBy: ['account', 'region', 'service', tagPrefix],
3737
type: CostOverviewWidgetType.reportSummary,
3838
};
3939

4040
export const regionSummaryWidget: IbmCostOverviewWidget = {
4141
id: getId(),
4242
reportSummary: {
4343
reportGroupBy: 'region',
44-
showWidgetOnGroupBy: ['account', 'project', 'service', tagPrefix],
4544
},
4645
reportPathsType: ReportPathsType.ibm,
4746
reportType: ReportType.cost,
47+
showWidgetOnGroupBy: ['account', 'project', 'service', tagPrefix],
4848
type: CostOverviewWidgetType.reportSummary,
4949
};
5050

5151
export const serviceSummaryWidget: IbmCostOverviewWidget = {
5252
id: getId(),
5353
reportSummary: {
5454
reportGroupBy: 'service',
55-
showWidgetOnGroupBy: ['project', 'region', 'account', tagPrefix],
5655
},
5756
reportPathsType: ReportPathsType.ibm,
5857
reportType: ReportType.cost,
58+
showWidgetOnGroupBy: ['project', 'region', 'account', tagPrefix],
5959
type: CostOverviewWidgetType.reportSummary,
6060
};

src/store/breakdown/costOverview/ociCostOverview/ociCostOverviewWidgets.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,31 @@ export const accountSummaryWidget: OciCostOverviewWidget = {
1818
id: getId(),
1919
reportSummary: {
2020
reportGroupBy: 'payer_tenant_id',
21-
showWidgetOnGroupBy: ['region', 'product_service', tagPrefix],
2221
},
2322
reportPathsType: ReportPathsType.oci,
2423
reportType: ReportType.cost,
24+
showWidgetOnGroupBy: ['region', 'product_service', tagPrefix],
2525
type: CostOverviewWidgetType.reportSummary,
2626
};
2727

2828
export const regionSummaryWidget: OciCostOverviewWidget = {
2929
id: getId(),
3030
reportSummary: {
3131
reportGroupBy: 'region',
32-
showWidgetOnGroupBy: ['payer_tenant_id', 'product_service', tagPrefix],
3332
},
3433
reportPathsType: ReportPathsType.oci,
3534
reportType: ReportType.cost,
35+
showWidgetOnGroupBy: ['payer_tenant_id', 'product_service', tagPrefix],
3636
type: CostOverviewWidgetType.reportSummary,
3737
};
3838

3939
export const serviceSummaryWidget: OciCostOverviewWidget = {
4040
id: getId(),
4141
reportSummary: {
4242
reportGroupBy: 'product_service',
43-
showWidgetOnGroupBy: ['region', 'payer_tenant_id', tagPrefix],
4443
},
4544
reportPathsType: ReportPathsType.oci,
4645
reportType: ReportType.cost,
46+
showWidgetOnGroupBy: ['region', 'payer_tenant_id', tagPrefix],
4747
type: CostOverviewWidgetType.reportSummary,
4848
};

0 commit comments

Comments
 (0)