Skip to content

Commit

Permalink
removed getting started from the main left menu; centered empty page …
Browse files Browse the repository at this point in the history
…content for security template
  • Loading branch information
YulNaumenko committed Mar 31, 2022
1 parent 36c7fb6 commit 2d65773
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const securitySolutionsDeepLinks: SecuritySolutionDeepLink[] = [
id: SecurityPageName.landing,
title: GETTING_STARTED,
path: LANDING_PATH,
navLinkStatus: AppNavLinkStatus.visible,
navLinkStatus: AppNavLinkStatus.hidden,
features: [FEATURE.general],
keywords: [
i18n.translate('xpack.securitySolution.search.getStarted', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import React, { useMemo } from 'react';
import styled from 'styled-components';
import { EuiPanel } from '@elastic/eui';
Expand Down Expand Up @@ -78,6 +77,10 @@ export const SecuritySolutionTemplateWrapper: React.FC<SecuritySolutionPageWrapp
);

const userHasSecuritySolutionVisible = useKibana().services.application.capabilities.siem.show;
const showEmptyState = useShowPagesWithEmptyView();
const emptyStateProps = showEmptyState
? { ...NO_DATA_PAGE_TEMPLATE_PROPS, template: 'centeredContent' }
: {};

/*
* StyledKibanaPageTemplate is a styled EuiPageTemplate. Security solution currently passes the header
Expand All @@ -97,19 +100,19 @@ export const SecuritySolutionTemplateWrapper: React.FC<SecuritySolutionPageWrapp
solutionNav={solutionNav}
restrictWidth={false}
template="default"
{...emptyStateProps}
>

<>
<GlobalKQLHeader />
<EuiPanel
className="securityPageWrapper"
data-test-subj="pageContainer"
hasShadow={false}
paddingSize="l"
>
{children}
</EuiPanel>
</>
<>
<GlobalKQLHeader />
<EuiPanel
className="securityPageWrapper"
data-test-subj="pageContainer"
hasShadow={false}
paddingSize="l"
>
{children}
</EuiPanel>
</>
</StyledKibanaPageTemplate>
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,11 @@
import { shallow } from 'enzyme';
import React from 'react';

import { EmptyPage } from './index';
import { LandingPageComponent } from './index';

describe('EmptyPage component', () => {
it('renders actions without descriptions', () => {
const actions = {
actions: {
label: 'Do Something',
url: 'my/url/from/nowwhere',
},
};
const EmptyComponent = shallow(<EmptyPage actions={actions} title="My Super Title" />);
expect(EmptyComponent).toMatchSnapshot();
});

it('renders actions with descriptions', () => {
const actions = {
actions: {
description: 'My Description',
label: 'Do Something',
url: 'my/url/from/nowwhere',
},
};
const EmptyComponent = shallow(<EmptyPage actions={actions} title="My Super Title" />);
describe('LandingPageComponent component', () => {
it('renders page properly', () => {
const EmptyComponent = shallow(<LandingPageComponent/>);
expect(EmptyComponent).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { SecurityNavKey } from '../navigation/types';
import { SecurityPageName } from '../../../app/types';

export { getDetectionEngineUrl, getRuleDetailsUrl } from './redirect_to_detection_engine';
export { getAppLandingUrl } from './redirect_to_landing';
export { getHostDetailsUrl, getTabsOnHostDetailsUrl, getHostsUrl } from './redirect_to_hosts';
export { getNetworkUrl, getNetworkDetailsUrl } from './redirect_to_network';
export { getTimelineTabsUrl, getTimelineUrl } from './redirect_to_timelines';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
AdministrationRouteSpyState,
UsersRouteSpyState,
} from '../../../utils/route/types';
import { getAppLandingUrl } from '../../link_to';
import { getAppLandingUrl } from '../../link_to/redirect_to_landing';
import { timelineActions } from '../../../../../public/timelines/store/timeline';
import { TimelineId } from '../../../../../common/types/timeline';
import { TabNavigationProps } from '../tab_navigation/types';
Expand Down Expand Up @@ -92,7 +92,7 @@ export const getBreadcrumbsForRoute = (
): ChromeBreadcrumb[] | null => {
const spyState: RouteSpyState = omit('navTabs', object);
const landingPath = getUrlForApp(APP_UI_ID, { deepLinkId: SecurityPageName.landing });
console.log(landingPath)

const siemRootBreadcrumb: ChromeBreadcrumb = {
text: APP_NAME,
href: getAppLandingUrl(landingPath),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ jest.mock('../route/use_route_spy', () => ({
.fn()
.mockImplementationOnce(() => [{ pageName: 'hosts' }])
.mockImplementationOnce(() => [{ pageName: 'rules' }])
.mockImplementationOnce(() => [{ pageName: 'network' }]),
.mockImplementationOnce(() => [{ pageName: 'network' }])
.mockImplementationOnce(() => [{ pageName: 'landing' }])
.mockImplementationOnce(() => [{ pageName: 'landing' }]),
}));
jest.mock('../../../common/containers/sourcerer', () => ({
useSourcererDataView: jest
.fn()
.mockImplementationOnce(() => [{ indicesExist: false }])
.mockImplementationOnce(() => [{ indicesExist: false }])
.mockImplementationOnce(() => [{ indicesExist: true }])
.mockImplementationOnce(() => [{ indicesExist: false }])
.mockImplementationOnce(() => [{ indicesExist: true }]),
}));

Expand Down Expand Up @@ -48,4 +52,22 @@ describe('use show pages with empty view', () => {
expect(emptyResult).toEqual(true);
});
});

it('apply empty view for the landing page if indices do not exist', async () => {
await act(async () => {
const { result, waitForNextUpdate } = renderHook(() => useShowPagesWithEmptyView());
await waitForNextUpdate();
const emptyResult = result.current;
expect(emptyResult).toEqual(true);
});
});

it('apply empty view for the landing page if indices exist', async () => {
await act(async () => {
const { result, waitForNextUpdate } = renderHook(() => useShowPagesWithEmptyView());
await waitForNextUpdate();
const emptyResult = result.current;
expect(emptyResult).toEqual(true);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const useShowPagesWithEmptyView = () => {
const [{ pageName }] = useRouteSpy();
const { indicesExist } = useSourcererDataView();

const shouldShowEmptyState = isPageNameWithEmptyView(pageName) && !indicesExist;
const shouldShowEmptyState = (isPageNameWithEmptyView(pageName) && !indicesExist) || pageName === SecurityPageName.landing;

const [showEmptyState, setShowEmptyState] = useState(shouldShowEmptyState);

Expand Down

0 comments on commit 2d65773

Please sign in to comment.