Skip to content

Commit

Permalink
[Security Solution] Changed landing page navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
YulNaumenko committed Mar 31, 2022
1 parent 5a17ada commit 73446a1
Show file tree
Hide file tree
Showing 35 changed files with 177 additions and 141 deletions.
2 changes: 1 addition & 1 deletion src/core/public/chrome/ui/header/collapsible_nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const overviewIDsToHide = ['kibanaOverview', 'enterpriseSearch'];
const overviewIDs = [
...overviewIDsToHide,
'observability-overview',
'securitySolutionUI:overview',
'securitySolutionUI:get_started',
'management',
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ import {
} from '../../../common/constants';

export const navTabs: SecurityNav = {
[SecurityPageName.overview]: {
id: SecurityPageName.overview,
name: i18n.OVERVIEW,
href: APP_OVERVIEW_PATH,
disabled: false,
urlKey: 'overview',
},
[SecurityPageName.landing]: {
id: SecurityPageName.landing,
name: i18n.GETTING_STARTED,
href: APP_LANDING_PATH,
disabled: false,
urlKey: 'get_started',
},
[SecurityPageName.overview]: {
id: SecurityPageName.overview,
name: i18n.OVERVIEW,
href: APP_OVERVIEW_PATH,
disabled: false,
urlKey: 'overview',
},
[SecurityPageName.detectionAndResponse]: {
id: SecurityPageName.detectionAndResponse,
name: i18n.DETECTION_RESPONSE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import endpointPng from '../../images/endpoint.png';
import siemPng from '../../images/siem.png';
import videoSvg from '../../images/video.svg';
import { ADD_DATA_PATH } from '../../../../common/constants';
import { useKibana } from '../../../common/lib/kibana';
import { useKibana } from '../../lib/kibana';

const imgUrls = {
siem: siemPng,
Expand Down

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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 { shallow } from 'enzyme';
import React from 'react';

import { EmptyPage } 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" />);
expect(EmptyComponent).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* 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, { memo } from 'react';
import { LandingCards } from '../landing_cards';
import { SecuritySolutionPageWrapper } from '../page_wrapper';

export const LandingPageComponent = memo(() => {
return (
<SecuritySolutionPageWrapper>
<LandingCards />
</SecuritySolutionPageWrapper>
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { SecurityPageName } from '../../../../app/types';

export { getDetectionEngineUrl } from '../redirect_to_detection_engine';
export { getAppOverviewUrl } from '../redirect_to_overview';
export { getAppLandingUrl } from '../redirect_to_landing';
export { getHostDetailsUrl, 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 @@ -14,7 +14,7 @@ import { SecurityNavKey } from '../navigation/types';
import { SecurityPageName } from '../../../app/types';

export { getDetectionEngineUrl, getRuleDetailsUrl } from './redirect_to_detection_engine';
export { getAppOverviewUrl } from './redirect_to_overview';
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 @@ -6,9 +6,6 @@
*/

import { appendSearch } from './helpers';
import { LANDING_PATH } from '../../../../common/constants';

export const getAppOverviewUrl = (overviewPath: string, search?: string) =>
export const getAppLandingUrl = (overviewPath: string, search?: string) =>
`${overviewPath}${appendSearch(search)}`;

export const getAppLandingUrl = (search?: string) => `${LANDING_PATH}${appendSearch(search)}`;
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
AdministrationRouteSpyState,
UsersRouteSpyState,
} from '../../../utils/route/types';
import { getAppOverviewUrl } from '../../link_to';
import { getAppLandingUrl } from '../../link_to';
import { timelineActions } from '../../../../../public/timelines/store/timeline';
import { TimelineId } from '../../../../../common/types/timeline';
import { TabNavigationProps } from '../tab_navigation/types';
Expand Down Expand Up @@ -91,10 +91,11 @@ export const getBreadcrumbsForRoute = (
getUrlForApp: GetUrlForApp
): ChromeBreadcrumb[] | null => {
const spyState: RouteSpyState = omit('navTabs', object);
const overviewPath = getUrlForApp(APP_UI_ID, { deepLinkId: SecurityPageName.overview });
const landingPath = getUrlForApp(APP_UI_ID, { deepLinkId: SecurityPageName.landing });
console.log(landingPath)
const siemRootBreadcrumb: ChromeBreadcrumb = {
text: APP_NAME,
href: getAppOverviewUrl(overviewPath),
href: getAppLandingUrl(landingPath),
};
if (isHostsRoutes(spyState) && object.navTabs) {
const tempNav: SearchNavTab = { urlKey: 'host', isDetailPage: false };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function usePrimaryNavigationItemsToDisplay(navTabs: Record<string, NavTab>) {
id: 'main',
name: '',
items: [
navTabs[SecurityPageName.overview],
navTabs[SecurityPageName.landing],
navTabs[SecurityPageName.overview],
// Temporary check for detectionAndResponse while page is feature flagged
...(navTabs[SecurityPageName.detectionAndResponse] != null
? [navTabs[SecurityPageName.detectionAndResponse]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const isPageNameWithEmptyView = (currentName: string) => {
SecurityPageName.network,
SecurityPageName.timelines,
SecurityPageName.overview,
SecurityPageName.landing,
];
return pageNamesWithEmptyView.includes(currentName);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import { AlertsTable } from '../../components/alerts_table';
import { NoApiIntegrationKeyCallOut } from '../../components/callouts/no_api_integration_callout';
import { AlertsHistogramPanel } from '../../components/alerts_kpis/alerts_histogram_panel';
import { useUserData } from '../../components/user_info';
import { OverviewEmpty } from '../../../overview/components/overview_empty';
import { DetectionEngineNoIndex } from './detection_engine_no_index';
import { useListsConfig } from '../../containers/detection_engine/lists/use_lists_config';
import { DetectionEngineUserUnauthenticated } from './detection_engine_user_unauthenticated';
Expand Down Expand Up @@ -77,6 +76,7 @@ import {
} from '../../components/alerts_table/alerts_filter_group';
import { EmptyPage } from '../../../common/components/empty_page';
import { HeaderPage } from '../../../common/components/header_page';
import { LandingPageComponent } from '../../../common/components/landing_page';
/**
* Need a 100% height here to account for the graph/analyze tool, which sets no explicit height parameters, but fills the available space.
*/
Expand Down Expand Up @@ -389,10 +389,7 @@ const DetectionEnginePageComponent: React.FC<DetectionEngineComponentProps> = ({
</SecuritySolutionPageWrapper>
</StyledFullHeightContainer>
) : (
<SecuritySolutionPageWrapper>
<HeaderPage border title={i18n.PAGE_TITLE} />
<OverviewEmpty />
</SecuritySolutionPageWrapper>
<LandingPageComponent />
)}
</>
);
Expand Down
8 changes: 4 additions & 4 deletions x-pack/plugins/security_solution/public/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
RULES_PATH,
SERVER_APP_ID,
CASES_FEATURE_ID,
OVERVIEW_PATH,
LANDING_PATH,
CASES_PATH,
} from '../common/constants';
import { Ecs } from '../common/ecs';
Expand Down Expand Up @@ -138,7 +138,7 @@ export const manageOldSiemRoutes = async (coreStart: CoreStart) => {
break;
default:
application.navigateToApp(APP_UI_ID, {
deepLinkId: SecurityPageName.overview,
deepLinkId: SecurityPageName.landing,
replace: true,
path,
});
Expand Down Expand Up @@ -197,12 +197,12 @@ export const RedirectRoute = React.memo<{ capabilities: Capabilities }>(({ capab
const overviewAvailable = isSubPluginAvailable('overview', capabilities);
const casesAvailable = isSubPluginAvailable(CASES_SUB_PLUGIN_KEY, capabilities);
if (overviewAvailable) {
return <Redirect to={OVERVIEW_PATH} />;
return <Redirect to={LANDING_PATH} />;
}
if (casesAvailable) {
return <Redirect to={CASES_PATH} />;
}
return <Redirect to={OVERVIEW_PATH} />;
return <Redirect to={LANDING_PATH} />;
});
RedirectRoute.displayName = 'RedirectRoute';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import { setAbsoluteRangeDatePicker } from '../../../common/store/inputs/actions
import { SpyRoute } from '../../../common/utils/route/spy_routes';
import { getEsQueryConfig } from '../../../../../../../src/plugins/data/common';

import { OverviewEmpty } from '../../../overview/components/overview_empty';
import { HostDetailsTabs } from './details_tabs';
import { navTabsHostDetails } from './nav_tabs';
import { HostDetailsProps } from './types';
Expand All @@ -54,6 +53,7 @@ import { manageQuery } from '../../../common/components/page/manage_query';
import { useInvalidFilterQuery } from '../../../common/hooks/use_invalid_filter_query';
import { useSourcererDataView } from '../../../common/containers/sourcerer';
import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features';
import { LandingPageComponent } from '../../../common/components/landing_page';

const HostOverviewManage = manageQuery(HostOverview);

Expand Down Expand Up @@ -227,9 +227,7 @@ const HostDetailsComponent: React.FC<HostDetailsProps> = ({ detailName, hostDeta
</SecuritySolutionPageWrapper>
</>
) : (
<SecuritySolutionPageWrapper>
<OverviewEmpty />
</SecuritySolutionPageWrapper>
<LandingPageComponent />
)}

<SpyRoute pageName={SecurityPageName.hosts} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { HostsTabs } from './hosts_tabs';
import { useSourcererDataView } from '../../common/containers/sourcerer';
import { mockCasesContract } from '../../../../cases/public/mocks';
import { APP_UI_ID, SecurityPageName } from '../../../common/constants';
import { getAppLandingUrl } from '../../common/components/link_to/redirect_to_overview';
import { getAppLandingUrl } from '../../common/components/link_to/redirect_to_landing';

jest.mock('../../common/containers/sourcerer');

Expand Down
6 changes: 2 additions & 4 deletions x-pack/plugins/security_solution/public/hosts/pages/hosts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import { setAbsoluteRangeDatePicker } from '../../common/store/inputs/actions';
import { SpyRoute } from '../../common/utils/route/spy_routes';
import { getEsQueryConfig } from '../../../../../../src/plugins/data/common';
import { useMlCapabilities } from '../../common/components/ml/hooks/use_ml_capabilities';
import { OverviewEmpty } from '../../overview/components/overview_empty';
import { Display } from './display';
import { HostsTabs } from './hosts_tabs';
import { navTabsHosts } from './nav_tabs';
Expand All @@ -56,6 +55,7 @@ import { useInvalidFilterQuery } from '../../common/hooks/use_invalid_filter_que
import { ID } from '../containers/hosts';
import { useIsExperimentalFeatureEnabled } from '../../common/hooks/use_experimental_features';
import { filterHostExternalAlertData } from '../../common/components/visualization_actions/utils';
import { LandingPageComponent } from '../../common/components/landing_page';

/**
* Need a 100% height here to account for the graph/analyze tool, which sets no explicit height parameters, but fills the available space.
Expand Down Expand Up @@ -240,9 +240,7 @@ const HostsComponent = () => {
</SecuritySolutionPageWrapper>
</StyledFullHeightContainer>
) : (
<SecuritySolutionPageWrapper>
<OverviewEmpty />
</SecuritySolutionPageWrapper>
<LandingPageComponent />
)}

<SpyRoute pageName={SecurityPageName.hosts} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import { inputsSelectors } from '../../../common/store';
import { setAbsoluteRangeDatePicker } from '../../../common/store/inputs/actions';
import { setNetworkDetailsTablesActivePageToZero } from '../../store/actions';
import { SpyRoute } from '../../../common/utils/route/spy_routes';
import { OverviewEmpty } from '../../../overview/components/overview_empty';
import { NetworkHttpQueryTable } from './network_http_query_table';
import { NetworkTopCountriesQueryTable } from './network_top_countries_query_table';
import { NetworkTopNFlowQueryTable } from './network_top_n_flow_query_table';
Expand All @@ -50,6 +49,7 @@ import { networkModel } from '../../store';
import { SecurityPageName } from '../../../app/types';
import { useSourcererDataView } from '../../../common/containers/sourcerer';
import { useInvalidFilterQuery } from '../../../common/hooks/use_invalid_filter_query';
import { LandingPageComponent } from '../../../common/components/landing_page';
export { getBreadcrumbs } from './utils';

const NetworkDetailsManage = manageQuery(IpOverview);
Expand Down Expand Up @@ -301,9 +301,7 @@ const NetworkDetailsComponent: React.FC = () => {
</SecuritySolutionPageWrapper>
</>
) : (
<SecuritySolutionPageWrapper>
<OverviewEmpty />
</SecuritySolutionPageWrapper>
<LandingPageComponent />
)}

<SpyRoute pageName={SecurityPageName.network} />
Expand Down
Loading

0 comments on commit 73446a1

Please sign in to comment.