Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update navigation landing pages to use appLinks config #132027

Merged
merged 8 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions x-pack/plugins/security_solution/public/app/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const USERS = i18n.translate('xpack.securitySolution.navigation.users', {
});
machadoum marked this conversation as resolved.
Show resolved Hide resolved

export const RULES = i18n.translate('xpack.securitySolution.navigation.rules', {
defaultMessage: 'Rules',
defaultMessage: 'SIEM rules',
});

export const EXCEPTIONS = i18n.translate('xpack.securitySolution.navigation.exceptions', {
Expand Down Expand Up @@ -71,7 +71,7 @@ export const ENDPOINTS = i18n.translate('xpack.securitySolution.search.administr
export const POLICIES = i18n.translate(
'xpack.securitySolution.navigation.administration.policies',
{
defaultMessage: 'Policies',
defaultMessage: 'Endpoint policies',
}
);
export const TRUSTED_APPLICATIONS = i18n.translate(
Expand All @@ -90,7 +90,7 @@ export const EVENT_FILTERS = i18n.translate(
export const HOST_ISOLATION_EXCEPTIONS = i18n.translate(
'xpack.securitySolution.search.administration.hostIsolationExceptions',
{
defaultMessage: 'Host isolation exceptions',
defaultMessage: 'Host isolation IP exceptions',
}
);
export const DETECT = i18n.translate('xpack.securitySolution.navigation.detect', {
Expand Down
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]);
});
});
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);
};
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,10 @@ export type GetUrlForApp = (
) => string;

export type NavigateToUrl = (url: string) => void;

export interface NavigationCategory {
label: string;
linkIds: readonly SecurityPageName[];
}

export type NavigationCategories = Readonly<NavigationCategory[]>;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading