mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Security Solution][Endpoint] Fixes a react minified error when there is a List API error (#137415)
* Fixes a react minified error when there is a List API error * Fixes error when body is not defined in error object Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
fd7af33a90
commit
07f532e926
2 changed files with 11 additions and 1 deletions
|
@ -5,12 +5,13 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import React, { memo, useCallback, useMemo, useState } from 'react';
|
||||
import React, { memo, useCallback, useMemo, useState, useEffect } from 'react';
|
||||
|
||||
import type { ExceptionListItemSchema } from '@kbn/securitysolution-io-ts-list-types';
|
||||
import { EuiButton, EuiSpacer, EuiText } from '@elastic/eui';
|
||||
import type { EuiFlyoutSize } from '@elastic/eui/src/components/flyout/flyout';
|
||||
import { useLocation } from 'react-router-dom';
|
||||
import type { ServerApiError } from '../../../common/types';
|
||||
import { AdministrationListPage } from '../administration_list_page';
|
||||
|
||||
import type { PaginatedContentProps } from '../paginated_content';
|
||||
|
@ -108,6 +109,12 @@ export const ArtifactListPage = memo<ArtifactListPageProps>(
|
|||
refetch: refetchListData,
|
||||
} = useWithArtifactListData(apiClient, searchableFields);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLoading && error) {
|
||||
toasts.addDanger((error?.body as ServerApiError)?.message || error.message);
|
||||
}
|
||||
}, [error, toasts, isLoading]);
|
||||
|
||||
const items = useMemo(() => {
|
||||
return listDataResponse?.data ?? [];
|
||||
}, [listDataResponse?.data]);
|
||||
|
|
|
@ -188,6 +188,9 @@ export const PaginatedContent = memo(
|
|||
|
||||
const generatedBodyItemContent = useMemo(() => {
|
||||
if (error) {
|
||||
if (error instanceof Error) {
|
||||
return <ErrorMessage message={error.message} data-test-subj={getTestId('error')} />;
|
||||
}
|
||||
return 'string' === typeof error ? (
|
||||
<ErrorMessage message={error} data-test-subj={getTestId('error')} />
|
||||
) : (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue