From 8c5abb388ac8770ed61edcc9189f0b44e373f788 Mon Sep 17 00:00:00 2001 From: Jen Evans Date: Tue, 7 Feb 2023 16:58:16 -0800 Subject: [PATCH 1/2] Check for empty costs array and allow title override Signed-off-by: Jen Evans --- .../src/components/CostInsightsLayout/CostInsightsLayout.tsx | 3 ++- .../cost-insights/src/components/EntityCosts/EntityCosts.tsx | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/cost-insights/src/components/CostInsightsLayout/CostInsightsLayout.tsx b/plugins/cost-insights/src/components/CostInsightsLayout/CostInsightsLayout.tsx index 0a583aae0d..55d5668189 100644 --- a/plugins/cost-insights/src/components/CostInsightsLayout/CostInsightsLayout.tsx +++ b/plugins/cost-insights/src/components/CostInsightsLayout/CostInsightsLayout.tsx @@ -37,6 +37,7 @@ type CostInsightsLayoutProps = { }; export const CostInsightsLayout = ({ + title = 'Cost Insights', groups, children, }: PropsWithChildren) => { @@ -46,7 +47,7 @@ export const CostInsightsLayout = ({
diff --git a/plugins/cost-insights/src/components/EntityCosts/EntityCosts.tsx b/plugins/cost-insights/src/components/EntityCosts/EntityCosts.tsx index 9dda1c65e3..69bf8885e7 100644 --- a/plugins/cost-insights/src/components/EntityCosts/EntityCosts.tsx +++ b/plugins/cost-insights/src/components/EntityCosts/EntityCosts.tsx @@ -120,7 +120,7 @@ export const EntityCostsCard = () => { return {error.message}; } - if (!dailyCost) { + if (!dailyCost || !dailyCost.aggregation.length) { return No daily costs; } From dfa0bb737ee4cd579c2117843b5f309d58e0c4a0 Mon Sep 17 00:00:00 2001 From: Jen Evans Date: Tue, 7 Feb 2023 17:04:26 -0800 Subject: [PATCH 2/2] Add changeset Signed-off-by: Jen Evans --- .changeset/sweet-yaks-taste.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sweet-yaks-taste.md diff --git a/.changeset/sweet-yaks-taste.md b/.changeset/sweet-yaks-taste.md new file mode 100644 index 0000000000..cbbbaea497 --- /dev/null +++ b/.changeset/sweet-yaks-taste.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-cost-insights': patch +--- + +Fix bug in EntityCostsCard if cost aggregation array is empty. Allow title override on the Cost Insights Page