Skip to content

Commit 7a1885d

Browse files
kqualters-elasticpaulinashakirova
authored andcommitted
[Security Solution] [Alerts] Fix deprecated pageNames with redirects (elastic#232558)
## Summary Related issue: elastic#232557 This pr fixes an issue where deprecated pages that are not registered with the global navigation and search, as the now deprecated app/security/detections/* routes are, but did have custom redirect logic with react router components, stopped working as a result of a recent change elastic#217890 that prevented any of this logic from running if the route was not registered globally, "useLinkInfo" is the hook below that checks this. Alert actions use an older url, app/security/detections/rules/id/{ruleId}, and redirect at the application level to the new url app/security/rules/id/{ruleId} and so this pr explicitly excludes the old route from this check, because we should also continue to not show a detections result in the global search bar that just redirects to the alerts page. Open to doing this in another way if we want, but this seemed the most direct and lowest friction way to make this core functionality work again. Before: ![fix_action_redirects_busted](https://github.com/user-attachments/assets/5f74b5ae-66e3-4590-8ee5-6d1f6c6fbe34) After: ![fix_action_redirects](https://github.com/user-attachments/assets/98a8ab29-5c55-4c2f-972c-1dcf484441e6) ### Checklist - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
1 parent 7b1ea01 commit 7a1885d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

x-pack/solutions/security/plugins/security_solution/public/common/components/security_route_page_wrapper/security_route_page_wrapper.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import React, { type PropsWithChildren } from 'react';
99
import { Redirect } from 'react-router-dom';
1010
import { TrackApplicationView } from '@kbn/usage-collection-plugin/public';
11-
import type { SecurityPageName } from '../../../../common';
11+
import { SecurityPageName } from '../../../../common';
1212
import { useLinkInfo } from '../../links';
1313
import { NoPrivilegesPage } from '../no_privileges';
1414
import { useUpsellingPage } from '../../hooks/use_upselling';
@@ -26,6 +26,8 @@ type SecurityRoutePageWrapperProps = {
2626
pageName: SecurityPageName;
2727
} & SecurityRoutePageWrapperOptionProps;
2828

29+
const deprectedPagesWithRedirect = [SecurityPageName.detections];
30+
2931
/**
3032
* This component is created to wrap all the pages in the security solution app.
3133
*
@@ -61,12 +63,13 @@ export const SecurityRoutePageWrapper: React.FC<PropsWithChildren<SecurityRouteP
6163

6264
// Redirect to the home page if the link does not exist in the application links (has been filtered out).
6365
// or if the link is unavailable (payment plan not met, if it had upselling page associated it would have been rendered above).
64-
if (link == null || link.unavailable) {
66+
// Some pages handle their own redirect logic, so we need to exclude them from this check.
67+
if (!deprectedPagesWithRedirect.includes(pageName) && (link == null || link.unavailable)) {
6568
return <Redirect to="" />;
6669
}
6770

6871
// Show the no privileges page if the link is unauthorized.
69-
if (link.unauthorized) {
72+
if (link && link.unauthorized) {
7073
return (
7174
<>
7275
<SpyRoute pageName={pageName} />

0 commit comments

Comments
 (0)