Skip to content

Commit

Permalink
[Security Solution] Remove Landing Pages sub-plugin (#157957)
Browse files Browse the repository at this point in the history
## Summary

This is a code cleaning to prepare for
#157847

This PR removes the Landing Pages sub-plugin without introducing any
noticeable change in the UX.
All the logic of the Landing Pages sub-plugin has been relocated to the
proper Explore and Management sub-plugins.
The Dashboard sub-plugin landing page was also relocated in a previous
PR.

The common components used by the different landing page components
(`LandingLinksIcons` and `LandingLinksImages`) have been relocated to
_public/common/components/landing_links/*_.

### Benefits

Cleaning of a non-necessary sub-plugin.

Each Security sub-team will now own its landing page component, route,
and link configuration.

More consistent directory organization, and less complexity.
  • Loading branch information
semd authored May 17, 2023
1 parent 0bd0463 commit f9f2d38
Show file tree
Hide file tree
Showing 23 changed files with 101 additions and 188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

import { render } from '@testing-library/react';
import React from 'react';
import { SecurityPageName } from '../../app/types';
import type { NavLinkItem } from '../../common/components/navigation/types';
import { TestProviders } from '../../common/mock';
import { SecurityPageName } from '../../../app/types';
import type { NavLinkItem } from '../navigation/types';
import { TestProviders } from '../../mock';
import { LandingLinksIcons } from './landing_links_icons';
import * as telemetry from '../../common/lib/telemetry';
import * as telemetry from '../../lib/telemetry';

const DEFAULT_NAV_ITEM: NavLinkItem = {
id: SecurityPageName.overview,
Expand All @@ -22,8 +22,8 @@ const DEFAULT_NAV_ITEM: NavLinkItem = {
const spyTrack = jest.spyOn(telemetry, 'track');

const mockNavigateTo = jest.fn();
jest.mock('../../common/lib/kibana', () => {
const originalModule = jest.requireActual('../../common/lib/kibana');
jest.mock('../../lib/kibana', () => {
const originalModule = jest.requireActual('../../lib/kibana');
return {
...originalModule,
useNavigateTo: () => ({
Expand All @@ -32,8 +32,8 @@ jest.mock('../../common/lib/kibana', () => {
};
});

jest.mock('../../common/components/link_to', () => {
const originalModule = jest.requireActual('../../common/components/link_to');
jest.mock('../link_to', () => {
const originalModule = jest.requireActual('../link_to');
return {
...originalModule,
useGetSecuritySolutionUrl: () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ import { EuiFlexGrid, EuiFlexGroup, EuiFlexItem, EuiIcon, EuiText, EuiTitle } fr
import React from 'react';
import styled from 'styled-components';

import { NavItemBetaBadge } from '../../common/components/navigation/nav_item_beta_badge';
import {
SecuritySolutionLinkAnchor,
withSecuritySolutionLink,
} from '../../common/components/links';
import type { NavLinkItem } from '../../common/components/navigation/types';
import { METRIC_TYPE, TELEMETRY_EVENT, track } from '../../common/lib/telemetry';
import { NavItemBetaBadge } from '../navigation/nav_item_beta_badge';
import { SecuritySolutionLinkAnchor, withSecuritySolutionLink } from '../links';
import type { NavLinkItem } from '../navigation/types';
import { METRIC_TYPE, TELEMETRY_EVENT, track } from '../../lib/telemetry';

interface LandingLinksImagesProps {
items: NavLinkItem[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import { render } from '@testing-library/react';
import React from 'react';
import { BETA } from '@kbn/kubernetes-security-plugin/common/translations';
import { SecurityPageName } from '../../app/types';
import type { NavLinkItem } from '../../common/components/navigation/types';
import { TestProviders } from '../../common/mock';
import { SecurityPageName } from '../../../app/types';
import type { NavLinkItem } from '../navigation/types';
import { TestProviders } from '../../mock';
import { LandingLinksImages, LandingImageCards } from './landing_links_images';
import * as telemetry from '../../common/lib/telemetry';
import * as telemetry from '../../lib/telemetry';

const DEFAULT_NAV_ITEM: NavLinkItem = {
id: SecurityPageName.overview,
Expand All @@ -29,7 +29,7 @@ const BETA_NAV_ITEM: NavLinkItem = {
isBeta: true,
};

jest.mock('../../common/lib/kibana/kibana_react', () => {
jest.mock('../../lib/kibana/kibana_react', () => {
return {
useKibana: jest.fn().mockReturnValue({
services: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import {
import { METRIC_TYPE } from '@kbn/analytics';
import React from 'react';
import styled from 'styled-components';
import { withSecuritySolutionLink } from '../../common/components/links';
import { NavItemBetaBadge } from '../../common/components/navigation/nav_item_beta_badge';
import type { NavLinkItem } from '../../common/components/navigation/types';
import { TELEMETRY_EVENT, track } from '../../common/lib/telemetry';
import { withSecuritySolutionLink } from '../links';
import { NavItemBetaBadge } from '../navigation/nav_item_beta_badge';
import type { NavLinkItem } from '../navigation/types';
import { TELEMETRY_EVENT, track } from '../../lib/telemetry';

interface LandingImagesProps {
items: NavLinkItem[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { links as detectionLinks } from '../../detections/links';
import { links as timelinesLinks } from '../../timelines/links';
import { getCasesLinkItems } from '../../cases/links';
import { links as managementLinks, getManagementFilteredLinks } from '../../management/links';
import { threatHuntingLandingLinks } from '../../landing_pages/links';
import { exploreLinks } from '../../explore/links';
import { gettingStartedLinks } from '../../overview/links';
import { rootLinks as cloudSecurityPostureRootLinks } from '../../cloud_security_posture/links';
import type { StartPlugins } from '../../types';
Expand All @@ -25,10 +25,10 @@ export const links = Object.freeze([
cloudSecurityPostureRootLinks,
timelinesLinks,
casesLinks,
threatHuntingLandingLinks,
exploreLinks,
indicatorsLinks,
gettingStartedLinks,
managementLinks,
indicatorsLinks,
]);

export const getFilteredLinks = async (
Expand All @@ -43,9 +43,9 @@ export const getFilteredLinks = async (
cloudSecurityPostureRootLinks,
timelinesLinks,
casesLinks,
threatHuntingLandingLinks,
exploreLinks,
indicatorsLinks,
gettingStartedLinks,
managementFilteredLinks,
indicatorsLinks,
]);
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { DashboardCapabilities } from '@kbn/dashboard-plugin/common/types';
import { LEGACY_DASHBOARD_APP_ID } from '@kbn/dashboard-plugin/public';
import { SecuritySolutionPageWrapper } from '../../../common/components/page_wrapper';
import { SpyRoute } from '../../../common/utils/route/spy_routes';
import { LandingImageCards } from '../../../landing_pages/components/landing_links_images';
import { LandingImageCards } from '../../../common/components/landing_links/landing_links_images';
import { SecurityPageName } from '../../../../common/constants';
import { useCapabilities, useNavigateTo } from '../../../common/lib/kibana';
import { useRootNavLink } from '../../../common/links/nav_links';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
* 2.0.
*/
import React from 'react';
import { SecurityPageName } from '../../app/types';
import { HeaderPage } from '../../common/components/header_page';
import { useRootNavLink } from '../../common/links/nav_links';
import { SecuritySolutionPageWrapper } from '../../common/components/page_wrapper';
import { SpyRoute } from '../../common/utils/route/spy_routes';
import { LandingLinksImages } from '../components/landing_links_images';
import { EXPLORE_PAGE_TITLE } from './translations';
import { i18n } from '@kbn/i18n';
import { SecurityPageName } from '../app/types';
import { HeaderPage } from '../common/components/header_page';
import { useRootNavLink } from '../common/links/nav_links';
import { SecuritySolutionPageWrapper } from '../common/components/page_wrapper';
import { SpyRoute } from '../common/utils/route/spy_routes';
import { LandingLinksImages } from '../common/components/landing_links/landing_links_images';

const EXPLORE_PAGE_TITLE = i18n.translate('xpack.securitySolution.explore.landing.pageTitle', {
defaultMessage: 'Explore',
});

export const ExploreLandingPage = () => {
const exploreLinks = useRootNavLink(SecurityPageName.exploreLanding)?.links ?? [];
Expand Down
26 changes: 23 additions & 3 deletions x-pack/plugins/security_solution/public/explore/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,15 @@
*/

import { i18n } from '@kbn/i18n';
import { HOSTS_PATH, NETWORK_PATH, SecurityPageName, USERS_PATH } from '../../common/constants';
import { HOSTS, NETWORK, USERS } from '../app/translations';
import {
HOSTS_PATH,
NETWORK_PATH,
USERS_PATH,
EXPLORE_PATH,
SERVER_APP_ID,
SecurityPageName,
} from '../../common/constants';
import { EXPLORE, HOSTS, NETWORK, USERS } from '../app/translations';
import type { LinkItem } from '../common/links/types';
import hostsPageImg from '../common/images/hosts_page.png';
import userPageImg from '../common/images/users_page.png';
Expand Down Expand Up @@ -169,4 +176,17 @@ const hostsLinks: LinkItem = {
],
};

export const exploreLinks = [hostsLinks, networkLinks, usersLinks];
export const exploreLinks: LinkItem = {
id: SecurityPageName.exploreLanding,
title: EXPLORE,
path: EXPLORE_PATH,
globalNavPosition: 6,
capabilities: [`${SERVER_APP_ID}.show`],
globalSearchKeywords: [
i18n.translate('xpack.securitySolution.appLinks.explore', {
defaultMessage: 'Explore',
}),
],
links: [hostsLinks, networkLinks, usersLinks],
skipUrlState: true,
};
16 changes: 15 additions & 1 deletion x-pack/plugins/security_solution/public/explore/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,17 @@ import { NetworkContainer } from './network/pages';

import type { SecuritySubPluginRoutes } from '../app/types';
import { SecurityPageName } from '../app/types';
import { HOSTS_PATH, NETWORK_PATH, USERS_PATH } from '../../common/constants';
import { EXPLORE_PATH, HOSTS_PATH, NETWORK_PATH, USERS_PATH } from '../../common/constants';
import { PluginTemplateWrapper } from '../common/components/plugin_template_wrapper';
import { ExploreLandingPage } from './landing';

const ExploreLanding = () => (
<PluginTemplateWrapper>
<TrackApplicationView viewId={SecurityPageName.exploreLanding}>
<ExploreLandingPage />
</TrackApplicationView>
</PluginTemplateWrapper>
);

const NetworkRoutes = () => (
<PluginTemplateWrapper>
Expand All @@ -41,6 +50,11 @@ const HostsRoutes = () => (
);

export const routes: SecuritySubPluginRoutes = [
{
path: EXPLORE_PATH,
exact: true,
component: ExploreLanding,
},
{
path: NETWORK_PATH,
component: NetworkRoutes,
Expand Down
19 changes: 0 additions & 19 deletions x-pack/plugins/security_solution/public/landing_pages/index.ts

This file was deleted.

This file was deleted.

28 changes: 0 additions & 28 deletions x-pack/plugins/security_solution/public/landing_pages/links.ts

This file was deleted.

This file was deleted.

43 changes: 0 additions & 43 deletions x-pack/plugins/security_solution/public/landing_pages/routes.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions x-pack/plugins/security_solution/public/lazy_sub_plugins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { Overview } from './overview';
import { Rules } from './rules';
import { Timelines } from './timelines';
import { Management } from './management';
import { LandingPages } from './landing_pages';
import { CloudDefend } from './cloud_defend';
import { CloudSecurityPosture } from './cloud_security_posture';
import { ThreatIntelligence } from './threat_intelligence';
Expand All @@ -38,7 +37,6 @@ const subPluginClasses = {
Rules,
Timelines,
Management,
LandingPages,
Dashboards,
CloudDefend,
CloudSecurityPosture,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { render } from '@testing-library/react';
import React from 'react';
import { SecurityPageName } from '../../app/types';
import { TestProviders } from '../../common/mock';
import { ManagementCategories } from './manage';
import { ManagementCategories } from './landing';
import type { NavigationLink } from '../../common/links';

const RULES_ITEM_LABEL = 'elastic rules!';
Expand Down
Loading

0 comments on commit f9f2d38

Please sign in to comment.