diff --git a/.changeset/cost-insights-quick-suits-brake.md b/.changeset/cost-insights-quick-suits-brake.md new file mode 100644 index 0000000000..0fa4414c6b --- /dev/null +++ b/.changeset/cost-insights-quick-suits-brake.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-cost-insights': patch +--- + +Fix styling issue on Cost Insights product panels with no cost diff --git a/app-config.yaml b/app-config.yaml index bec048ce33..148627dc5a 100644 --- a/app-config.yaml +++ b/app-config.yaml @@ -253,7 +253,7 @@ costInsights: name: Cloud Storage icon: storage bigQuery: - name: Big Query + name: BigQuery icon: search metrics: DAU: diff --git a/plugins/cost-insights/src/components/ProductInsightsCard/ProductInsightsCard.tsx b/plugins/cost-insights/src/components/ProductInsightsCard/ProductInsightsCard.tsx index 17b1624c05..b78053ab5b 100644 --- a/plugins/cost-insights/src/components/ProductInsightsCard/ProductInsightsCard.tsx +++ b/plugins/cost-insights/src/components/ProductInsightsCard/ProductInsightsCard.tsx @@ -16,7 +16,7 @@ import React, { useCallback, useEffect, useState } from 'react'; import { InfoCard, useApi } from '@backstage/core'; -import { Box } from '@material-ui/core'; +import { Box, Typography } from '@material-ui/core'; import Alert from '@material-ui/lab/Alert'; import { costInsightsApiRef } from '../../api'; import { PeriodSelect } from '../PeriodSelect'; @@ -58,7 +58,7 @@ export const ProductInsightsCard = ({ product }: ProductInsightsCardProps) => { const dispatchLoadingProduct = useCallback(dispatchLoading, [product.kind]); const amount = resource?.entities?.length || 0; - const hasCostsWithinTimeframe = resource?.change && !!amount; + const hasCostsWithinTimeframe = !!(resource?.change && amount); const previousName = formatPeriod( productFilter.duration, @@ -71,9 +71,9 @@ export const ProductInsightsCard = ({ product }: ProductInsightsCardProps) => { true, ); - const subheader = amount + const subheader = hasCostsWithinTimeframe ? `${amount} ${pluralOf(amount, 'entity', 'entities')}, sorted by cost` - : `There are no ${product.name} costs within this timeframe for your team's projects.`; + : null; const costStart = resource?.aggregation[0] || 0; const costEnd = resource?.aggregation[1] || 0; @@ -144,26 +144,29 @@ export const ProductInsightsCard = ({ product }: ProductInsightsCardProps) => { return ( - {hasCostsWithinTimeframe && ( - <> - - - - - + + - + + + ) : ( + + There are no {product.name} costs within this timeframe for your + team's projects. + )} );