Skip to content

Commit

Permalink
Show error if policies can't be loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
Esteban Beltran committed Nov 30, 2021
1 parent 247948d commit 3aa2ef0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,10 @@ export const getCreationSuccessMessage = (name: string) => {
}
);
};

export const getLoadPoliciesError = (error: ServerApiError) => {
return i18n.translate('xpack.securitySolution.hostIsolationExceptions.failedLoadPolicies', {
defaultMessage: 'There was an error loading policies: "{error}"',
values: { error: error.message },
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useHistory } from 'react-router-dom';
import { Immutable } from '../../../../../common/endpoint/types';
import { ExceptionItem } from '../../../../common/components/exceptions/viewer/exception_item';
import { useEndpointPrivileges } from '../../../../common/components/user_privileges/endpoint';
import { useToasts } from '../../../../common/lib/kibana';
import {
MANAGEMENT_DEFAULT_PAGE_SIZE,
MANAGEMENT_PAGE_SIZE_OPTIONS,
Expand All @@ -32,6 +33,7 @@ import { HostIsolationExceptionsFormFlyout } from './components/form_flyout';
import {
DELETE_HOST_ISOLATION_EXCEPTION_LABEL,
EDIT_HOST_ISOLATION_EXCEPTION_LABEL,
getLoadPoliciesError,
} from './components/translations';
import {
useFetchHostIsolationExceptionsList,
Expand All @@ -54,10 +56,13 @@ export const HostIsolationExceptionsList = () => {
const [itemToDelete, setItemToDelete] = useState<ExceptionListItemSchema | null>(null);

const { isLoading, data, error, refetch } = useFetchHostIsolationExceptionsList();
const toasts = useToasts();

// load the list of policies>
const policiesRequest = useGetEndpointSpecificPolicies({
onError: () => {},
onError: (err) => {
toasts.addDanger(getLoadPoliciesError(err));
},
});

const pagination = {
Expand Down

0 comments on commit 3aa2ef0

Please sign in to comment.