-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'inventory' item to Security navigation menu (#204373)
## Summary Add 'inventory' item to Security navigation menu (either when the sidebar is expanded and the full navigation menu is shown or when the sidebar is collapsed and only the Security menu is visible). ### Changeset details - Render 'inventory' item and enable `/app/security/asset_inventory` route both conditionally based on feature flag - Async loading/rendering of AssetInventory main page from within SecuritySolution plugin - Delete unnecessary boilerplate existing in AssetInventory ### Out of scope - AssetInventory nav sub-menu is skipped until more concrete requirements are defined on what to do with them ### How to test Activate the feature flag by adding this line to your local `kibana.dev.yml`: ```yml xpack.securitySolution.enableExperimental: ['assetInventoryStoreEnabled'] ``` ### Screenshots <details><summary>Full menu (expanded mode)</summary> <img width="240" alt="Screenshot 2024-12-16 at 13 12 45" src="https://github.com/user-attachments/assets/f0939f38-5be6-481b-ace1-07f46f3622ae" /> </details> <details><summary>Only Security menu (collapsed mode)</summary> <img width="256" alt="Screenshot 2024-12-16 at 13 12 33" src="https://github.com/user-attachments/assets/b0bd62f0-5cea-4b7b-a731-3a53be362192" /> </details> <details><summary>AssetInventory loaded async from within Security Solution</summary> <img width="1640" alt="Screenshot 2024-12-16 at 17 23 01" src="https://github.com/user-attachments/assets/b84716c9-6b18-4225-bf71-62c8ef07b302" /> </details> ### Checklist - [x] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Risks No risks. Navigation item will be added if and only if feature flag is enabled, which shouldn't happen for end users until development is completed.
- Loading branch information
1 parent
71303af
commit 6d5be74
Showing
22 changed files
with
191 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
x-pack/solutions/security/plugins/asset_inventory/public/application.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
x-pack/solutions/security/plugins/asset_inventory/public/methods/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { lazy, Suspense } from 'react'; | ||
import { EuiLoadingSpinner } from '@elastic/eui'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { AppPluginStartDependencies } from '../types'; | ||
|
||
// Initializing react-query | ||
const queryClient = new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
refetchOnWindowFocus: false, | ||
refetchOnMount: false, | ||
refetchOnReconnect: false, | ||
}, | ||
}, | ||
}); | ||
|
||
const AssetInventoryLazy = lazy(() => import('../components/app')); | ||
|
||
export const getAssetInventoryLazy = (props: AppPluginStartDependencies) => { | ||
return ( | ||
<QueryClientProvider client={queryClient}> | ||
<Suspense fallback={<EuiLoadingSpinner />}> | ||
<AssetInventoryLazy {...props} /> | ||
</Suspense> | ||
</QueryClientProvider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
], | ||
"requiredPlugins": [ | ||
"actions", | ||
"assetInventory", | ||
"alerting", | ||
"cases", | ||
"cloud", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
x-pack/solutions/security/plugins/security_solution/public/asset_inventory/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { SecuritySubPlugin } from '../app/types'; | ||
import { routes } from './routes'; | ||
|
||
export class AssetInventory { | ||
public setup() {} | ||
|
||
public start(): SecuritySubPlugin { | ||
return { | ||
routes, | ||
}; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
x-pack/solutions/security/plugins/security_solution/public/asset_inventory/links.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { INVENTORY } from '../app/translations'; | ||
import { ASSET_INVENTORY_PATH, SecurityPageName, SERVER_APP_ID } from '../../common/constants'; | ||
import type { LinkItem } from '../common/links/types'; | ||
|
||
export const links: LinkItem = { | ||
capabilities: [`${SERVER_APP_ID}.show`], | ||
globalNavPosition: 10, | ||
globalSearchKeywords: [ | ||
i18n.translate('xpack.securitySolution.appLinks.inventory', { | ||
defaultMessage: 'Inventory', | ||
}), | ||
], | ||
experimentalKey: 'assetInventoryStoreEnabled', | ||
id: SecurityPageName.assetInventory, | ||
path: ASSET_INVENTORY_PATH, | ||
title: INVENTORY, | ||
}; |
25 changes: 25 additions & 0 deletions
25
x-pack/solutions/security/plugins/security_solution/public/asset_inventory/pages/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { SecuritySolutionPageWrapper } from '../../common/components/page_wrapper'; | ||
import { useKibana } from '../../common/lib/kibana'; | ||
import { SecurityPageName } from '../../../common/constants'; | ||
import { SpyRoute } from '../../common/utils/route/spy_routes'; | ||
|
||
export const AssetInventoryContainer = React.memo(() => { | ||
const { assetInventory } = useKibana().services; | ||
|
||
return ( | ||
<SecuritySolutionPageWrapper noPadding> | ||
{assetInventory.getAssetInventoryPage({})} | ||
<SpyRoute pageName={SecurityPageName.assetInventory} /> | ||
</SecuritySolutionPageWrapper> | ||
); | ||
}); | ||
|
||
AssetInventoryContainer.displayName = 'AssetInventoryContainer'; |
30 changes: 30 additions & 0 deletions
30
x-pack/solutions/security/plugins/security_solution/public/asset_inventory/routes.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import type { SecuritySubPluginRoutes } from '../app/types'; | ||
import { SecurityPageName } from '../app/types'; | ||
import { ASSET_INVENTORY_PATH } from '../../common/constants'; | ||
import { PluginTemplateWrapper } from '../common/components/plugin_template_wrapper'; | ||
import { SecurityRoutePageWrapper } from '../common/components/security_route_page_wrapper'; | ||
import { ExperimentalFeaturesService } from '../common/experimental_features_service'; | ||
import { AssetInventoryContainer } from './pages'; | ||
|
||
export const AssetInventoryRoutes = () => ( | ||
<PluginTemplateWrapper> | ||
<SecurityRoutePageWrapper pageName={SecurityPageName.assetInventory}> | ||
<AssetInventoryContainer /> | ||
</SecurityRoutePageWrapper> | ||
</PluginTemplateWrapper> | ||
); | ||
|
||
export const routes: SecuritySubPluginRoutes = [ | ||
{ | ||
path: ExperimentalFeaturesService.get().assetInventoryStoreEnabled ? ASSET_INVENTORY_PATH : [], | ||
component: AssetInventoryRoutes, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.