forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update navigation landing pages to use appLinks config (elastic#132027)
* Update navigation landing pages to use appLinks config * Please code review * align app links changes * Update links descriptions * Rollback title changes * Fix wrong links descriptions * Fix unit tests * Fix description Co-authored-by: semd <sergi.massaneda@elastic.co>
- Loading branch information
1 parent
59ffe0d
commit b5dc585
Showing
32 changed files
with
580 additions
and
527 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
x-pack/plugins/security_solution/public/common/components/navigation/nav_links.test.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,54 @@ | ||
/* | ||
* 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 { renderHook } from '@testing-library/react-hooks'; | ||
import { SecurityPageName } from '../../../app/types'; | ||
import { NavLinkItem } from '../../links/types'; | ||
import { TestProviders } from '../../mock'; | ||
import { useAppNavLinks, useAppRootNavLink } from './nav_links'; | ||
|
||
const mockNavLinks = [ | ||
{ | ||
description: 'description', | ||
id: SecurityPageName.administration, | ||
links: [ | ||
{ | ||
description: 'description 2', | ||
id: SecurityPageName.endpoints, | ||
links: [], | ||
path: '/path_2', | ||
title: 'title 2', | ||
}, | ||
], | ||
path: '/path', | ||
title: 'title', | ||
}, | ||
]; | ||
|
||
jest.mock('../../links', () => ({ | ||
getNavLinkItems: () => mockNavLinks, | ||
})); | ||
|
||
const renderUseAppNavLinks = () => | ||
renderHook<{}, NavLinkItem[]>(() => useAppNavLinks(), { wrapper: TestProviders }); | ||
|
||
const renderUseAppRootNavLink = (id: SecurityPageName) => | ||
renderHook<{ id: SecurityPageName }, NavLinkItem | undefined>(() => useAppRootNavLink(id), { | ||
wrapper: TestProviders, | ||
}); | ||
|
||
describe('useAppNavLinks', () => { | ||
it('should return all nav links', () => { | ||
const { result } = renderUseAppNavLinks(); | ||
expect(result.current).toEqual(mockNavLinks); | ||
}); | ||
|
||
it('should return a root nav links', () => { | ||
const { result } = renderUseAppRootNavLink(SecurityPageName.administration); | ||
expect(result.current).toEqual(mockNavLinks[0]); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
x-pack/plugins/security_solution/public/common/components/navigation/nav_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,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 { useKibana } from '../../lib/kibana'; | ||
import { useEnableExperimental } from '../../hooks/use_experimental_features'; | ||
import { useLicense } from '../../hooks/use_license'; | ||
import { getNavLinkItems } from '../../links'; | ||
import type { SecurityPageName } from '../../../app/types'; | ||
import type { NavLinkItem } from '../../links/types'; | ||
|
||
export const useAppNavLinks = (): NavLinkItem[] => { | ||
const license = useLicense(); | ||
const enableExperimental = useEnableExperimental(); | ||
const capabilities = useKibana().services.application.capabilities; | ||
|
||
return getNavLinkItems({ enableExperimental, license, capabilities }); | ||
}; | ||
|
||
export const useAppRootNavLink = (linkId: SecurityPageName): NavLinkItem | undefined => { | ||
return useAppNavLinks().find(({ id }) => id === linkId); | ||
}; |
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
170 changes: 170 additions & 0 deletions
170
.../components/navigation/use_security_solution_navigation/__snapshots__/index.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.