Skip to content

Commit

Permalink
Fix typecheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Zacqary committed Nov 16, 2020
1 parent 3a58684 commit c49e5ea
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import React, { useMemo } from 'react';
import { mapValues, countBy } from 'lodash';
import { i18n } from '@kbn/i18n';
import { EuiBasicTable, EuiLoadingSpinner } from '@elastic/eui';
import { EuiBasicTable, EuiLoadingSpinner, EuiBasicTableColumn } from '@elastic/eui';
import { euiStyled } from '../../../../../../../../../observability/public';
import { ProcessListAPIResponse } from '../../../../../../../../common/http_api';
import { parseProcessList } from './parse_process_list';
Expand All @@ -18,19 +18,26 @@ interface Props {
isLoading: boolean;
}

type SummaryColumn = {
total: number;
} & Record<keyof typeof STATE_NAMES, number>;

export const SummaryTable = ({ processList, isLoading }: Props) => {
const parsedList = parseProcessList(processList);
const processCount = useMemo(
() => ({
total: isLoading ? -1 : parsedList.length,
...mapValues(STATE_NAMES, () => (isLoading ? -1 : 0)),
...(isLoading ? [] : countBy(parsedList, 'state')),
}),
() =>
[
{
total: isLoading ? -1 : parsedList.length,
...mapValues(STATE_NAMES, () => (isLoading ? -1 : 0)),
...(isLoading ? [] : countBy(parsedList, 'state')),
},
] as SummaryColumn[],
[parsedList, isLoading]
);
return (
<StyleWrapper>
<EuiBasicTable items={[processCount]} columns={columns} />
<EuiBasicTable items={processCount} columns={columns} />
</StyleWrapper>
);
};
Expand All @@ -47,7 +54,7 @@ const columns = [
render: loadingRenderer,
},
...Object.entries(STATE_NAMES).map(([field, name]) => ({ field, name, render: loadingRenderer })),
];
] as Array<EuiBasicTableColumn<SummaryColumn>>;

const LoadingSpinner = euiStyled(EuiLoadingSpinner).attrs({ size: 'm' })`
margin-top: 2px;
Expand Down

0 comments on commit c49e5ea

Please sign in to comment.