diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/services/analytics_service/get_analytics.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/services/analytics_service/get_analytics.ts index 96f9b8f8780e4..9a3ea0c9bef90 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/services/analytics_service/get_analytics.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/services/analytics_service/get_analytics.ts @@ -108,7 +108,7 @@ export function getAnalyticsJobsStats( export const getAnalyticsFactory = ( setAnalytics: React.Dispatch>, - setAnalyticsStats: React.Dispatch>, + setAnalyticsStats: (update: AnalyticStatsBarStats | undefined) => void, setErrorMessage: React.Dispatch< React.SetStateAction >, diff --git a/x-pack/plugins/ml/public/application/overview/components/analytics_panel/analytics_panel.tsx b/x-pack/plugins/ml/public/application/overview/components/analytics_panel/analytics_panel.tsx index f70346038d35a..41e9732461bb3 100644 --- a/x-pack/plugins/ml/public/application/overview/components/analytics_panel/analytics_panel.tsx +++ b/x-pack/plugins/ml/public/application/overview/components/analytics_panel/analytics_panel.tsx @@ -12,7 +12,10 @@ import { i18n } from '@kbn/i18n'; import { useStorage } from '@kbn/ml-local-storage'; import { FormattedMessage } from '@kbn/i18n-react'; import { type AnalyticStatsBarStats } from '../../../components/stats_bar'; -import { OverviewStatsBar } from '../../../components/collapsible_panel/collapsible_panel'; +import { + OverviewStatsBar, + type StatEntry, +} from '../../../components/collapsible_panel/collapsible_panel'; import { ML_OVERVIEW_PANELS, MlStorageKey, @@ -36,9 +39,7 @@ export const AnalyticsPanel: FC = ({ setLazyJobCount }) => { const refresh = useRefresh(); const [analytics, setAnalytics] = useState([]); - const [analyticsStats, setAnalyticsStats] = useState< - Array<{ label: string; value: number }> | undefined - >(undefined); + const [analyticsStats, setAnalyticsStats] = useState(undefined); const [errorMessage, setErrorMessage] = useState(); const [isInitialized, setIsInitialized] = useState(false); @@ -51,7 +52,9 @@ export const AnalyticsPanel: FC = ({ setLazyJobCount }) => { TMlStorageMapped >(ML_OVERVIEW_PANELS, overviewPanelDefaultState); - const setAnalyticsStatsCustom = useCallback((stats: AnalyticStatsBarStats) => { + const setAnalyticsStatsCustom = useCallback((stats: AnalyticStatsBarStats | undefined) => { + if (!stats) return; + const result = Object.entries(stats) .filter(([k, v]) => v.show) .map(([k, v]) => v); @@ -61,7 +64,6 @@ export const AnalyticsPanel: FC = ({ setLazyJobCount }) => { const getAnalytics = getAnalyticsFactory( setAnalytics, - // @ts-ignore setAnalyticsStatsCustom, setErrorMessage, setIsInitialized,