Skip to content

Commit fabfb43

Browse files
[Fleet] Implement subcategories in integrations UI (#148894)
## Summary Closes #147125 Closes #148654 - Implement subcategories in integrations UI. - I also refactored the `AvailablePackages`, `InstalledPackages` and `PackageListGrid` components to make easier to do changes. I extracted the logic from `AvailablePackages` in a hook `useAvailablePackages` and updated it. - Sneaked a small bugfix into it. It's in commit 7b2946f: removed the js logic that handled the sticky sidemenu, that would cause flickering in some cases and implemented it with some css instead. ## Repro steps ### Display actual subcategories coming from EPR - Enable `showIntegrationsSubcategories` feature flag; - Navigate to Integrations page. `Security` and `infrastructure` categories have sub categories. - When clicking on a subcategory, the page URL gets updated. For example, if clicking on `Infrastructure` > `Kubernetes`, the url will be `/integrations/browse/infrastructure/kubernetes`. It works with search too, if searching `abc` in the subcategory the url will update to `/integrations/browse/infrastructure/kubernetes?q=abc` ### Display mock data Same repro steps as before, but I added some mock subcategories: Added the following subcategories file <details> <p> ``` export const mockSubcategories = [ { id: 'kubernetes', title: 'Kubernetes', count: 18, parent_id: 'infrastructure', parent_title: 'Infrastructure', }, { id: 'message_queue', title: 'Message Broker', count: 7, parent_id: 'infrastructure', parent_title: 'Infrastructure', }, { id: 'monitoring', title: 'Monitoring', count: 16, parent_id: 'observability', parent_title: 'Observability', }, { id: 'threat_intel', title: 'Threat Intelligence', count: 10, parent_id: 'security', parent_title: 'Security', }, { id: 'web', title: 'Web Server', count: 36, parent_id: 'infrastructure', parent_title: 'Infrastructure', }, { id: 'security_mock_1', title: 'Security mock 1', count: 10, parent_id: 'security', parent_title: 'Security', }, { id: 'infrastructure_mock_1', title: 'Subcategory 1', count: 12, parent_id: 'infrastructure', parent_title: 'Infrastructure', }, { id: 'infrastructure_mock_2', title: 'Subcategory 2', count: 12, parent_id: 'infrastructure', parent_title: 'Infrastructure', }, { id: 'infrastructure_mock_3', title: 'Subcategory 3', count: 12, parent_id: 'infrastructure', parent_title: 'Infrastructure', }, { id: 'infrastructure_mock_4', title: 'Subcategory 4', count: 12, parent_id: 'infrastructure', parent_title: 'Infrastructure', }, { id: 'infrastructure_mock_5', title: 'Subcategory 5', count: 12, parent_id: 'infrastructure', parent_title: 'Infrastructure', }, { id: 'infrastructure_mock_6', title: 'Subcategory 6', count: 12, parent_id: 'infrastructure', parent_title: 'Infrastructure', }, ]; ``` </p> </details> I then imported it and replaced the subcategories here: https://github.com/criamico/kibana/blob/7b2946fe3b5067418fffb5fef9812a5080760200/x-pack/plugins/fleet/public/applications/integrations/sections/epm/screens/home/hooks/use_available_packages.tsx#L226. It should provide more subcategories under `infrastructure`. ### Screenshots If subcategories are up to 6, they get rendered on top of the integrations page: <img width="1679" alt="Screenshot 2023-01-17 at 16 11 01" src="https://user-images.githubusercontent.com/16084106/212963949-6e1fdccc-872d-4c40-a594-905e34218494.png"> If more the 6 subcategories are present, the remaining ones get hidden under an option button: <img width="1593" alt="Screenshot 2023-01-17 at 16 07 27" src="https://user-images.githubusercontent.com/16084106/212963863-0be8a97f-75ba-4bfb-a28c-bb9bbeb4c8b3.png"> <img width="1693" alt="Screenshot 2023-01-17 at 16 07 41" src="https://user-images.githubusercontent.com/16084106/212963899-2846b292-45c2-4fc2-91ca-e947653ec961.png"> ### Checklist - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [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 - [ ] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) - [ ] This renders correctly on smaller devices using a responsive layout. (You can test this [in your browser](https://www.browserstack.com/guide/responsive-testing-on-local-server)) Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
1 parent f83a60c commit fabfb43

File tree

11 files changed

+663
-375
lines changed

11 files changed

+663
-375
lines changed

x-pack/plugins/fleet/common/experimental_features.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const allowedExperimentalValues = Object.freeze({
1717
showDevtoolsRequest: true,
1818
diagnosticFileUploadEnabled: false,
1919
experimentalDataStreamSettings: false,
20+
showIntegrationsSubcategories: false,
2021
});
2122

2223
type ExperimentalConfigKeys = Array<keyof ExperimentalFeatures>;

x-pack/plugins/fleet/common/types/models/epm.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ export interface CategorySummaryItem {
289289
id: CategoryId;
290290
title: string;
291291
count: number;
292+
parent_id?: string;
293+
parent_title?: string;
292294
}
293295

294296
export type RequirementsByServiceName = PackageSpecManifest['conditions'];

x-pack/plugins/fleet/cypress/e2e/integrations_real.cy.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ describe('Add Integration - Real API', () => {
172172

173173
it('should filter integrations by category', () => {
174174
setupIntegrations();
175-
cy.getBySel(getIntegrationCategories('aws')).click();
175+
cy.getBySel(getIntegrationCategories('aws')).click({ scrollBehavior: false });
176+
176177
cy.getBySel(INTEGRATIONS_SEARCHBAR.BADGE).contains('AWS').should('exist');
177178
cy.getBySel(INTEGRATION_LIST).find('.euiCard').should('have.length.greaterThan', 29);
178179

x-pack/plugins/fleet/public/applications/integrations/sections/epm/components/package_list_grid.stories.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,13 @@ const categories = [
4545
export const EmptyList = (props: Args) => (
4646
<PackageListGrid
4747
list={[]}
48-
onSearchChange={action('onSearchChange')}
49-
setSelectedCategory={action('setSelectedCategory')}
48+
searchTerm=""
49+
setSearchTerm={action('setSearchTerm')}
50+
setCategory={action('setCategory')}
5051
categories={categories}
5152
selectedCategory=""
53+
setUrlandReplaceHistory={action('setUrlandReplaceHistory')}
54+
setUrlandPushHistory={action('setUrlandPushHistory')}
5255
{...props}
5356
/>
5457
);
@@ -129,10 +132,13 @@ export const List = (props: Args) => (
129132
categories: ['category_two'],
130133
},
131134
]}
132-
onSearchChange={action('onSearchChange')}
133-
setSelectedCategory={action('setSelectedCategory')}
135+
searchTerm=""
136+
setSearchTerm={action('setSearchTerm')}
137+
setCategory={action('setCategory')}
134138
categories={categories}
135139
selectedCategory=""
140+
setUrlandReplaceHistory={action('setUrlandReplaceHistory')}
141+
setUrlandPushHistory={action('setUrlandPushHistory')}
136142
{...props}
137143
/>
138144
);

0 commit comments

Comments
 (0)