Skip to content

Commit

Permalink
feature on child deep links not required
Browse files Browse the repository at this point in the history
  • Loading branch information
semd committed Oct 26, 2021
1 parent 3a75ef4 commit 5a92c94
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions x-pack/plugins/security_solution/public/app/deep_links/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { i18n } from '@kbn/i18n';

import { isEmpty, get } from 'lodash';
import { get } from 'lodash';
import { LicenseType } from '../../../../licensing/common/types';
import { SecurityPageName } from '../types';
import { AppDeepLink, AppNavLinkStatus, Capabilities } from '../../../../../../src/core/public';
Expand Down Expand Up @@ -95,7 +95,6 @@ export const securitySolutionsDeepLinks: SecuritySolutionDeepLink[] = [
title: ALERTS,
path: ALERTS_PATH,
navLinkStatus: AppNavLinkStatus.visible,
features: [FEATURE.general],
keywords: [
i18n.translate('xpack.securitySolution.search.alerts', {
defaultMessage: 'Alerts',
Expand All @@ -109,7 +108,6 @@ export const securitySolutionsDeepLinks: SecuritySolutionDeepLink[] = [
title: RULES,
path: RULES_PATH,
navLinkStatus: AppNavLinkStatus.hidden,
features: [FEATURE.general],
keywords: [
i18n.translate('xpack.securitySolution.search.rules', {
defaultMessage: 'Rules',
Expand All @@ -122,7 +120,6 @@ export const securitySolutionsDeepLinks: SecuritySolutionDeepLink[] = [
title: EXCEPTIONS,
path: EXCEPTIONS_PATH,
navLinkStatus: AppNavLinkStatus.hidden,
features: [FEATURE.general],
keywords: [
i18n.translate('xpack.securitySolution.search.exceptions', {
defaultMessage: 'Exceptions',
Expand All @@ -148,7 +145,6 @@ export const securitySolutionsDeepLinks: SecuritySolutionDeepLink[] = [
title: HOSTS,
path: HOSTS_PATH,
navLinkStatus: AppNavLinkStatus.visible,
features: [FEATURE.general],
keywords: [
i18n.translate('xpack.securitySolution.search.hosts', {
defaultMessage: 'Hosts',
Expand All @@ -162,39 +158,34 @@ export const securitySolutionsDeepLinks: SecuritySolutionDeepLink[] = [
defaultMessage: 'Authentications',
}),
path: `${HOSTS_PATH}/authentications`,
features: [FEATURE.general],
},
{
id: SecurityPageName.uncommonProcesses,
title: i18n.translate('xpack.securitySolution.search.hosts.uncommonProcesses', {
defaultMessage: 'Uncommon Processes',
}),
path: `${HOSTS_PATH}/uncommonProcesses`,
features: [FEATURE.general],
},
{
id: SecurityPageName.events,
title: i18n.translate('xpack.securitySolution.search.hosts.events', {
defaultMessage: 'Events',
}),
path: `${HOSTS_PATH}/events`,
features: [FEATURE.general],
},
{
id: SecurityPageName.hostsExternalAlerts,
title: i18n.translate('xpack.securitySolution.search.hosts.externalAlerts', {
defaultMessage: 'External Alerts',
}),
path: `${HOSTS_PATH}/externalAlerts`,
features: [FEATURE.general],
},
{
id: SecurityPageName.hostsAnomalies,
title: i18n.translate('xpack.securitySolution.search.hosts.anomalies', {
defaultMessage: 'Anomalies',
}),
path: `${HOSTS_PATH}/anomalies`,
features: [FEATURE.general],
isPremium: true,
},
],
Expand All @@ -204,7 +195,6 @@ export const securitySolutionsDeepLinks: SecuritySolutionDeepLink[] = [
title: NETWORK,
path: NETWORK_PATH,
navLinkStatus: AppNavLinkStatus.visible,
features: [FEATURE.general],
keywords: [
i18n.translate('xpack.securitySolution.search.network', {
defaultMessage: 'Network',
Expand All @@ -218,39 +208,34 @@ export const securitySolutionsDeepLinks: SecuritySolutionDeepLink[] = [
defaultMessage: 'DNS',
}),
path: `${NETWORK_PATH}/dns`,
features: [FEATURE.general],
},
{
id: SecurityPageName.networkHttp,
title: i18n.translate('xpack.securitySolution.search.network.http', {
defaultMessage: 'HTTP',
}),
path: `${NETWORK_PATH}/http`,
features: [FEATURE.general],
},
{
id: SecurityPageName.networkTls,
title: i18n.translate('xpack.securitySolution.search.network.tls', {
defaultMessage: 'TLS',
}),
path: `${NETWORK_PATH}/tls`,
features: [FEATURE.general],
},
{
id: SecurityPageName.networkExternalAlerts,
title: i18n.translate('xpack.securitySolution.search.network.externalAlerts', {
defaultMessage: 'External Alerts',
}),
path: `${NETWORK_PATH}/external-alerts`,
features: [FEATURE.general],
},
{
id: SecurityPageName.networkAnomalies,
title: i18n.translate('xpack.securitySolution.search.hosts.anomalies', {
defaultMessage: 'Anomalies',
}),
path: `${NETWORK_PATH}/anomalies`,
features: [FEATURE.general],
isPremium: true,
},
],
Expand Down Expand Up @@ -301,7 +286,6 @@ export const securitySolutionsDeepLinks: SecuritySolutionDeepLink[] = [
defaultMessage: 'Templates',
}),
path: `${TIMELINES_PATH}/template`,
features: [FEATURE.general],
},
],
},
Expand Down Expand Up @@ -357,25 +341,21 @@ export const securitySolutionsDeepLinks: SecuritySolutionDeepLink[] = [
title: ENDPOINTS,
order: 9006,
path: ENDPOINTS_PATH,
features: [FEATURE.general],
},
{
id: SecurityPageName.trustedApps,
title: TRUSTED_APPLICATIONS,
path: TRUSTED_APPS_PATH,
features: [FEATURE.general],
},
{
id: SecurityPageName.eventFilters,
title: EVENT_FILTERS,
path: EVENT_FILTERS_PATH,
features: [FEATURE.general],
},
{
id: SecurityPageName.hostIsolationExceptions,
title: HOST_ISOLATION_EXCEPTIONS,
path: HOST_ISOLATION_EXCEPTIONS_PATH,
features: [FEATURE.general],
},
],
},
Expand Down Expand Up @@ -404,7 +384,7 @@ export function getDeepLinks(
if (experimentalKey && !enableExperimental[experimentalKey]) {
return deepLinks;
}
if (capabilities != null && !hasFeaturesCapability(features ?? [], capabilities)) {
if (capabilities != null && !hasFeaturesCapability(features, capabilities)) {
return deepLinks;
}
if (deepLink.deepLinks) {
Expand All @@ -419,9 +399,12 @@ export function getDeepLinks(
return filterDeepLinks(securitySolutionsDeepLinks);
}

function hasFeaturesCapability(features: Feature[], capabilities: Capabilities): boolean {
if (isEmpty(features)) {
return false;
function hasFeaturesCapability(
features: Feature[] | undefined,
capabilities: Capabilities
): boolean {
if (!features) {
return true;
}
return features.some((featureKey) => get(capabilities, featureKey, false));
}
Expand Down

0 comments on commit 5a92c94

Please sign in to comment.