[8.6] [Security Solution][List Details Page]: Fixing not found page (#145833) (#145860)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[Security Solution][List Details Page]: Fixing not found page
(#145833)](https://github.com/elastic/kibana/pull/145833)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Wafaa
Nasr","email":"wafaa.nasr@elastic.co"},"sourceCommit":{"committedDate":"2022-11-21T13:35:12Z","message":"[Security
Solution][List Details Page]: Fixing not found page (#145833)\n\n##
Summary\r\n\r\n- Fixing showing Page not found in case the URL is
incorrect or listId\r\n- Address
https://github.com/elastic/kibana/issues/145548\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"f96d81cae374d6b08f2201a2da22691cda9c70d4","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:
SecuritySolution","Team:Security Solution
Platform","v8.6.0","v8.7.0"],"number":145833,"url":"https://github.com/elastic/kibana/pull/145833","mergeCommit":{"message":"[Security
Solution][List Details Page]: Fixing not found page (#145833)\n\n##
Summary\r\n\r\n- Fixing showing Page not found in case the URL is
incorrect or listId\r\n- Address
https://github.com/elastic/kibana/issues/145548\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"f96d81cae374d6b08f2201a2da22691cda9c70d4"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145833","number":145833,"mergeCommit":{"message":"[Security
Solution][List Details Page]: Fixing not found page (#145833)\n\n##
Summary\r\n\r\n- Fixing showing Page not found in case the URL is
incorrect or listId\r\n- Address
https://github.com/elastic/kibana/issues/145548\r\n\r\nCo-authored-by:
Kibana Machine
<42973632+kibanamachine@users.noreply.github.com>","sha":"f96d81cae374d6b08f2201a2da22691cda9c70d4"}}]}]
BACKPORT-->

Co-authored-by: Wafaa Nasr <wafaa.nasr@elastic.co>
This commit is contained in:
Kibana Machine 2022-11-21 10:04:35 -05:00 committed by GitHub
parent c2871d07b8
commit c27eedd28c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -45,7 +45,7 @@ const exceptionReferenceModalInitialState: ReferenceModalState = {
listNamespaceType: 'single',
};
export const useExceptionListDetails = () => {
export const useListDetailsView = () => {
const toasts = useToasts();
const { services } = useKibana();
const { http, notifications } = services;
@ -114,7 +114,10 @@ export const useExceptionListDetails = () => {
id: exceptionListId,
http,
});
if (!result || !isAnExceptionListItem(result)) return setInvalidListId(true);
if (!result || !isAnExceptionListItem(result)) {
setIsLoading(false);
return setInvalidListId(true);
}
setList(result);
await initializeListRules(result);

View file

@ -19,7 +19,7 @@ import { MissingPrivilegesCallOut } from '../../../detections/components/callout
import { NotFoundPage } from '../../../app/404';
import { AutoDownload } from '../../../common/components/auto_download/auto_download';
import { ListWithSearch, ManageRules, ListDetailsLinkAnchor } from '../../components';
import { useExceptionListDetails } from '../../hooks';
import { useListDetailsView } from '../../hooks';
import * as i18n from '../../translations';
export const ListsDetailViewComponent: FC = () => {
@ -51,14 +51,14 @@ export const ListsDetailViewComponent: FC = () => {
handleDelete,
handleCloseReferenceErrorModal,
handleReferenceDelete,
} = useExceptionListDetails();
} = useListDetailsView();
if (viewerStatus === ViewerStatus.ERROR)
return <EmptyViewerState isReadOnly={isReadOnly} viewerStatus={viewerStatus} />;
if (isLoading) return <EuiLoadingContent lines={4} data-test-subj="loading" />;
if (invalidListId || !listName || !listDescription || !list) return <NotFoundPage />;
if (invalidListId || !listName || !list) return <NotFoundPage />;
return (
<>
<MissingPrivilegesCallOut />