Skip to content

Commit

Permalink
refactor, remove ts-ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed Jun 14, 2023
1 parent 9ca5a6e commit 4d2ded2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function getAnalyticsJobsStats(

export const getAnalyticsFactory = (
setAnalytics: React.Dispatch<React.SetStateAction<DataFrameAnalyticsListRow[]>>,
setAnalyticsStats: React.Dispatch<React.SetStateAction<AnalyticStatsBarStats | undefined>>,
setAnalyticsStats: (update: AnalyticStatsBarStats | undefined) => void,
setErrorMessage: React.Dispatch<
React.SetStateAction<GetDataFrameAnalyticsStatsResponseError | undefined>
>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -36,9 +39,7 @@ export const AnalyticsPanel: FC<Props> = ({ setLazyJobCount }) => {
const refresh = useRefresh();

const [analytics, setAnalytics] = useState<DataFrameAnalyticsListRow[]>([]);
const [analyticsStats, setAnalyticsStats] = useState<
Array<{ label: string; value: number }> | undefined
>(undefined);
const [analyticsStats, setAnalyticsStats] = useState<StatEntry[] | undefined>(undefined);
const [errorMessage, setErrorMessage] = useState<GetDataFrameAnalyticsStatsResponseError>();
const [isInitialized, setIsInitialized] = useState(false);

Expand All @@ -51,7 +52,9 @@ export const AnalyticsPanel: FC<Props> = ({ setLazyJobCount }) => {
TMlStorageMapped<typeof ML_OVERVIEW_PANELS>
>(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);
Expand All @@ -61,7 +64,6 @@ export const AnalyticsPanel: FC<Props> = ({ setLazyJobCount }) => {

const getAnalytics = getAnalyticsFactory(
setAnalytics,
// @ts-ignore
setAnalyticsStatsCustom,
setErrorMessage,
setIsInitialized,
Expand Down

0 comments on commit 4d2ded2

Please sign in to comment.