Skip to content

Commit 604316a

Browse files
committed
use queryparam initially, navigate to correct url
1 parent 1c078cf commit 604316a

File tree

2 files changed

+14
-4
lines changed
  • x-pack/plugins
    • ingest_manager/public/applications/ingest_manager/sections/epm/screens/home
    • security_solution/public/overview/components/overview_empty

2 files changed

+14
-4
lines changed

x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/index.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import React, { useState } from 'react';
8-
import { useRouteMatch, Switch, Route } from 'react-router-dom';
8+
import { useRouteMatch, Switch, Route, useLocation, useHistory } from 'react-router-dom';
99
import { Props as EuiTabProps } from '@elastic/eui/src/components/tabs/tab';
1010
import { i18n } from '@kbn/i18n';
1111
import { PAGE_ROUTING_PATHS } from '../../../../constants';
@@ -114,7 +114,11 @@ function InstalledPackages() {
114114

115115
function AvailablePackages() {
116116
useBreadcrumbs('integrations_all');
117-
const [selectedCategory, setSelectedCategory] = useState('');
117+
const history = useHistory();
118+
const queryParams = new URLSearchParams(useLocation().search);
119+
const initialCategory =
120+
queryParams.get('category') !== null ? (queryParams.get('category') as string) : '';
121+
const [selectedCategory, setSelectedCategory] = useState(initialCategory);
118122
const { data: categoryPackagesRes, isLoading: isLoadingPackages } = useGetPackages({
119123
category: selectedCategory,
120124
});
@@ -141,7 +145,13 @@ function AvailablePackages() {
141145
isLoading={isLoadingCategories}
142146
categories={categories}
143147
selectedCategory={selectedCategory}
144-
onCategoryChange={({ id }: CategorySummaryItem) => setSelectedCategory(id)}
148+
onCategoryChange={({ id }: CategorySummaryItem) => {
149+
// clear category query param in the url
150+
if (queryParams.get('category') !== null) {
151+
history.push({});
152+
}
153+
setSelectedCategory(id);
154+
}}
145155
/>
146156
) : null;
147157

x-pack/plugins/security_solution/public/overview/components/overview_empty/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const OverviewEmptyComponent: React.FC = () => {
1717
const { http, docLinks } = useKibana().services;
1818
const basePath = http.basePath.get();
1919
const { appId: ingestAppId, appPath: ingestPath, url: ingestUrl } = useHostIngestUrl(
20-
'integrations'
20+
'integrations?category=security'
2121
);
2222
const handleOnClick = useNavigateToAppEventHandler(ingestAppId, { path: ingestPath });
2323

0 commit comments

Comments
 (0)