From 37dee75e3122ba8cf818e957fe84b1f0bf8343cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 20 Mar 2024 12:39:47 +0000 Subject: [PATCH] [Stateful sidenav] Add deeplink definitions & hide page side nav (#178861) --- .github/CODEOWNERS | 5 +- .i18nrc.json | 5 +- config/serverless.security.yml | 1 - package.json | 3 + .../project_navigation_service.ts | 4 +- .../ui/solution_nav_switcher_breadcrumbs.tsx | 3 +- .../src/project_navigation.ts | 13 ++- .../chrome/core-chrome-browser/tsconfig.json | 5 +- packages/deeplinks/fleet/README.md | 3 + packages/deeplinks/fleet/deep_links.ts | 21 +++++ packages/deeplinks/fleet/index.ts | 9 ++ packages/deeplinks/fleet/jest.config.js | 13 +++ packages/deeplinks/fleet/kibana.jsonc | 5 ++ packages/deeplinks/fleet/package.json | 6 ++ packages/deeplinks/fleet/tsconfig.json | 19 +++++ packages/deeplinks/management/deep_links.ts | 9 ++ packages/deeplinks/security/README.md | 3 + packages/deeplinks/security/deep_links.ts | 84 +++++++++++++++++++ packages/deeplinks/security/index.ts | 19 +++++ packages/deeplinks/security/jest.config.js | 13 +++ packages/deeplinks/security/kibana.jsonc | 5 ++ packages/deeplinks/security/package.json | 6 ++ packages/deeplinks/security/tsconfig.json | 19 +++++ packages/deeplinks/shared/README.md | 3 + packages/deeplinks/shared/deep_links.ts | 13 +++ packages/deeplinks/shared/index.ts | 9 ++ packages/deeplinks/shared/jest.config.js | 13 +++ packages/deeplinks/shared/kibana.jsonc | 5 ++ packages/deeplinks/shared/package.json | 6 ++ packages/deeplinks/shared/tsconfig.json | 19 +++++ src/plugins/management/public/mocks/index.ts | 1 - src/plugins/management/public/plugin.tsx | 8 +- src/plugins/management/public/types.ts | 1 - src/plugins/navigation/public/plugin.tsx | 31 +------ tsconfig.base.json | 6 ++ .../navigation/src/constants.ts | 77 +---------------- .../navigation/tsconfig.json | 1 + x-pack/plugins/ml/public/application/app.tsx | 8 +- .../contexts/ml/serverless_context.tsx | 4 +- .../observability_shared/public/plugin.ts | 8 +- .../security_solution/public/plugin.tsx | 15 +++- .../public/navigation/index.ts | 3 +- .../serverless_observability/kibana.jsonc | 5 +- .../serverless_observability/public/plugin.ts | 4 +- .../serverless_search/public/plugin.ts | 1 - yarn.lock | 12 +++ 46 files changed, 392 insertions(+), 134 deletions(-) create mode 100644 packages/deeplinks/fleet/README.md create mode 100644 packages/deeplinks/fleet/deep_links.ts create mode 100644 packages/deeplinks/fleet/index.ts create mode 100644 packages/deeplinks/fleet/jest.config.js create mode 100644 packages/deeplinks/fleet/kibana.jsonc create mode 100644 packages/deeplinks/fleet/package.json create mode 100644 packages/deeplinks/fleet/tsconfig.json create mode 100644 packages/deeplinks/security/README.md create mode 100644 packages/deeplinks/security/deep_links.ts create mode 100644 packages/deeplinks/security/index.ts create mode 100644 packages/deeplinks/security/jest.config.js create mode 100644 packages/deeplinks/security/kibana.jsonc create mode 100644 packages/deeplinks/security/package.json create mode 100644 packages/deeplinks/security/tsconfig.json create mode 100644 packages/deeplinks/shared/README.md create mode 100644 packages/deeplinks/shared/deep_links.ts create mode 100644 packages/deeplinks/shared/index.ts create mode 100644 packages/deeplinks/shared/jest.config.js create mode 100644 packages/deeplinks/shared/kibana.jsonc create mode 100644 packages/deeplinks/shared/package.json create mode 100644 packages/deeplinks/shared/tsconfig.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5df9411929677..1c33310d98de5 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -339,10 +339,13 @@ x-pack/plugins/observability_solution/dataset_quality @elastic/obs-ux-logs-team packages/kbn-datemath @elastic/kibana-data-discovery packages/deeplinks/analytics @elastic/kibana-data-discovery @elastic/kibana-presentation @elastic/kibana-visualizations packages/deeplinks/devtools @elastic/kibana-management +packages/deeplinks/fleet @elastic/fleet packages/deeplinks/management @elastic/kibana-management packages/deeplinks/ml @elastic/ml-ui packages/deeplinks/observability @elastic/obs-ux-logs-team packages/deeplinks/search @elastic/enterprise-search-frontend +packages/deeplinks/security @elastic/security-solution +packages/deeplinks/shared @elastic/appex-sharedux packages/default-nav/analytics @elastic/kibana-data-discovery @elastic/kibana-presentation @elastic/kibana-visualizations packages/default-nav/devtools @elastic/kibana-management packages/default-nav/management @elastic/kibana-management @@ -722,7 +725,7 @@ packages/kbn-server-http-tools @elastic/kibana-core packages/kbn-server-route-repository @elastic/obs-knowledge-team x-pack/plugins/serverless @elastic/appex-sharedux packages/serverless/settings/common @elastic/appex-sharedux @elastic/kibana-management -x-pack/plugins/serverless_observability @elastic/appex-sharedux @elastic/obs-ux-management-team +x-pack/plugins/serverless_observability @elastic/obs-ux-management-team packages/serverless/settings/observability_project @elastic/appex-sharedux @elastic/kibana-management @elastic/obs-ux-management-team packages/serverless/project_switcher @elastic/appex-sharedux x-pack/plugins/serverless_search @elastic/enterprise-search-frontend diff --git a/.i18nrc.json b/.i18nrc.json index 1f9a4e193decc..adac4ebac3811 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -89,7 +89,10 @@ "packages/kbn-management" ], "monaco": "packages/kbn-monaco/src", - "navigation": "src/plugins/navigation", + "navigation": [ + "src/plugins/navigation", + "packages/solution-nav" + ], "links": "src/plugins/links", "newsfeed": "src/plugins/newsfeed", "presentationUtil": "src/plugins/presentation_util", diff --git a/config/serverless.security.yml b/config/serverless.security.yml index 8319f38da9cf6..b5b3c9b436638 100644 --- a/config/serverless.security.yml +++ b/config/serverless.security.yml @@ -20,7 +20,6 @@ xpack.securitySolutionServerless.productTypes: ] xpack.securitySolution.offeringSettings: { - sideNavEnabled: false, # Internal security side navigation disabled, the serverless global chrome navigation is used instead ILMEnabled: false, # Index Lifecycle Management (ILM) functionalities disabled, not supported by serverless Elasticsearch ESQLEnabled: false, # ES|QL disabled, not supported by serverless Elasticsearch } diff --git a/package.json b/package.json index a08bf29df358a..5bb6a0cd6664d 100644 --- a/package.json +++ b/package.json @@ -392,10 +392,13 @@ "@kbn/datemath": "link:packages/kbn-datemath", "@kbn/deeplinks-analytics": "link:packages/deeplinks/analytics", "@kbn/deeplinks-devtools": "link:packages/deeplinks/devtools", + "@kbn/deeplinks-fleet": "link:packages/deeplinks/fleet", "@kbn/deeplinks-management": "link:packages/deeplinks/management", "@kbn/deeplinks-ml": "link:packages/deeplinks/ml", "@kbn/deeplinks-observability": "link:packages/deeplinks/observability", "@kbn/deeplinks-search": "link:packages/deeplinks/search", + "@kbn/deeplinks-security": "link:packages/deeplinks/security", + "@kbn/deeplinks-shared": "link:packages/deeplinks/shared", "@kbn/default-nav-analytics": "link:packages/default-nav/analytics", "@kbn/default-nav-devtools": "link:packages/default-nav/devtools", "@kbn/default-nav-management": "link:packages/default-nav/management", diff --git a/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/project_navigation_service.ts b/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/project_navigation_service.ts index 15ebb6f499d42..73b789b5bf349 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/project_navigation_service.ts +++ b/packages/core/chrome/core-chrome-browser-internal/src/project_navigation/project_navigation_service.ts @@ -230,6 +230,7 @@ export class ProjectNavigationService { this.navigationChangeSubscription.unsubscribe(); } + let redirectLocation = location; this.projectNavigationNavTreeFlattened = {}; this.navigationChangeSubscription = combineLatest([ navTreeDefinition$, @@ -251,7 +252,8 @@ export class ProjectNavigationService { this.navigationTreeUi$.next(navigationTreeUI); this.projectNavigationNavTreeFlattened = flattenNav(navigationTree); - this.updateActiveProjectNavigationNodes(location); + this.updateActiveProjectNavigationNodes(redirectLocation); + redirectLocation = undefined; // we don't want to redirect on subsequent changes, only when initiating }, error: (err) => { this.logger?.error(err); diff --git a/packages/core/chrome/core-chrome-browser-internal/src/ui/solution_nav_switcher_breadcrumbs.tsx b/packages/core/chrome/core-chrome-browser-internal/src/ui/solution_nav_switcher_breadcrumbs.tsx index da9b105b7355b..a536cb0e0bfd8 100644 --- a/packages/core/chrome/core-chrome-browser-internal/src/ui/solution_nav_switcher_breadcrumbs.tsx +++ b/packages/core/chrome/core-chrome-browser-internal/src/ui/solution_nav_switcher_breadcrumbs.tsx @@ -29,7 +29,7 @@ export const getSolutionNavSwitcherBreadCrumb = ({ return { text, 'data-test-subj': 'solutionNavSwitcher', - popoverContent: ( + popoverContent: (closePopover) => ( <>

@@ -49,6 +49,7 @@ export const getSolutionNavSwitcherBreadCrumb = ({ data-test-subj={`solutionNavSwitcher-${id}`} onClick={() => { onChange(id, { redirect: true }); + closePopover(); }} />, ])} diff --git a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts index 463bb473ee7ae..f2e5a87afc88d 100644 --- a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts +++ b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts @@ -25,6 +25,9 @@ import type { AppId as ObservabilityApp, DeepLinkId as ObservabilityLink, } from '@kbn/deeplinks-observability'; +import type { AppId as SecurityApp, DeepLinkId as SecurityLink } from '@kbn/deeplinks-security'; +import type { AppId as FleetApp, DeepLinkId as FleetLink } from '@kbn/deeplinks-fleet'; +import type { AppId as SharedApp, DeepLinkId as SharedLink } from '@kbn/deeplinks-shared'; import type { ChromeBreadcrumb } from './breadcrumb'; import type { ChromeNavLink } from './nav_links'; @@ -37,7 +40,10 @@ export type AppId = | MlApp | ManagementApp | SearchApp - | ObservabilityApp; + | ObservabilityApp + | SecurityApp + | FleetApp + | SharedApp; /** @public */ export type AppDeepLinkId = @@ -46,7 +52,10 @@ export type AppDeepLinkId = | MlLink | ManagementLink | SearchLink - | ObservabilityLink; + | ObservabilityLink + | SecurityLink + | FleetLink + | SharedLink; /** @public */ export type CloudLinkId = diff --git a/packages/core/chrome/core-chrome-browser/tsconfig.json b/packages/core/chrome/core-chrome-browser/tsconfig.json index 5878b7d51f3be..03ae62928c03e 100644 --- a/packages/core/chrome/core-chrome-browser/tsconfig.json +++ b/packages/core/chrome/core-chrome-browser/tsconfig.json @@ -20,7 +20,10 @@ "@kbn/deeplinks-management", "@kbn/deeplinks-search", "@kbn/deeplinks-observability", - "@kbn/core-application-browser" + "@kbn/core-application-browser", + "@kbn/deeplinks-security", + "@kbn/deeplinks-fleet", + "@kbn/deeplinks-shared" ], "exclude": [ "target/**/*", diff --git a/packages/deeplinks/fleet/README.md b/packages/deeplinks/fleet/README.md new file mode 100644 index 0000000000000..6669f4c61fe62 --- /dev/null +++ b/packages/deeplinks/fleet/README.md @@ -0,0 +1,3 @@ +# @kbn/deeplinks-fleet + +Empty package generated by @kbn/generate diff --git a/packages/deeplinks/fleet/deep_links.ts b/packages/deeplinks/fleet/deep_links.ts new file mode 100644 index 0000000000000..652ff887a8e33 --- /dev/null +++ b/packages/deeplinks/fleet/deep_links.ts @@ -0,0 +1,21 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export const FLEET_APP_ID = 'fleet'; + +export type AppId = typeof FLEET_APP_ID; + +export type LinkId = + | 'agents' + | 'policies' + | 'enrollment_tokens' + | 'uninstall_tokens' + | 'data_streams' + | 'settings'; + +export type DeepLinkId = AppId | `${AppId}:${LinkId}`; diff --git a/packages/deeplinks/fleet/index.ts b/packages/deeplinks/fleet/index.ts new file mode 100644 index 0000000000000..364799992aff7 --- /dev/null +++ b/packages/deeplinks/fleet/index.ts @@ -0,0 +1,9 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export type { LinkId, AppId, DeepLinkId } from './deep_links'; diff --git a/packages/deeplinks/fleet/jest.config.js b/packages/deeplinks/fleet/jest.config.js new file mode 100644 index 0000000000000..17b66d9b0059e --- /dev/null +++ b/packages/deeplinks/fleet/jest.config.js @@ -0,0 +1,13 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../..', + roots: ['/packages/deeplinks/fleet'], +}; diff --git a/packages/deeplinks/fleet/kibana.jsonc b/packages/deeplinks/fleet/kibana.jsonc new file mode 100644 index 0000000000000..2190110ac778c --- /dev/null +++ b/packages/deeplinks/fleet/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/deeplinks-fleet", + "owner": "@elastic/fleet" +} diff --git a/packages/deeplinks/fleet/package.json b/packages/deeplinks/fleet/package.json new file mode 100644 index 0000000000000..f26bfa9e6ac3c --- /dev/null +++ b/packages/deeplinks/fleet/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/deeplinks-fleet", + "private": true, + "version": "1.0.0", + "license": "SSPL-1.0 OR Elastic License 2.0" +} \ No newline at end of file diff --git a/packages/deeplinks/fleet/tsconfig.json b/packages/deeplinks/fleet/tsconfig.json new file mode 100644 index 0000000000000..d1414086f2187 --- /dev/null +++ b/packages/deeplinks/fleet/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", + "react" + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [] +} diff --git a/packages/deeplinks/management/deep_links.ts b/packages/deeplinks/management/deep_links.ts index 2b055f42e214e..a1f1a232c154b 100644 --- a/packages/deeplinks/management/deep_links.ts +++ b/packages/deeplinks/management/deep_links.ts @@ -33,15 +33,22 @@ export type ManagementId = | 'cases' | 'cross_cluster_replication' | 'dataViews' + | 'filesManagement' + | 'license_management' | 'index_lifecycle_management' | 'index_management' | 'ingest_pipelines' | 'jobsListLink' + | 'maintenanceWindows' + | 'migrate_data' | 'objects' | 'pipelines' | 'remote_clusters' | 'reporting' + | 'role_mappings' + | 'roles' | 'rollup_jobs' + | 'search_sessions' | 'settings' | 'snapshot_restore' | 'spaces' @@ -49,6 +56,8 @@ export type ManagementId = | 'transform' | 'triggersActions' | 'triggersActionsConnectors' + | 'upgrade_assistant' + | 'users' | 'watcher'; export type ManagementDeepLinkId = MonitoringAppId | `${ManagementAppId}:${ManagementId}`; diff --git a/packages/deeplinks/security/README.md b/packages/deeplinks/security/README.md new file mode 100644 index 0000000000000..16cf64c6f7281 --- /dev/null +++ b/packages/deeplinks/security/README.md @@ -0,0 +1,3 @@ +# @kbn/deeplinks-security + +Empty package generated by @kbn/generate diff --git a/packages/deeplinks/security/deep_links.ts b/packages/deeplinks/security/deep_links.ts new file mode 100644 index 0000000000000..243476d52b4a5 --- /dev/null +++ b/packages/deeplinks/security/deep_links.ts @@ -0,0 +1,84 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export enum SecurityPageName { + administration = 'administration', + alerts = 'alerts', + assets = 'assets', + blocklist = 'blocklist', + /* + * Warning: Computed values are not permitted in an enum with string valued members + * All Cases page names must match `CasesDeepLinkId` in x-pack/plugins/cases/public/common/navigation/deep_links.ts + */ + case = 'cases', // must match `CasesDeepLinkId.cases` + caseConfigure = 'cases_configure', // must match `CasesDeepLinkId.casesConfigure` + caseCreate = 'cases_create', // must match `CasesDeepLinkId.casesCreate` + /* + * Warning: Computed values are not permitted in an enum with string valued members + * All cloud security posture page names must match `CloudSecurityPosturePageId` in x-pack/plugins/cloud_security_posture/public/common/navigation/types.ts + */ + cloudSecurityPostureBenchmarks = 'cloud_security_posture-benchmarks', + cloudSecurityPostureDashboard = 'cloud_security_posture-dashboard', + cloudSecurityPostureFindings = 'cloud_security_posture-findings', + cloudSecurityPostureRules = 'cloud_security_posture-rules', + /* + * Warning: Computed values are not permitted in an enum with string valued members + * All cloud defend page names must match `CloudDefendPageId` in x-pack/plugins/cloud_defend/public/common/navigation/types.ts + */ + cloudDefend = 'cloud_defend', + cloudDefendPolicies = 'cloud_defend-policies', + dashboards = 'dashboards', + dataQuality = 'data_quality', + detections = 'detections', + detectionAndResponse = 'detection_response', + endpoints = 'endpoints', + eventFilters = 'event_filters', + exceptions = 'exceptions', + exploreLanding = 'explore', + hostIsolationExceptions = 'host_isolation_exceptions', + hosts = 'hosts', + hostsAnomalies = 'hosts-anomalies', + hostsRisk = 'hosts-risk', + hostsEvents = 'hosts-events', + investigations = 'investigations', + kubernetes = 'kubernetes', + landing = 'get_started', + mlLanding = 'machine_learning-landing', // serverless only + network = 'network', + networkAnomalies = 'network-anomalies', + networkDns = 'network-dns', + networkEvents = 'network-events', + networkHttp = 'network-http', + networkTls = 'network-tls', + noPage = '', + overview = 'overview', + policies = 'policy', + responseActionsHistory = 'response_actions_history', + rules = 'rules', + rulesAdd = 'rules-add', + rulesCreate = 'rules-create', + rulesLanding = 'rules-landing', + sessions = 'sessions', + /* + * Warning: Computed values are not permitted in an enum with string valued members + * All threat intelligence page names must match `TIPageId` in x-pack/plugins/threat_intelligence/public/common/navigation/types.ts + */ + threatIntelligence = 'threat_intelligence', + timelines = 'timelines', + timelinesTemplates = 'timelines-templates', + trustedApps = 'trusted_apps', + uncommonProcesses = 'uncommon_processes', + users = 'users', + usersAnomalies = 'users-anomalies', + usersAuthentications = 'users-authentications', + usersEvents = 'users-events', + usersRisk = 'users-risk', + entityAnalytics = 'entity_analytics', + entityAnalyticsManagement = 'entity_analytics-management', + coverageOverview = 'coverage-overview', +} diff --git a/packages/deeplinks/security/index.ts b/packages/deeplinks/security/index.ts new file mode 100644 index 0000000000000..53b412ecb05b5 --- /dev/null +++ b/packages/deeplinks/security/index.ts @@ -0,0 +1,19 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import type { SecurityPageName } from './deep_links'; + +export { SecurityPageName } from './deep_links'; + +export const SECURITY_APP_ID = 'securitySolutionUI'; + +export type AppId = typeof SECURITY_APP_ID; + +export type LinkId = `${SecurityPageName}`; + +export type DeepLinkId = AppId | `${AppId}:${LinkId}`; diff --git a/packages/deeplinks/security/jest.config.js b/packages/deeplinks/security/jest.config.js new file mode 100644 index 0000000000000..285bce61990ed --- /dev/null +++ b/packages/deeplinks/security/jest.config.js @@ -0,0 +1,13 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../..', + roots: ['/packages/deeplinks/security'], +}; diff --git a/packages/deeplinks/security/kibana.jsonc b/packages/deeplinks/security/kibana.jsonc new file mode 100644 index 0000000000000..42aefc7fdc3a0 --- /dev/null +++ b/packages/deeplinks/security/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/deeplinks-security", + "owner": "@elastic/security-solution" +} diff --git a/packages/deeplinks/security/package.json b/packages/deeplinks/security/package.json new file mode 100644 index 0000000000000..d8f0ae487a069 --- /dev/null +++ b/packages/deeplinks/security/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/deeplinks-security", + "private": true, + "version": "1.0.0", + "license": "SSPL-1.0 OR Elastic License 2.0" +} \ No newline at end of file diff --git a/packages/deeplinks/security/tsconfig.json b/packages/deeplinks/security/tsconfig.json new file mode 100644 index 0000000000000..d1414086f2187 --- /dev/null +++ b/packages/deeplinks/security/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", + "react" + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [] +} diff --git a/packages/deeplinks/shared/README.md b/packages/deeplinks/shared/README.md new file mode 100644 index 0000000000000..b46937f057673 --- /dev/null +++ b/packages/deeplinks/shared/README.md @@ -0,0 +1,3 @@ +# @kbn/deeplinks-shared + +Empty package generated by @kbn/generate diff --git a/packages/deeplinks/shared/deep_links.ts b/packages/deeplinks/shared/deep_links.ts new file mode 100644 index 0000000000000..f2f4fc5dcad0d --- /dev/null +++ b/packages/deeplinks/shared/deep_links.ts @@ -0,0 +1,13 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export const HOME_APP_ID = 'home'; + +export type AppId = typeof HOME_APP_ID; + +export type DeepLinkId = AppId; diff --git a/packages/deeplinks/shared/index.ts b/packages/deeplinks/shared/index.ts new file mode 100644 index 0000000000000..5999eebc2c4e7 --- /dev/null +++ b/packages/deeplinks/shared/index.ts @@ -0,0 +1,9 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export type { AppId, DeepLinkId } from './deep_links'; diff --git a/packages/deeplinks/shared/jest.config.js b/packages/deeplinks/shared/jest.config.js new file mode 100644 index 0000000000000..63b22bedbeedf --- /dev/null +++ b/packages/deeplinks/shared/jest.config.js @@ -0,0 +1,13 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../..', + roots: ['/packages/deeplinks/shared'], +}; diff --git a/packages/deeplinks/shared/kibana.jsonc b/packages/deeplinks/shared/kibana.jsonc new file mode 100644 index 0000000000000..c223a88e907fd --- /dev/null +++ b/packages/deeplinks/shared/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/deeplinks-shared", + "owner": "@elastic/appex-sharedux" +} diff --git a/packages/deeplinks/shared/package.json b/packages/deeplinks/shared/package.json new file mode 100644 index 0000000000000..99d57b502d97c --- /dev/null +++ b/packages/deeplinks/shared/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/deeplinks-shared", + "private": true, + "version": "1.0.0", + "license": "SSPL-1.0 OR Elastic License 2.0" +} \ No newline at end of file diff --git a/packages/deeplinks/shared/tsconfig.json b/packages/deeplinks/shared/tsconfig.json new file mode 100644 index 0000000000000..d1414086f2187 --- /dev/null +++ b/packages/deeplinks/shared/tsconfig.json @@ -0,0 +1,19 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", + "react" + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [] +} diff --git a/src/plugins/management/public/mocks/index.ts b/src/plugins/management/public/mocks/index.ts index 93ccefbe5130f..f6807e371057c 100644 --- a/src/plugins/management/public/mocks/index.ts +++ b/src/plugins/management/public/mocks/index.ts @@ -42,7 +42,6 @@ const createSetupContract = (): ManagementSetup => ({ }); const createStartContract = (): ManagementStart => ({ - setIsSidebarEnabled: jest.fn(), setupCardsNavigation: jest.fn(), }); diff --git a/src/plugins/management/public/plugin.tsx b/src/plugins/management/public/plugin.tsx index 060165e673d69..36c766e1493a4 100644 --- a/src/plugins/management/public/plugin.tsx +++ b/src/plugins/management/public/plugin.tsx @@ -138,6 +138,12 @@ export class ManagementPlugin }, }); + core.getStartServices().then(([coreStart]) => { + coreStart.chrome + .getChromeStyle$() + .subscribe((style) => this.isSidebarEnabled$.next(style === 'classic')); + }); + return { sections: this.managementSections.setup(), locator, @@ -160,8 +166,6 @@ export class ManagementPlugin } return { - setIsSidebarEnabled: (isSidebarEnabled: boolean) => - this.isSidebarEnabled$.next(isSidebarEnabled), setupCardsNavigation: ({ enabled, hideLinksTo, extendCardNavDefinitions }) => this.cardsNavigationConfig$.next({ enabled, hideLinksTo, extendCardNavDefinitions }), }; diff --git a/src/plugins/management/public/types.ts b/src/plugins/management/public/types.ts index 25b572ff4089e..264a4450e8f91 100644 --- a/src/plugins/management/public/types.ts +++ b/src/plugins/management/public/types.ts @@ -29,7 +29,6 @@ export interface DefinedSections { } export interface ManagementStart { - setIsSidebarEnabled: (enabled: boolean) => void; setupCardsNavigation: ({ enabled, hideLinksTo, diff --git a/src/plugins/navigation/public/plugin.tsx b/src/plugins/navigation/public/plugin.tsx index 9877e92675d19..c4b91615e3970 100644 --- a/src/plugins/navigation/public/plugin.tsx +++ b/src/plugins/navigation/public/plugin.tsx @@ -6,7 +6,7 @@ * Side Public License, v 1. */ import React from 'react'; -import { combineLatest, debounceTime, of, ReplaySubject, takeUntil } from 'rxjs'; +import { combineLatest, debounceTime, ReplaySubject, takeUntil } from 'rxjs'; import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; import type { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; import type { @@ -103,35 +103,6 @@ export class NavigationPublicPlugin chrome.project.setCloudUrls(cloud); this.addDefaultSolutionNavigation({ chrome }); this.susbcribeToSolutionNavUiSettings(core); - - // Temp. This is temporary to simulate adding a solution nav after bootstrapping - setTimeout(() => { - this.addSolutionNavigation({ - id: 'security', - title: 'Security', - icon: 'logoSecurity', - homePage: 'dashboards', // Temp. Wil be updated when all links are registered - navigationTree$: of({ - body: [ - // Temp. In future work this will be loaded from a package - { - type: 'navGroup', - id: 'security_project_nav', - title: 'Security', - icon: 'logoSecurity', - breadcrumbStatus: 'hidden', - defaultIsCollapsed: false, - children: [ - { - link: 'dashboards', - spaceBefore: 'm', - }, - ], - }, - ], - }), - }); - }, 5000); } return { diff --git a/tsconfig.base.json b/tsconfig.base.json index 3e40960b54735..674ca428983e6 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -672,6 +672,8 @@ "@kbn/deeplinks-analytics/*": ["packages/deeplinks/analytics/*"], "@kbn/deeplinks-devtools": ["packages/deeplinks/devtools"], "@kbn/deeplinks-devtools/*": ["packages/deeplinks/devtools/*"], + "@kbn/deeplinks-fleet": ["packages/deeplinks/fleet"], + "@kbn/deeplinks-fleet/*": ["packages/deeplinks/fleet/*"], "@kbn/deeplinks-management": ["packages/deeplinks/management"], "@kbn/deeplinks-management/*": ["packages/deeplinks/management/*"], "@kbn/deeplinks-ml": ["packages/deeplinks/ml"], @@ -680,6 +682,10 @@ "@kbn/deeplinks-observability/*": ["packages/deeplinks/observability/*"], "@kbn/deeplinks-search": ["packages/deeplinks/search"], "@kbn/deeplinks-search/*": ["packages/deeplinks/search/*"], + "@kbn/deeplinks-security": ["packages/deeplinks/security"], + "@kbn/deeplinks-security/*": ["packages/deeplinks/security/*"], + "@kbn/deeplinks-shared": ["packages/deeplinks/shared"], + "@kbn/deeplinks-shared/*": ["packages/deeplinks/shared/*"], "@kbn/default-nav-analytics": ["packages/default-nav/analytics"], "@kbn/default-nav-analytics/*": ["packages/default-nav/analytics/*"], "@kbn/default-nav-devtools": ["packages/default-nav/devtools"], diff --git a/x-pack/packages/security-solution/navigation/src/constants.ts b/x-pack/packages/security-solution/navigation/src/constants.ts index 704c24424cd43..7afbd93f4e675 100644 --- a/x-pack/packages/security-solution/navigation/src/constants.ts +++ b/x-pack/packages/security-solution/navigation/src/constants.ts @@ -7,82 +7,7 @@ export const SECURITY_UI_APP_ID = 'securitySolutionUI' as const; -export enum SecurityPageName { - administration = 'administration', - alerts = 'alerts', - assets = 'assets', - blocklist = 'blocklist', - /* - * Warning: Computed values are not permitted in an enum with string valued members - * All Cases page names must match `CasesDeepLinkId` in x-pack/plugins/cases/public/common/navigation/deep_links.ts - */ - case = 'cases', // must match `CasesDeepLinkId.cases` - caseConfigure = 'cases_configure', // must match `CasesDeepLinkId.casesConfigure` - caseCreate = 'cases_create', // must match `CasesDeepLinkId.casesCreate` - /* - * Warning: Computed values are not permitted in an enum with string valued members - * All cloud security posture page names must match `CloudSecurityPosturePageId` in x-pack/plugins/cloud_security_posture/public/common/navigation/types.ts - */ - cloudSecurityPostureBenchmarks = 'cloud_security_posture-benchmarks', - cloudSecurityPostureDashboard = 'cloud_security_posture-dashboard', - cloudSecurityPostureFindings = 'cloud_security_posture-findings', - cloudSecurityPostureRules = 'cloud_security_posture-rules', - /* - * Warning: Computed values are not permitted in an enum with string valued members - * All cloud defend page names must match `CloudDefendPageId` in x-pack/plugins/cloud_defend/public/common/navigation/types.ts - */ - cloudDefend = 'cloud_defend', - cloudDefendPolicies = 'cloud_defend-policies', - dashboards = 'dashboards', - dataQuality = 'data_quality', - detections = 'detections', - detectionAndResponse = 'detection_response', - endpoints = 'endpoints', - eventFilters = 'event_filters', - exceptions = 'exceptions', - exploreLanding = 'explore', - hostIsolationExceptions = 'host_isolation_exceptions', - hosts = 'hosts', - hostsAnomalies = 'hosts-anomalies', - hostsRisk = 'hosts-risk', - hostsEvents = 'hosts-events', - investigations = 'investigations', - kubernetes = 'kubernetes', - landing = 'get_started', - mlLanding = 'machine_learning-landing', // serverless only - network = 'network', - networkAnomalies = 'network-anomalies', - networkDns = 'network-dns', - networkEvents = 'network-events', - networkHttp = 'network-http', - networkTls = 'network-tls', - noPage = '', - overview = 'overview', - policies = 'policy', - responseActionsHistory = 'response_actions_history', - rules = 'rules', - rulesAdd = 'rules-add', - rulesCreate = 'rules-create', - rulesLanding = 'rules-landing', - sessions = 'sessions', - /* - * Warning: Computed values are not permitted in an enum with string valued members - * All threat intelligence page names must match `TIPageId` in x-pack/plugins/threat_intelligence/public/common/navigation/types.ts - */ - threatIntelligence = 'threat_intelligence', - timelines = 'timelines', - timelinesTemplates = 'timelines-templates', - trustedApps = 'trusted_apps', - uncommonProcesses = 'uncommon_processes', - users = 'users', - usersAnomalies = 'users-anomalies', - usersAuthentications = 'users-authentications', - usersEvents = 'users-events', - usersRisk = 'users-risk', - entityAnalytics = 'entity_analytics', - entityAnalyticsManagement = 'entity_analytics-management', - coverageOverview = 'coverage-overview', -} +export { SecurityPageName } from '@kbn/deeplinks-security'; export enum LinkCategoryType { title = 'title', diff --git a/x-pack/packages/security-solution/navigation/tsconfig.json b/x-pack/packages/security-solution/navigation/tsconfig.json index ca3efc5663990..a0ba8fb180bfb 100644 --- a/x-pack/packages/security-solution/navigation/tsconfig.json +++ b/x-pack/packages/security-solution/navigation/tsconfig.json @@ -15,6 +15,7 @@ "kbn_references": [ "@kbn/i18n", "@kbn/core", + "@kbn/deeplinks-security" ], "exclude": ["target/**/*"] } diff --git a/x-pack/plugins/ml/public/application/app.tsx b/x-pack/plugins/ml/public/application/app.tsx index 676282bb66551..59871c8b2aa83 100644 --- a/x-pack/plugins/ml/public/application/app.tsx +++ b/x-pack/plugins/ml/public/application/app.tsx @@ -98,6 +98,8 @@ const App: FC = ({ coreStart, deps, appMountParams, isServerless, mlFe setBreadcrumbs: coreStart.chrome!.setBreadcrumbs, }; + const chromeStyle = useObservable(coreStart.chrome.getChromeStyle$(), 'classic'); + const services: StartServices = useMemo(() => { return { ...coreStart, @@ -165,7 +167,11 @@ const App: FC = ({ coreStart, deps, appMountParams, isServerless, mlFe - + diff --git a/x-pack/plugins/ml/public/application/contexts/ml/serverless_context.tsx b/x-pack/plugins/ml/public/application/contexts/ml/serverless_context.tsx index e227b6bb146c5..9d981bd004ca5 100644 --- a/x-pack/plugins/ml/public/application/contexts/ml/serverless_context.tsx +++ b/x-pack/plugins/ml/public/application/contexts/ml/serverless_context.tsx @@ -29,16 +29,18 @@ export const EnabledFeaturesContext = createContext({ interface Props { isServerless: boolean; mlFeatures: MlFeatures; + showMLNavMenu?: boolean; } export const EnabledFeaturesContextProvider: FC = ({ children, isServerless, + showMLNavMenu = true, mlFeatures, }) => { const features: EnabledFeatures = { showNodeInfo: !isServerless, - showMLNavMenu: !isServerless, + showMLNavMenu, showLicenseInfo: !isServerless, isADEnabled: mlFeatures.ad, isDFAEnabled: mlFeatures.dfa, diff --git a/x-pack/plugins/observability_solution/observability_shared/public/plugin.ts b/x-pack/plugins/observability_solution/observability_shared/public/plugin.ts index 9280a38a6bd8e..c23611b367a1b 100644 --- a/x-pack/plugins/observability_solution/observability_shared/public/plugin.ts +++ b/x-pack/plugins/observability_solution/observability_shared/public/plugin.ts @@ -39,7 +39,6 @@ export interface ObservabilitySharedStart { spaces?: SpacesPluginStart; cases: CasesPublicStart; guidedOnboarding?: GuidedOnboardingPluginStart; - setIsSidebarEnabled: (isEnabled: boolean) => void; embeddable: EmbeddableStart; share: SharePluginStart; } @@ -65,6 +64,12 @@ export class ObservabilitySharedPlugin implements Plugin { } public setup(coreSetup: CoreSetup, pluginsSetup: ObservabilitySharedSetup) { + coreSetup.getStartServices().then(([coreStart]) => { + coreStart.chrome + .getChromeStyle$() + .subscribe((style) => this.isSidebarEnabled$.next(style === 'classic')); + }); + return { locators: this.createLocators(pluginsSetup.share.url), navigation: { @@ -93,7 +98,6 @@ export class ObservabilitySharedPlugin implements Plugin { registerSections: this.navigationRegistry.registerSections, }, updateGlobalNavigation, - setIsSidebarEnabled: (isEnabled: boolean) => this.isSidebarEnabled$.next(isEnabled), }; } diff --git a/x-pack/plugins/security_solution/public/plugin.tsx b/x-pack/plugins/security_solution/public/plugin.tsx index 516dc0166bdd1..dfa4f47c16dda 100644 --- a/x-pack/plugins/security_solution/public/plugin.tsx +++ b/x-pack/plugins/security_solution/public/plugin.tsx @@ -6,7 +6,7 @@ */ import { i18n } from '@kbn/i18n'; -import { Subject, mergeMap } from 'rxjs'; +import { Subject, mergeMap, firstValueFrom } from 'rxjs'; import type * as H from 'history'; import type { AppMountParameters, @@ -197,11 +197,16 @@ export class Plugin implements IPlugin { - const { serverless, management } = services; + const { serverless } = services; serverless.setProjectHome(APP_PATH); initSideNavigation(services); enableManagementCardsLanding(services); - management.setIsSidebarEnabled(false); subscribeBreadcrumbs(services); }; diff --git a/x-pack/plugins/serverless_observability/kibana.jsonc b/x-pack/plugins/serverless_observability/kibana.jsonc index 50088e8152526..f8ba3cc645543 100644 --- a/x-pack/plugins/serverless_observability/kibana.jsonc +++ b/x-pack/plugins/serverless_observability/kibana.jsonc @@ -1,10 +1,7 @@ { "type": "plugin", "id": "@kbn/serverless-observability", - "owner": [ - "@elastic/appex-sharedux", - "@elastic/obs-ux-management-team" - ], + "owner": "@elastic/obs-ux-management-team", "description": "Serverless customizations for observability.", "plugin": { "id": "serverlessObservability", diff --git a/x-pack/plugins/serverless_observability/public/plugin.ts b/x-pack/plugins/serverless_observability/public/plugin.ts index 8ca6232cd4f23..8ddf0d769909d 100644 --- a/x-pack/plugins/serverless_observability/public/plugin.ts +++ b/x-pack/plugins/serverless_observability/public/plugin.ts @@ -52,14 +52,12 @@ export class ServerlessObservabilityPlugin core: CoreStart, setupDeps: ServerlessObservabilityPublicStartDependencies ): ServerlessObservabilityPublicStart { - const { observabilityShared, serverless, management } = setupDeps; - observabilityShared.setIsSidebarEnabled(false); + const { serverless, management } = setupDeps; const navigationTree$ = of(navigationTree); serverless.setProjectHome('/app/observability/landing'); serverless.initNavigation(navigationTree$, { dataTestSubj: 'svlObservabilitySideNav' }); - management.setIsSidebarEnabled(false); management.setupCardsNavigation({ enabled: true, hideLinksTo: [appIds.RULES], diff --git a/x-pack/plugins/serverless_search/public/plugin.ts b/x-pack/plugins/serverless_search/public/plugin.ts index 19601855f1427..4c805e4cb2daa 100644 --- a/x-pack/plugins/serverless_search/public/plugin.ts +++ b/x-pack/plugins/serverless_search/public/plugin.ts @@ -127,7 +127,6 @@ export class ServerlessSearchPlugin const navigationTree$ = of(navigationTree); serverless.initNavigation(navigationTree$, { dataTestSubj: 'svlSearchSideNav' }); - management.setIsSidebarEnabled(false); management.setupCardsNavigation({ enabled: true, hideLinksTo: [appIds.MAINTENANCE_WINDOWS], diff --git a/yarn.lock b/yarn.lock index 88acba7a679bc..53ff07f181e2b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4391,6 +4391,10 @@ version "0.0.0" uid "" +"@kbn/deeplinks-fleet@link:packages/deeplinks/fleet": + version "0.0.0" + uid "" + "@kbn/deeplinks-management@link:packages/deeplinks/management": version "0.0.0" uid "" @@ -4407,6 +4411,14 @@ version "0.0.0" uid "" +"@kbn/deeplinks-security@link:packages/deeplinks/security": + version "0.0.0" + uid "" + +"@kbn/deeplinks-shared@link:packages/deeplinks/shared": + version "0.0.0" + uid "" + "@kbn/default-nav-analytics@link:packages/default-nav/analytics": version "0.0.0" uid ""