From f44964babff0861639c3853e519525efd10d2177 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Mon, 5 Jun 2023 15:23:36 +0100 Subject: [PATCH 01/60] Sort imports --- packages/shared-ux/chrome/navigation/index.ts | 5 +++-- packages/shared-ux/chrome/navigation/src/ui/index.ts | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/shared-ux/chrome/navigation/index.ts b/packages/shared-ux/chrome/navigation/index.ts index 13034398065a5..de3baec6d6ee2 100644 --- a/packages/shared-ux/chrome/navigation/index.ts +++ b/packages/shared-ux/chrome/navigation/index.ts @@ -16,6 +16,7 @@ export type { NavigationGroupPreset, NavigationTreeDefinition, NodeDefinition, + NodeDefinitionWithChildren, ProjectNavigationDefinition, RecentlyAccessedDefinition, RootNavigationItemDefinition, @@ -23,8 +24,8 @@ export type { export type { ChromeNavigation, - ChromeNavigationViewModel, - NavigationServices, ChromeNavigationNode, ChromeNavigationNodeViewModel, + ChromeNavigationViewModel, + NavigationServices, } from './types'; diff --git a/packages/shared-ux/chrome/navigation/src/ui/index.ts b/packages/shared-ux/chrome/navigation/src/ui/index.ts index f0c63fda8e27f..e46694103ca8b 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/index.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/index.ts @@ -18,6 +18,7 @@ export type { NavigationGroupPreset, NavigationTreeDefinition, NodeDefinition, + NodeDefinitionWithChildren, ProjectNavigationDefinition, RecentlyAccessedDefinition, RootNavigationItemDefinition, From 898b8053736290b173961b858046e53482529ae8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Thu, 1 Jun 2023 14:28:18 +0100 Subject: [PATCH 02/60] Add devTools deeplinks --- .../src/project_navigation.ts | 9 ++-- packages/deeplinks/devtools/README.md | 3 ++ packages/deeplinks/devtools/index.ts | 47 +++++++++++++++++++ packages/deeplinks/devtools/jest.config.js | 13 +++++ packages/deeplinks/devtools/kibana.jsonc | 5 ++ packages/deeplinks/devtools/package.json | 6 +++ packages/deeplinks/devtools/tsconfig.json | 19 ++++++++ .../src/ui/nav_tree_presets/devtools.ts | 8 ++-- src/plugins/dev_tools/public/plugin.ts | 17 +++++-- tsconfig.base.json | 2 + yarn.lock | 4 ++ 11 files changed, 118 insertions(+), 15 deletions(-) create mode 100644 packages/deeplinks/devtools/README.md create mode 100644 packages/deeplinks/devtools/index.ts create mode 100644 packages/deeplinks/devtools/jest.config.js create mode 100644 packages/deeplinks/devtools/kibana.jsonc create mode 100644 packages/deeplinks/devtools/package.json create mode 100644 packages/deeplinks/devtools/tsconfig.json 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 7ef86b1e34a98..21763541bc2da 100644 --- a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts +++ b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts @@ -5,19 +5,16 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ - +import type { AppDeepLinkId as DevToolsLink, AppId as DevToolsApp } from '@kbn/deeplinks-devtools'; import type { ComponentType } from 'react'; import type { ChromeBreadcrumb } from './breadcrumb'; import type { ChromeNavLink } from './nav_links'; /** @internal */ -type AppId = string; - -/** @internal */ -type DeepLinkId = string; +type AppId = DevToolsApp; /** @internal */ -export type AppDeepLinkId = `${AppId}:${DeepLinkId}`; +export type AppDeepLinkId = AppId | DevToolsLink; /** * @public diff --git a/packages/deeplinks/devtools/README.md b/packages/deeplinks/devtools/README.md new file mode 100644 index 0000000000000..7875bc63e527c --- /dev/null +++ b/packages/deeplinks/devtools/README.md @@ -0,0 +1,3 @@ +# @kbn/deeplinks-devtools + +Empty package generated by @kbn/generate diff --git a/packages/deeplinks/devtools/index.ts b/packages/deeplinks/devtools/index.ts new file mode 100644 index 0000000000000..ace939e753729 --- /dev/null +++ b/packages/deeplinks/devtools/index.ts @@ -0,0 +1,47 @@ +/* + * 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 DEV_TOOLS_APP_ID = 'dev_tools' as const; + +export const searchProfiler = { + id: 'searchprofiler', + title: 'Search Profiler', + path: '#/searchprofiler', +} as const; + +export const painlessLab = { + id: 'painless_lab', + title: 'Painless Lab', + path: '#/painless_lab', +} as const; + +export const grokDebugger = { + id: 'grokdebugger', + title: 'Grok Debugger', + path: '#/grokdebugger', +} as const; + +export const console = { + id: 'console', + title: 'Console', + path: '#/console', +} as const; + +export type DeepLink = + | typeof searchProfiler + | typeof painlessLab + | typeof grokDebugger + | typeof console; + +export type LinkId = DeepLink['id']; + +export type AppId = typeof DEV_TOOLS_APP_ID; + +export type AppDeepLinkId = `${AppId}:${LinkId}`; + +export const deepLinks: DeepLink[] = [searchProfiler, painlessLab, grokDebugger, console]; diff --git a/packages/deeplinks/devtools/jest.config.js b/packages/deeplinks/devtools/jest.config.js new file mode 100644 index 0000000000000..75fbc22465b19 --- /dev/null +++ b/packages/deeplinks/devtools/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/devtools'], +}; diff --git a/packages/deeplinks/devtools/kibana.jsonc b/packages/deeplinks/devtools/kibana.jsonc new file mode 100644 index 0000000000000..8ea511e08fdf7 --- /dev/null +++ b/packages/deeplinks/devtools/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/deeplinks-devtools", + "owner": "@elastic/platform-deployment-management" +} diff --git a/packages/deeplinks/devtools/package.json b/packages/deeplinks/devtools/package.json new file mode 100644 index 0000000000000..f66d9a96db06c --- /dev/null +++ b/packages/deeplinks/devtools/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/deeplinks-devtools", + "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/devtools/tsconfig.json b/packages/deeplinks/devtools/tsconfig.json new file mode 100644 index 0000000000000..5b34775c71159 --- /dev/null +++ b/packages/deeplinks/devtools/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/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts index 03b2eff015433..2b0e396ee6d73 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts @@ -27,22 +27,22 @@ export const devtools: NodeDefinitionWithChildren = { { id: 'console', title: 'Console', - href: '/app/dev_tools#/console', + link: 'dev_tools:console', }, { id: 'search_profiler', title: 'Search profiler', - href: '/app/dev_tools#/searchprofiler', + link: 'dev_tools:searchprofiler', }, { id: 'grok_debugger', title: 'Grok debugger', - href: '/app/dev_tools#/grokdebugger', + link: 'dev_tools:grokdebugger', }, { id: 'painless_lab', title: 'Painless lab', - href: '/app/dev_tools#/painless_lab', + link: 'dev_tools:painless_lab', }, ], }, diff --git a/src/plugins/dev_tools/public/plugin.ts b/src/plugins/dev_tools/public/plugin.ts index 86c26f099b55d..29eef33c29a86 100644 --- a/src/plugins/dev_tools/public/plugin.ts +++ b/src/plugins/dev_tools/public/plugin.ts @@ -14,6 +14,7 @@ import { sortBy } from 'lodash'; import { AppNavLinkStatus, DEFAULT_APP_CATEGORIES } from '@kbn/core/public'; import { UrlForwardingSetup } from '@kbn/url-forwarding-plugin/public'; +import { deepLinks as devtoolsDeeplinks } from '@kbn/deeplinks-devtools'; import { CreateDevToolArgs, DevToolApp, createDevToolApp } from './dev_tool'; import { DocTitleService, BreadcrumbService } from './services'; @@ -112,11 +113,17 @@ export class DevToolsPlugin implements Plugin { // Some tools do not use a string title, so we filter those out (tool) => !tool.enableRouting && !tool.isDisabled() && typeof tool.title === 'string' ) - .map((tool) => ({ - id: tool.id, - title: tool.title as string, - path: `#/${tool.id}`, - })); + .map((tool) => { + const deepLink = { + id: tool.id, + title: tool.title as string, + path: `#/${tool.id}`, + }; + if (!devtoolsDeeplinks.some((dl) => dl.id === deepLink.id)) { + throw new Error('Deeplink must be registered in package.'); + } + return deepLink; + }); return { deepLinks }; }); } diff --git a/tsconfig.base.json b/tsconfig.base.json index f8ed16064cc8f..148f593c51904 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -606,6 +606,8 @@ "@kbn/data-visualizer-plugin/*": ["x-pack/plugins/data_visualizer/*"], "@kbn/datemath": ["packages/kbn-datemath"], "@kbn/datemath/*": ["packages/kbn-datemath/*"], + "@kbn/deeplinks-devtools": ["packages/deeplinks/devtools"], + "@kbn/deeplinks-devtools/*": ["packages/deeplinks/devtools/*"], "@kbn/dev-cli-errors": ["packages/kbn-dev-cli-errors"], "@kbn/dev-cli-errors/*": ["packages/kbn-dev-cli-errors/*"], "@kbn/dev-cli-runner": ["packages/kbn-dev-cli-runner"], diff --git a/yarn.lock b/yarn.lock index d7fb5298305a3..257d797e84cdf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4047,6 +4047,10 @@ version "0.0.0" uid "" +"@kbn/deeplinks-devtools@link:packages/deeplinks/devtools": + version "0.0.0" + uid "" + "@kbn/dev-cli-errors@link:packages/kbn-dev-cli-errors": version "0.0.0" uid "" From 4d96353cf058ad9baaac51e245287af0b79b2ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Mon, 5 Jun 2023 12:26:37 +0100 Subject: [PATCH 03/60] Add analytics deeplink ids and update TS types --- .../src/project_navigation.ts | 17 ++++--- packages/deeplinks/analytics/README.md | 3 ++ packages/deeplinks/analytics/index.ts | 17 +++++++ packages/deeplinks/analytics/jest.config.js | 13 +++++ packages/deeplinks/analytics/kibana.jsonc | 5 ++ packages/deeplinks/analytics/package.json | 6 +++ packages/deeplinks/analytics/tsconfig.json | 19 +++++++ packages/deeplinks/devtools/index.ts | 8 +-- .../src/ui/nav_tree_presets/analytics.ts | 18 +++---- .../src/ui/nav_tree_presets/devtools.ts | 17 ++----- .../src/ui/nav_tree_presets/index.ts | 51 ++++++++++--------- .../src/ui/nav_tree_presets/management.ts | 5 +- .../navigation/src/ui/nav_tree_presets/ml.ts | 6 ++- .../src/ui/nav_tree_presets/types.ts | 36 +++++++++++++ .../chrome/navigation/src/ui/types.ts | 12 +++-- 15 files changed, 168 insertions(+), 65 deletions(-) create mode 100644 packages/deeplinks/analytics/README.md create mode 100644 packages/deeplinks/analytics/index.ts create mode 100644 packages/deeplinks/analytics/jest.config.js create mode 100644 packages/deeplinks/analytics/kibana.jsonc create mode 100644 packages/deeplinks/analytics/package.json create mode 100644 packages/deeplinks/analytics/tsconfig.json create mode 100644 packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts 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 21763541bc2da..df00f5e86182f 100644 --- a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts +++ b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts @@ -5,23 +5,28 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { AppDeepLinkId as DevToolsLink, AppId as DevToolsApp } from '@kbn/deeplinks-devtools'; import type { ComponentType } from 'react'; +import type { AppId as DevToolsApp, DeepLinkId as DevToolsLink } from '@kbn/deeplinks-devtools'; +import type { + AppId as AnalyticsApp, + DeepLinkId as AnalyticsDeepLink, +} from '@kbn/deeplinks-analytics'; + import type { ChromeBreadcrumb } from './breadcrumb'; import type { ChromeNavLink } from './nav_links'; -/** @internal */ -type AppId = DevToolsApp; +/** @public */ +export type AppId = DevToolsApp | AnalyticsApp; -/** @internal */ -export type AppDeepLinkId = AppId | DevToolsLink; +/** @public */ +export type AppDeepLinkId = AnalyticsDeepLink | DevToolsLink; /** * @public * * App id or deeplink id */ -export type ChromeProjectNavigationLink = AppId | AppDeepLinkId; +export type ChromeProjectNavigationLink = AppDeepLinkId; /** @public */ export interface ChromeProjectNavigationNode { diff --git a/packages/deeplinks/analytics/README.md b/packages/deeplinks/analytics/README.md new file mode 100644 index 0000000000000..390f0428c0bf5 --- /dev/null +++ b/packages/deeplinks/analytics/README.md @@ -0,0 +1,3 @@ +# @kbn/deeplinks-analytics + +Empty package generated by @kbn/generate diff --git a/packages/deeplinks/analytics/index.ts b/packages/deeplinks/analytics/index.ts new file mode 100644 index 0000000000000..ca6180a1efddd --- /dev/null +++ b/packages/deeplinks/analytics/index.ts @@ -0,0 +1,17 @@ +/* + * 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 DISCOVER_APP_ID = 'discover'; + +export const DASHBOARD_APP_ID = 'dashboard'; + +export const VISUALIZE_APP_ID = 'visualize'; + +export type AppId = typeof DISCOVER_APP_ID | typeof DASHBOARD_APP_ID | typeof VISUALIZE_APP_ID; + +export type DeepLinkId = AppId; diff --git a/packages/deeplinks/analytics/jest.config.js b/packages/deeplinks/analytics/jest.config.js new file mode 100644 index 0000000000000..1800587bc0eed --- /dev/null +++ b/packages/deeplinks/analytics/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/analytics'], +}; diff --git a/packages/deeplinks/analytics/kibana.jsonc b/packages/deeplinks/analytics/kibana.jsonc new file mode 100644 index 0000000000000..daadecdf8581b --- /dev/null +++ b/packages/deeplinks/analytics/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/deeplinks-analytics", + "owner": "@elastic/kibana-data-discovery" +} diff --git a/packages/deeplinks/analytics/package.json b/packages/deeplinks/analytics/package.json new file mode 100644 index 0000000000000..9de92d5611eb9 --- /dev/null +++ b/packages/deeplinks/analytics/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/deeplinks-analytics", + "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/analytics/tsconfig.json b/packages/deeplinks/analytics/tsconfig.json new file mode 100644 index 0000000000000..5b34775c71159 --- /dev/null +++ b/packages/deeplinks/analytics/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/devtools/index.ts b/packages/deeplinks/devtools/index.ts index ace939e753729..571c2e0b58a24 100644 --- a/packages/deeplinks/devtools/index.ts +++ b/packages/deeplinks/devtools/index.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -export const DEV_TOOLS_APP_ID = 'dev_tools' as const; +export const DEV_TOOLS_APP_ID = 'dev_tools'; export const searchProfiler = { id: 'searchprofiler', @@ -38,10 +38,10 @@ export type DeepLink = | typeof grokDebugger | typeof console; -export type LinkId = DeepLink['id']; - export type AppId = typeof DEV_TOOLS_APP_ID; -export type AppDeepLinkId = `${AppId}:${LinkId}`; +export type LinkId = DeepLink['id']; + +export type DeepLinkId = AppId | `${AppId}:${LinkId}`; export const deepLinks: DeepLink[] = [searchProfiler, painlessLab, grokDebugger, console]; diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/analytics.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/analytics.ts index 6435fe6b0f55e..0668c429f5ceb 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/analytics.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/analytics.ts @@ -6,11 +6,13 @@ * Side Public License, v 1. */ -import type { NodeDefinitionWithChildren } from '.'; +import type { DeepLinkId as AnalyticsDeepLink } from '@kbn/deeplinks-analytics'; -export type ID = 'sharedux:analytics' | 'root' | 'discover' | 'dashboard' | 'visualize_library'; +import type { NodeDefinitionWithChildren } from './types'; -export const analytics: NodeDefinitionWithChildren = { +export type ID = 'sharedux:analytics' | 'root'; + +export const analytics: NodeDefinitionWithChildren = { // Make sure we have a unique id otherwise it might override a custom id from the project id: 'sharedux:analytics', title: 'Data exploration', @@ -21,18 +23,14 @@ export const analytics: NodeDefinitionWithChildren = { children: [ { title: 'Discover', - id: 'discover', - href: '/app/discover', + link: 'discover', }, { title: 'Dashboard', - id: 'dashboard', - href: '/app/dashboards', + link: 'dashboard', }, { - id: 'visualize_library', - title: 'Visualize Library', - href: '/app/visualize', + link: 'visualize', }, ], }, diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts index 2b0e396ee6d73..07438d289a7b1 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts @@ -5,18 +5,13 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ +import type { DeepLinkId as DevToolsLink } from '@kbn/deeplinks-devtools'; -import type { NodeDefinitionWithChildren } from '.'; +import type { NodeDefinitionWithChildren } from './types'; -export type ID = - | 'sharedux:devtools' - | 'root' - | 'console' - | 'search_profiler' - | 'grok_debugger' - | 'painless_lab'; +export type ID = 'sharedux:devtools' | 'root'; -export const devtools: NodeDefinitionWithChildren = { +export const devtools: NodeDefinitionWithChildren = { title: 'Developer tools', id: 'sharedux:devtools', icon: 'editorCodeBlock', @@ -25,22 +20,18 @@ export const devtools: NodeDefinitionWithChildren = { id: 'root', children: [ { - id: 'console', title: 'Console', link: 'dev_tools:console', }, { - id: 'search_profiler', title: 'Search profiler', link: 'dev_tools:searchprofiler', }, { - id: 'grok_debugger', title: 'Grok debugger', link: 'dev_tools:grokdebugger', }, { - id: 'painless_lab', title: 'Painless lab', link: 'dev_tools:painless_lab', }, diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts index 0aefcf3f92aa7..7bbb566d2ba03 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts @@ -7,36 +7,39 @@ */ import { cloneDeep } from 'lodash'; -import { NavigationGroupPreset, NodeDefinition } from '../types'; -import { analytics, type ID as AnalyticsID } from './analytics'; -import { devtools, type ID as DevtoolsID } from './devtools'; -import { management, type ID as ManagementID } from './management'; -import { ml, type ID as MlID } from './ml'; -export type NodeDefinitionWithChildren = NodeDefinition & { - children: Required>['children']; -}; +import type { NavigationGroupPreset } from '../types'; +import type { + AnalyticsNodeDefinition, + DevToolsNodeDefinition, + ManagementNodeDefinition, + MlNodeDefinition, +} from './types'; +import { analytics } from './analytics'; +import { devtools } from './devtools'; +import { management } from './management'; +import { ml } from './ml'; -export function getPresets(preset: 'devtools'): NodeDefinitionWithChildren; -export function getPresets(preset: 'management'): NodeDefinitionWithChildren; -export function getPresets(preset: 'ml'): NodeDefinitionWithChildren; -export function getPresets(preset: 'analytics'): NodeDefinitionWithChildren; +export function getPresets(preset: 'devtools'): DevToolsNodeDefinition; +export function getPresets(preset: 'management'): ManagementNodeDefinition; +export function getPresets(preset: 'ml'): MlNodeDefinition; +export function getPresets(preset: 'analytics'): AnalyticsNodeDefinition; export function getPresets(preset: 'all'): { - analytics: NodeDefinitionWithChildren; - devtools: NodeDefinitionWithChildren; - ml: NodeDefinitionWithChildren; - management: NodeDefinitionWithChildren; + analytics: AnalyticsNodeDefinition; + devtools: DevToolsNodeDefinition; + ml: MlNodeDefinition; + management: ManagementNodeDefinition; }; export function getPresets(preset: NavigationGroupPreset | 'all'): - | NodeDefinitionWithChildren - | NodeDefinitionWithChildren - | NodeDefinitionWithChildren - | NodeDefinitionWithChildren + | DevToolsNodeDefinition + | ManagementNodeDefinition + | MlNodeDefinition + | AnalyticsNodeDefinition | { - analytics: NodeDefinitionWithChildren; - devtools: NodeDefinitionWithChildren; - ml: NodeDefinitionWithChildren; - management: NodeDefinitionWithChildren; + analytics: AnalyticsNodeDefinition; + devtools: DevToolsNodeDefinition; + ml: MlNodeDefinition; + management: ManagementNodeDefinition; } { if (preset === 'all') { return { diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts index db87f84ec37d2..77f928b25f183 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts @@ -5,8 +5,9 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ +import type { ChromeProjectNavigationLink } from '@kbn/core-chrome-browser'; -import type { NodeDefinitionWithChildren } from '.'; +import type { NodeDefinitionWithChildren } from './types'; export type ID = | 'sharedux:management' @@ -49,7 +50,7 @@ export type ID = | 'advanced_settings' | 'upgrade_assistant'; -export const management: NodeDefinitionWithChildren = { +export const management: NodeDefinitionWithChildren = { id: 'sharedux:management', title: 'Management', icon: 'gear', diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts index ba3b7e0645d67..83e44267279f5 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts @@ -6,7 +6,9 @@ * Side Public License, v 1. */ -import type { NodeDefinitionWithChildren } from '.'; +import type { ChromeProjectNavigationLink } from '@kbn/core-chrome-browser'; + +import type { NodeDefinitionWithChildren } from './types'; export type ID = | 'sharedux:ml' @@ -31,7 +33,7 @@ export type ID = | 'explain_log_rate_spikes' | 'log_pattern_analysis'; -export const ml: NodeDefinitionWithChildren = { +export const ml: NodeDefinitionWithChildren = { id: 'sharedux:ml', title: 'Machine learning', icon: 'indexMapping', diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts new file mode 100644 index 0000000000000..3aede3784e60f --- /dev/null +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts @@ -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 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 { ChromeProjectNavigationLink } from '@kbn/core-chrome-browser'; +import type { DeepLinkId as DevToolsLink } from '@kbn/deeplinks-devtools'; +import type { DeepLinkId as AnalyticsDeepLink } from '@kbn/deeplinks-analytics'; + +import type { NodeDefinition } from '../types'; +import type { ID as AnalyticsID } from './analytics'; +import type { ID as DevtoolsID } from './devtools'; +import type { ID as ManagementID } from './management'; +import type { ID as MlID } from './ml'; + +export type NodeDefinitionWithChildren< + LinkId extends ChromeProjectNavigationLink = ChromeProjectNavigationLink, + Id extends ChromeProjectNavigationLink = LinkId, + ChildrenID extends ChromeProjectNavigationLink = Id +> = NodeDefinition & { + children: Required>['children']; +}; + +export type AnalyticsNodeDefinition = NodeDefinitionWithChildren; + +export type DevToolsNodeDefinition = NodeDefinitionWithChildren; + +export type ManagementNodeDefinition = NodeDefinitionWithChildren< + ChromeProjectNavigationLink, + ManagementID +>; + +export type MlNodeDefinition = NodeDefinitionWithChildren; diff --git a/packages/shared-ux/chrome/navigation/src/ui/types.ts b/packages/shared-ux/chrome/navigation/src/ui/types.ts index 96c283d508f87..72d76676189e9 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/types.ts @@ -20,17 +20,21 @@ import type { CloudLinkProps, RecentlyAccessedProps } from './components'; * A navigation node definition with its unique id, title, path in the tree and optional * deep link and children. */ -export interface NodeDefinition { +export interface NodeDefinition< + LinkId extends ChromeProjectNavigationLink = ChromeProjectNavigationLink, + Id extends ChromeProjectNavigationLink = LinkId, + ChildrenId extends ChromeProjectNavigationLink = Id +> { /** Optional id, if not passed a "link" must be provided. */ - id?: T; + id?: Id; /** Optional title. If not provided and a "link" is provided the title will be the Deep link title */ title?: string; /** App id or deeplink id */ - link?: ChromeProjectNavigationLink; + link?: LinkId; /** Optional icon for the navigation node. Note: not all navigation depth will render the icon */ icon?: string; /** Optional children of the navigation node */ - children?: Array>; + children?: Array>; /** * Temporarilly we allow href to be passed. * Once all the deeplinks will be exposed in packages we will not allow href anymore From 4a1a7f33156773a88f66250b29bad0d3c3a9126e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Mon, 5 Jun 2023 12:34:01 +0100 Subject: [PATCH 04/60] Replace ChromeProjectNavigationLink with AppDeepLinkId & AppId --- packages/core/chrome/core-chrome-browser/index.ts | 3 ++- .../core/chrome/core-chrome-browser/src/index.ts | 3 ++- .../core-chrome-browser/src/project_navigation.ts | 7 ------- .../src/ui/nav_tree_presets/management.ts | 4 ++-- .../navigation/src/ui/nav_tree_presets/ml.ts | 4 ++-- .../navigation/src/ui/nav_tree_presets/types.ts | 15 ++++++--------- .../shared-ux/chrome/navigation/src/ui/types.ts | 11 ++++------- 7 files changed, 18 insertions(+), 29 deletions(-) diff --git a/packages/core/chrome/core-chrome-browser/index.ts b/packages/core/chrome/core-chrome-browser/index.ts index 78efd33849aec..a38ac9dbdb750 100644 --- a/packages/core/chrome/core-chrome-browser/index.ts +++ b/packages/core/chrome/core-chrome-browser/index.ts @@ -7,6 +7,8 @@ */ export type { + AppDeepLinkId, + AppId, ChromeBadge, ChromeBreadcrumb, ChromeBreadcrumbsAppendExtension, @@ -29,7 +31,6 @@ export type { ChromeStart, ChromeStyle, ChromeUserBanner, - ChromeProjectNavigationLink, ChromeProjectNavigation, ChromeProjectNavigationNode, SideNavCompProps, diff --git a/packages/core/chrome/core-chrome-browser/src/index.ts b/packages/core/chrome/core-chrome-browser/src/index.ts index a8cdd85d6b401..665957978da33 100644 --- a/packages/core/chrome/core-chrome-browser/src/index.ts +++ b/packages/core/chrome/core-chrome-browser/src/index.ts @@ -31,7 +31,8 @@ export type { ChromeBadge, ChromeUserBanner, ChromeStyle } from './types'; export type { ChromeProjectNavigation, ChromeProjectNavigationNode, - ChromeProjectNavigationLink, + AppDeepLinkId, + AppId, SideNavCompProps, SideNavComponent, ChromeSetProjectBreadcrumbsParams, 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 df00f5e86182f..e72144c446371 100644 --- a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts +++ b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts @@ -21,13 +21,6 @@ export type AppId = DevToolsApp | AnalyticsApp; /** @public */ export type AppDeepLinkId = AnalyticsDeepLink | DevToolsLink; -/** - * @public - * - * App id or deeplink id - */ -export type ChromeProjectNavigationLink = AppDeepLinkId; - /** @public */ export interface ChromeProjectNavigationNode { /** Optional id, if not passed a "link" must be provided. */ diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts index 77f928b25f183..a0d68513ca29a 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts @@ -5,7 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { ChromeProjectNavigationLink } from '@kbn/core-chrome-browser'; +import type { AppDeepLinkId } from '@kbn/core-chrome-browser'; import type { NodeDefinitionWithChildren } from './types'; @@ -50,7 +50,7 @@ export type ID = | 'advanced_settings' | 'upgrade_assistant'; -export const management: NodeDefinitionWithChildren = { +export const management: NodeDefinitionWithChildren = { id: 'sharedux:management', title: 'Management', icon: 'gear', diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts index 83e44267279f5..9eb49f1da551a 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { ChromeProjectNavigationLink } from '@kbn/core-chrome-browser'; +import type { AppDeepLinkId } from '@kbn/core-chrome-browser'; import type { NodeDefinitionWithChildren } from './types'; @@ -33,7 +33,7 @@ export type ID = | 'explain_log_rate_spikes' | 'log_pattern_analysis'; -export const ml: NodeDefinitionWithChildren = { +export const ml: NodeDefinitionWithChildren = { id: 'sharedux:ml', title: 'Machine learning', icon: 'indexMapping', diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts index 3aede3784e60f..5feedd450ae9e 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ -import type { ChromeProjectNavigationLink } from '@kbn/core-chrome-browser'; +import type { AppDeepLinkId } from '@kbn/core-chrome-browser'; import type { DeepLinkId as DevToolsLink } from '@kbn/deeplinks-devtools'; import type { DeepLinkId as AnalyticsDeepLink } from '@kbn/deeplinks-analytics'; @@ -17,9 +17,9 @@ import type { ID as ManagementID } from './management'; import type { ID as MlID } from './ml'; export type NodeDefinitionWithChildren< - LinkId extends ChromeProjectNavigationLink = ChromeProjectNavigationLink, - Id extends ChromeProjectNavigationLink = LinkId, - ChildrenID extends ChromeProjectNavigationLink = Id + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenID extends string = Id > = NodeDefinition & { children: Required>['children']; }; @@ -28,9 +28,6 @@ export type AnalyticsNodeDefinition = NodeDefinitionWithChildren; -export type ManagementNodeDefinition = NodeDefinitionWithChildren< - ChromeProjectNavigationLink, - ManagementID ->; +export type ManagementNodeDefinition = NodeDefinitionWithChildren; -export type MlNodeDefinition = NodeDefinitionWithChildren; +export type MlNodeDefinition = NodeDefinitionWithChildren; diff --git a/packages/shared-ux/chrome/navigation/src/ui/types.ts b/packages/shared-ux/chrome/navigation/src/ui/types.ts index 72d76676189e9..c88538c608e90 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/types.ts @@ -7,10 +7,7 @@ */ import type { ReactElement, ReactNode } from 'react'; -import type { - ChromeProjectNavigationLink, - ChromeProjectNavigationNode, -} from '@kbn/core-chrome-browser'; +import type { AppDeepLinkId, ChromeProjectNavigationNode } from '@kbn/core-chrome-browser'; import type { CloudLinkProps, RecentlyAccessedProps } from './components'; @@ -21,9 +18,9 @@ import type { CloudLinkProps, RecentlyAccessedProps } from './components'; * deep link and children. */ export interface NodeDefinition< - LinkId extends ChromeProjectNavigationLink = ChromeProjectNavigationLink, - Id extends ChromeProjectNavigationLink = LinkId, - ChildrenId extends ChromeProjectNavigationLink = Id + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenId extends string = Id > { /** Optional id, if not passed a "link" must be provided. */ id?: Id; From 39a233482dc07dfe08fdf78f47fe9b68baa27216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Mon, 5 Jun 2023 12:35:53 +0100 Subject: [PATCH 05/60] Update package.json and tsconfig.base.jfon --- package.json | 2 ++ tsconfig.base.json | 2 ++ yarn.lock | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/package.json b/package.json index ec435c81e69c3..f78aca98331c5 100644 --- a/package.json +++ b/package.json @@ -351,6 +351,8 @@ "@kbn/data-views-plugin": "link:src/plugins/data_views", "@kbn/data-visualizer-plugin": "link:x-pack/plugins/data_visualizer", "@kbn/datemath": "link:packages/kbn-datemath", + "@kbn/deeplinks-analytics": "link:packages/deeplinks/analytics", + "@kbn/deeplinks-devtools": "link:packages/deeplinks/devtools", "@kbn/dev-tools-plugin": "link:src/plugins/dev_tools", "@kbn/developer-examples-plugin": "link:examples/developer_examples", "@kbn/discover-enhanced-plugin": "link:x-pack/plugins/discover_enhanced", diff --git a/tsconfig.base.json b/tsconfig.base.json index 148f593c51904..bf1f4f02662dc 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -606,6 +606,8 @@ "@kbn/data-visualizer-plugin/*": ["x-pack/plugins/data_visualizer/*"], "@kbn/datemath": ["packages/kbn-datemath"], "@kbn/datemath/*": ["packages/kbn-datemath/*"], + "@kbn/deeplinks-analytics": ["packages/deeplinks/analytics"], + "@kbn/deeplinks-analytics/*": ["packages/deeplinks/analytics/*"], "@kbn/deeplinks-devtools": ["packages/deeplinks/devtools"], "@kbn/deeplinks-devtools/*": ["packages/deeplinks/devtools/*"], "@kbn/dev-cli-errors": ["packages/kbn-dev-cli-errors"], diff --git a/yarn.lock b/yarn.lock index 257d797e84cdf..245605d5a2aef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4047,6 +4047,10 @@ version "0.0.0" uid "" +"@kbn/deeplinks-analytics@link:packages/deeplinks/analytics": + version "0.0.0" + uid "" + "@kbn/deeplinks-devtools@link:packages/deeplinks/devtools": version "0.0.0" uid "" From 3f4fb414b3a8b125f905d83c11efab27553468c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Mon, 5 Jun 2023 14:58:27 +0100 Subject: [PATCH 06/60] Add generic to AppDeepLink to define ids --- .../core-application-browser/src/application.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/application/core-application-browser/src/application.ts b/packages/core/application/core-application-browser/src/application.ts index 418d8816dd89b..969d5ef4f0df5 100644 --- a/packages/core/application/core-application-browser/src/application.ts +++ b/packages/core/application/core-application-browser/src/application.ts @@ -286,9 +286,9 @@ export type PublicAppDeepLinkInfo = Omit< * user-accessible. * @public */ -export type AppDeepLink = { +export type AppDeepLink = { /** Identifier to represent this sublink, should be unique for this application */ - id: string; + id: Id; /** Title to label represent this deep link */ title: string; /** Optional keywords to match with in deep links search. Omit if this part of the hierarchy does not have a page URL. */ @@ -303,13 +303,13 @@ export type AppDeepLink = { /** URL path to access this link, relative to the application's appRoute. */ path: string; /** Optional array of links that are 'underneath' this section in the hierarchy */ - deepLinks?: AppDeepLink[]; + deepLinks?: Array>; } | { /** Optional path to access this section. Omit if this part of the hierarchy does not have a page URL. */ path?: string; /** Array links that are 'underneath' this section in this hierarchy. */ - deepLinks: AppDeepLink[]; + deepLinks: Array>; } ); From 553dec8f198de8d12b72451d2ffcf260197ce114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Mon, 5 Jun 2023 15:00:40 +0100 Subject: [PATCH 07/60] Add machine learning deeplinks --- package.json | 1 + .../src/project_navigation.ts | 5 +- packages/deeplinks/ml/README.md | 3 + packages/deeplinks/ml/deep_links.ts | 38 +++++++ packages/deeplinks/ml/index.ts | 9 ++ packages/deeplinks/ml/jest.config.js | 13 +++ packages/deeplinks/ml/kibana.jsonc | 5 + packages/deeplinks/ml/package.json | 6 ++ packages/deeplinks/ml/tsconfig.json | 19 ++++ .../navigation/src/ui/nav_tree_presets/ml.ts | 75 ++++---------- .../src/ui/nav_tree_presets/types.ts | 7 +- .../chrome/navigation/src/ui/types.ts | 4 +- tsconfig.base.json | 2 + x-pack/plugins/ml/common/constants/locator.ts | 1 + .../search_deep_links.ts | 98 +++++++++++++------ yarn.lock | 4 + 16 files changed, 197 insertions(+), 93 deletions(-) create mode 100644 packages/deeplinks/ml/README.md create mode 100644 packages/deeplinks/ml/deep_links.ts create mode 100644 packages/deeplinks/ml/index.ts create mode 100644 packages/deeplinks/ml/jest.config.js create mode 100644 packages/deeplinks/ml/kibana.jsonc create mode 100644 packages/deeplinks/ml/package.json create mode 100644 packages/deeplinks/ml/tsconfig.json diff --git a/package.json b/package.json index f78aca98331c5..58109a7f0c461 100644 --- a/package.json +++ b/package.json @@ -353,6 +353,7 @@ "@kbn/datemath": "link:packages/kbn-datemath", "@kbn/deeplinks-analytics": "link:packages/deeplinks/analytics", "@kbn/deeplinks-devtools": "link:packages/deeplinks/devtools", + "@kbn/deeplinks-ml": "link:packages/deeplinks/ml", "@kbn/dev-tools-plugin": "link:src/plugins/dev_tools", "@kbn/developer-examples-plugin": "link:examples/developer_examples", "@kbn/discover-enhanced-plugin": "link:x-pack/plugins/discover_enhanced", 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 e72144c446371..7362adf14a661 100644 --- a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts +++ b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts @@ -11,15 +11,16 @@ import type { AppId as AnalyticsApp, DeepLinkId as AnalyticsDeepLink, } from '@kbn/deeplinks-analytics'; +import type { AppId as MlApp, DeepLinkId as MlToolsLink } from '@kbn/deeplinks-ml'; import type { ChromeBreadcrumb } from './breadcrumb'; import type { ChromeNavLink } from './nav_links'; /** @public */ -export type AppId = DevToolsApp | AnalyticsApp; +export type AppId = DevToolsApp | AnalyticsApp | MlApp; /** @public */ -export type AppDeepLinkId = AnalyticsDeepLink | DevToolsLink; +export type AppDeepLinkId = AnalyticsDeepLink | DevToolsLink | MlToolsLink; /** @public */ export interface ChromeProjectNavigationNode { diff --git a/packages/deeplinks/ml/README.md b/packages/deeplinks/ml/README.md new file mode 100644 index 0000000000000..f96a4807eac53 --- /dev/null +++ b/packages/deeplinks/ml/README.md @@ -0,0 +1,3 @@ +# @kbn/deeplinks-ml + +Empty package generated by @kbn/generate diff --git a/packages/deeplinks/ml/deep_links.ts b/packages/deeplinks/ml/deep_links.ts new file mode 100644 index 0000000000000..f08a1c03e5d0d --- /dev/null +++ b/packages/deeplinks/ml/deep_links.ts @@ -0,0 +1,38 @@ +/* + * 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 ML_APP_ID = 'ml'; + +export type AppId = typeof ML_APP_ID; + +export type LinkId = + | 'overview' + | 'anomalyDetection' + | 'anomalyExplorer' + | 'singleMetricViewer' + | 'dataFrameAnalytics' + | 'resultExplorer' + | 'analyticsMap' + | 'aiOps' + | 'explainLogRateSpikes' + | 'logPatternAnalysis' + | 'changePointDetections' + | 'modelManagement' + | 'nodesOverview' + | 'nodes' + | 'memoryUsage' + | 'dataVisualizer' + | 'fileUpload' + | 'indexDataVisualizer' + | 'settings' + | 'calendarSettings' + | 'calendarSettings' + | 'filterListsSettings' + | 'notifications'; + +export type DeepLinkId = AppId | `${AppId}:${LinkId}`; diff --git a/packages/deeplinks/ml/index.ts b/packages/deeplinks/ml/index.ts new file mode 100644 index 0000000000000..364799992aff7 --- /dev/null +++ b/packages/deeplinks/ml/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/ml/jest.config.js b/packages/deeplinks/ml/jest.config.js new file mode 100644 index 0000000000000..7995276417aca --- /dev/null +++ b/packages/deeplinks/ml/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/ml'], +}; diff --git a/packages/deeplinks/ml/kibana.jsonc b/packages/deeplinks/ml/kibana.jsonc new file mode 100644 index 0000000000000..912c9026a6adb --- /dev/null +++ b/packages/deeplinks/ml/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/deeplinks-ml", + "owner": "@elastic/ml-ui" +} diff --git a/packages/deeplinks/ml/package.json b/packages/deeplinks/ml/package.json new file mode 100644 index 0000000000000..fde897dbb7e1c --- /dev/null +++ b/packages/deeplinks/ml/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/deeplinks-ml", + "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/ml/tsconfig.json b/packages/deeplinks/ml/tsconfig.json new file mode 100644 index 0000000000000..5b34775c71159 --- /dev/null +++ b/packages/deeplinks/ml/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/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts index 9eb49f1da551a..10e6f2ecd3c4c 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts @@ -6,34 +6,20 @@ * Side Public License, v 1. */ -import type { AppDeepLinkId } from '@kbn/core-chrome-browser'; +import type { DeepLinkId as MlDeepLink } from '@kbn/deeplinks-ml'; import type { NodeDefinitionWithChildren } from './types'; export type ID = | 'sharedux:ml' | 'root' - | 'overview' - | 'notifications' | 'anomaly_detection' - | 'jobs' - | 'explorer' - | 'single_metric_viewer' - | 'settings' | 'data_frame_analytics' - | 'results_explorer' - | 'analytics_map' | 'model_management' - | 'trained_models' - | 'nodes' | 'data_visualizer' - | 'file' - | 'data_view' - | 'aiops_labs' - | 'explain_log_rate_spikes' - | 'log_pattern_analysis'; + | 'aiops_labs'; -export const ml: NodeDefinitionWithChildren = { +export const ml: NodeDefinitionWithChildren = { id: 'sharedux:ml', title: 'Machine learning', icon: 'indexMapping', @@ -43,14 +29,10 @@ export const ml: NodeDefinitionWithChildren = { id: 'root', children: [ { - id: 'overview', - title: 'Overview', - href: '/app/ml/overview', + link: 'ml:overview', }, { - id: 'notifications', - title: 'Notifications', - href: '/app/ml/notifications', + link: 'ml:notifications', }, ], }, @@ -59,24 +41,17 @@ export const ml: NodeDefinitionWithChildren = { id: 'anomaly_detection', children: [ { - id: 'jobs', title: 'Jobs', - href: '/app/ml/jobs', + link: 'ml:anomalyDetection', }, { - id: 'explorer', - title: 'Anomaly explorer', - href: '/app/ml/explorer', + link: 'ml:anomalyExplorer', }, { - id: 'single_metric_viewer', - title: 'Single metric viewer', - href: '/app/ml/timeseriesexplorer', + link: 'ml:singleMetricViewer', }, { - id: 'settings', - title: 'Settings', - href: '/app/ml/settings', + link: 'ml:settings', }, ], }, @@ -85,19 +60,14 @@ export const ml: NodeDefinitionWithChildren = { title: 'Data frame analytics', children: [ { - id: 'jobs', title: 'Jobs', - href: '/app/ml/data_frame_analytics', + link: 'ml:dataFrameAnalytics', }, { - id: 'results_explorer', - title: 'Results explorer', - href: '/app/ml/data_frame_analytics/exploration', + link: 'ml:resultExplorer', }, { - id: 'analytics_map', - title: 'Analytics map', - href: '/app/ml/data_frame_analytics/map', + link: 'ml:analyticsMap', }, ], }, @@ -106,14 +76,10 @@ export const ml: NodeDefinitionWithChildren = { title: 'Model management', children: [ { - id: 'trained_models', - title: 'Trained models', - href: '/app/ml/trained_models', + link: 'ml:nodesOverview', }, { - id: 'nodes', - title: 'Nodes', - href: '/app/ml/nodes', + link: 'ml:nodes', }, ], }, @@ -122,14 +88,12 @@ export const ml: NodeDefinitionWithChildren = { title: 'Data visualizer', children: [ { - id: 'file', title: 'File', - href: '/app/ml/filedatavisualizer', + link: 'ml:fileUpload', }, { - id: 'data_view', title: 'Data view', - href: '/app/ml/datavisualizer_index_select', + link: 'ml:indexDataVisualizer', }, ], }, @@ -138,14 +102,11 @@ export const ml: NodeDefinitionWithChildren = { title: 'AIOps labs', children: [ { - id: 'explain_log_rate_spikes', title: 'Explain log rate spikes', - href: '/app/ml/aiops/explain_log_rate_spikes_index_select', + link: 'ml:explainLogRateSpikes', }, { - id: 'log_pattern_analysis', - title: 'Log pattern analysis', - href: '/app/ml/aiops/log_categorization_index_select', + link: 'ml:logPatternAnalysis', }, ], }, diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts index 5feedd450ae9e..8eff1789ad3f8 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts @@ -7,8 +7,9 @@ */ import type { AppDeepLinkId } from '@kbn/core-chrome-browser'; -import type { DeepLinkId as DevToolsLink } from '@kbn/deeplinks-devtools'; +import type { DeepLinkId as DevToolsDeepLink } from '@kbn/deeplinks-devtools'; import type { DeepLinkId as AnalyticsDeepLink } from '@kbn/deeplinks-analytics'; +import type { DeepLinkId as MlDeepLink } from '@kbn/deeplinks-ml'; import type { NodeDefinition } from '../types'; import type { ID as AnalyticsID } from './analytics'; @@ -26,8 +27,8 @@ export type NodeDefinitionWithChildren< export type AnalyticsNodeDefinition = NodeDefinitionWithChildren; -export type DevToolsNodeDefinition = NodeDefinitionWithChildren; +export type DevToolsNodeDefinition = NodeDefinitionWithChildren; export type ManagementNodeDefinition = NodeDefinitionWithChildren; -export type MlNodeDefinition = NodeDefinitionWithChildren; +export type MlNodeDefinition = NodeDefinitionWithChildren; diff --git a/packages/shared-ux/chrome/navigation/src/ui/types.ts b/packages/shared-ux/chrome/navigation/src/ui/types.ts index c88538c608e90..0d82b61baded7 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/types.ts @@ -104,11 +104,11 @@ export interface CloudLinkDefinition extends CloudLinkProps { * * A group root item definition. */ -export interface GroupDefinition extends NodeDefinition { +export interface GroupDefinition extends NodeDefinition { type: 'navGroup'; /** Flag to indicate if the group is initially collapsed or not. */ defaultIsCollapsed?: boolean; - children?: NodeDefinition[]; + children?: Array>; preset?: NavigationGroupPreset; } diff --git a/tsconfig.base.json b/tsconfig.base.json index bf1f4f02662dc..40aee9fed1637 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -610,6 +610,8 @@ "@kbn/deeplinks-analytics/*": ["packages/deeplinks/analytics/*"], "@kbn/deeplinks-devtools": ["packages/deeplinks/devtools"], "@kbn/deeplinks-devtools/*": ["packages/deeplinks/devtools/*"], + "@kbn/deeplinks-ml": ["packages/deeplinks/ml"], + "@kbn/deeplinks-ml/*": ["packages/deeplinks/ml/*"], "@kbn/dev-cli-errors": ["packages/kbn-dev-cli-errors"], "@kbn/dev-cli-errors/*": ["packages/kbn-dev-cli-errors/*"], "@kbn/dev-cli-runner": ["packages/kbn-dev-cli-runner"], diff --git a/x-pack/plugins/ml/common/constants/locator.ts b/x-pack/plugins/ml/common/constants/locator.ts index d23a7754d4e75..d0b18773ad84a 100644 --- a/x-pack/plugins/ml/common/constants/locator.ts +++ b/x-pack/plugins/ml/common/constants/locator.ts @@ -15,6 +15,7 @@ export const ML_PAGES = { DATA_FRAME_ANALYTICS_SOURCE_SELECTION: 'data_frame_analytics/source_selection', DATA_FRAME_ANALYTICS_CREATE_JOB: 'data_frame_analytics/new_job', TRAINED_MODELS_MANAGE: 'trained_models', + NODES: 'nodes', MEMORY_USAGE: 'memory_usage', DATA_FRAME_ANALYTICS_EXPLORATION: 'data_frame_analytics/exploration', DATA_FRAME_ANALYTICS_MAP: 'data_frame_analytics/map', diff --git a/x-pack/plugins/ml/public/register_helper/register_search_links/search_deep_links.ts b/x-pack/plugins/ml/public/register_helper/register_search_links/search_deep_links.ts index 2b1cc16f131b6..d892c949b1d52 100644 --- a/x-pack/plugins/ml/public/register_helper/register_search_links/search_deep_links.ts +++ b/x-pack/plugins/ml/public/register_helper/register_search_links/search_deep_links.ts @@ -6,36 +6,69 @@ */ import { i18n } from '@kbn/i18n'; +import type { LinkId } from '@kbn/deeplinks-ml'; import type { AppDeepLink } from '@kbn/core/public'; import { ML_PAGES } from '../../../common/constants/locator'; -const OVERVIEW_LINK_DEEP_LINK: AppDeepLink = { - id: 'mlOverviewDeepLink', +const OVERVIEW_LINK_DEEP_LINK: AppDeepLink = { + id: 'overview', title: i18n.translate('xpack.ml.deepLink.overview', { defaultMessage: 'Overview', }), path: `/${ML_PAGES.OVERVIEW}`, }; -const ANOMALY_DETECTION_DEEP_LINK: AppDeepLink = { - id: 'mlAnomalyDetectionDeepLink', +const ANOMALY_DETECTION_DEEP_LINK: AppDeepLink = { + id: 'anomalyDetection', title: i18n.translate('xpack.ml.deepLink.anomalyDetection', { defaultMessage: 'Anomaly Detection', }), path: `/${ML_PAGES.ANOMALY_DETECTION_JOBS_MANAGE}`, + deepLinks: [ + { + id: 'anomalyExplorer', + title: i18n.translate('xpack.ml.deepLink.anomalyExplorer', { + defaultMessage: 'Anomaly explorer', + }), + path: `/${ML_PAGES.ANOMALY_EXPLORER}`, + }, + { + id: 'singleMetricViewer', + title: i18n.translate('xpack.ml.deepLink.singleMetricViewer', { + defaultMessage: 'Single metric viewer', + }), + path: `/${ML_PAGES.SINGLE_METRIC_VIEWER}`, + }, + ], }; -const DATA_FRAME_ANALYTICS_DEEP_LINK: AppDeepLink = { - id: 'mlDataFrameAnalyticsDeepLink', +const DATA_FRAME_ANALYTICS_DEEP_LINK: AppDeepLink = { + id: 'dataFrameAnalytics', title: i18n.translate('xpack.ml.deepLink.dataFrameAnalytics', { defaultMessage: 'Data Frame Analytics', }), path: `/${ML_PAGES.DATA_FRAME_ANALYTICS_JOBS_MANAGE}`, + deepLinks: [ + { + id: 'resultExplorer', + title: i18n.translate('xpack.ml.deepLink.resultExplorer', { + defaultMessage: 'Results explorer', + }), + path: `/${ML_PAGES.DATA_FRAME_ANALYTICS_EXPLORATION}`, + }, + { + id: 'analyticsMap', + title: i18n.translate('xpack.ml.deepLink.analyticsMap', { + defaultMessage: 'Analytics map', + }), + path: `/${ML_PAGES.DATA_FRAME_ANALYTICS_MAP}`, + }, + ], }; -const AIOPS_DEEP_LINK: AppDeepLink = { - id: 'aiOpsDeepLink', +const AIOPS_DEEP_LINK: AppDeepLink = { + id: 'aiOps', title: i18n.translate('xpack.ml.deepLink.aiOps', { defaultMessage: 'AIOps', }), @@ -43,21 +76,21 @@ const AIOPS_DEEP_LINK: AppDeepLink = { path: `/${ML_PAGES.AIOPS_EXPLAIN_LOG_RATE_SPIKES_INDEX_SELECT}`, deepLinks: [ { - id: 'explainLogRateSpikesDeepLink', + id: 'explainLogRateSpikes', title: i18n.translate('xpack.ml.deepLink.explainLogRateSpikes', { defaultMessage: 'Explain Log Rate Spikes', }), path: `/${ML_PAGES.AIOPS_EXPLAIN_LOG_RATE_SPIKES_INDEX_SELECT}`, }, { - id: 'logPatternAnalysisDeepLink', + id: 'logPatternAnalysis', title: i18n.translate('xpack.ml.deepLink.logPatternAnalysis', { defaultMessage: 'Log Pattern Analysis', }), path: `/${ML_PAGES.AIOPS_LOG_CATEGORIZATION_INDEX_SELECT}`, }, { - id: 'changePointDetectionsDeepLink', + id: 'changePointDetections', title: i18n.translate('xpack.ml.deepLink.changePointDetection', { defaultMessage: 'Change Point Detection', }), @@ -66,41 +99,48 @@ const AIOPS_DEEP_LINK: AppDeepLink = { ], }; -const MODEL_MANAGEMENT_DEEP_LINK: AppDeepLink = { - id: 'mlModelManagementDeepLink', +const MODEL_MANAGEMENT_DEEP_LINK: AppDeepLink = { + id: 'modelManagement', title: i18n.translate('xpack.ml.deepLink.modelManagement', { defaultMessage: 'Model Management', }), path: `/${ML_PAGES.TRAINED_MODELS_MANAGE}`, deepLinks: [ { - id: 'mlNodesOverviewDeepLink', + id: 'nodesOverview', title: i18n.translate('xpack.ml.deepLink.trainedModels', { defaultMessage: 'Trained Models', }), path: `/${ML_PAGES.TRAINED_MODELS_MANAGE}`, }, + { + id: 'nodes', + title: i18n.translate('xpack.ml.deepLink.nodes', { + defaultMessage: 'Nodes', + }), + path: `/${ML_PAGES.NODES}`, + }, ], }; -const MEMORY_USAGE_DEEP_LINK: AppDeepLink = { - id: 'mlMemoryUsageDeepLink', +const MEMORY_USAGE_DEEP_LINK: AppDeepLink = { + id: 'memoryUsage', title: i18n.translate('xpack.ml.deepLink.memoryUsage', { defaultMessage: 'Memory Usage', }), path: `/${ML_PAGES.MEMORY_USAGE}`, }; -const DATA_VISUALIZER_DEEP_LINK: AppDeepLink = { - id: 'dataVisualizerDeepLink', +const DATA_VISUALIZER_DEEP_LINK: AppDeepLink = { + id: 'dataVisualizer', title: i18n.translate('xpack.ml.deepLink.dataVisualizer', { defaultMessage: 'Data Visualizer', }), path: `/${ML_PAGES.DATA_VISUALIZER}`, }; -const FILE_UPLOAD_DEEP_LINK: AppDeepLink = { - id: 'mlFileUploadDeepLink', +const FILE_UPLOAD_DEEP_LINK: AppDeepLink = { + id: 'fileUpload', title: i18n.translate('xpack.ml.deepLink.fileUpload', { defaultMessage: 'File Upload', }), @@ -108,30 +148,30 @@ const FILE_UPLOAD_DEEP_LINK: AppDeepLink = { path: `/${ML_PAGES.DATA_VISUALIZER_FILE}`, }; -const INDEX_DATA_VISUALIZER_DEEP_LINK: AppDeepLink = { - id: 'mlIndexDataVisualizerDeepLink', +const INDEX_DATA_VISUALIZER_DEEP_LINK: AppDeepLink = { + id: 'indexDataVisualizer', title: i18n.translate('xpack.ml.deepLink.indexDataVisualizer', { defaultMessage: 'Index Data Visualizer', }), path: `/${ML_PAGES.DATA_VISUALIZER_INDEX_SELECT}`, }; -const SETTINGS_DEEP_LINK: AppDeepLink = { - id: 'mlSettingsDeepLink', +const SETTINGS_DEEP_LINK: AppDeepLink = { + id: 'settings', title: i18n.translate('xpack.ml.deepLink.settings', { defaultMessage: 'Settings', }), path: `/${ML_PAGES.SETTINGS}`, deepLinks: [ { - id: 'mlCalendarSettingsDeepLink', + id: 'calendarSettings', title: i18n.translate('xpack.ml.deepLink.calendarSettings', { defaultMessage: 'Calendars', }), path: `/${ML_PAGES.CALENDARS_MANAGE}`, }, { - id: 'mlFilterListsSettingsDeepLink', + id: 'filterListsSettings', title: i18n.translate('xpack.ml.deepLink.filterListsSettings', { defaultMessage: 'Filter Lists', }), @@ -140,8 +180,8 @@ const SETTINGS_DEEP_LINK: AppDeepLink = { ], }; -const NOTIFICATIONS_DEEP_LINK: AppDeepLink = { - id: 'mlNotificationsDeepLink', +const NOTIFICATIONS_DEEP_LINK: AppDeepLink = { + id: 'notifications', title: i18n.translate('xpack.ml.deepLink.notifications', { defaultMessage: 'Notifications', }), @@ -149,7 +189,7 @@ const NOTIFICATIONS_DEEP_LINK: AppDeepLink = { }; export function getDeepLinks(isFullLicense: boolean) { - const deepLinks: AppDeepLink[] = [ + const deepLinks: Array> = [ DATA_VISUALIZER_DEEP_LINK, FILE_UPLOAD_DEEP_LINK, INDEX_DATA_VISUALIZER_DEEP_LINK, diff --git a/yarn.lock b/yarn.lock index 245605d5a2aef..1765e0effd539 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4055,6 +4055,10 @@ version "0.0.0" uid "" +"@kbn/deeplinks-ml@link:packages/deeplinks/ml": + version "0.0.0" + uid "" + "@kbn/dev-cli-errors@link:packages/kbn-dev-cli-errors": version "0.0.0" uid "" From 015c81a152962a574640f759309856ab0a846ab8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Mon, 5 Jun 2023 15:16:38 +0100 Subject: [PATCH 08/60] Move ml default navigation to the deeplinks package --- .../ml/default_navigation.ts} | 10 ++++++---- packages/deeplinks/ml/index.ts | 2 ++ .../src/ui/nav_tree_presets/analytics.ts | 2 +- .../src/ui/nav_tree_presets/devtools.ts | 2 +- .../src/ui/nav_tree_presets/index.ts | 4 ++-- .../src/ui/nav_tree_presets/management.ts | 2 +- .../src/ui/nav_tree_presets/types.ts | 14 +------------ .../chrome/navigation/src/ui/types.ts | 20 +++++++++++++++++-- 8 files changed, 32 insertions(+), 24 deletions(-) rename packages/{shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts => deeplinks/ml/default_navigation.ts} (88%) diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts b/packages/deeplinks/ml/default_navigation.ts similarity index 88% rename from packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts rename to packages/deeplinks/ml/default_navigation.ts index 10e6f2ecd3c4c..da29c0237b7ea 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/ml.ts +++ b/packages/deeplinks/ml/default_navigation.ts @@ -6,11 +6,11 @@ * Side Public License, v 1. */ -import type { DeepLinkId as MlDeepLink } from '@kbn/deeplinks-ml'; +import type { NodeDefinitionWithChildren } from '@kbn/shared-ux-chrome-navigation'; -import type { NodeDefinitionWithChildren } from './types'; +import type { DeepLinkId } from './deep_links'; -export type ID = +export type NavigationID = | 'sharedux:ml' | 'root' | 'anomaly_detection' @@ -19,7 +19,9 @@ export type ID = | 'data_visualizer' | 'aiops_labs'; -export const ml: NodeDefinitionWithChildren = { +export type MlNodeDefinition = NodeDefinitionWithChildren; + +export const defaultNavigation: MlNodeDefinition = { id: 'sharedux:ml', title: 'Machine learning', icon: 'indexMapping', diff --git a/packages/deeplinks/ml/index.ts b/packages/deeplinks/ml/index.ts index 364799992aff7..0d624c9062a52 100644 --- a/packages/deeplinks/ml/index.ts +++ b/packages/deeplinks/ml/index.ts @@ -7,3 +7,5 @@ */ export type { LinkId, AppId, DeepLinkId } from './deep_links'; + +export { defaultNavigation, type NavigationID, type MlNodeDefinition } from './default_navigation'; diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/analytics.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/analytics.ts index 0668c429f5ceb..777db635ded65 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/analytics.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/analytics.ts @@ -8,7 +8,7 @@ import type { DeepLinkId as AnalyticsDeepLink } from '@kbn/deeplinks-analytics'; -import type { NodeDefinitionWithChildren } from './types'; +import type { NodeDefinitionWithChildren } from '../types'; export type ID = 'sharedux:analytics' | 'root'; diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts index 07438d289a7b1..fbc2ca47d8578 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts @@ -7,7 +7,7 @@ */ import type { DeepLinkId as DevToolsLink } from '@kbn/deeplinks-devtools'; -import type { NodeDefinitionWithChildren } from './types'; +import type { NodeDefinitionWithChildren } from '../types'; export type ID = 'sharedux:devtools' | 'root'; diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts index 7bbb566d2ba03..dd0b999d9fc67 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts @@ -8,17 +8,17 @@ import { cloneDeep } from 'lodash'; +import { defaultNavigation as ml, type MlNodeDefinition } from '@kbn/deeplinks-ml'; + import type { NavigationGroupPreset } from '../types'; import type { AnalyticsNodeDefinition, DevToolsNodeDefinition, ManagementNodeDefinition, - MlNodeDefinition, } from './types'; import { analytics } from './analytics'; import { devtools } from './devtools'; import { management } from './management'; -import { ml } from './ml'; export function getPresets(preset: 'devtools'): DevToolsNodeDefinition; export function getPresets(preset: 'management'): ManagementNodeDefinition; diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts index a0d68513ca29a..9765cad3cf5fb 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts @@ -7,7 +7,7 @@ */ import type { AppDeepLinkId } from '@kbn/core-chrome-browser'; -import type { NodeDefinitionWithChildren } from './types'; +import type { NodeDefinitionWithChildren } from '../types'; export type ID = | 'sharedux:management' diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts index 8eff1789ad3f8..1d40c076b3398 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts @@ -9,26 +9,14 @@ import type { AppDeepLinkId } from '@kbn/core-chrome-browser'; import type { DeepLinkId as DevToolsDeepLink } from '@kbn/deeplinks-devtools'; import type { DeepLinkId as AnalyticsDeepLink } from '@kbn/deeplinks-analytics'; -import type { DeepLinkId as MlDeepLink } from '@kbn/deeplinks-ml'; -import type { NodeDefinition } from '../types'; +import type { NodeDefinitionWithChildren } from '../types'; import type { ID as AnalyticsID } from './analytics'; import type { ID as DevtoolsID } from './devtools'; import type { ID as ManagementID } from './management'; -import type { ID as MlID } from './ml'; - -export type NodeDefinitionWithChildren< - LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, - ChildrenID extends string = Id -> = NodeDefinition & { - children: Required>['children']; -}; export type AnalyticsNodeDefinition = NodeDefinitionWithChildren; export type DevToolsNodeDefinition = NodeDefinitionWithChildren; export type ManagementNodeDefinition = NodeDefinitionWithChildren; - -export type MlNodeDefinition = NodeDefinitionWithChildren; diff --git a/packages/shared-ux/chrome/navigation/src/ui/types.ts b/packages/shared-ux/chrome/navigation/src/ui/types.ts index 0d82b61baded7..9f93eb2dfc470 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/types.ts @@ -11,6 +11,8 @@ import type { AppDeepLinkId, ChromeProjectNavigationNode } from '@kbn/core-chrom import type { CloudLinkProps, RecentlyAccessedProps } from './components'; +export type NonEmptyArray = [T, ...T[]]; + /** * @public * @@ -31,7 +33,7 @@ export interface NodeDefinition< /** Optional icon for the navigation node. Note: not all navigation depth will render the icon */ icon?: string; /** Optional children of the navigation node */ - children?: Array>; + children?: NonEmptyArray>; /** * Temporarilly we allow href to be passed. * Once all the deeplinks will be exposed in packages we will not allow href anymore @@ -40,6 +42,20 @@ export interface NodeDefinition< href?: string; } +/** + * @public + * + * A navigation node definition with its unique id, title, path in the tree and optional + * deep link and children. + */ +export type NodeDefinitionWithChildren< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenID extends string = Id +> = NodeDefinition & { + children: Required>['children']; +}; + /** * @public * @@ -108,7 +124,7 @@ export interface GroupDefinition extends NodeDefinition { type: 'navGroup'; /** Flag to indicate if the group is initially collapsed or not. */ defaultIsCollapsed?: boolean; - children?: Array>; + children?: NonEmptyArray>; preset?: NavigationGroupPreset; } From 9b785f8e2c60986ca78a1be5423fa613a8f89269 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Tue, 6 Jun 2023 14:22:45 +0100 Subject: [PATCH 09/60] Update types --- packages/shared-ux/chrome/navigation/src/ui/types.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/shared-ux/chrome/navigation/src/ui/types.ts b/packages/shared-ux/chrome/navigation/src/ui/types.ts index 9f93eb2dfc470..abdb6a2716162 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/types.ts @@ -120,11 +120,11 @@ export interface CloudLinkDefinition extends CloudLinkProps { * * A group root item definition. */ -export interface GroupDefinition extends NodeDefinition { +export interface GroupDefinition extends NodeDefinition { type: 'navGroup'; /** Flag to indicate if the group is initially collapsed or not. */ defaultIsCollapsed?: boolean; - children?: NonEmptyArray>; + children?: NonEmptyArray>; preset?: NavigationGroupPreset; } From 0a3d98de039216e53e87fd9653af2bd3ac038581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Tue, 6 Jun 2023 15:40:03 +0100 Subject: [PATCH 10/60] Move analytics default navigation to package --- packages/deeplinks/analytics/constants.ts | 13 +++++++++++++ packages/deeplinks/analytics/deep_links.ts | 13 +++++++++++++ .../analytics/default_navigation.ts} | 19 ++++++++++--------- packages/deeplinks/analytics/index.ts | 14 +++++++------- .../src/ui/nav_tree_presets/index.ts | 11 +++++------ .../src/ui/nav_tree_presets/types.ts | 4 ---- 6 files changed, 48 insertions(+), 26 deletions(-) create mode 100644 packages/deeplinks/analytics/constants.ts create mode 100644 packages/deeplinks/analytics/deep_links.ts rename packages/{shared-ux/chrome/navigation/src/ui/nav_tree_presets/analytics.ts => deeplinks/analytics/default_navigation.ts} (54%) diff --git a/packages/deeplinks/analytics/constants.ts b/packages/deeplinks/analytics/constants.ts new file mode 100644 index 0000000000000..a67516b808de0 --- /dev/null +++ b/packages/deeplinks/analytics/constants.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 DISCOVER_APP_ID = 'discover'; + +export const DASHBOARD_APP_ID = 'dashboard'; + +export const VISUALIZE_APP_ID = 'visualize'; diff --git a/packages/deeplinks/analytics/deep_links.ts b/packages/deeplinks/analytics/deep_links.ts new file mode 100644 index 0000000000000..e2a19ee30b80d --- /dev/null +++ b/packages/deeplinks/analytics/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. + */ + +import { DASHBOARD_APP_ID, DISCOVER_APP_ID, VISUALIZE_APP_ID } from './constants'; + +export type AppId = typeof DISCOVER_APP_ID | typeof DASHBOARD_APP_ID | typeof VISUALIZE_APP_ID; + +export type DeepLinkId = AppId; diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/analytics.ts b/packages/deeplinks/analytics/default_navigation.ts similarity index 54% rename from packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/analytics.ts rename to packages/deeplinks/analytics/default_navigation.ts index 777db635ded65..214a7f8da810f 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/analytics.ts +++ b/packages/deeplinks/analytics/default_navigation.ts @@ -5,28 +5,29 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ +import { i18n } from '@kbn/i18n'; +import type { NodeDefinitionWithChildren } from '@kbn/shared-ux-chrome-navigation'; -import type { DeepLinkId as AnalyticsDeepLink } from '@kbn/deeplinks-analytics'; +import type { DeepLinkId } from './deep_links'; -import type { NodeDefinitionWithChildren } from '../types'; +export type NavigationID = 'rootNav:analytics' | 'root'; -export type ID = 'sharedux:analytics' | 'root'; +export type AnalyticsNodeDefinition = NodeDefinitionWithChildren; -export const analytics: NodeDefinitionWithChildren = { - // Make sure we have a unique id otherwise it might override a custom id from the project - id: 'sharedux:analytics', - title: 'Data exploration', +export const defaultNavigation: AnalyticsNodeDefinition = { + id: 'rootNav:analytics', + title: i18n.translate('deeplinks.analytics.dataExploration', { + defaultMessage: 'Data exploration', + }), icon: 'stats', children: [ { id: 'root', children: [ { - title: 'Discover', link: 'discover', }, { - title: 'Dashboard', link: 'dashboard', }, { diff --git a/packages/deeplinks/analytics/index.ts b/packages/deeplinks/analytics/index.ts index ca6180a1efddd..e705d79bcb688 100644 --- a/packages/deeplinks/analytics/index.ts +++ b/packages/deeplinks/analytics/index.ts @@ -6,12 +6,12 @@ * Side Public License, v 1. */ -export const DISCOVER_APP_ID = 'discover'; +export { DASHBOARD_APP_ID, DISCOVER_APP_ID, VISUALIZE_APP_ID } from './constants'; -export const DASHBOARD_APP_ID = 'dashboard'; +export { + defaultNavigation, + type NavigationID, + type AnalyticsNodeDefinition, +} from './default_navigation'; -export const VISUALIZE_APP_ID = 'visualize'; - -export type AppId = typeof DISCOVER_APP_ID | typeof DASHBOARD_APP_ID | typeof VISUALIZE_APP_ID; - -export type DeepLinkId = AppId; +export type { AppId, DeepLinkId } from './deep_links'; diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts index dd0b999d9fc67..76973a4a04f7e 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts @@ -8,15 +8,14 @@ import { cloneDeep } from 'lodash'; +import { + defaultNavigation as analytics, + type AnalyticsNodeDefinition, +} from '@kbn/deeplinks-analytics'; import { defaultNavigation as ml, type MlNodeDefinition } from '@kbn/deeplinks-ml'; import type { NavigationGroupPreset } from '../types'; -import type { - AnalyticsNodeDefinition, - DevToolsNodeDefinition, - ManagementNodeDefinition, -} from './types'; -import { analytics } from './analytics'; +import type { DevToolsNodeDefinition, ManagementNodeDefinition } from './types'; import { devtools } from './devtools'; import { management } from './management'; diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts index 1d40c076b3398..804d536a31c42 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts @@ -8,15 +8,11 @@ import type { AppDeepLinkId } from '@kbn/core-chrome-browser'; import type { DeepLinkId as DevToolsDeepLink } from '@kbn/deeplinks-devtools'; -import type { DeepLinkId as AnalyticsDeepLink } from '@kbn/deeplinks-analytics'; import type { NodeDefinitionWithChildren } from '../types'; -import type { ID as AnalyticsID } from './analytics'; import type { ID as DevtoolsID } from './devtools'; import type { ID as ManagementID } from './management'; -export type AnalyticsNodeDefinition = NodeDefinitionWithChildren; - export type DevToolsNodeDefinition = NodeDefinitionWithChildren; export type ManagementNodeDefinition = NodeDefinitionWithChildren; From d051dd2dbd976f17c730362e308a0bac2ce0e2ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Tue, 6 Jun 2023 15:41:13 +0100 Subject: [PATCH 11/60] Add i18n to defaultNavigation ml --- .i18nrc.json | 1 + packages/deeplinks/ml/default_navigation.ts | 45 +++++++++++++++------ 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/.i18nrc.json b/.i18nrc.json index a2f4444c54d3a..c08634b2b8aeb 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -19,6 +19,7 @@ "data": "src/plugins/data", "observabilityAlertDetails": "x-pack/packages/observability/alert_details", "dataViews": "src/plugins/data_views", + "deepLinks": "packages/deeplinks", "devTools": "src/plugins/dev_tools", "discover": "src/plugins/discover", "savedSearch": "src/plugins/saved_search", diff --git a/packages/deeplinks/ml/default_navigation.ts b/packages/deeplinks/ml/default_navigation.ts index da29c0237b7ea..0ce21ff098eeb 100644 --- a/packages/deeplinks/ml/default_navigation.ts +++ b/packages/deeplinks/ml/default_navigation.ts @@ -5,13 +5,14 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ +import { i18n } from '@kbn/i18n'; import type { NodeDefinitionWithChildren } from '@kbn/shared-ux-chrome-navigation'; import type { DeepLinkId } from './deep_links'; export type NavigationID = - | 'sharedux:ml' + | 'rootNav:ml' | 'root' | 'anomaly_detection' | 'data_frame_analytics' @@ -22,8 +23,10 @@ export type NavigationID = export type MlNodeDefinition = NodeDefinitionWithChildren; export const defaultNavigation: MlNodeDefinition = { - id: 'sharedux:ml', - title: 'Machine learning', + id: 'rootNav:ml', + title: i18n.translate('deeplinks.ml.machineLearning', { + defaultMessage: 'Machine learning', + }), icon: 'indexMapping', children: [ { @@ -39,11 +42,15 @@ export const defaultNavigation: MlNodeDefinition = { ], }, { - title: 'Anomaly detection', + title: i18n.translate('deeplinks.ml.anomalyDetection', { + defaultMessage: 'Anomaly Detection', + }), id: 'anomaly_detection', children: [ { - title: 'Jobs', + title: i18n.translate('deeplinks.ml.jobs', { + defaultMessage: 'Jobs', + }), link: 'ml:anomalyDetection', }, { @@ -59,7 +66,9 @@ export const defaultNavigation: MlNodeDefinition = { }, { id: 'data_frame_analytics', - title: 'Data frame analytics', + title: i18n.translate('deeplinks.ml.dataFrameAnalytics', { + defaultMessage: 'Data frame analytics', + }), children: [ { title: 'Jobs', @@ -75,7 +84,9 @@ export const defaultNavigation: MlNodeDefinition = { }, { id: 'model_management', - title: 'Model management', + title: i18n.translate('deeplinks.ml.modelManagement', { + defaultMessage: 'Model management', + }), children: [ { link: 'ml:nodesOverview', @@ -87,24 +98,34 @@ export const defaultNavigation: MlNodeDefinition = { }, { id: 'data_visualizer', - title: 'Data visualizer', + title: i18n.translate('deeplinks.ml.dataVisualizer', { + defaultMessage: 'Data visualizer', + }), children: [ { - title: 'File', + title: i18n.translate('deeplinks.ml.file', { + defaultMessage: 'File', + }), link: 'ml:fileUpload', }, { - title: 'Data view', + title: i18n.translate('deeplinks.ml.dataView', { + defaultMessage: 'Data view', + }), link: 'ml:indexDataVisualizer', }, ], }, { id: 'aiops_labs', - title: 'AIOps labs', + title: i18n.translate('deeplinks.ml.aiopsLabs', { + defaultMessage: 'AIOps labs', + }), children: [ { - title: 'Explain log rate spikes', + title: i18n.translate('deeplinks.ml.explainLogRateSpikes', { + defaultMessage: 'Explain log rate spikes', + }), link: 'ml:explainLogRateSpikes', }, { From 04228b5d96cb795a81bb053c963ed8495fd9502a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Tue, 6 Jun 2023 15:55:40 +0100 Subject: [PATCH 12/60] Move devtools default navigation to package --- packages/deeplinks/devtools/constants.ts | 43 +++++++++++++++ packages/deeplinks/devtools/deep_links.ts | 15 +++++ .../devtools/default_navigation.ts} | 21 +++---- packages/deeplinks/devtools/index.ts | 55 ++++++------------- .../src/ui/nav_tree_presets/index.ts | 7 ++- .../src/ui/nav_tree_presets/types.ts | 4 -- 6 files changed, 90 insertions(+), 55 deletions(-) create mode 100644 packages/deeplinks/devtools/constants.ts create mode 100644 packages/deeplinks/devtools/deep_links.ts rename packages/{shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts => deeplinks/devtools/default_navigation.ts} (58%) diff --git a/packages/deeplinks/devtools/constants.ts b/packages/deeplinks/devtools/constants.ts new file mode 100644 index 0000000000000..37322dd95558a --- /dev/null +++ b/packages/deeplinks/devtools/constants.ts @@ -0,0 +1,43 @@ +/* + * 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 { AppDeepLink } from '@kbn/core/public'; + +import type { LinkId } from './deep_links'; + +export const DEV_TOOLS_APP_ID = 'dev_tools'; + +export const searchProfiler: AppDeepLink = { + id: 'searchprofiler', + title: 'Search Profiler', + path: '#/searchprofiler', +}; + +export const painlessLab: AppDeepLink = { + id: 'painless_lab', + title: 'Painless Lab', + path: '#/painless_lab', +}; + +export const grokDebugger: AppDeepLink = { + id: 'grokdebugger', + title: 'Grok Debugger', + path: '#/grokdebugger', +}; + +export const console: AppDeepLink = { + id: 'console', + title: 'Console', + path: '#/console', +}; + +export const deepLinks: Array> = [ + searchProfiler, + painlessLab, + grokDebugger, + console, +]; diff --git a/packages/deeplinks/devtools/deep_links.ts b/packages/deeplinks/devtools/deep_links.ts new file mode 100644 index 0000000000000..8ec43edd6d3fe --- /dev/null +++ b/packages/deeplinks/devtools/deep_links.ts @@ -0,0 +1,15 @@ +/* + * 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 { DEV_TOOLS_APP_ID } from './constants'; + +export type AppId = typeof DEV_TOOLS_APP_ID; + +export type LinkId = 'searchprofiler' | 'painless_lab' | 'grokdebugger' | 'console'; + +export type DeepLinkId = AppId | `${AppId}:${LinkId}`; diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts b/packages/deeplinks/devtools/default_navigation.ts similarity index 58% rename from packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts rename to packages/deeplinks/devtools/default_navigation.ts index fbc2ca47d8578..955868e6d715e 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/devtools.ts +++ b/packages/deeplinks/devtools/default_navigation.ts @@ -5,34 +5,35 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { DeepLinkId as DevToolsLink } from '@kbn/deeplinks-devtools'; +import { i18n } from '@kbn/i18n'; +import type { NodeDefinitionWithChildren } from '@kbn/shared-ux-chrome-navigation'; -import type { NodeDefinitionWithChildren } from '../types'; +import type { DeepLinkId } from './deep_links'; -export type ID = 'sharedux:devtools' | 'root'; +export type NavigationID = 'rootNav:devtools' | 'root'; -export const devtools: NodeDefinitionWithChildren = { - title: 'Developer tools', - id: 'sharedux:devtools', +export type DevToolsNodeDefinition = NodeDefinitionWithChildren; + +export const defaultNavigation: DevToolsNodeDefinition = { + title: i18n.translate('deeplinks.devTools.developerTools', { + defaultMessage: 'Developer tools', + }), + id: 'rootNav:devtools', icon: 'editorCodeBlock', children: [ { id: 'root', children: [ { - title: 'Console', link: 'dev_tools:console', }, { - title: 'Search profiler', link: 'dev_tools:searchprofiler', }, { - title: 'Grok debugger', link: 'dev_tools:grokdebugger', }, { - title: 'Painless lab', link: 'dev_tools:painless_lab', }, ], diff --git a/packages/deeplinks/devtools/index.ts b/packages/deeplinks/devtools/index.ts index 571c2e0b58a24..60b20580f1006 100644 --- a/packages/deeplinks/devtools/index.ts +++ b/packages/deeplinks/devtools/index.ts @@ -6,42 +6,19 @@ * Side Public License, v 1. */ -export const DEV_TOOLS_APP_ID = 'dev_tools'; - -export const searchProfiler = { - id: 'searchprofiler', - title: 'Search Profiler', - path: '#/searchprofiler', -} as const; - -export const painlessLab = { - id: 'painless_lab', - title: 'Painless Lab', - path: '#/painless_lab', -} as const; - -export const grokDebugger = { - id: 'grokdebugger', - title: 'Grok Debugger', - path: '#/grokdebugger', -} as const; - -export const console = { - id: 'console', - title: 'Console', - path: '#/console', -} as const; - -export type DeepLink = - | typeof searchProfiler - | typeof painlessLab - | typeof grokDebugger - | typeof console; - -export type AppId = typeof DEV_TOOLS_APP_ID; - -export type LinkId = DeepLink['id']; - -export type DeepLinkId = AppId | `${AppId}:${LinkId}`; - -export const deepLinks: DeepLink[] = [searchProfiler, painlessLab, grokDebugger, console]; +export { + DEV_TOOLS_APP_ID, + console, + deepLinks, + grokDebugger, + painlessLab, + searchProfiler, +} from './constants'; + +export type { AppId, LinkId, DeepLinkId } from './deep_links'; + +export { + defaultNavigation, + type NavigationID, + type DevToolsNodeDefinition, +} from './default_navigation'; diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts index 76973a4a04f7e..af30c99706ae4 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts @@ -13,10 +13,13 @@ import { type AnalyticsNodeDefinition, } from '@kbn/deeplinks-analytics'; import { defaultNavigation as ml, type MlNodeDefinition } from '@kbn/deeplinks-ml'; +import { + defaultNavigation as devtools, + type DevToolsNodeDefinition, +} from '@kbn/deeplinks-devtools'; import type { NavigationGroupPreset } from '../types'; -import type { DevToolsNodeDefinition, ManagementNodeDefinition } from './types'; -import { devtools } from './devtools'; +import type { ManagementNodeDefinition } from './types'; import { management } from './management'; export function getPresets(preset: 'devtools'): DevToolsNodeDefinition; diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts index 804d536a31c42..a8a3506edbfa0 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts @@ -7,12 +7,8 @@ */ import type { AppDeepLinkId } from '@kbn/core-chrome-browser'; -import type { DeepLinkId as DevToolsDeepLink } from '@kbn/deeplinks-devtools'; import type { NodeDefinitionWithChildren } from '../types'; -import type { ID as DevtoolsID } from './devtools'; import type { ID as ManagementID } from './management'; -export type DevToolsNodeDefinition = NodeDefinitionWithChildren; - export type ManagementNodeDefinition = NodeDefinitionWithChildren; From 8421ee4aadfa2a78b9b7ffbb119979fcdcfcabae Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 6 Jun 2023 13:50:03 +0000 Subject: [PATCH 13/60] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- packages/core/chrome/core-chrome-browser/tsconfig.json | 5 ++++- packages/deeplinks/analytics/tsconfig.json | 2 +- packages/deeplinks/devtools/tsconfig.json | 2 +- packages/deeplinks/ml/tsconfig.json | 6 ++++-- packages/shared-ux/chrome/navigation/tsconfig.json | 5 ++++- src/plugins/dev_tools/tsconfig.json | 1 + x-pack/plugins/ml/tsconfig.json | 1 + 7 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/core/chrome/core-chrome-browser/tsconfig.json b/packages/core/chrome/core-chrome-browser/tsconfig.json index 281389cd0927c..6c4cc21ee9191 100644 --- a/packages/core/chrome/core-chrome-browser/tsconfig.json +++ b/packages/core/chrome/core-chrome-browser/tsconfig.json @@ -13,7 +13,10 @@ ], "kbn_references": [ "@kbn/core-mount-utils-browser", - "@kbn/core-application-common" + "@kbn/core-application-common", + "@kbn/deeplinks-devtools", + "@kbn/deeplinks-analytics", + "@kbn/deeplinks-ml" ], "exclude": [ "target/**/*", diff --git a/packages/deeplinks/analytics/tsconfig.json b/packages/deeplinks/analytics/tsconfig.json index 5b34775c71159..d1414086f2187 100644 --- a/packages/deeplinks/analytics/tsconfig.json +++ b/packages/deeplinks/analytics/tsconfig.json @@ -10,7 +10,7 @@ }, "include": [ "**/*.ts", - "**/*.tsx", + "**/*.tsx", ], "exclude": [ "target/**/*" diff --git a/packages/deeplinks/devtools/tsconfig.json b/packages/deeplinks/devtools/tsconfig.json index 5b34775c71159..d1414086f2187 100644 --- a/packages/deeplinks/devtools/tsconfig.json +++ b/packages/deeplinks/devtools/tsconfig.json @@ -10,7 +10,7 @@ }, "include": [ "**/*.ts", - "**/*.tsx", + "**/*.tsx", ], "exclude": [ "target/**/*" diff --git a/packages/deeplinks/ml/tsconfig.json b/packages/deeplinks/ml/tsconfig.json index 5b34775c71159..9ebfd580230a5 100644 --- a/packages/deeplinks/ml/tsconfig.json +++ b/packages/deeplinks/ml/tsconfig.json @@ -10,10 +10,12 @@ }, "include": [ "**/*.ts", - "**/*.tsx", + "**/*.tsx", ], "exclude": [ "target/**/*" ], - "kbn_references": [] + "kbn_references": [ + "@kbn/shared-ux-chrome-navigation", + ] } diff --git a/packages/shared-ux/chrome/navigation/tsconfig.json b/packages/shared-ux/chrome/navigation/tsconfig.json index 1ad187e43906f..b948f231193ea 100644 --- a/packages/shared-ux/chrome/navigation/tsconfig.json +++ b/packages/shared-ux/chrome/navigation/tsconfig.json @@ -21,7 +21,10 @@ "@kbn/core-http-browser", "@kbn/shared-ux-storybook-mock", "@kbn/i18n", - "@kbn/core-chrome-browser" + "@kbn/core-chrome-browser", + "@kbn/deeplinks-analytics", + "@kbn/deeplinks-devtools", + "@kbn/deeplinks-ml" ], "exclude": [ "target/**/*" diff --git a/src/plugins/dev_tools/tsconfig.json b/src/plugins/dev_tools/tsconfig.json index c9ca3b8f62896..458ecd1ca45d7 100644 --- a/src/plugins/dev_tools/tsconfig.json +++ b/src/plugins/dev_tools/tsconfig.json @@ -13,6 +13,7 @@ "@kbn/ui-theme", "@kbn/kibana-react-plugin", "@kbn/shared-ux-router", + "@kbn/deeplinks-devtools", ], "exclude": [ "target/**/*", diff --git a/x-pack/plugins/ml/tsconfig.json b/x-pack/plugins/ml/tsconfig.json index 8e3013b9ac138..5590d5b5f9c60 100644 --- a/x-pack/plugins/ml/tsconfig.json +++ b/x-pack/plugins/ml/tsconfig.json @@ -96,5 +96,6 @@ "@kbn/ml-kibana-theme", "@kbn/ml-runtime-field-utils", "@kbn/ml-date-utils", + "@kbn/deeplinks-ml", ], } From 8fba7f8ddff009a18ca3604929745ae32e537abf Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 6 Jun 2023 13:57:54 +0000 Subject: [PATCH 14/60] [CI] Auto-commit changed files from 'node scripts/generate codeowners' --- .github/CODEOWNERS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index dc6e697fc2259..dca5730ed677f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -306,6 +306,9 @@ src/plugins/data_view_management @elastic/kibana-data-discovery src/plugins/data_views @elastic/kibana-data-discovery x-pack/plugins/data_visualizer @elastic/ml-ui packages/kbn-datemath @elastic/kibana-data-discovery +packages/deeplinks/analytics @elastic/kibana-data-discovery +packages/deeplinks/devtools @elastic/platform-deployment-management +packages/deeplinks/ml @elastic/ml-ui packages/kbn-dev-cli-errors @elastic/kibana-operations packages/kbn-dev-cli-runner @elastic/kibana-operations packages/kbn-dev-proc-runner @elastic/kibana-operations From 496e52547c1abd307b603ceefd30c248b5a6a021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Tue, 6 Jun 2023 16:23:09 +0100 Subject: [PATCH 15/60] Move NodeDefinition and NodeDefinitionWithChildren to core-chrome-browser --- .../core/chrome/core-chrome-browser/index.ts | 2 + .../chrome/core-chrome-browser/src/index.ts | 2 + .../src/project_navigation.ts | 47 +++++++++++++++++ .../deeplinks/analytics/default_navigation.ts | 2 +- packages/deeplinks/analytics/tsconfig.json | 4 +- .../deeplinks/devtools/default_navigation.ts | 2 +- packages/deeplinks/devtools/tsconfig.json | 4 +- packages/deeplinks/ml/default_navigation.ts | 3 +- packages/deeplinks/ml/tsconfig.json | 2 +- packages/shared-ux/chrome/navigation/index.ts | 2 - .../chrome/navigation/src/ui/index.ts | 2 - .../chrome/navigation/src/ui/types.ts | 51 +++---------------- 12 files changed, 67 insertions(+), 56 deletions(-) diff --git a/packages/core/chrome/core-chrome-browser/index.ts b/packages/core/chrome/core-chrome-browser/index.ts index a38ac9dbdb750..c2d7243f34d6f 100644 --- a/packages/core/chrome/core-chrome-browser/index.ts +++ b/packages/core/chrome/core-chrome-browser/index.ts @@ -37,4 +37,6 @@ export type { SideNavComponent, ChromeProjectBreadcrumb, ChromeSetProjectBreadcrumbsParams, + NodeDefinition, + NodeDefinitionWithChildren, } from './src'; diff --git a/packages/core/chrome/core-chrome-browser/src/index.ts b/packages/core/chrome/core-chrome-browser/src/index.ts index 665957978da33..858b1c4e3647a 100644 --- a/packages/core/chrome/core-chrome-browser/src/index.ts +++ b/packages/core/chrome/core-chrome-browser/src/index.ts @@ -37,4 +37,6 @@ export type { SideNavComponent, ChromeSetProjectBreadcrumbsParams, ChromeProjectBreadcrumb, + NodeDefinition, + NodeDefinitionWithChildren, } from './project_navigation'; 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 7362adf14a661..01b98efe1e4f5 100644 --- a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts +++ b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts @@ -73,3 +73,50 @@ export type ChromeProjectBreadcrumb = ChromeBreadcrumb; export interface ChromeSetProjectBreadcrumbsParams { absolute: boolean; } + +type NonEmptyArray = [T, ...T[]]; + +/** + * @public + * + * A navigation node definition with its unique id, title, path in the tree and optional + * deep link and children. + * This definition serves to build the full ChromeProjectNavigation.navigationTree, converting + * "link" to "deepLink" and adding the "path" property for each node. + */ +export interface NodeDefinition< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenId extends string = Id +> { + /** Optional id, if not passed a "link" must be provided. */ + id?: Id; + /** Optional title. If not provided and a "link" is provided the title will be the Deep link title */ + title?: string; + /** App id or deeplink id */ + link?: LinkId; + /** Optional icon for the navigation node. Note: not all navigation depth will render the icon */ + icon?: string; + /** Optional children of the navigation node */ + children?: NonEmptyArray>; + /** + * Temporarilly we allow href to be passed. + * Once all the deeplinks will be exposed in packages we will not allow href anymore + * and force deeplink id to be passed + */ + href?: string; +} + +/** + * @public + * + * A navigation node definition with its unique id, title, path in the tree and optional + * deep link and children. + */ +export type NodeDefinitionWithChildren< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenID extends string = Id +> = NodeDefinition & { + children: Required>['children']; +}; diff --git a/packages/deeplinks/analytics/default_navigation.ts b/packages/deeplinks/analytics/default_navigation.ts index 214a7f8da810f..f286d28238979 100644 --- a/packages/deeplinks/analytics/default_navigation.ts +++ b/packages/deeplinks/analytics/default_navigation.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ import { i18n } from '@kbn/i18n'; -import type { NodeDefinitionWithChildren } from '@kbn/shared-ux-chrome-navigation'; +import type { NodeDefinitionWithChildren } from '@kbn/core-chrome-browser'; import type { DeepLinkId } from './deep_links'; diff --git a/packages/deeplinks/analytics/tsconfig.json b/packages/deeplinks/analytics/tsconfig.json index d1414086f2187..179f97857f0db 100644 --- a/packages/deeplinks/analytics/tsconfig.json +++ b/packages/deeplinks/analytics/tsconfig.json @@ -15,5 +15,7 @@ "exclude": [ "target/**/*" ], - "kbn_references": [] + "kbn_references": [ + "@kbn/core-chrome-browser" + ] } diff --git a/packages/deeplinks/devtools/default_navigation.ts b/packages/deeplinks/devtools/default_navigation.ts index 955868e6d715e..345b7665a14ef 100644 --- a/packages/deeplinks/devtools/default_navigation.ts +++ b/packages/deeplinks/devtools/default_navigation.ts @@ -6,7 +6,7 @@ * Side Public License, v 1. */ import { i18n } from '@kbn/i18n'; -import type { NodeDefinitionWithChildren } from '@kbn/shared-ux-chrome-navigation'; +import type { NodeDefinitionWithChildren } from '@kbn/core-chrome-browser'; import type { DeepLinkId } from './deep_links'; diff --git a/packages/deeplinks/devtools/tsconfig.json b/packages/deeplinks/devtools/tsconfig.json index d1414086f2187..179f97857f0db 100644 --- a/packages/deeplinks/devtools/tsconfig.json +++ b/packages/deeplinks/devtools/tsconfig.json @@ -15,5 +15,7 @@ "exclude": [ "target/**/*" ], - "kbn_references": [] + "kbn_references": [ + "@kbn/core-chrome-browser" + ] } diff --git a/packages/deeplinks/ml/default_navigation.ts b/packages/deeplinks/ml/default_navigation.ts index 0ce21ff098eeb..2b9987891fdc3 100644 --- a/packages/deeplinks/ml/default_navigation.ts +++ b/packages/deeplinks/ml/default_navigation.ts @@ -6,8 +6,7 @@ * Side Public License, v 1. */ import { i18n } from '@kbn/i18n'; - -import type { NodeDefinitionWithChildren } from '@kbn/shared-ux-chrome-navigation'; +import type { NodeDefinitionWithChildren } from '@kbn/core-chrome-browser'; import type { DeepLinkId } from './deep_links'; diff --git a/packages/deeplinks/ml/tsconfig.json b/packages/deeplinks/ml/tsconfig.json index 9ebfd580230a5..98dd78fb7d5f5 100644 --- a/packages/deeplinks/ml/tsconfig.json +++ b/packages/deeplinks/ml/tsconfig.json @@ -16,6 +16,6 @@ "target/**/*" ], "kbn_references": [ - "@kbn/shared-ux-chrome-navigation", + "@kbn/core-chrome-browser", ] } diff --git a/packages/shared-ux/chrome/navigation/index.ts b/packages/shared-ux/chrome/navigation/index.ts index de3baec6d6ee2..83c6a19688029 100644 --- a/packages/shared-ux/chrome/navigation/index.ts +++ b/packages/shared-ux/chrome/navigation/index.ts @@ -15,8 +15,6 @@ export type { GroupDefinition, NavigationGroupPreset, NavigationTreeDefinition, - NodeDefinition, - NodeDefinitionWithChildren, ProjectNavigationDefinition, RecentlyAccessedDefinition, RootNavigationItemDefinition, diff --git a/packages/shared-ux/chrome/navigation/src/ui/index.ts b/packages/shared-ux/chrome/navigation/src/ui/index.ts index e46694103ca8b..7bb534a32a8c0 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/index.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/index.ts @@ -17,8 +17,6 @@ export type { GroupDefinition, NavigationGroupPreset, NavigationTreeDefinition, - NodeDefinition, - NodeDefinitionWithChildren, ProjectNavigationDefinition, RecentlyAccessedDefinition, RootNavigationItemDefinition, diff --git a/packages/shared-ux/chrome/navigation/src/ui/types.ts b/packages/shared-ux/chrome/navigation/src/ui/types.ts index abdb6a2716162..87831e5146f7e 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/types.ts @@ -7,54 +7,15 @@ */ import type { ReactElement, ReactNode } from 'react'; -import type { AppDeepLinkId, ChromeProjectNavigationNode } from '@kbn/core-chrome-browser'; +import type { + AppDeepLinkId, + ChromeProjectNavigationNode, + NodeDefinition, +} from '@kbn/core-chrome-browser'; import type { CloudLinkProps, RecentlyAccessedProps } from './components'; -export type NonEmptyArray = [T, ...T[]]; - -/** - * @public - * - * A navigation node definition with its unique id, title, path in the tree and optional - * deep link and children. - */ -export interface NodeDefinition< - LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, - ChildrenId extends string = Id -> { - /** Optional id, if not passed a "link" must be provided. */ - id?: Id; - /** Optional title. If not provided and a "link" is provided the title will be the Deep link title */ - title?: string; - /** App id or deeplink id */ - link?: LinkId; - /** Optional icon for the navigation node. Note: not all navigation depth will render the icon */ - icon?: string; - /** Optional children of the navigation node */ - children?: NonEmptyArray>; - /** - * Temporarilly we allow href to be passed. - * Once all the deeplinks will be exposed in packages we will not allow href anymore - * and force deeplink id to be passed - */ - href?: string; -} - -/** - * @public - * - * A navigation node definition with its unique id, title, path in the tree and optional - * deep link and children. - */ -export type NodeDefinitionWithChildren< - LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, - ChildrenID extends string = Id -> = NodeDefinition & { - children: Required>['children']; -}; +type NonEmptyArray = [T, ...T[]]; /** * @public From 9bbbd9c5ad96e0a5eb96a14a6dd4183946548a76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Tue, 6 Jun 2023 16:26:56 +0100 Subject: [PATCH 16/60] Create default-nav packages to avoid circular dependencies --- package.json | 3 +++ packages/deeplinks/analytics/index.ts | 6 ------ packages/deeplinks/analytics/tsconfig.json | 4 +--- packages/deeplinks/devtools/index.ts | 6 ------ packages/deeplinks/devtools/tsconfig.json | 4 +--- packages/deeplinks/ml/index.ts | 2 -- packages/deeplinks/ml/tsconfig.json | 4 +--- packages/default-nav/analytics/README.md | 3 +++ .../analytics/default_navigation.ts | 3 +-- packages/default-nav/analytics/index.ts | 13 +++++++++++++ packages/default-nav/analytics/jest.config.js | 13 +++++++++++++ packages/default-nav/analytics/kibana.jsonc | 5 +++++ packages/default-nav/analytics/package.json | 6 ++++++ packages/default-nav/analytics/tsconfig.json | 19 +++++++++++++++++++ packages/default-nav/devtools/README.md | 3 +++ .../devtools/default_navigation.ts | 3 +-- packages/default-nav/devtools/index.ts | 13 +++++++++++++ packages/default-nav/devtools/jest.config.js | 13 +++++++++++++ packages/default-nav/devtools/kibana.jsonc | 5 +++++ packages/default-nav/devtools/package.json | 6 ++++++ packages/default-nav/devtools/tsconfig.json | 19 +++++++++++++++++++ packages/default-nav/ml/README.md | 3 +++ .../ml/default_navigation.ts | 3 +-- packages/default-nav/ml/index.ts | 9 +++++++++ packages/default-nav/ml/jest.config.js | 13 +++++++++++++ packages/default-nav/ml/kibana.jsonc | 5 +++++ packages/default-nav/ml/package.json | 6 ++++++ packages/default-nav/ml/tsconfig.json | 19 +++++++++++++++++++ .../src/ui/nav_tree_presets/index.ts | 6 +++--- tsconfig.base.json | 6 ++++++ yarn.lock | 12 ++++++++++++ 31 files changed, 203 insertions(+), 32 deletions(-) create mode 100644 packages/default-nav/analytics/README.md rename packages/{deeplinks => default-nav}/analytics/default_navigation.ts (94%) create mode 100644 packages/default-nav/analytics/index.ts create mode 100644 packages/default-nav/analytics/jest.config.js create mode 100644 packages/default-nav/analytics/kibana.jsonc create mode 100644 packages/default-nav/analytics/package.json create mode 100644 packages/default-nav/analytics/tsconfig.json create mode 100644 packages/default-nav/devtools/README.md rename packages/{deeplinks => default-nav}/devtools/default_navigation.ts (95%) create mode 100644 packages/default-nav/devtools/index.ts create mode 100644 packages/default-nav/devtools/jest.config.js create mode 100644 packages/default-nav/devtools/kibana.jsonc create mode 100644 packages/default-nav/devtools/package.json create mode 100644 packages/default-nav/devtools/tsconfig.json create mode 100644 packages/default-nav/ml/README.md rename packages/{deeplinks => default-nav}/ml/default_navigation.ts (98%) create mode 100644 packages/default-nav/ml/index.ts create mode 100644 packages/default-nav/ml/jest.config.js create mode 100644 packages/default-nav/ml/kibana.jsonc create mode 100644 packages/default-nav/ml/package.json create mode 100644 packages/default-nav/ml/tsconfig.json diff --git a/package.json b/package.json index 58109a7f0c461..38ea65bcafa2b 100644 --- a/package.json +++ b/package.json @@ -354,6 +354,9 @@ "@kbn/deeplinks-analytics": "link:packages/deeplinks/analytics", "@kbn/deeplinks-devtools": "link:packages/deeplinks/devtools", "@kbn/deeplinks-ml": "link:packages/deeplinks/ml", + "@kbn/default-nav-analytics": "link:packages/default-nav/analytics", + "@kbn/default-nav-devtools": "link:packages/default-nav/devtools", + "@kbn/default-nav-ml": "link:packages/default-nav/ml", "@kbn/dev-tools-plugin": "link:src/plugins/dev_tools", "@kbn/developer-examples-plugin": "link:examples/developer_examples", "@kbn/discover-enhanced-plugin": "link:x-pack/plugins/discover_enhanced", diff --git a/packages/deeplinks/analytics/index.ts b/packages/deeplinks/analytics/index.ts index e705d79bcb688..e2d605988231a 100644 --- a/packages/deeplinks/analytics/index.ts +++ b/packages/deeplinks/analytics/index.ts @@ -8,10 +8,4 @@ export { DASHBOARD_APP_ID, DISCOVER_APP_ID, VISUALIZE_APP_ID } from './constants'; -export { - defaultNavigation, - type NavigationID, - type AnalyticsNodeDefinition, -} from './default_navigation'; - export type { AppId, DeepLinkId } from './deep_links'; diff --git a/packages/deeplinks/analytics/tsconfig.json b/packages/deeplinks/analytics/tsconfig.json index 179f97857f0db..d1414086f2187 100644 --- a/packages/deeplinks/analytics/tsconfig.json +++ b/packages/deeplinks/analytics/tsconfig.json @@ -15,7 +15,5 @@ "exclude": [ "target/**/*" ], - "kbn_references": [ - "@kbn/core-chrome-browser" - ] + "kbn_references": [] } diff --git a/packages/deeplinks/devtools/index.ts b/packages/deeplinks/devtools/index.ts index 60b20580f1006..7774b6742a811 100644 --- a/packages/deeplinks/devtools/index.ts +++ b/packages/deeplinks/devtools/index.ts @@ -16,9 +16,3 @@ export { } from './constants'; export type { AppId, LinkId, DeepLinkId } from './deep_links'; - -export { - defaultNavigation, - type NavigationID, - type DevToolsNodeDefinition, -} from './default_navigation'; diff --git a/packages/deeplinks/devtools/tsconfig.json b/packages/deeplinks/devtools/tsconfig.json index 179f97857f0db..d1414086f2187 100644 --- a/packages/deeplinks/devtools/tsconfig.json +++ b/packages/deeplinks/devtools/tsconfig.json @@ -15,7 +15,5 @@ "exclude": [ "target/**/*" ], - "kbn_references": [ - "@kbn/core-chrome-browser" - ] + "kbn_references": [] } diff --git a/packages/deeplinks/ml/index.ts b/packages/deeplinks/ml/index.ts index 0d624c9062a52..364799992aff7 100644 --- a/packages/deeplinks/ml/index.ts +++ b/packages/deeplinks/ml/index.ts @@ -7,5 +7,3 @@ */ export type { LinkId, AppId, DeepLinkId } from './deep_links'; - -export { defaultNavigation, type NavigationID, type MlNodeDefinition } from './default_navigation'; diff --git a/packages/deeplinks/ml/tsconfig.json b/packages/deeplinks/ml/tsconfig.json index 98dd78fb7d5f5..d1414086f2187 100644 --- a/packages/deeplinks/ml/tsconfig.json +++ b/packages/deeplinks/ml/tsconfig.json @@ -15,7 +15,5 @@ "exclude": [ "target/**/*" ], - "kbn_references": [ - "@kbn/core-chrome-browser", - ] + "kbn_references": [] } diff --git a/packages/default-nav/analytics/README.md b/packages/default-nav/analytics/README.md new file mode 100644 index 0000000000000..7f0ea9a87753f --- /dev/null +++ b/packages/default-nav/analytics/README.md @@ -0,0 +1,3 @@ +# @kbn/default-nav-analytics + +Empty package generated by @kbn/generate diff --git a/packages/deeplinks/analytics/default_navigation.ts b/packages/default-nav/analytics/default_navigation.ts similarity index 94% rename from packages/deeplinks/analytics/default_navigation.ts rename to packages/default-nav/analytics/default_navigation.ts index f286d28238979..d40bfd5185a42 100644 --- a/packages/deeplinks/analytics/default_navigation.ts +++ b/packages/default-nav/analytics/default_navigation.ts @@ -7,8 +7,7 @@ */ import { i18n } from '@kbn/i18n'; import type { NodeDefinitionWithChildren } from '@kbn/core-chrome-browser'; - -import type { DeepLinkId } from './deep_links'; +import type { DeepLinkId } from '@kbn/deeplinks-analytics'; export type NavigationID = 'rootNav:analytics' | 'root'; diff --git a/packages/default-nav/analytics/index.ts b/packages/default-nav/analytics/index.ts new file mode 100644 index 0000000000000..ead038478f278 --- /dev/null +++ b/packages/default-nav/analytics/index.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 { + defaultNavigation, + type AnalyticsNodeDefinition, + type NavigationID, +} from './default_navigation'; diff --git a/packages/default-nav/analytics/jest.config.js b/packages/default-nav/analytics/jest.config.js new file mode 100644 index 0000000000000..cda6565eb561d --- /dev/null +++ b/packages/default-nav/analytics/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/default-nav/analytics'], +}; diff --git a/packages/default-nav/analytics/kibana.jsonc b/packages/default-nav/analytics/kibana.jsonc new file mode 100644 index 0000000000000..b5c4718b29e6a --- /dev/null +++ b/packages/default-nav/analytics/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/default-nav-analytics", + "owner": "@elastic/kibana-data-discovery" +} diff --git a/packages/default-nav/analytics/package.json b/packages/default-nav/analytics/package.json new file mode 100644 index 0000000000000..a94bee6d8783c --- /dev/null +++ b/packages/default-nav/analytics/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/default-nav-analytics", + "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/default-nav/analytics/tsconfig.json b/packages/default-nav/analytics/tsconfig.json new file mode 100644 index 0000000000000..5b34775c71159 --- /dev/null +++ b/packages/default-nav/analytics/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/default-nav/devtools/README.md b/packages/default-nav/devtools/README.md new file mode 100644 index 0000000000000..6398cb969a97f --- /dev/null +++ b/packages/default-nav/devtools/README.md @@ -0,0 +1,3 @@ +# @kbn/default-nav-devtools + +Empty package generated by @kbn/generate diff --git a/packages/deeplinks/devtools/default_navigation.ts b/packages/default-nav/devtools/default_navigation.ts similarity index 95% rename from packages/deeplinks/devtools/default_navigation.ts rename to packages/default-nav/devtools/default_navigation.ts index 345b7665a14ef..2ba1c25e79f59 100644 --- a/packages/deeplinks/devtools/default_navigation.ts +++ b/packages/default-nav/devtools/default_navigation.ts @@ -7,8 +7,7 @@ */ import { i18n } from '@kbn/i18n'; import type { NodeDefinitionWithChildren } from '@kbn/core-chrome-browser'; - -import type { DeepLinkId } from './deep_links'; +import type { DeepLinkId } from '@kbn/deeplinks-devtools'; export type NavigationID = 'rootNav:devtools' | 'root'; diff --git a/packages/default-nav/devtools/index.ts b/packages/default-nav/devtools/index.ts new file mode 100644 index 0000000000000..9c10ca70f81fc --- /dev/null +++ b/packages/default-nav/devtools/index.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 { + defaultNavigation, + type DevToolsNodeDefinition, + type NavigationID, +} from './default_navigation'; diff --git a/packages/default-nav/devtools/jest.config.js b/packages/default-nav/devtools/jest.config.js new file mode 100644 index 0000000000000..5e8b8e1c16754 --- /dev/null +++ b/packages/default-nav/devtools/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/default-nav/devtools'], +}; diff --git a/packages/default-nav/devtools/kibana.jsonc b/packages/default-nav/devtools/kibana.jsonc new file mode 100644 index 0000000000000..6c3a5b98e7425 --- /dev/null +++ b/packages/default-nav/devtools/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/default-nav-devtools", + "owner": "@elastic/platform-deployment-management" +} diff --git a/packages/default-nav/devtools/package.json b/packages/default-nav/devtools/package.json new file mode 100644 index 0000000000000..c1f1aa4f510aa --- /dev/null +++ b/packages/default-nav/devtools/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/default-nav-devtools", + "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/default-nav/devtools/tsconfig.json b/packages/default-nav/devtools/tsconfig.json new file mode 100644 index 0000000000000..5b34775c71159 --- /dev/null +++ b/packages/default-nav/devtools/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/default-nav/ml/README.md b/packages/default-nav/ml/README.md new file mode 100644 index 0000000000000..f5b02f4f5d7bb --- /dev/null +++ b/packages/default-nav/ml/README.md @@ -0,0 +1,3 @@ +# @kbn/default-nav-ml + +Empty package generated by @kbn/generate diff --git a/packages/deeplinks/ml/default_navigation.ts b/packages/default-nav/ml/default_navigation.ts similarity index 98% rename from packages/deeplinks/ml/default_navigation.ts rename to packages/default-nav/ml/default_navigation.ts index 2b9987891fdc3..ffa97c4475b0a 100644 --- a/packages/deeplinks/ml/default_navigation.ts +++ b/packages/default-nav/ml/default_navigation.ts @@ -7,8 +7,7 @@ */ import { i18n } from '@kbn/i18n'; import type { NodeDefinitionWithChildren } from '@kbn/core-chrome-browser'; - -import type { DeepLinkId } from './deep_links'; +import type { DeepLinkId } from '@kbn/deeplinks-ml'; export type NavigationID = | 'rootNav:ml' diff --git a/packages/default-nav/ml/index.ts b/packages/default-nav/ml/index.ts new file mode 100644 index 0000000000000..98053e634d84a --- /dev/null +++ b/packages/default-nav/ml/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 { defaultNavigation, type MlNodeDefinition, type NavigationID } from './default_navigation'; diff --git a/packages/default-nav/ml/jest.config.js b/packages/default-nav/ml/jest.config.js new file mode 100644 index 0000000000000..9ec3d99fdd1e3 --- /dev/null +++ b/packages/default-nav/ml/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/default-nav/ml'], +}; diff --git a/packages/default-nav/ml/kibana.jsonc b/packages/default-nav/ml/kibana.jsonc new file mode 100644 index 0000000000000..a9d0a2fe4b1d3 --- /dev/null +++ b/packages/default-nav/ml/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/default-nav-ml", + "owner": "@elastic/ml-ui" +} diff --git a/packages/default-nav/ml/package.json b/packages/default-nav/ml/package.json new file mode 100644 index 0000000000000..26bc078735958 --- /dev/null +++ b/packages/default-nav/ml/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/default-nav-ml", + "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/default-nav/ml/tsconfig.json b/packages/default-nav/ml/tsconfig.json new file mode 100644 index 0000000000000..5b34775c71159 --- /dev/null +++ b/packages/default-nav/ml/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/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts index af30c99706ae4..889f44ca9aa04 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts @@ -11,12 +11,12 @@ import { cloneDeep } from 'lodash'; import { defaultNavigation as analytics, type AnalyticsNodeDefinition, -} from '@kbn/deeplinks-analytics'; -import { defaultNavigation as ml, type MlNodeDefinition } from '@kbn/deeplinks-ml'; +} from '@kbn/default-nav-analytics'; +import { defaultNavigation as ml, type MlNodeDefinition } from '@kbn/default-nav-ml'; import { defaultNavigation as devtools, type DevToolsNodeDefinition, -} from '@kbn/deeplinks-devtools'; +} from '@kbn/default-nav-devtools'; import type { NavigationGroupPreset } from '../types'; import type { ManagementNodeDefinition } from './types'; diff --git a/tsconfig.base.json b/tsconfig.base.json index 40aee9fed1637..d8da32b48b103 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -612,6 +612,12 @@ "@kbn/deeplinks-devtools/*": ["packages/deeplinks/devtools/*"], "@kbn/deeplinks-ml": ["packages/deeplinks/ml"], "@kbn/deeplinks-ml/*": ["packages/deeplinks/ml/*"], + "@kbn/default-nav-analytics": ["packages/default-nav/analytics"], + "@kbn/default-nav-analytics/*": ["packages/default-nav/analytics/*"], + "@kbn/default-nav-devtools": ["packages/default-nav/devtools"], + "@kbn/default-nav-devtools/*": ["packages/default-nav/devtools/*"], + "@kbn/default-nav-ml": ["packages/default-nav/ml"], + "@kbn/default-nav-ml/*": ["packages/default-nav/ml/*"], "@kbn/dev-cli-errors": ["packages/kbn-dev-cli-errors"], "@kbn/dev-cli-errors/*": ["packages/kbn-dev-cli-errors/*"], "@kbn/dev-cli-runner": ["packages/kbn-dev-cli-runner"], diff --git a/yarn.lock b/yarn.lock index 1765e0effd539..b17befd97ff7c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4059,6 +4059,18 @@ version "0.0.0" uid "" +"@kbn/default-nav-analytics@link:packages/default-nav/analytics": + version "0.0.0" + uid "" + +"@kbn/default-nav-devtools@link:packages/default-nav/devtools": + version "0.0.0" + uid "" + +"@kbn/default-nav-ml@link:packages/default-nav/ml": + version "0.0.0" + uid "" + "@kbn/dev-cli-errors@link:packages/kbn-dev-cli-errors": version "0.0.0" uid "" From cbf36bc043abf3942bcf5472fe63df145b4a9907 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 6 Jun 2023 15:02:12 +0000 Subject: [PATCH 17/60] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- packages/deeplinks/analytics/tsconfig.json | 5 ++++- packages/deeplinks/devtools/tsconfig.json | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/deeplinks/analytics/tsconfig.json b/packages/deeplinks/analytics/tsconfig.json index d1414086f2187..147bf52e3c9f2 100644 --- a/packages/deeplinks/analytics/tsconfig.json +++ b/packages/deeplinks/analytics/tsconfig.json @@ -15,5 +15,8 @@ "exclude": [ "target/**/*" ], - "kbn_references": [] + "kbn_references": [ + "@kbn/i18n", + "@kbn/shared-ux-chrome-navigation", + ] } diff --git a/packages/deeplinks/devtools/tsconfig.json b/packages/deeplinks/devtools/tsconfig.json index d1414086f2187..60efcacf24e75 100644 --- a/packages/deeplinks/devtools/tsconfig.json +++ b/packages/deeplinks/devtools/tsconfig.json @@ -15,5 +15,9 @@ "exclude": [ "target/**/*" ], - "kbn_references": [] + "kbn_references": [ + "@kbn/core", + "@kbn/i18n", + "@kbn/shared-ux-chrome-navigation", + ] } From 87b16fd12ebcd985c1727d2f273cd364e30c53a1 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 6 Jun 2023 15:35:56 +0000 Subject: [PATCH 18/60] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- packages/default-nav/analytics/tsconfig.json | 8 ++++++-- packages/default-nav/devtools/tsconfig.json | 8 ++++++-- packages/default-nav/ml/tsconfig.json | 8 ++++++-- packages/shared-ux/chrome/navigation/tsconfig.json | 6 +++--- 4 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/default-nav/analytics/tsconfig.json b/packages/default-nav/analytics/tsconfig.json index 5b34775c71159..190b6bd1195eb 100644 --- a/packages/default-nav/analytics/tsconfig.json +++ b/packages/default-nav/analytics/tsconfig.json @@ -10,10 +10,14 @@ }, "include": [ "**/*.ts", - "**/*.tsx", + "**/*.tsx", ], "exclude": [ "target/**/*" ], - "kbn_references": [] + "kbn_references": [ + "@kbn/i18n", + "@kbn/core-chrome-browser", + "@kbn/deeplinks-analytics", + ] } diff --git a/packages/default-nav/devtools/tsconfig.json b/packages/default-nav/devtools/tsconfig.json index 5b34775c71159..7adfc75ce745d 100644 --- a/packages/default-nav/devtools/tsconfig.json +++ b/packages/default-nav/devtools/tsconfig.json @@ -10,10 +10,14 @@ }, "include": [ "**/*.ts", - "**/*.tsx", + "**/*.tsx", ], "exclude": [ "target/**/*" ], - "kbn_references": [] + "kbn_references": [ + "@kbn/i18n", + "@kbn/core-chrome-browser", + "@kbn/deeplinks-devtools", + ] } diff --git a/packages/default-nav/ml/tsconfig.json b/packages/default-nav/ml/tsconfig.json index 5b34775c71159..d1c9e532620f0 100644 --- a/packages/default-nav/ml/tsconfig.json +++ b/packages/default-nav/ml/tsconfig.json @@ -10,10 +10,14 @@ }, "include": [ "**/*.ts", - "**/*.tsx", + "**/*.tsx", ], "exclude": [ "target/**/*" ], - "kbn_references": [] + "kbn_references": [ + "@kbn/i18n", + "@kbn/core-chrome-browser", + "@kbn/deeplinks-ml", + ] } diff --git a/packages/shared-ux/chrome/navigation/tsconfig.json b/packages/shared-ux/chrome/navigation/tsconfig.json index b948f231193ea..48e4d6f824e67 100644 --- a/packages/shared-ux/chrome/navigation/tsconfig.json +++ b/packages/shared-ux/chrome/navigation/tsconfig.json @@ -22,9 +22,9 @@ "@kbn/shared-ux-storybook-mock", "@kbn/i18n", "@kbn/core-chrome-browser", - "@kbn/deeplinks-analytics", - "@kbn/deeplinks-devtools", - "@kbn/deeplinks-ml" + "@kbn/default-nav-analytics", + "@kbn/default-nav-ml", + "@kbn/default-nav-devtools" ], "exclude": [ "target/**/*" From 23548ca8e29e1feb95264aebeea6c06ab727b08d Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 6 Jun 2023 15:42:24 +0000 Subject: [PATCH 19/60] [CI] Auto-commit changed files from 'node scripts/generate codeowners' --- .github/CODEOWNERS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index dca5730ed677f..ea055b7140538 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -309,6 +309,9 @@ packages/kbn-datemath @elastic/kibana-data-discovery packages/deeplinks/analytics @elastic/kibana-data-discovery packages/deeplinks/devtools @elastic/platform-deployment-management packages/deeplinks/ml @elastic/ml-ui +packages/default-nav/analytics @elastic/kibana-data-discovery +packages/default-nav/devtools @elastic/platform-deployment-management +packages/default-nav/ml @elastic/ml-ui packages/kbn-dev-cli-errors @elastic/kibana-operations packages/kbn-dev-cli-runner @elastic/kibana-operations packages/kbn-dev-proc-runner @elastic/kibana-operations From 0a2657d230b024872514c27b471adbe18888f638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 12:24:38 +0100 Subject: [PATCH 20/60] Only expose deepLink ids from dev tool package --- packages/deeplinks/devtools/constants.ts | 33 +----------------------- packages/deeplinks/devtools/index.ts | 9 +------ 2 files changed, 2 insertions(+), 40 deletions(-) diff --git a/packages/deeplinks/devtools/constants.ts b/packages/deeplinks/devtools/constants.ts index 37322dd95558a..2aa7c2a37e5c5 100644 --- a/packages/deeplinks/devtools/constants.ts +++ b/packages/deeplinks/devtools/constants.ts @@ -5,39 +5,8 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { AppDeepLink } from '@kbn/core/public'; - import type { LinkId } from './deep_links'; export const DEV_TOOLS_APP_ID = 'dev_tools'; -export const searchProfiler: AppDeepLink = { - id: 'searchprofiler', - title: 'Search Profiler', - path: '#/searchprofiler', -}; - -export const painlessLab: AppDeepLink = { - id: 'painless_lab', - title: 'Painless Lab', - path: '#/painless_lab', -}; - -export const grokDebugger: AppDeepLink = { - id: 'grokdebugger', - title: 'Grok Debugger', - path: '#/grokdebugger', -}; - -export const console: AppDeepLink = { - id: 'console', - title: 'Console', - path: '#/console', -}; - -export const deepLinks: Array> = [ - searchProfiler, - painlessLab, - grokDebugger, - console, -]; +export const deepLinkIds: LinkId[] = ['searchprofiler', 'painless_lab', 'grokdebugger', 'console']; diff --git a/packages/deeplinks/devtools/index.ts b/packages/deeplinks/devtools/index.ts index 7774b6742a811..89a4709f4942d 100644 --- a/packages/deeplinks/devtools/index.ts +++ b/packages/deeplinks/devtools/index.ts @@ -6,13 +6,6 @@ * Side Public License, v 1. */ -export { - DEV_TOOLS_APP_ID, - console, - deepLinks, - grokDebugger, - painlessLab, - searchProfiler, -} from './constants'; +export { DEV_TOOLS_APP_ID, deepLinkIds } from './constants'; export type { AppId, LinkId, DeepLinkId } from './deep_links'; From 15248fa884d87ba7aa670978755cc3c4a37dc406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 12:25:32 +0100 Subject: [PATCH 21/60] Update imports --- .../chrome/navigation/src/ui/nav_tree_presets/management.ts | 4 +--- .../chrome/navigation/src/ui/nav_tree_presets/types.ts | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts index 9765cad3cf5fb..19ac7f98f1a9a 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts @@ -5,9 +5,7 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { AppDeepLinkId } from '@kbn/core-chrome-browser'; - -import type { NodeDefinitionWithChildren } from '../types'; +import type { AppDeepLinkId, NodeDefinitionWithChildren } from '@kbn/core-chrome-browser'; export type ID = | 'sharedux:management' diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts index a8a3506edbfa0..4bcd9d3c05936 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts @@ -6,9 +6,8 @@ * Side Public License, v 1. */ -import type { AppDeepLinkId } from '@kbn/core-chrome-browser'; +import type { AppDeepLinkId, NodeDefinitionWithChildren } from '@kbn/core-chrome-browser'; -import type { NodeDefinitionWithChildren } from '../types'; import type { ID as ManagementID } from './management'; export type ManagementNodeDefinition = NodeDefinitionWithChildren; From f500afe7956a6667c812fb603503170220c3ef33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 12:25:43 +0100 Subject: [PATCH 22/60] Only expose deepLink ids from dev tool package (2) --- src/plugins/dev_tools/public/plugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/dev_tools/public/plugin.ts b/src/plugins/dev_tools/public/plugin.ts index 29eef33c29a86..e0306ed1dddab 100644 --- a/src/plugins/dev_tools/public/plugin.ts +++ b/src/plugins/dev_tools/public/plugin.ts @@ -14,7 +14,7 @@ import { sortBy } from 'lodash'; import { AppNavLinkStatus, DEFAULT_APP_CATEGORIES } from '@kbn/core/public'; import { UrlForwardingSetup } from '@kbn/url-forwarding-plugin/public'; -import { deepLinks as devtoolsDeeplinks } from '@kbn/deeplinks-devtools'; +import { deepLinkIds as devtoolsDeeplinkIds } from '@kbn/deeplinks-devtools'; import { CreateDevToolArgs, DevToolApp, createDevToolApp } from './dev_tool'; import { DocTitleService, BreadcrumbService } from './services'; @@ -119,7 +119,7 @@ export class DevToolsPlugin implements Plugin { title: tool.title as string, path: `#/${tool.id}`, }; - if (!devtoolsDeeplinks.some((dl) => dl.id === deepLink.id)) { + if (!devtoolsDeeplinkIds.some((id) => id === deepLink.id)) { throw new Error('Deeplink must be registered in package.'); } return deepLink; From 0318001366403a9ef4b4389e7b7600a19a9b9b4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 12:25:55 +0100 Subject: [PATCH 23/60] Clear kbn_references --- packages/shared-ux/chrome/navigation/tsconfig.json | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/packages/shared-ux/chrome/navigation/tsconfig.json b/packages/shared-ux/chrome/navigation/tsconfig.json index 48e4d6f824e67..f0d1c0f0e23da 100644 --- a/packages/shared-ux/chrome/navigation/tsconfig.json +++ b/packages/shared-ux/chrome/navigation/tsconfig.json @@ -16,16 +16,7 @@ "**/*.ts", "**/*.tsx" ], - "kbn_references": [ - "@kbn/core-application-browser", - "@kbn/core-http-browser", - "@kbn/shared-ux-storybook-mock", - "@kbn/i18n", - "@kbn/core-chrome-browser", - "@kbn/default-nav-analytics", - "@kbn/default-nav-ml", - "@kbn/default-nav-devtools" - ], + "kbn_references": [], "exclude": [ "target/**/*" ] From e51cc59892b1a615ac61d98adfa877521e14381c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 12:26:09 +0100 Subject: [PATCH 24/60] Update stories path --- .../shared-ux/chrome/navigation/src/ui/navigation.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx b/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx index cc6bd2978a9c5..6b5bb55180a3d 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx @@ -428,7 +428,7 @@ export const MinimalUIAndCustomCloudLink = ( }; export default { - title: 'Chrome/Navigation/v2', + title: 'Chrome/Navigation', description: 'Navigation container to render items for cross-app linking', parameters: { docs: { From 855251448781359d871b1cb65e5cd1258ed51b98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 12:43:08 +0100 Subject: [PATCH 25/60] Create deeplinks package for management --- packages/deeplinks/management/README.md | 3 +++ packages/deeplinks/management/constants.ts | 9 +++++++++ packages/deeplinks/management/deep_links.ts | 15 +++++++++++++++ packages/deeplinks/management/index.ts | 11 +++++++++++ packages/deeplinks/management/jest.config.js | 13 +++++++++++++ packages/deeplinks/management/kibana.jsonc | 8 ++++++++ packages/deeplinks/management/package.json | 6 ++++++ packages/deeplinks/management/tsconfig.json | 19 +++++++++++++++++++ 8 files changed, 84 insertions(+) create mode 100644 packages/deeplinks/management/README.md create mode 100644 packages/deeplinks/management/constants.ts create mode 100644 packages/deeplinks/management/deep_links.ts create mode 100644 packages/deeplinks/management/index.ts create mode 100644 packages/deeplinks/management/jest.config.js create mode 100644 packages/deeplinks/management/kibana.jsonc create mode 100644 packages/deeplinks/management/package.json create mode 100644 packages/deeplinks/management/tsconfig.json diff --git a/packages/deeplinks/management/README.md b/packages/deeplinks/management/README.md new file mode 100644 index 0000000000000..c12858e1b02c5 --- /dev/null +++ b/packages/deeplinks/management/README.md @@ -0,0 +1,3 @@ +# @kbn/deeplinks-management + +Empty package generated by @kbn/generate diff --git a/packages/deeplinks/management/constants.ts b/packages/deeplinks/management/constants.ts new file mode 100644 index 0000000000000..41404a3f5caf5 --- /dev/null +++ b/packages/deeplinks/management/constants.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 const DEV_TOOLS_APP_ID = 'dev_tools'; diff --git a/packages/deeplinks/management/deep_links.ts b/packages/deeplinks/management/deep_links.ts new file mode 100644 index 0000000000000..8ec43edd6d3fe --- /dev/null +++ b/packages/deeplinks/management/deep_links.ts @@ -0,0 +1,15 @@ +/* + * 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 { DEV_TOOLS_APP_ID } from './constants'; + +export type AppId = typeof DEV_TOOLS_APP_ID; + +export type LinkId = 'searchprofiler' | 'painless_lab' | 'grokdebugger' | 'console'; + +export type DeepLinkId = AppId | `${AppId}:${LinkId}`; diff --git a/packages/deeplinks/management/index.ts b/packages/deeplinks/management/index.ts new file mode 100644 index 0000000000000..89a4709f4942d --- /dev/null +++ b/packages/deeplinks/management/index.ts @@ -0,0 +1,11 @@ +/* + * 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 { DEV_TOOLS_APP_ID, deepLinkIds } from './constants'; + +export type { AppId, LinkId, DeepLinkId } from './deep_links'; diff --git a/packages/deeplinks/management/jest.config.js b/packages/deeplinks/management/jest.config.js new file mode 100644 index 0000000000000..fc71720d6f257 --- /dev/null +++ b/packages/deeplinks/management/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/management'], +}; diff --git a/packages/deeplinks/management/kibana.jsonc b/packages/deeplinks/management/kibana.jsonc new file mode 100644 index 0000000000000..56c26521f76c1 --- /dev/null +++ b/packages/deeplinks/management/kibana.jsonc @@ -0,0 +1,8 @@ +{ + "type": "shared-common", + "id": "@kbn/deeplinks-management", + "owner": [ + "@elastic/platform-deployment-management", + "@elastic/kibana-data-discovery" + ] +} diff --git a/packages/deeplinks/management/package.json b/packages/deeplinks/management/package.json new file mode 100644 index 0000000000000..49a86f47e0d68 --- /dev/null +++ b/packages/deeplinks/management/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/deeplinks-management", + "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/management/tsconfig.json b/packages/deeplinks/management/tsconfig.json new file mode 100644 index 0000000000000..5b34775c71159 --- /dev/null +++ b/packages/deeplinks/management/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": [] +} From 46f7609c5dfff0f1370840b85e10642ed65df54d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 12:43:23 +0100 Subject: [PATCH 26/60] Create deeplinks package for management (2) --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 38ea65bcafa2b..e25f57a7e1700 100644 --- a/package.json +++ b/package.json @@ -353,6 +353,7 @@ "@kbn/datemath": "link:packages/kbn-datemath", "@kbn/deeplinks-analytics": "link:packages/deeplinks/analytics", "@kbn/deeplinks-devtools": "link:packages/deeplinks/devtools", + "@kbn/deeplinks-management": "link:packages/deeplinks/management", "@kbn/deeplinks-ml": "link:packages/deeplinks/ml", "@kbn/default-nav-analytics": "link:packages/default-nav/analytics", "@kbn/default-nav-devtools": "link:packages/default-nav/devtools", From bb0a09127eb9068c10ae3cce164bd3e8215874c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 13:32:21 +0100 Subject: [PATCH 27/60] Create default nav package for management --- packages/default-nav/management/README.md | 3 ++ .../management/default_navigation.ts} | 51 +++---------------- .../management/index.ts} | 10 ++-- .../default-nav/management/jest.config.js | 13 +++++ packages/default-nav/management/kibana.jsonc | 8 +++ packages/default-nav/management/package.json | 6 +++ packages/default-nav/management/tsconfig.json | 19 +++++++ .../src/ui/nav_tree_presets/index.ts | 6 ++- tsconfig.base.json | 4 ++ yarn.lock | 8 +++ 10 files changed, 78 insertions(+), 50 deletions(-) create mode 100644 packages/default-nav/management/README.md rename packages/{shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts => default-nav/management/default_navigation.ts} (86%) rename packages/{shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts => default-nav/management/index.ts} (59%) create mode 100644 packages/default-nav/management/jest.config.js create mode 100644 packages/default-nav/management/kibana.jsonc create mode 100644 packages/default-nav/management/package.json create mode 100644 packages/default-nav/management/tsconfig.json diff --git a/packages/default-nav/management/README.md b/packages/default-nav/management/README.md new file mode 100644 index 0000000000000..dc788ec979ae5 --- /dev/null +++ b/packages/default-nav/management/README.md @@ -0,0 +1,3 @@ +# @kbn/default-nav-management + +Empty package generated by @kbn/generate diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts b/packages/default-nav/management/default_navigation.ts similarity index 86% rename from packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts rename to packages/default-nav/management/default_navigation.ts index 19ac7f98f1a9a..419dd163dfaeb 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/management.ts +++ b/packages/default-nav/management/default_navigation.ts @@ -5,51 +5,16 @@ * in compliance with, at your election, the Elastic License 2.0 or the Server * Side Public License, v 1. */ -import type { AppDeepLinkId, NodeDefinitionWithChildren } from '@kbn/core-chrome-browser'; +import { i18n } from '@kbn/i18n'; +import type { NodeDefinitionWithChildren } from '@kbn/core-chrome-browser'; +import type { DeepLinkId } from '@kbn/deeplinks-devtools'; -export type ID = - | 'sharedux:management' - | 'root' - | 'stack_monitoring' - | 'integration_management' - | 'integrations' - | 'fleet' - | 'osquery' - | 'stack_management' - | 'ingest' - | 'ingest_pipelines' - | 'logstash_pipelines' - | 'data' - | 'index_management' - | 'index_lifecycle_policies' - | 'snapshot_and_restore' - | 'rollup_jobs' - | 'transforms' - | 'cross_cluster_replication' - | 'remote_clusters' - | 'alerts_and_insights' - | 'rules' - | 'cases' - | 'connectors' - | 'reporting' - | 'machine_learning' - | 'watcher' - | 'security' - | 'users' - | 'roles' - | 'role_mappings' - | 'api_keys' - | 'kibana' - | 'data_views' - | 'saved_objects' - | 'tags' - | 'search_sessions' - | 'spaces' - | 'advanced_settings' - | 'upgrade_assistant'; +export type NavigationID = 'rootNav:management' | 'root'; -export const management: NodeDefinitionWithChildren = { - id: 'sharedux:management', +export type ManagementNodeDefinition = NodeDefinitionWithChildren; + +export const defaultNavigation: ManagementNodeDefinition = { + id: 'rootNav:management', title: 'Management', icon: 'gear', children: [ diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts b/packages/default-nav/management/index.ts similarity index 59% rename from packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts rename to packages/default-nav/management/index.ts index 4bcd9d3c05936..04ebc2e270531 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/types.ts +++ b/packages/default-nav/management/index.ts @@ -6,8 +6,8 @@ * Side Public License, v 1. */ -import type { AppDeepLinkId, NodeDefinitionWithChildren } from '@kbn/core-chrome-browser'; - -import type { ID as ManagementID } from './management'; - -export type ManagementNodeDefinition = NodeDefinitionWithChildren; +export { + defaultNavigation, + type ManagementNodeDefinition, + type NavigationID, +} from './default_navigation'; diff --git a/packages/default-nav/management/jest.config.js b/packages/default-nav/management/jest.config.js new file mode 100644 index 0000000000000..728680c45b9ca --- /dev/null +++ b/packages/default-nav/management/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/default-nav/management'], +}; diff --git a/packages/default-nav/management/kibana.jsonc b/packages/default-nav/management/kibana.jsonc new file mode 100644 index 0000000000000..bf1f29ae3a9ab --- /dev/null +++ b/packages/default-nav/management/kibana.jsonc @@ -0,0 +1,8 @@ +{ + "type": "shared-common", + "id": "@kbn/default-nav-management", + "owner": [ + "@elastic/platform-deployment-management", + "@elastic/kibana-data-discovery" + ] +} diff --git a/packages/default-nav/management/package.json b/packages/default-nav/management/package.json new file mode 100644 index 0000000000000..fc8f35796c911 --- /dev/null +++ b/packages/default-nav/management/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/default-nav-management", + "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/default-nav/management/tsconfig.json b/packages/default-nav/management/tsconfig.json new file mode 100644 index 0000000000000..5b34775c71159 --- /dev/null +++ b/packages/default-nav/management/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/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts index 889f44ca9aa04..3626f19355f35 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts @@ -17,10 +17,12 @@ import { defaultNavigation as devtools, type DevToolsNodeDefinition, } from '@kbn/default-nav-devtools'; +import { + defaultNavigation as management, + type ManagementNodeDefinition, +} from '@kbn/default-nav-management'; import type { NavigationGroupPreset } from '../types'; -import type { ManagementNodeDefinition } from './types'; -import { management } from './management'; export function getPresets(preset: 'devtools'): DevToolsNodeDefinition; export function getPresets(preset: 'management'): ManagementNodeDefinition; diff --git a/tsconfig.base.json b/tsconfig.base.json index d8da32b48b103..c58f8f06a1359 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -610,12 +610,16 @@ "@kbn/deeplinks-analytics/*": ["packages/deeplinks/analytics/*"], "@kbn/deeplinks-devtools": ["packages/deeplinks/devtools"], "@kbn/deeplinks-devtools/*": ["packages/deeplinks/devtools/*"], + "@kbn/deeplinks-management": ["packages/deeplinks/management"], + "@kbn/deeplinks-management/*": ["packages/deeplinks/management/*"], "@kbn/deeplinks-ml": ["packages/deeplinks/ml"], "@kbn/deeplinks-ml/*": ["packages/deeplinks/ml/*"], "@kbn/default-nav-analytics": ["packages/default-nav/analytics"], "@kbn/default-nav-analytics/*": ["packages/default-nav/analytics/*"], "@kbn/default-nav-devtools": ["packages/default-nav/devtools"], "@kbn/default-nav-devtools/*": ["packages/default-nav/devtools/*"], + "@kbn/default-nav-management": ["packages/default-nav/management"], + "@kbn/default-nav-management/*": ["packages/default-nav/management/*"], "@kbn/default-nav-ml": ["packages/default-nav/ml"], "@kbn/default-nav-ml/*": ["packages/default-nav/ml/*"], "@kbn/dev-cli-errors": ["packages/kbn-dev-cli-errors"], diff --git a/yarn.lock b/yarn.lock index b17befd97ff7c..8dd18d34542c3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4055,6 +4055,10 @@ version "0.0.0" uid "" +"@kbn/deeplinks-management@link:packages/deeplinks/management": + version "0.0.0" + uid "" + "@kbn/deeplinks-ml@link:packages/deeplinks/ml": version "0.0.0" uid "" @@ -4067,6 +4071,10 @@ version "0.0.0" uid "" +"@kbn/default-nav-management@link:packages/default-nav/management": + version "0.0.0" + uid "" + "@kbn/default-nav-ml@link:packages/default-nav/ml": version "0.0.0" uid "" From 2759c635518c66160fd2dfc627a9aba625ca7f53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 13:32:37 +0100 Subject: [PATCH 28/60] Create default nav package for management (2) --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index e25f57a7e1700..5f6d801a59944 100644 --- a/package.json +++ b/package.json @@ -357,6 +357,7 @@ "@kbn/deeplinks-ml": "link:packages/deeplinks/ml", "@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", "@kbn/default-nav-ml": "link:packages/default-nav/ml", "@kbn/dev-tools-plugin": "link:src/plugins/dev_tools", "@kbn/developer-examples-plugin": "link:examples/developer_examples", From 9ddb14c73f11027b6e3140be615d9feb7b3e511c Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 7 Jun 2023 11:30:51 +0000 Subject: [PATCH 29/60] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- packages/shared-ux/chrome/navigation/tsconfig.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/shared-ux/chrome/navigation/tsconfig.json b/packages/shared-ux/chrome/navigation/tsconfig.json index f0d1c0f0e23da..d652740f3cd6f 100644 --- a/packages/shared-ux/chrome/navigation/tsconfig.json +++ b/packages/shared-ux/chrome/navigation/tsconfig.json @@ -16,7 +16,16 @@ "**/*.ts", "**/*.tsx" ], - "kbn_references": [], + "kbn_references": [ + "@kbn/shared-ux-storybook-mock", + "@kbn/core-chrome-browser", + "@kbn/i18n", + "@kbn/default-nav-analytics", + "@kbn/default-nav-ml", + "@kbn/default-nav-devtools", + "@kbn/core-application-browser", + "@kbn/core-http-browser", + ], "exclude": [ "target/**/*" ] From d2b0c6ccf3b5842972e673d49e9ebd8819beb5e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 13:35:59 +0100 Subject: [PATCH 30/60] Update kbn_references --- packages/shared-ux/chrome/navigation/tsconfig.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/shared-ux/chrome/navigation/tsconfig.json b/packages/shared-ux/chrome/navigation/tsconfig.json index d652740f3cd6f..cc7b9ecc76121 100644 --- a/packages/shared-ux/chrome/navigation/tsconfig.json +++ b/packages/shared-ux/chrome/navigation/tsconfig.json @@ -17,14 +17,14 @@ "**/*.tsx" ], "kbn_references": [ - "@kbn/shared-ux-storybook-mock", "@kbn/core-chrome-browser", + "@kbn/core-application-browser", "@kbn/i18n", "@kbn/default-nav-analytics", "@kbn/default-nav-ml", + "@kbn/default-nav-management", "@kbn/default-nav-devtools", - "@kbn/core-application-browser", - "@kbn/core-http-browser", + "@kbn/shared-ux-storybook-mock", ], "exclude": [ "target/**/*" From 0da001a7cd35cd7d753f831740c33ea983a55407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 14:11:35 +0100 Subject: [PATCH 31/60] WIP management deep links --- .../src/project_navigation.ts | 10 +- packages/deeplinks/management/constants.ts | 2 +- packages/deeplinks/management/deep_links.ts | 14 +- .../management/default_navigation.ts | 384 +++++++++--------- 4 files changed, 209 insertions(+), 201 deletions(-) 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 01b98efe1e4f5..5ea54059dc92b 100644 --- a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts +++ b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts @@ -11,16 +11,20 @@ import type { AppId as AnalyticsApp, DeepLinkId as AnalyticsDeepLink, } from '@kbn/deeplinks-analytics'; -import type { AppId as MlApp, DeepLinkId as MlToolsLink } from '@kbn/deeplinks-ml'; +import type { AppId as MlApp, DeepLinkId as MlLink } from '@kbn/deeplinks-ml'; +import type { + AppId as ManagementApp, + DeepLinkId as ManagementLink, +} from '@kbn/deeplinks-management'; import type { ChromeBreadcrumb } from './breadcrumb'; import type { ChromeNavLink } from './nav_links'; /** @public */ -export type AppId = DevToolsApp | AnalyticsApp | MlApp; +export type AppId = DevToolsApp | AnalyticsApp | MlApp | ManagementApp; /** @public */ -export type AppDeepLinkId = AnalyticsDeepLink | DevToolsLink | MlToolsLink; +export type AppDeepLinkId = AnalyticsDeepLink | DevToolsLink | MlLink | ManagementLink; /** @public */ export interface ChromeProjectNavigationNode { diff --git a/packages/deeplinks/management/constants.ts b/packages/deeplinks/management/constants.ts index 41404a3f5caf5..a04f55a3b4855 100644 --- a/packages/deeplinks/management/constants.ts +++ b/packages/deeplinks/management/constants.ts @@ -6,4 +6,4 @@ * Side Public License, v 1. */ -export const DEV_TOOLS_APP_ID = 'dev_tools'; +export const MONITORING_APP_ID = 'monitoring'; diff --git a/packages/deeplinks/management/deep_links.ts b/packages/deeplinks/management/deep_links.ts index 8ec43edd6d3fe..451447701485d 100644 --- a/packages/deeplinks/management/deep_links.ts +++ b/packages/deeplinks/management/deep_links.ts @@ -6,10 +6,14 @@ * Side Public License, v 1. */ -import { DEV_TOOLS_APP_ID } from './constants'; +import { MONITORING_APP_ID } from './constants'; -export type AppId = typeof DEV_TOOLS_APP_ID; +// Monitoring +export type MonitoringAppId = typeof MONITORING_APP_ID; +export type MonitoringId = 'xxx'; +export type MonitoringDeepLinkId = MonitoringAppId | `${MonitoringAppId}:${LinkId}`; -export type LinkId = 'searchprofiler' | 'painless_lab' | 'grokdebugger' | 'console'; - -export type DeepLinkId = AppId | `${AppId}:${LinkId}`; +// Combined +export type AppId = MonitoringAppId; +export type LinkId = MonitoringId; +export type DeepLinkId = MonitoringDeepLinkId; diff --git a/packages/default-nav/management/default_navigation.ts b/packages/default-nav/management/default_navigation.ts index 419dd163dfaeb..e892e8700f3a3 100644 --- a/packages/default-nav/management/default_navigation.ts +++ b/packages/default-nav/management/default_navigation.ts @@ -7,7 +7,7 @@ */ import { i18n } from '@kbn/i18n'; import type { NodeDefinitionWithChildren } from '@kbn/core-chrome-browser'; -import type { DeepLinkId } from '@kbn/deeplinks-devtools'; +import type { DeepLinkId } from '@kbn/deeplinks-management'; export type NavigationID = 'rootNav:management' | 'root'; @@ -15,7 +15,9 @@ export type ManagementNodeDefinition = NodeDefinitionWithChildren Date: Wed, 7 Jun 2023 13:17:46 +0000 Subject: [PATCH 32/60] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- packages/core/chrome/core-chrome-browser/tsconfig.json | 3 ++- packages/deeplinks/management/tsconfig.json | 2 +- packages/default-nav/management/tsconfig.json | 8 ++++++-- packages/shared-ux/chrome/navigation/tsconfig.json | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/core/chrome/core-chrome-browser/tsconfig.json b/packages/core/chrome/core-chrome-browser/tsconfig.json index 6c4cc21ee9191..70288b7a53a83 100644 --- a/packages/core/chrome/core-chrome-browser/tsconfig.json +++ b/packages/core/chrome/core-chrome-browser/tsconfig.json @@ -16,7 +16,8 @@ "@kbn/core-application-common", "@kbn/deeplinks-devtools", "@kbn/deeplinks-analytics", - "@kbn/deeplinks-ml" + "@kbn/deeplinks-ml", + "@kbn/deeplinks-management" ], "exclude": [ "target/**/*", diff --git a/packages/deeplinks/management/tsconfig.json b/packages/deeplinks/management/tsconfig.json index 5b34775c71159..d1414086f2187 100644 --- a/packages/deeplinks/management/tsconfig.json +++ b/packages/deeplinks/management/tsconfig.json @@ -10,7 +10,7 @@ }, "include": [ "**/*.ts", - "**/*.tsx", + "**/*.tsx", ], "exclude": [ "target/**/*" diff --git a/packages/default-nav/management/tsconfig.json b/packages/default-nav/management/tsconfig.json index 5b34775c71159..2e7b8415084c9 100644 --- a/packages/default-nav/management/tsconfig.json +++ b/packages/default-nav/management/tsconfig.json @@ -10,10 +10,14 @@ }, "include": [ "**/*.ts", - "**/*.tsx", + "**/*.tsx", ], "exclude": [ "target/**/*" ], - "kbn_references": [] + "kbn_references": [ + "@kbn/i18n", + "@kbn/core-chrome-browser", + "@kbn/deeplinks-management", + ] } diff --git a/packages/shared-ux/chrome/navigation/tsconfig.json b/packages/shared-ux/chrome/navigation/tsconfig.json index cc7b9ecc76121..45e8325bc9d3e 100644 --- a/packages/shared-ux/chrome/navigation/tsconfig.json +++ b/packages/shared-ux/chrome/navigation/tsconfig.json @@ -25,6 +25,7 @@ "@kbn/default-nav-management", "@kbn/default-nav-devtools", "@kbn/shared-ux-storybook-mock", + "@kbn/core-http-browser", ], "exclude": [ "target/**/*" From a6597f9cfbea586d0f3326a68d74e32e538bf2c5 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 7 Jun 2023 13:24:51 +0000 Subject: [PATCH 33/60] [CI] Auto-commit changed files from 'node scripts/generate codeowners' --- .github/CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ea055b7140538..b6fa04d4830ca 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -308,9 +308,11 @@ x-pack/plugins/data_visualizer @elastic/ml-ui packages/kbn-datemath @elastic/kibana-data-discovery packages/deeplinks/analytics @elastic/kibana-data-discovery packages/deeplinks/devtools @elastic/platform-deployment-management +packages/deeplinks/management @elastic/platform-deployment-management @elastic/kibana-data-discovery packages/deeplinks/ml @elastic/ml-ui packages/default-nav/analytics @elastic/kibana-data-discovery packages/default-nav/devtools @elastic/platform-deployment-management +packages/default-nav/management @elastic/platform-deployment-management @elastic/kibana-data-discovery packages/default-nav/ml @elastic/ml-ui packages/kbn-dev-cli-errors @elastic/kibana-operations packages/kbn-dev-cli-runner @elastic/kibana-operations From 891d55085cb2376bfb4404dde05020645e972fab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 15:07:28 +0100 Subject: [PATCH 34/60] Fix TS issues --- packages/deeplinks/management/index.ts | 2 +- .../src/ui/components/navigation.test.tsx | 10 +++---- .../src/ui/components/navigation_group.tsx | 21 +++++++++++--- .../src/ui/components/navigation_item.tsx | 15 ++++++++-- .../src/ui/hooks/use_init_navnode.ts | 28 +++++++++++++++---- .../navigation/src/ui/navigation.stories.tsx | 8 +++--- .../chrome/navigation/src/ui/types.ts | 14 ++++++++-- 7 files changed, 73 insertions(+), 25 deletions(-) diff --git a/packages/deeplinks/management/index.ts b/packages/deeplinks/management/index.ts index 89a4709f4942d..54d91921b6ef2 100644 --- a/packages/deeplinks/management/index.ts +++ b/packages/deeplinks/management/index.ts @@ -6,6 +6,6 @@ * Side Public License, v 1. */ -export { DEV_TOOLS_APP_ID, deepLinkIds } from './constants'; +export { MONITORING_APP_ID } from './constants'; export type { AppId, LinkId, DeepLinkId } from './deep_links'; diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/navigation.test.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/navigation.test.tsx index e5bf85341345e..5d2efd0e48464 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/navigation.test.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/navigation.test.tsx @@ -132,8 +132,8 @@ describe('', () => { {/* Title from deeplink */} - - + id="item1" link="item1" /> + id="item2" link="item1" title="Overwrite deeplink title" /> Title in children @@ -225,9 +225,9 @@ describe('', () => { {/* Title from deeplink */} - + id="item1" link="item1" /> {/* Should not appear */} - + id="unknownLink" link="unknown" title="Should NOT be there" /> @@ -297,7 +297,7 @@ describe('', () => { - + link="item1">
Custom element
diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_group.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_group.tsx index aa896f6bf45e5..66253dea2cf79 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_group.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_group.tsx @@ -8,11 +8,12 @@ import React, { createContext, useCallback, useMemo, useContext } from 'react'; +import type { AppDeepLinkId } from '@kbn/core-chrome-browser'; import { useInitNavNode } from '../hooks'; import type { NodeProps, RegisterFunction } from '../types'; import { NavigationSectionUI } from './navigation_section_ui'; import { useNavigation } from './navigation'; -import { NavigationBucket, Props as NavigationBucketProps } from './navigation_bucket'; +import { NavigationBucket, type Props as NavigationBucketProps } from './navigation_bucket'; interface Context { register: RegisterFunction; @@ -30,12 +31,20 @@ export function useNavigationGroup( return context as T extends true ? Context : Context | undefined; } -export interface Props extends NodeProps { +export interface Props< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenId extends string = Id +> extends NodeProps { unstyled?: boolean; defaultIsCollapsed?: boolean; } -function NavigationGroupInternalComp(props: Props) { +function NavigationGroupInternalComp< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenId extends string = Id +>(props: Props) { const navigationContext = useNavigation(); const { children, defaultIsCollapsed, ...node } = props; const { navNode, registerChildNode, path, childrenNodes } = useInitNavNode(node); @@ -90,7 +99,11 @@ function NavigationGroupInternalComp(props: Props) { ); } -function NavigationGroupComp(props: Props & NavigationBucketProps) { +function NavigationGroupComp< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenId extends string = Id +>(props: Props & NavigationBucketProps) { if (props.preset) { const { id, title, link, icon, children, ...rest } = props; return ; diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_item.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_item.tsx index 44ffe44572d6e..35ef2151378f6 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_item.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_item.tsx @@ -8,11 +8,16 @@ import React, { Fragment, ReactElement, ReactNode, useEffect } from 'react'; +import type { AppDeepLinkId } from '@kbn/core-chrome-browser'; import type { ChromeProjectNavigationNodeEnhanced, NodeProps } from '../types'; import { useInitNavNode } from '../hooks'; import { useNavigation } from './navigation'; -export interface Props extends NodeProps { +export interface Props< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenId extends string = Id +> extends NodeProps { element?: string; unstyled?: boolean; } @@ -21,7 +26,11 @@ function isReactElement(element: ReactNode): element is ReactElement { return React.isValidElement(element); } -function NavigationItemComp(props: Props) { +function NavigationItemComp< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenId extends string = Id +>(props: Props) { const navigationContext = useNavigation(); const navNodeRef = React.useRef(null); @@ -57,4 +66,4 @@ function NavigationItemComp(props: Props) { return {navNode.title}; } -export const NavigationItem = React.memo(NavigationItemComp); +export const NavigationItem = React.memo(NavigationItemComp) as typeof NavigationItemComp; diff --git a/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts b/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts index 1ee9972f58a12..c24b8e6d2b55a 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts @@ -6,7 +6,11 @@ * Side Public License, v 1. */ -import { ChromeNavLink, ChromeProjectNavigationNode } from '@kbn/core-chrome-browser'; +import { + AppDeepLinkId, + ChromeNavLink, + ChromeProjectNavigationNode, +} from '@kbn/core-chrome-browser'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import useObservable from 'react-use/lib/useObservable'; @@ -20,7 +24,11 @@ import { } from '../types'; import { useRegisterTreeNode } from './use_register_tree_node'; -function getIdFromNavigationNode({ id: _id, link, title }: NodeProps): string { +function getIdFromNavigationNode< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenId extends string = Id +>({ id: _id, link, title }: NodeProps): string { const id = _id ?? link; if (!id) { @@ -38,9 +46,13 @@ function isNodeVisible({ link, deepLink }: { link?: string; deepLink?: ChromeNav return true; } -function createInternalNavNode( +function createInternalNavNode< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenId extends string = Id +>( id: string, - _navNode: NodePropsEnhanced, + _navNode: NodePropsEnhanced, deepLinks: Readonly, path: string[] | null ): ChromeProjectNavigationNodeEnhanced | null { @@ -64,7 +76,13 @@ function createInternalNavNode( }; } -export const useInitNavNode = (node: NodePropsEnhanced) => { +export const useInitNavNode = < + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenId extends string = Id +>( + node: NodePropsEnhanced +) => { /** * Map of children nodes */ diff --git a/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx b/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx index 6b5bb55180a3d..141d75b52e688 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx @@ -30,7 +30,7 @@ import { NavigationProvider } from '../services'; import { DefaultNavigation } from './default_navigation'; import type { ChromeNavigationViewModel, NavigationServices } from '../../types'; import { Navigation } from './components'; -import { ProjectNavigationDefinition } from './types'; +import type { NonEmptyArray, ProjectNavigationDefinition } from './types'; import { getPresets } from './nav_tree_presets'; const storybookMock = new NavigationStorybookMock(); @@ -252,9 +252,9 @@ const navigationDefinition: ProjectNavigationDefinition = { ...child, children: child.children?.filter((item) => { // Hide discover and dashboard - return item.id !== 'discover' && item.id !== 'dashboard'; + return item.link !== 'discover' && item.link !== 'dashboard'; }), - })), + })) as NonEmptyArray, }, ], footer: [ @@ -333,7 +333,7 @@ export const WithUIComponents = (args: ChromeNavigationViewModel & NavigationSer defaultIsCollapsed={false} > - + id="item1" link="item1" /> {(navNode) => { return ( diff --git a/packages/shared-ux/chrome/navigation/src/ui/types.ts b/packages/shared-ux/chrome/navigation/src/ui/types.ts index 87831e5146f7e..c11ba23020015 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/types.ts @@ -15,7 +15,7 @@ import type { import type { CloudLinkProps, RecentlyAccessedProps } from './components'; -type NonEmptyArray = [T, ...T[]]; +export type NonEmptyArray = [T, ...T[]]; /** * @public @@ -23,7 +23,11 @@ type NonEmptyArray = [T, ...T[]]; * A navigation node definition with its unique id, title, path in the tree and optional deep link. * Those are the props that can be passed to the Navigation.Group and Navigation.Item components. */ -export interface NodeProps extends Omit { +export interface NodeProps< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenId extends string = Id +> extends Omit, 'children'> { /** * Children of the node. For Navigation.Item (only) it allows a function to be set. * This function will receive the ChromeProjectNavigationNode object @@ -36,7 +40,11 @@ export interface NodeProps extends Omit { * * Internally we enhance the Props passed to the Navigation.Item component. */ -export interface NodePropsEnhanced extends NodeProps { +export interface NodePropsEnhanced< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = LinkId, + ChildrenId extends string = Id +> extends NodeProps { /** * This function correspond to the same "itemRender" function that can be passed to * the EuiSideNavItemType (see navigation_section_ui.tsx) From 90abdc670a2d682ca792db18f08e26a41028641b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 16:15:22 +0100 Subject: [PATCH 35/60] Update management deeplinks --- packages/deeplinks/management/constants.ts | 4 + packages/deeplinks/management/deep_links.ts | 50 ++- .../management/default_navigation.ts | 296 +++++++----------- 3 files changed, 156 insertions(+), 194 deletions(-) diff --git a/packages/deeplinks/management/constants.ts b/packages/deeplinks/management/constants.ts index a04f55a3b4855..1910641ac47c8 100644 --- a/packages/deeplinks/management/constants.ts +++ b/packages/deeplinks/management/constants.ts @@ -7,3 +7,7 @@ */ export const MONITORING_APP_ID = 'monitoring'; +export const INTEGRATIONS_APP_ID = 'integrations'; +export const FLEET_APP_ID = 'fleet'; +export const OSQUERY_APP_ID = 'osquery'; +export const MANAGEMENT_APP_ID = 'management'; diff --git a/packages/deeplinks/management/deep_links.ts b/packages/deeplinks/management/deep_links.ts index 451447701485d..8aea7038ee470 100644 --- a/packages/deeplinks/management/deep_links.ts +++ b/packages/deeplinks/management/deep_links.ts @@ -6,14 +6,52 @@ * Side Public License, v 1. */ -import { MONITORING_APP_ID } from './constants'; +import { + MONITORING_APP_ID, + INTEGRATIONS_APP_ID, + FLEET_APP_ID, + OSQUERY_APP_ID, + MANAGEMENT_APP_ID, +} from './constants'; // Monitoring export type MonitoringAppId = typeof MONITORING_APP_ID; -export type MonitoringId = 'xxx'; -export type MonitoringDeepLinkId = MonitoringAppId | `${MonitoringAppId}:${LinkId}`; +export type MonitoringDeepLinkId = MonitoringAppId; + +// Integrations +export type IntegrationsAppId = typeof INTEGRATIONS_APP_ID; +export type FleetAppId = typeof FLEET_APP_ID; +export type OsQueryAppId = typeof OSQUERY_APP_ID; +export type IntegrationsDeepLinkId = IntegrationsAppId | FleetAppId | OsQueryAppId; + +// Management +export type ManagementAppId = typeof MANAGEMENT_APP_ID; +export type ManagementId = + | 'cross_cluster_replication' + | 'index_lifecycle_management' + | 'index_management' + | 'ingest_pipelines' + | 'pipelines' + | 'remote_clusters' + | 'rollup_jobs' + | 'snapshot_restore' + | 'transform' + // Alerts and insights + | 'cases' + | 'jobsListLink' + | 'triggersActions' + | 'triggersActionsConnectors' + | 'reporting' + | 'watcher' + // Kibana + | 'dataViews' + | 'objects' + | 'tags' + | 'spaces' + | 'settings'; +export type ManagementDeepLinkId = MonitoringAppId | `${ManagementAppId}:${ManagementId}`; // Combined -export type AppId = MonitoringAppId; -export type LinkId = MonitoringId; -export type DeepLinkId = MonitoringDeepLinkId; +export type AppId = MonitoringAppId | IntegrationsAppId | ManagementAppId; +export type LinkId = ManagementId; +export type DeepLinkId = MonitoringDeepLinkId | IntegrationsDeepLinkId | ManagementDeepLinkId; diff --git a/packages/default-nav/management/default_navigation.ts b/packages/default-nav/management/default_navigation.ts index e892e8700f3a3..b586e2925077e 100644 --- a/packages/default-nav/management/default_navigation.ts +++ b/packages/default-nav/management/default_navigation.ts @@ -9,7 +9,15 @@ import { i18n } from '@kbn/i18n'; import type { NodeDefinitionWithChildren } from '@kbn/core-chrome-browser'; import type { DeepLinkId } from '@kbn/deeplinks-management'; -export type NavigationID = 'rootNav:management' | 'root'; +export type NavigationID = + | 'rootNav:management' + | 'root' + | 'integration_management' + | 'stack_management' + | 'ingest' + | 'data' + | 'alerts_and_insights' + | 'kibana'; export type ManagementNodeDefinition = NodeDefinitionWithChildren; @@ -29,192 +37,104 @@ export const defaultNavigation: ManagementNodeDefinition = { }, ], }, - // { - // id: 'integration_management', - // title: 'Integration management', - // children: [ - // { - // id: 'integrations', - // title: 'Integrations', - // href: '/app/integrations', - // }, - // { - // id: 'fleet', - // title: 'Fleet', - // href: '/app/fleet', - // }, - // { - // id: 'osquery', - // title: 'Osquery', - // href: '/app/osquery', - // }, - // ], - // }, - // { - // id: 'stack_management', - // title: 'Stack management', - // children: [ - // { - // id: 'ingest', - // title: 'Ingest', - // children: [ - // { - // id: 'ingest_pipelines', - // title: 'Ingest pipelines', - // href: '/app/management/ingest/ingest_pipelines', - // }, - // { - // id: 'logstash_pipelines', - // title: 'Logstash pipelines', - // href: '/app/management/ingest/pipelines', - // }, - // ], - // }, - // { - // id: 'data', - // title: 'Data', - // children: [ - // { - // id: 'index_management', - // title: 'Index management', - // href: '/app/management/data/index_management', - // }, - // { - // id: 'index_lifecycle_policies', - // title: 'Index lifecycle policies', - // href: '/app/management/data/index_lifecycle_management', - // }, - // { - // id: 'snapshot_and_restore', - // title: 'Snapshot and restore', - // href: 'app/management/data/snapshot_restore', - // }, - // { - // id: 'rollup_jobs', - // title: 'Rollup jobs', - // href: '/app/management/data/rollup_jobs', - // }, - // { - // id: 'transforms', - // title: 'Transforms', - // href: '/app/management/data/transform', - // }, - // { - // id: 'cross_cluster_replication', - // title: 'Cross-cluster replication', - // href: '/app/management/data/cross_cluster_replication', - // }, - // { - // id: 'remote_clusters', - // title: 'Remote clusters', - // href: '/app/management/data/remote_clusters', - // }, - // ], - // }, - // { - // id: 'alerts_and_insights', - // title: 'Alerts and insights', - // children: [ - // { - // id: 'rules', - // title: 'Rules', - // href: '/app/management/insightsAndAlerting/triggersActions/rules', - // }, - // { - // id: 'cases', - // title: 'Cases', - // href: '/app/management/insightsAndAlerting/cases', - // }, - // { - // id: 'connectors', - // title: 'Connectors', - // href: '/app/management/insightsAndAlerting/triggersActionsConnectors/connectors', - // }, - // { - // id: 'reporting', - // title: 'Reporting', - // href: '/app/management/insightsAndAlerting/reporting', - // }, - // { - // id: 'machine_learning', - // title: 'Machine learning', - // href: '/app/management/insightsAndAlerting/jobsListLink', - // }, - // { - // id: 'watcher', - // title: 'Watcher', - // href: '/app/management/insightsAndAlerting/watcher', - // }, - // ], - // }, - // { - // id: 'security', - // title: 'Security', - // children: [ - // { - // id: 'users', - // title: 'Users', - // href: '/app/management/security/users', - // }, - // { - // id: 'roles', - // title: 'Roles', - // href: '/app/management/security/roles', - // }, - // { - // id: 'role_mappings', - // title: 'Role mappings', - // href: '/app/management/security/role_mappings', - // }, - // { - // id: 'api_keys', - // title: 'API keys', - // href: '/app/management/security/api_keys', - // }, - // ], - // }, - // { - // id: 'kibana', - // title: 'Kibana', - // children: [ - // { - // id: 'data_views', - // title: 'Data view', - // href: '/app/management/kibana/dataViews', - // }, - // { - // id: 'saved_objects', - // title: 'Saved objects', - // href: '/app/management/kibana/objects', - // }, - // { - // id: 'tags', - // title: 'Tags', - // href: '/app/management/kibana/tags', - // }, - // { - // id: 'search_sessions', - // title: 'Search sessions', - // href: '/app/management/kibana/search_sessions', - // }, - // { - // id: 'spaces', - // title: 'Spaces', - // href: '/app/management/kibana/spaces', - // }, - // { - // id: 'advanced_settings', - // title: 'Advanced settings', - // href: '/app/management/kibana/settings', - // }, - // ], - // }, - // { - // id: 'upgrade_assistant', - // title: 'Upgrade assistant', - // href: '/app/management/stack/upgrade_assistant', - // }, - // ], - // }, + { + id: 'integration_management', + title: i18n.translate('deeplinks.management.integrationManagement', { + defaultMessage: 'Integration management', + }), + children: [ + { + link: 'integrations', + }, + { + link: 'fleet', + }, + { + link: 'osquery', + }, + ], + }, + { + id: 'stack_management', + title: i18n.translate('deeplinks.management.integrationManagement', { + defaultMessage: 'Stack management', + }), + children: [ + { + id: 'ingest', + title: i18n.translate('deeplinks.management.ingest', { + defaultMessage: 'Ingest', + }), + children: [ + { + link: 'management:ingest_pipelines', + }, + { + link: 'management:pipelines', + }, + ], + }, + { + id: 'data', + title: i18n.translate('deeplinks.management.integrationManagement', { + defaultMessage: 'Data', + }), + children: [ + { + link: 'management:index_management', + }, + { + link: 'management:transform', + }, + ], + }, + { + id: 'alerts_and_insights', + title: i18n.translate('deeplinks.management.alertAndInsights', { + defaultMessage: 'Alerts and insights', + }), + children: [ + { + // Rules + link: 'management:triggersActions', + }, + { + link: 'management:cases', + }, + { + // Connectors + link: 'management:triggersActionsConnectors', + }, + { + // Machine Learning + link: 'management:jobsListLink', + }, + ], + }, + { + id: 'kibana', + title: 'Kibana', + children: [ + { + link: 'management:dataViews', + }, + { + // Saved objects + link: 'management:objects', + }, + { + link: 'management:tags', + }, + { + link: 'management:spaces', + }, + { + // Advanced settings + link: 'management:settings', + }, + ], + }, + ], + }, ], }; From 7c345cce455e62167080c527f99041e96357ed0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Wed, 7 Jun 2023 16:47:51 +0100 Subject: [PATCH 36/60] Fix TS issues --- .../src/project_navigation.ts | 6 ++-- .../src/ui/components/navigation_bucket.tsx | 31 ++++++++++++------- .../src/ui/components/navigation_group.tsx | 6 ++-- .../src/ui/components/navigation_item.tsx | 4 +-- .../src/ui/default_navigation.test.tsx | 4 +-- .../navigation/src/ui/default_navigation.tsx | 19 +++++++----- .../src/ui/hooks/use_init_navnode.ts | 6 ++-- .../chrome/navigation/src/ui/types.ts | 26 ++++++++++------ 8 files changed, 60 insertions(+), 42 deletions(-) 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 5ea54059dc92b..640283ed0d7c1 100644 --- a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts +++ b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts @@ -90,7 +90,7 @@ type NonEmptyArray = [T, ...T[]]; */ export interface NodeDefinition< LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, + Id extends string = string, ChildrenId extends string = Id > { /** Optional id, if not passed a "link" must be provided. */ @@ -102,7 +102,7 @@ export interface NodeDefinition< /** Optional icon for the navigation node. Note: not all navigation depth will render the icon */ icon?: string; /** Optional children of the navigation node */ - children?: NonEmptyArray>; + children?: NonEmptyArray>; /** * Temporarilly we allow href to be passed. * Once all the deeplinks will be exposed in packages we will not allow href anymore @@ -119,7 +119,7 @@ export interface NodeDefinition< */ export type NodeDefinitionWithChildren< LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, + Id extends string = string, ChildrenID extends string = Id > = NodeDefinition & { children: Required>['children']; diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_bucket.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_bucket.tsx index 3d287e918d5c8..f28bf7ce6151a 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_bucket.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_bucket.tsx @@ -6,33 +6,40 @@ * Side Public License, v 1. */ -import React, { FC, useCallback } from 'react'; +import React, { useCallback } from 'react'; +import type { AppDeepLinkId, NodeDefinition } from '@kbn/core-chrome-browser'; import { getPresets } from '../nav_tree_presets'; import { Navigation } from './navigation'; -import type { NavigationGroupPreset, NodeDefinition } from '../types'; +import type { NavigationGroupPreset } from '../types'; const navTreePresets = getPresets('all'); -export interface Props { +export interface Props< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = string, + ChildrenId extends string = Id +> { preset?: NavigationGroupPreset; - nodeDefinition?: NodeDefinition; + nodeDefinition?: NodeDefinition; defaultIsCollapsed?: boolean; } -export const NavigationBucket: FC = ({ - nodeDefinition: _nodeDefinition, - defaultIsCollapsed, - preset, -}) => { - const nodeDefinition = preset ? navTreePresets[preset] : _nodeDefinition; +export function NavigationBucket< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = string, + ChildrenId extends string = Id +>({ nodeDefinition: _nodeDefinition, defaultIsCollapsed, preset }: Props) { + const nodeDefinition = preset + ? (navTreePresets[preset] as NodeDefinition) + : _nodeDefinition; if (!nodeDefinition) { throw new Error('Either preset or nodeDefinition must be defined'); } const renderItems = useCallback( - (items: NodeDefinition[], isRoot = false) => { + (items: Array>, isRoot = false) => { return items.map((item) => { const id = item.id ?? item.link; @@ -64,4 +71,4 @@ export const NavigationBucket: FC = ({ ); return <>{renderItems([nodeDefinition], true)}; -}; +} diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_group.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_group.tsx index 66253dea2cf79..e28c66550034a 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_group.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_group.tsx @@ -33,7 +33,7 @@ export function useNavigationGroup( export interface Props< LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, + Id extends string = string, ChildrenId extends string = Id > extends NodeProps { unstyled?: boolean; @@ -42,7 +42,7 @@ export interface Props< function NavigationGroupInternalComp< LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, + Id extends string = string, ChildrenId extends string = Id >(props: Props) { const navigationContext = useNavigation(); @@ -101,7 +101,7 @@ function NavigationGroupInternalComp< function NavigationGroupComp< LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, + Id extends string = string, ChildrenId extends string = Id >(props: Props & NavigationBucketProps) { if (props.preset) { diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_item.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_item.tsx index 35ef2151378f6..a0564b7180970 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_item.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_item.tsx @@ -15,7 +15,7 @@ import { useNavigation } from './navigation'; export interface Props< LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, + Id extends string = string, ChildrenId extends string = Id > extends NodeProps { element?: string; @@ -28,7 +28,7 @@ function isReactElement(element: ReactNode): element is ReactElement { function NavigationItemComp< LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, + Id extends string = string, ChildrenId extends string = Id >(props: Props) { const navigationContext = useNavigation(); diff --git a/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx b/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx index 323d6056a73c1..274e04171180e 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx @@ -158,7 +158,7 @@ describe('', () => { const onProjectNavigationChange = jest.fn(); - const navigationBody: RootNavigationItemDefinition[] = [ + const navigationBody: Array> = [ { type: 'navGroup', id: 'root', @@ -333,7 +333,7 @@ describe('', () => { const onProjectNavigationChange = jest.fn(); // Custom project navigation tree definition - const projectNavigationTree: ProjectNavigationTreeDefinition = [ + const projectNavigationTree: ProjectNavigationTreeDefinition = [ { id: 'group1', title: 'Group 1', diff --git a/packages/shared-ux/chrome/navigation/src/ui/default_navigation.tsx b/packages/shared-ux/chrome/navigation/src/ui/default_navigation.tsx index ec2b921e01e82..6f179c9ff821d 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/default_navigation.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/default_navigation.tsx @@ -7,13 +7,13 @@ */ import React, { FC, useCallback } from 'react'; +import type { AppDeepLinkId, NodeDefinition } from '@kbn/core-chrome-browser'; import { Navigation } from './components'; import type { GroupDefinition, NavigationGroupPreset, NavigationTreeDefinition, - NodeDefinition, ProjectNavigationDefinition, ProjectNavigationTreeDefinition, RootNavigationItemDefinition, @@ -23,7 +23,9 @@ import { RecentlyAccessed } from './components/recently_accessed'; import { NavigationFooter } from './components/navigation_footer'; import { getPresets } from './nav_tree_presets'; -type NodeDefinitionWithPreset = NodeDefinition & { preset?: NavigationGroupPreset }; +type NodeDefinitionWithPreset = NodeDefinition & { + preset?: NavigationGroupPreset; +}; const isRootNavigationItemDefinition = ( item: RootNavigationItemDefinition | NodeDefinitionWithPreset @@ -85,7 +87,7 @@ export const DefaultNavigation: FC = [], + items: RootNavigationItemDefinition[] | NodeDefinitionWithPreset[] = [], path: string[] = [] ) => { return items.map((item) => { @@ -112,16 +114,17 @@ export const DefaultNavigation: FC - {rest.children ? ( - - {renderItems(rest.children, [...path, id])} + {copy.children ? ( + + {renderItems(copy.children, [...path, id])} ) : ( - + )} ); diff --git a/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts b/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts index c24b8e6d2b55a..bac37a5e05a88 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts @@ -26,7 +26,7 @@ import { useRegisterTreeNode } from './use_register_tree_node'; function getIdFromNavigationNode< LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, + Id extends string = string, ChildrenId extends string = Id >({ id: _id, link, title }: NodeProps): string { const id = _id ?? link; @@ -48,7 +48,7 @@ function isNodeVisible({ link, deepLink }: { link?: string; deepLink?: ChromeNav function createInternalNavNode< LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, + Id extends string = string, ChildrenId extends string = Id >( id: string, @@ -78,7 +78,7 @@ function createInternalNavNode< export const useInitNavNode = < LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, + Id extends string = string, ChildrenId extends string = Id >( node: NodePropsEnhanced diff --git a/packages/shared-ux/chrome/navigation/src/ui/types.ts b/packages/shared-ux/chrome/navigation/src/ui/types.ts index c11ba23020015..1d479bfafd43d 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/types.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/types.ts @@ -25,7 +25,7 @@ export type NonEmptyArray = [T, ...T[]]; */ export interface NodeProps< LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, + Id extends string = string, ChildrenId extends string = Id > extends Omit, 'children'> { /** @@ -42,7 +42,7 @@ export interface NodeProps< */ export interface NodePropsEnhanced< LinkId extends AppDeepLinkId = AppDeepLinkId, - Id extends string = LinkId, + Id extends string = string, ChildrenId extends string = Id > extends NodeProps { /** @@ -89,11 +89,14 @@ export interface CloudLinkDefinition extends CloudLinkProps { * * A group root item definition. */ -export interface GroupDefinition extends NodeDefinition { +export interface GroupDefinition< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = string, + ChildrenId extends string = Id +> extends NodeDefinition { type: 'navGroup'; /** Flag to indicate if the group is initially collapsed or not. */ defaultIsCollapsed?: boolean; - children?: NonEmptyArray>; preset?: NavigationGroupPreset; } @@ -102,12 +105,17 @@ export interface GroupDefinition extends NodeDefinition { * * The navigation definition for a root item in the side navigation. */ -export type RootNavigationItemDefinition = - | RecentlyAccessedDefinition - | CloudLinkDefinition - | GroupDefinition; +export type RootNavigationItemDefinition< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = string, + ChildrenId extends string = Id +> = RecentlyAccessedDefinition | CloudLinkDefinition | GroupDefinition; -export type ProjectNavigationTreeDefinition = Array>; +export type ProjectNavigationTreeDefinition< + LinkId extends AppDeepLinkId = AppDeepLinkId, + Id extends string = string, + ChildrenId extends string = Id +> = Array, 'type'>>; /** * @public From 582ab5a53b402360f2dfa97b39d10229db1cb0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Thu, 8 Jun 2023 06:53:34 +0100 Subject: [PATCH 37/60] Fix i18n --- .i18nrc.json | 2 +- .../analytics/default_navigation.ts | 2 +- .../devtools/default_navigation.ts | 2 +- .../management/default_navigation.ts | 12 +++++------ packages/default-nav/ml/default_navigation.ts | 20 +++++++++---------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.i18nrc.json b/.i18nrc.json index c08634b2b8aeb..3d457a16a3fbc 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -19,7 +19,7 @@ "data": "src/plugins/data", "observabilityAlertDetails": "x-pack/packages/observability/alert_details", "dataViews": "src/plugins/data_views", - "deepLinks": "packages/deeplinks", + "defaultNavigation": "packages/default-nav", "devTools": "src/plugins/dev_tools", "discover": "src/plugins/discover", "savedSearch": "src/plugins/saved_search", diff --git a/packages/default-nav/analytics/default_navigation.ts b/packages/default-nav/analytics/default_navigation.ts index d40bfd5185a42..76d32cdc9870f 100644 --- a/packages/default-nav/analytics/default_navigation.ts +++ b/packages/default-nav/analytics/default_navigation.ts @@ -15,7 +15,7 @@ export type AnalyticsNodeDefinition = NodeDefinitionWithChildren; export const defaultNavigation: DevToolsNodeDefinition = { - title: i18n.translate('deeplinks.devTools.developerTools', { + title: i18n.translate('defaultNavigation.devTools.developerTools', { defaultMessage: 'Developer tools', }), id: 'rootNav:devtools', diff --git a/packages/default-nav/management/default_navigation.ts b/packages/default-nav/management/default_navigation.ts index b586e2925077e..f61edf13eca72 100644 --- a/packages/default-nav/management/default_navigation.ts +++ b/packages/default-nav/management/default_navigation.ts @@ -23,7 +23,7 @@ export type ManagementNodeDefinition = NodeDefinitionWithChildren Date: Fri, 9 Jun 2023 11:32:00 +0100 Subject: [PATCH 38/60] Fix i18n issue --- packages/default-nav/management/default_navigation.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/default-nav/management/default_navigation.ts b/packages/default-nav/management/default_navigation.ts index f61edf13eca72..afc889c9a1e1b 100644 --- a/packages/default-nav/management/default_navigation.ts +++ b/packages/default-nav/management/default_navigation.ts @@ -56,7 +56,7 @@ export const defaultNavigation: ManagementNodeDefinition = { }, { id: 'stack_management', - title: i18n.translate('defaultNavigation.management.integrationManagement', { + title: i18n.translate('defaultNavigation.management.stackManagement', { defaultMessage: 'Stack management', }), children: [ @@ -76,7 +76,7 @@ export const defaultNavigation: ManagementNodeDefinition = { }, { id: 'data', - title: i18n.translate('defaultNavigation.management.integrationManagement', { + title: i18n.translate('defaultNavigation.management.stackManagementData', { defaultMessage: 'Data', }), children: [ From 7e86d83741b8d6c563d11f5b74ecc257d8bd9fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Fri, 9 Jun 2023 11:59:57 +0100 Subject: [PATCH 39/60] Fix dashboard app id --- packages/deeplinks/analytics/constants.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/deeplinks/analytics/constants.ts b/packages/deeplinks/analytics/constants.ts index a67516b808de0..81d8646cfa074 100644 --- a/packages/deeplinks/analytics/constants.ts +++ b/packages/deeplinks/analytics/constants.ts @@ -8,6 +8,6 @@ export const DISCOVER_APP_ID = 'discover'; -export const DASHBOARD_APP_ID = 'dashboard'; +export const DASHBOARD_APP_ID = 'dashboards'; export const VISUALIZE_APP_ID = 'visualize'; From 0b45a404a3dccec9d0b0dbf78489b92a5944e60f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Fri, 9 Jun 2023 12:56:00 +0100 Subject: [PATCH 40/60] Update search navigation --- packages/deeplinks/management/deep_links.ts | 22 ++++++------ .../serverless_search/public/layout/nav.tsx | 34 ++++--------------- 2 files changed, 18 insertions(+), 38 deletions(-) diff --git a/packages/deeplinks/management/deep_links.ts b/packages/deeplinks/management/deep_links.ts index 8aea7038ee470..1fa3d0f7d30bd 100644 --- a/packages/deeplinks/management/deep_links.ts +++ b/packages/deeplinks/management/deep_links.ts @@ -27,28 +27,28 @@ export type IntegrationsDeepLinkId = IntegrationsAppId | FleetAppId | OsQueryApp // Management export type ManagementAppId = typeof MANAGEMENT_APP_ID; export type ManagementId = + | 'api_keys' + | 'cases' | 'cross_cluster_replication' + | 'dataViews' | 'index_lifecycle_management' | 'index_management' | 'ingest_pipelines' + | 'jobsListLink' + | 'objects' | 'pipelines' | 'remote_clusters' + | 'reporting' | 'rollup_jobs' + | 'settings' | 'snapshot_restore' + | 'spaces' + | 'tags' | 'transform' - // Alerts and insights - | 'cases' - | 'jobsListLink' | 'triggersActions' | 'triggersActionsConnectors' - | 'reporting' - | 'watcher' - // Kibana - | 'dataViews' - | 'objects' - | 'tags' - | 'spaces' - | 'settings'; + | 'watcher'; + export type ManagementDeepLinkId = MonitoringAppId | `${ManagementAppId}:${ManagementId}`; // Combined diff --git a/x-pack/plugins/serverless_search/public/layout/nav.tsx b/x-pack/plugins/serverless_search/public/layout/nav.tsx index 409c46ba68490..4910c7ec6349a 100644 --- a/x-pack/plugins/serverless_search/public/layout/nav.tsx +++ b/x-pack/plugins/serverless_search/public/layout/nav.tsx @@ -16,8 +16,6 @@ import React from 'react'; import { i18n } from '@kbn/i18n'; import { ServerlessPluginStart } from '@kbn/serverless/public'; -const devTools = getPresets('devtools'); - const navigationTree: NavigationTreeDefinition = { body: [ { type: 'cloudLink', preset: 'projects' }, @@ -41,7 +39,7 @@ const navigationTree: NavigationTreeDefinition = { title: i18n.translate('xpack.serverlessSearch.nav.devTools', { defaultMessage: 'Dev Tools', }), - children: devTools.children[0].children, + children: getPresets('devtools').children[0].children, }, { id: 'explore', @@ -50,25 +48,13 @@ const navigationTree: NavigationTreeDefinition = { }), children: [ { - id: 'explore_discover', - title: i18n.translate('xpack.serverlessSearch.nav.explore.discover', { - defaultMessage: 'Discover', - }), - href: '/app/discover', + link: 'discover', }, { - id: 'explore_dashboard', - title: i18n.translate('xpack.serverlessSearch.nav.explore.dashboard', { - defaultMessage: 'Dashboard', - }), - href: '/app/dashboards', + link: 'dashboards', }, { - id: 'explore_visualize_library', - title: i18n.translate('xpack.serverlessSearch.nav.explore.visualizeLibrary', { - defaultMessage: 'Visualize Library', - }), - href: '/app/visualize', + link: 'visualize', }, ], }, @@ -79,20 +65,18 @@ const navigationTree: NavigationTreeDefinition = { }), children: [ { - id: 'content_indices', title: i18n.translate('xpack.serverlessSearch.nav.content.indices', { defaultMessage: 'Indices', }), // TODO: this will be updated to a new Indices page - href: '/app/management/data/index_management/indices', + link: 'management:index_management', }, { - id: 'content_transforms', title: i18n.translate('xpack.serverlessSearch.nav.content.transforms', { defaultMessage: 'Transforms', }), // TODO: this will be updated to a new Transforms page - href: '/app/management/ingest/ingest_pipelines', + link: 'management:ingest_pipelines', }, { id: 'content_indexing_api', @@ -111,11 +95,7 @@ const navigationTree: NavigationTreeDefinition = { }), children: [ { - id: 'security_api_keys', - title: i18n.translate('xpack.serverlessSearch.nav.security.apiKeys', { - defaultMessage: 'API Keys', - }), - href: '/app/management/security/api_keys', + link: 'management:api_keys', }, ], }, From 060974cea899e14d83c4488746862bb40edd7b91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Fri, 9 Jun 2023 13:01:39 +0100 Subject: [PATCH 41/60] Add deeplink package for search --- package.json | 1 + .../src/project_navigation.ts | 5 +++-- packages/deeplinks/search/README.md | 3 +++ packages/deeplinks/search/constants.ts | 9 +++++++++ packages/deeplinks/search/deep_links.ts | 13 +++++++++++++ packages/deeplinks/search/index.ts | 11 +++++++++++ packages/deeplinks/search/jest.config.js | 13 +++++++++++++ packages/deeplinks/search/kibana.jsonc | 5 +++++ packages/deeplinks/search/package.json | 6 ++++++ packages/deeplinks/search/tsconfig.json | 19 +++++++++++++++++++ tsconfig.base.json | 2 ++ .../serverless_search/public/layout/nav.tsx | 4 ++-- yarn.lock | 4 ++++ 13 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 packages/deeplinks/search/README.md create mode 100644 packages/deeplinks/search/constants.ts create mode 100644 packages/deeplinks/search/deep_links.ts create mode 100644 packages/deeplinks/search/index.ts create mode 100644 packages/deeplinks/search/jest.config.js create mode 100644 packages/deeplinks/search/kibana.jsonc create mode 100644 packages/deeplinks/search/package.json create mode 100644 packages/deeplinks/search/tsconfig.json diff --git a/package.json b/package.json index 5f6d801a59944..ec5435a5187dd 100644 --- a/package.json +++ b/package.json @@ -355,6 +355,7 @@ "@kbn/deeplinks-devtools": "link:packages/deeplinks/devtools", "@kbn/deeplinks-management": "link:packages/deeplinks/management", "@kbn/deeplinks-ml": "link:packages/deeplinks/ml", + "@kbn/deeplinks-search": "link:packages/deeplinks/search", "@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/src/project_navigation.ts b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts index 640283ed0d7c1..9a13d3ffdbacb 100644 --- a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts +++ b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts @@ -16,15 +16,16 @@ import type { AppId as ManagementApp, DeepLinkId as ManagementLink, } from '@kbn/deeplinks-management'; +import type { AppId as SearchApp, DeepLinkId as SearchLink } from '@kbn/deeplinks-search'; import type { ChromeBreadcrumb } from './breadcrumb'; import type { ChromeNavLink } from './nav_links'; /** @public */ -export type AppId = DevToolsApp | AnalyticsApp | MlApp | ManagementApp; +export type AppId = DevToolsApp | AnalyticsApp | MlApp | ManagementApp | SearchApp; /** @public */ -export type AppDeepLinkId = AnalyticsDeepLink | DevToolsLink | MlLink | ManagementLink; +export type AppDeepLinkId = AnalyticsDeepLink | DevToolsLink | MlLink | ManagementLink | SearchLink; /** @public */ export interface ChromeProjectNavigationNode { diff --git a/packages/deeplinks/search/README.md b/packages/deeplinks/search/README.md new file mode 100644 index 0000000000000..a0a33892aa272 --- /dev/null +++ b/packages/deeplinks/search/README.md @@ -0,0 +1,3 @@ +# @kbn/deeplinks-search + +Empty package generated by @kbn/generate diff --git a/packages/deeplinks/search/constants.ts b/packages/deeplinks/search/constants.ts new file mode 100644 index 0000000000000..d97628489ec40 --- /dev/null +++ b/packages/deeplinks/search/constants.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 const SERVERLESS_ES_APP_ID = 'serverlessElasticsearch'; diff --git a/packages/deeplinks/search/deep_links.ts b/packages/deeplinks/search/deep_links.ts new file mode 100644 index 0000000000000..e92759fcef752 --- /dev/null +++ b/packages/deeplinks/search/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. + */ + +import { SERVERLESS_ES_APP_ID } from './constants'; + +export type AppId = typeof SERVERLESS_ES_APP_ID; + +export type DeepLinkId = AppId; diff --git a/packages/deeplinks/search/index.ts b/packages/deeplinks/search/index.ts new file mode 100644 index 0000000000000..c4f8e835e2fca --- /dev/null +++ b/packages/deeplinks/search/index.ts @@ -0,0 +1,11 @@ +/* + * 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 { SERVERLESS_ES_APP_ID } from './constants'; + +export type { AppId, DeepLinkId } from './deep_links'; diff --git a/packages/deeplinks/search/jest.config.js b/packages/deeplinks/search/jest.config.js new file mode 100644 index 0000000000000..a5382da931905 --- /dev/null +++ b/packages/deeplinks/search/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/search'], +}; diff --git a/packages/deeplinks/search/kibana.jsonc b/packages/deeplinks/search/kibana.jsonc new file mode 100644 index 0000000000000..cb5584982e072 --- /dev/null +++ b/packages/deeplinks/search/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/deeplinks-search", + "owner": "@elastic/enterprise-search-frontend" +} diff --git a/packages/deeplinks/search/package.json b/packages/deeplinks/search/package.json new file mode 100644 index 0000000000000..6693ee3753504 --- /dev/null +++ b/packages/deeplinks/search/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/deeplinks-search", + "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/search/tsconfig.json b/packages/deeplinks/search/tsconfig.json new file mode 100644 index 0000000000000..5b34775c71159 --- /dev/null +++ b/packages/deeplinks/search/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/tsconfig.base.json b/tsconfig.base.json index c58f8f06a1359..c7a810042be0d 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -614,6 +614,8 @@ "@kbn/deeplinks-management/*": ["packages/deeplinks/management/*"], "@kbn/deeplinks-ml": ["packages/deeplinks/ml"], "@kbn/deeplinks-ml/*": ["packages/deeplinks/ml/*"], + "@kbn/deeplinks-search": ["packages/deeplinks/search"], + "@kbn/deeplinks-search/*": ["packages/deeplinks/search/*"], "@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/plugins/serverless_search/public/layout/nav.tsx b/x-pack/plugins/serverless_search/public/layout/nav.tsx index 4910c7ec6349a..adbb0e0e5a414 100644 --- a/x-pack/plugins/serverless_search/public/layout/nav.tsx +++ b/x-pack/plugins/serverless_search/public/layout/nav.tsx @@ -32,7 +32,7 @@ const navigationTree: NavigationTreeDefinition = { title: i18n.translate('xpack.serverlessSearch.nav.gettingStarted', { defaultMessage: 'Getting started', }), - href: '/app/elasticsearch', + link: 'serverlessElasticsearch', }, { id: 'dev_tools', @@ -84,7 +84,7 @@ const navigationTree: NavigationTreeDefinition = { defaultMessage: 'Indexing API', }), // TODO: this page does not exist yet, linking to getting started for now - href: '/app/elasticsearch', + link: 'serverlessElasticsearch', }, ], }, diff --git a/yarn.lock b/yarn.lock index 8dd18d34542c3..2022514028eb5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4063,6 +4063,10 @@ version "0.0.0" uid "" +"@kbn/deeplinks-search@link:packages/deeplinks/search": + version "0.0.0" + uid "" + "@kbn/default-nav-analytics@link:packages/default-nav/analytics": version "0.0.0" uid "" From 61a02e1ecfcb0c495fcb685d7614880d8d47a746 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 9 Jun 2023 10:41:46 +0000 Subject: [PATCH 42/60] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- packages/deeplinks/analytics/tsconfig.json | 2 -- packages/deeplinks/devtools/tsconfig.json | 3 --- 2 files changed, 5 deletions(-) diff --git a/packages/deeplinks/analytics/tsconfig.json b/packages/deeplinks/analytics/tsconfig.json index 147bf52e3c9f2..94b099694eaf4 100644 --- a/packages/deeplinks/analytics/tsconfig.json +++ b/packages/deeplinks/analytics/tsconfig.json @@ -16,7 +16,5 @@ "target/**/*" ], "kbn_references": [ - "@kbn/i18n", - "@kbn/shared-ux-chrome-navigation", ] } diff --git a/packages/deeplinks/devtools/tsconfig.json b/packages/deeplinks/devtools/tsconfig.json index 60efcacf24e75..94b099694eaf4 100644 --- a/packages/deeplinks/devtools/tsconfig.json +++ b/packages/deeplinks/devtools/tsconfig.json @@ -16,8 +16,5 @@ "target/**/*" ], "kbn_references": [ - "@kbn/core", - "@kbn/i18n", - "@kbn/shared-ux-chrome-navigation", ] } From 61f0001ba486d3950ea4e8169d6a1fe411d78949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Fri, 9 Jun 2023 13:39:53 +0100 Subject: [PATCH 43/60] Fix jest tests --- .../analytics/default_navigation.ts | 2 +- .../src/default_navigation.test.helpers.ts | 734 +++++++++++------- .../chrome/navigation/mocks/src/jest.ts | 8 +- .../chrome/navigation/mocks/src/navlinks.ts | 81 ++ .../src/ui/components/navigation_group.tsx | 9 +- .../src/ui/default_navigation.test.tsx | 3 + 6 files changed, 547 insertions(+), 290 deletions(-) create mode 100644 packages/shared-ux/chrome/navigation/mocks/src/navlinks.ts diff --git a/packages/default-nav/analytics/default_navigation.ts b/packages/default-nav/analytics/default_navigation.ts index 76d32cdc9870f..a9c0c414936b5 100644 --- a/packages/default-nav/analytics/default_navigation.ts +++ b/packages/default-nav/analytics/default_navigation.ts @@ -27,7 +27,7 @@ export const defaultNavigation: AnalyticsNodeDefinition = { link: 'discover', }, { - link: 'dashboard', + link: 'dashboards', }, { link: 'visualize', diff --git a/packages/shared-ux/chrome/navigation/mocks/src/default_navigation.test.helpers.ts b/packages/shared-ux/chrome/navigation/mocks/src/default_navigation.test.helpers.ts index 35d0cd1728a80..352ce20128199 100644 --- a/packages/shared-ux/chrome/navigation/mocks/src/default_navigation.test.helpers.ts +++ b/packages/shared-ux/chrome/navigation/mocks/src/default_navigation.test.helpers.ts @@ -14,33 +14,51 @@ */ export const defaultAnalyticsNavGroup = { - id: 'sharedux:analytics', + id: 'rootNav:analytics', title: 'Data exploration', icon: 'stats', - path: ['sharedux:analytics'], + path: ['rootNav:analytics'], children: [ { id: 'root', - path: ['sharedux:analytics', 'root'], + path: ['rootNav:analytics', 'root'], title: '', children: [ { - title: 'Discover', id: 'discover', - href: '/app/discover', - path: ['sharedux:analytics', 'root', 'discover'], - }, - { - title: 'Dashboard', - id: 'dashboard', - href: '/app/dashboards', - path: ['sharedux:analytics', 'root', 'dashboard'], - }, - { - id: 'visualize_library', - title: 'Visualize Library', - href: '/app/visualize', - path: ['sharedux:analytics', 'root', 'visualize_library'], + path: ['rootNav:analytics', 'root', 'discover'], + title: 'Mocked discover', + deepLink: { + id: 'discover', + title: 'Mocked discover', + href: '/mocked/discover', + baseUrl: '/mocked', + url: 'http://mocked/discover', + }, + }, + { + id: 'dashboards', + path: ['rootNav:analytics', 'root', 'dashboards'], + title: 'Mocked dashboards', + deepLink: { + id: 'dashboards', + title: 'Mocked dashboards', + href: '/mocked/dashboards', + baseUrl: '/mocked', + url: 'http://mocked/dashboards', + }, + }, + { + id: 'visualize', + path: ['rootNav:analytics', 'root', 'visualize'], + title: 'Mocked visualize', + deepLink: { + id: 'visualize', + title: 'Mocked visualize', + href: '/mocked/visualize', + baseUrl: '/mocked', + url: 'http://mocked/visualize', + }, }, ], }, @@ -48,140 +66,230 @@ export const defaultAnalyticsNavGroup = { }; export const defaultMlNavGroup = { - id: 'sharedux:ml', + id: 'rootNav:ml', title: 'Machine learning', icon: 'indexMapping', - path: ['sharedux:ml'], + path: ['rootNav:ml'], children: [ { title: '', id: 'root', - path: ['sharedux:ml', 'root'], + path: ['rootNav:ml', 'root'], children: [ { - id: 'overview', - title: 'Overview', - href: '/app/ml/overview', - path: ['sharedux:ml', 'root', 'overview'], - }, - { - id: 'notifications', - title: 'Notifications', - href: '/app/ml/notifications', - path: ['sharedux:ml', 'root', 'notifications'], + id: 'ml:overview', + path: ['rootNav:ml', 'root', 'ml:overview'], + title: 'Mocked ml:overview', + deepLink: { + id: 'ml:overview', + title: 'Mocked ml:overview', + href: '/mocked/ml:overview', + baseUrl: '/mocked', + url: 'http://mocked/ml:overview', + }, + }, + { + id: 'ml:notifications', + path: ['rootNav:ml', 'root', 'ml:notifications'], + title: 'Mocked ml:notifications', + deepLink: { + id: 'ml:notifications', + title: 'Mocked ml:notifications', + href: '/mocked/ml:notifications', + baseUrl: '/mocked', + url: 'http://mocked/ml:notifications', + }, }, ], }, { - title: 'Anomaly detection', + title: 'Anomaly Detection', id: 'anomaly_detection', - path: ['sharedux:ml', 'anomaly_detection'], + path: ['rootNav:ml', 'anomaly_detection'], children: [ { - id: 'jobs', title: 'Jobs', - href: '/app/ml/jobs', - path: ['sharedux:ml', 'anomaly_detection', 'jobs'], - }, - { - id: 'explorer', - title: 'Anomaly explorer', - href: '/app/ml/explorer', - path: ['sharedux:ml', 'anomaly_detection', 'explorer'], - }, - { - id: 'single_metric_viewer', - title: 'Single metric viewer', - href: '/app/ml/timeseriesexplorer', - path: ['sharedux:ml', 'anomaly_detection', 'single_metric_viewer'], - }, - { - id: 'settings', - title: 'Settings', - href: '/app/ml/settings', - path: ['sharedux:ml', 'anomaly_detection', 'settings'], + id: 'ml:anomalyDetection', + path: ['rootNav:ml', 'anomaly_detection', 'ml:anomalyDetection'], + deepLink: { + id: 'ml:anomalyDetection', + title: 'Mocked ml:anomalyDetection', + href: '/mocked/ml:anomalyDetection', + baseUrl: '/mocked', + url: 'http://mocked/ml:anomalyDetection', + }, + }, + { + id: 'ml:anomalyExplorer', + path: ['rootNav:ml', 'anomaly_detection', 'ml:anomalyExplorer'], + title: 'Mocked ml:anomalyExplorer', + deepLink: { + id: 'ml:anomalyExplorer', + title: 'Mocked ml:anomalyExplorer', + href: '/mocked/ml:anomalyExplorer', + baseUrl: '/mocked', + url: 'http://mocked/ml:anomalyExplorer', + }, + }, + { + id: 'ml:singleMetricViewer', + path: ['rootNav:ml', 'anomaly_detection', 'ml:singleMetricViewer'], + title: 'Mocked ml:singleMetricViewer', + deepLink: { + id: 'ml:singleMetricViewer', + title: 'Mocked ml:singleMetricViewer', + href: '/mocked/ml:singleMetricViewer', + baseUrl: '/mocked', + url: 'http://mocked/ml:singleMetricViewer', + }, + }, + { + id: 'ml:settings', + path: ['rootNav:ml', 'anomaly_detection', 'ml:settings'], + title: 'Mocked ml:settings', + deepLink: { + id: 'ml:settings', + title: 'Mocked ml:settings', + href: '/mocked/ml:settings', + baseUrl: '/mocked', + url: 'http://mocked/ml:settings', + }, }, ], }, { id: 'data_frame_analytics', title: 'Data frame analytics', - path: ['sharedux:ml', 'data_frame_analytics'], + path: ['rootNav:ml', 'data_frame_analytics'], children: [ { - id: 'jobs', title: 'Jobs', - href: '/app/ml/data_frame_analytics', - path: ['sharedux:ml', 'data_frame_analytics', 'jobs'], - }, - { - id: 'results_explorer', - title: 'Results explorer', - href: '/app/ml/data_frame_analytics/exploration', - path: ['sharedux:ml', 'data_frame_analytics', 'results_explorer'], - }, - { - id: 'analytics_map', - title: 'Analytics map', - href: '/app/ml/data_frame_analytics/map', - path: ['sharedux:ml', 'data_frame_analytics', 'analytics_map'], + id: 'ml:dataFrameAnalytics', + path: ['rootNav:ml', 'data_frame_analytics', 'ml:dataFrameAnalytics'], + deepLink: { + id: 'ml:dataFrameAnalytics', + title: 'Mocked ml:dataFrameAnalytics', + href: '/mocked/ml:dataFrameAnalytics', + baseUrl: '/mocked', + url: 'http://mocked/ml:dataFrameAnalytics', + }, + }, + { + id: 'ml:resultExplorer', + path: ['rootNav:ml', 'data_frame_analytics', 'ml:resultExplorer'], + title: 'Mocked ml:resultExplorer', + deepLink: { + id: 'ml:resultExplorer', + title: 'Mocked ml:resultExplorer', + href: '/mocked/ml:resultExplorer', + baseUrl: '/mocked', + url: 'http://mocked/ml:resultExplorer', + }, + }, + { + id: 'ml:analyticsMap', + path: ['rootNav:ml', 'data_frame_analytics', 'ml:analyticsMap'], + title: 'Mocked ml:analyticsMap', + deepLink: { + id: 'ml:analyticsMap', + title: 'Mocked ml:analyticsMap', + href: '/mocked/ml:analyticsMap', + baseUrl: '/mocked', + url: 'http://mocked/ml:analyticsMap', + }, }, ], }, { id: 'model_management', title: 'Model management', - path: ['sharedux:ml', 'model_management'], + path: ['rootNav:ml', 'model_management'], children: [ { - id: 'trained_models', - title: 'Trained models', - href: '/app/ml/trained_models', - path: ['sharedux:ml', 'model_management', 'trained_models'], - }, - { - id: 'nodes', - title: 'Nodes', - href: '/app/ml/nodes', - path: ['sharedux:ml', 'model_management', 'nodes'], + id: 'ml:nodesOverview', + path: ['rootNav:ml', 'model_management', 'ml:nodesOverview'], + title: 'Mocked ml:nodesOverview', + deepLink: { + id: 'ml:nodesOverview', + title: 'Mocked ml:nodesOverview', + href: '/mocked/ml:nodesOverview', + baseUrl: '/mocked', + url: 'http://mocked/ml:nodesOverview', + }, + }, + { + id: 'ml:nodes', + path: ['rootNav:ml', 'model_management', 'ml:nodes'], + title: 'Mocked ml:nodes', + deepLink: { + id: 'ml:nodes', + title: 'Mocked ml:nodes', + href: '/mocked/ml:nodes', + baseUrl: '/mocked', + url: 'http://mocked/ml:nodes', + }, }, ], }, { id: 'data_visualizer', title: 'Data visualizer', - path: ['sharedux:ml', 'data_visualizer'], + path: ['rootNav:ml', 'data_visualizer'], children: [ { - id: 'file', title: 'File', - href: '/app/ml/filedatavisualizer', - path: ['sharedux:ml', 'data_visualizer', 'file'], + id: 'ml:fileUpload', + path: ['rootNav:ml', 'data_visualizer', 'ml:fileUpload'], + deepLink: { + id: 'ml:fileUpload', + title: 'Mocked ml:fileUpload', + href: '/mocked/ml:fileUpload', + baseUrl: '/mocked', + url: 'http://mocked/ml:fileUpload', + }, }, { - id: 'data_view', title: 'Data view', - href: '/app/ml/datavisualizer_index_select', - path: ['sharedux:ml', 'data_visualizer', 'data_view'], + id: 'ml:indexDataVisualizer', + path: ['rootNav:ml', 'data_visualizer', 'ml:indexDataVisualizer'], + deepLink: { + id: 'ml:indexDataVisualizer', + title: 'Mocked ml:indexDataVisualizer', + href: '/mocked/ml:indexDataVisualizer', + baseUrl: '/mocked', + url: 'http://mocked/ml:indexDataVisualizer', + }, }, ], }, { id: 'aiops_labs', title: 'AIOps labs', - path: ['sharedux:ml', 'aiops_labs'], + path: ['rootNav:ml', 'aiops_labs'], children: [ { - id: 'explain_log_rate_spikes', title: 'Explain log rate spikes', - href: '/app/ml/aiops/explain_log_rate_spikes_index_select', - path: ['sharedux:ml', 'aiops_labs', 'explain_log_rate_spikes'], - }, - { - id: 'log_pattern_analysis', - title: 'Log pattern analysis', - href: '/app/ml/aiops/log_categorization_index_select', - path: ['sharedux:ml', 'aiops_labs', 'log_pattern_analysis'], + id: 'ml:explainLogRateSpikes', + path: ['rootNav:ml', 'aiops_labs', 'ml:explainLogRateSpikes'], + deepLink: { + id: 'ml:explainLogRateSpikes', + title: 'Mocked ml:explainLogRateSpikes', + href: '/mocked/ml:explainLogRateSpikes', + baseUrl: '/mocked', + url: 'http://mocked/ml:explainLogRateSpikes', + }, + }, + { + id: 'ml:logPatternAnalysis', + path: ['rootNav:ml', 'aiops_labs', 'ml:logPatternAnalysis'], + title: 'Mocked ml:logPatternAnalysis', + deepLink: { + id: 'ml:logPatternAnalysis', + title: 'Mocked ml:logPatternAnalysis', + href: '/mocked/ml:logPatternAnalysis', + baseUrl: '/mocked', + url: 'http://mocked/ml:logPatternAnalysis', + }, }, ], }, @@ -190,38 +298,62 @@ export const defaultMlNavGroup = { export const defaultDevtoolsNavGroup = { title: 'Developer tools', - id: 'sharedux:devtools', + id: 'rootNav:devtools', icon: 'editorCodeBlock', - path: ['sharedux:devtools'], + path: ['rootNav:devtools'], children: [ { id: 'root', - path: ['sharedux:devtools', 'root'], + path: ['rootNav:devtools', 'root'], title: '', children: [ { - id: 'console', - title: 'Console', - href: '/app/dev_tools#/console', - path: ['sharedux:devtools', 'root', 'console'], - }, - { - id: 'search_profiler', - title: 'Search profiler', - href: '/app/dev_tools#/searchprofiler', - path: ['sharedux:devtools', 'root', 'search_profiler'], - }, - { - id: 'grok_debugger', - title: 'Grok debugger', - href: '/app/dev_tools#/grokdebugger', - path: ['sharedux:devtools', 'root', 'grok_debugger'], - }, - { - id: 'painless_lab', - title: 'Painless lab', - href: '/app/dev_tools#/painless_lab', - path: ['sharedux:devtools', 'root', 'painless_lab'], + id: 'dev_tools:console', + path: ['rootNav:devtools', 'root', 'dev_tools:console'], + title: 'Mocked dev_tools:console', + deepLink: { + id: 'dev_tools:console', + title: 'Mocked dev_tools:console', + href: '/mocked/dev_tools:console', + baseUrl: '/mocked', + url: 'http://mocked/dev_tools:console', + }, + }, + { + id: 'dev_tools:searchprofiler', + path: ['rootNav:devtools', 'root', 'dev_tools:searchprofiler'], + title: 'Mocked dev_tools:searchprofiler', + deepLink: { + id: 'dev_tools:searchprofiler', + title: 'Mocked dev_tools:searchprofiler', + href: '/mocked/dev_tools:searchprofiler', + baseUrl: '/mocked', + url: 'http://mocked/dev_tools:searchprofiler', + }, + }, + { + id: 'dev_tools:grokdebugger', + path: ['rootNav:devtools', 'root', 'dev_tools:grokdebugger'], + title: 'Mocked dev_tools:grokdebugger', + deepLink: { + id: 'dev_tools:grokdebugger', + title: 'Mocked dev_tools:grokdebugger', + href: '/mocked/dev_tools:grokdebugger', + baseUrl: '/mocked', + url: 'http://mocked/dev_tools:grokdebugger', + }, + }, + { + id: 'dev_tools:painless_lab', + path: ['rootNav:devtools', 'root', 'dev_tools:painless_lab'], + title: 'Mocked dev_tools:painless_lab', + deepLink: { + id: 'dev_tools:painless_lab', + title: 'Mocked dev_tools:painless_lab', + href: '/mocked/dev_tools:painless_lab', + baseUrl: '/mocked', + url: 'http://mocked/dev_tools:painless_lab', + }, }, ], }, @@ -229,257 +361,289 @@ export const defaultDevtoolsNavGroup = { }; export const defaultManagementNavGroup = { - id: 'sharedux:management', + id: 'rootNav:management', title: 'Management', icon: 'gear', - path: ['sharedux:management'], + path: ['rootNav:management'], children: [ { id: 'root', title: '', - path: ['sharedux:management', 'root'], + path: ['rootNav:management', 'root'], children: [ { - id: 'stack_monitoring', - title: 'Stack monitoring', - href: '/app/monitoring', - path: ['sharedux:management', 'root', 'stack_monitoring'], + id: 'monitoring', + path: ['rootNav:management', 'root', 'monitoring'], + title: 'Mocked monitoring', + deepLink: { + id: 'monitoring', + title: 'Mocked monitoring', + href: '/mocked/monitoring', + baseUrl: '/mocked', + url: 'http://mocked/monitoring', + }, }, ], }, { id: 'integration_management', title: 'Integration management', - path: ['sharedux:management', 'integration_management'], + path: ['rootNav:management', 'integration_management'], children: [ { id: 'integrations', - title: 'Integrations', - href: '/app/integrations', - path: ['sharedux:management', 'integration_management', 'integrations'], + path: ['rootNav:management', 'integration_management', 'integrations'], + title: 'Mocked integrations', + deepLink: { + id: 'integrations', + title: 'Mocked integrations', + href: '/mocked/integrations', + baseUrl: '/mocked', + url: 'http://mocked/integrations', + }, }, { id: 'fleet', - title: 'Fleet', - href: '/app/fleet', - path: ['sharedux:management', 'integration_management', 'fleet'], + path: ['rootNav:management', 'integration_management', 'fleet'], + title: 'Mocked fleet', + deepLink: { + id: 'fleet', + title: 'Mocked fleet', + href: '/mocked/fleet', + baseUrl: '/mocked', + url: 'http://mocked/fleet', + }, }, { id: 'osquery', - title: 'Osquery', - href: '/app/osquery', - path: ['sharedux:management', 'integration_management', 'osquery'], + path: ['rootNav:management', 'integration_management', 'osquery'], + title: 'Mocked osquery', + deepLink: { + id: 'osquery', + title: 'Mocked osquery', + href: '/mocked/osquery', + baseUrl: '/mocked', + url: 'http://mocked/osquery', + }, }, ], }, { id: 'stack_management', title: 'Stack management', - path: ['sharedux:management', 'stack_management'], + path: ['rootNav:management', 'stack_management'], children: [ - { - id: 'upgrade_assistant', - title: 'Upgrade assistant', - href: '/app/management/stack/upgrade_assistant', - path: ['sharedux:management', 'stack_management', 'upgrade_assistant'], - }, { id: 'ingest', title: 'Ingest', - path: ['sharedux:management', 'stack_management', 'ingest'], + path: ['rootNav:management', 'stack_management', 'ingest'], children: [ { - id: 'ingest_pipelines', - title: 'Ingest pipelines', - href: '/app/management/ingest/ingest_pipelines', - path: ['sharedux:management', 'stack_management', 'ingest', 'ingest_pipelines'], + id: 'management:ingest_pipelines', + path: [ + 'rootNav:management', + 'stack_management', + 'ingest', + 'management:ingest_pipelines', + ], + title: 'Mocked management:ingest_pipelines', + deepLink: { + id: 'management:ingest_pipelines', + title: 'Mocked management:ingest_pipelines', + href: '/mocked/management:ingest_pipelines', + baseUrl: '/mocked', + url: 'http://mocked/management:ingest_pipelines', + }, }, { - id: 'logstash_pipelines', - title: 'Logstash pipelines', - href: '/app/management/ingest/pipelines', - path: ['sharedux:management', 'stack_management', 'ingest', 'logstash_pipelines'], + id: 'management:pipelines', + path: ['rootNav:management', 'stack_management', 'ingest', 'management:pipelines'], + title: 'Mocked management:pipelines', + deepLink: { + id: 'management:pipelines', + title: 'Mocked management:pipelines', + href: '/mocked/management:pipelines', + baseUrl: '/mocked', + url: 'http://mocked/management:pipelines', + }, }, ], }, { id: 'data', title: 'Data', - path: ['sharedux:management', 'stack_management', 'data'], + path: ['rootNav:management', 'stack_management', 'data'], children: [ { - id: 'index_management', - title: 'Index management', - href: '/app/management/data/index_management', - path: ['sharedux:management', 'stack_management', 'data', 'index_management'], - }, - { - id: 'index_lifecycle_policies', - title: 'Index lifecycle policies', - href: '/app/management/data/index_lifecycle_management', - path: ['sharedux:management', 'stack_management', 'data', 'index_lifecycle_policies'], - }, - { - id: 'snapshot_and_restore', - title: 'Snapshot and restore', - href: 'app/management/data/snapshot_restore', - path: ['sharedux:management', 'stack_management', 'data', 'snapshot_and_restore'], - }, - { - id: 'rollup_jobs', - title: 'Rollup jobs', - href: '/app/management/data/rollup_jobs', - path: ['sharedux:management', 'stack_management', 'data', 'rollup_jobs'], - }, - { - id: 'transforms', - title: 'Transforms', - href: '/app/management/data/transform', - path: ['sharedux:management', 'stack_management', 'data', 'transforms'], - }, - { - id: 'cross_cluster_replication', - title: 'Cross-cluster replication', - href: '/app/management/data/cross_cluster_replication', + id: 'management:index_management', path: [ - 'sharedux:management', + 'rootNav:management', 'stack_management', 'data', - 'cross_cluster_replication', + 'management:index_management', ], + title: 'Mocked management:index_management', + deepLink: { + id: 'management:index_management', + title: 'Mocked management:index_management', + href: '/mocked/management:index_management', + baseUrl: '/mocked', + url: 'http://mocked/management:index_management', + }, }, { - id: 'remote_clusters', - title: 'Remote clusters', - href: '/app/management/data/remote_clusters', - path: ['sharedux:management', 'stack_management', 'data', 'remote_clusters'], + id: 'management:transform', + path: ['rootNav:management', 'stack_management', 'data', 'management:transform'], + title: 'Mocked management:transform', + deepLink: { + id: 'management:transform', + title: 'Mocked management:transform', + href: '/mocked/management:transform', + baseUrl: '/mocked', + url: 'http://mocked/management:transform', + }, }, ], }, { id: 'alerts_and_insights', title: 'Alerts and insights', - path: ['sharedux:management', 'stack_management', 'alerts_and_insights'], + path: ['rootNav:management', 'stack_management', 'alerts_and_insights'], children: [ { - id: 'rules', - title: 'Rules', - href: '/app/management/insightsAndAlerting/triggersActions/rules', - path: ['sharedux:management', 'stack_management', 'alerts_and_insights', 'rules'], - }, - { - id: 'cases', - title: 'Cases', - href: '/app/management/insightsAndAlerting/cases', - path: ['sharedux:management', 'stack_management', 'alerts_and_insights', 'cases'], - }, - { - id: 'connectors', - title: 'Connectors', - href: '/app/management/insightsAndAlerting/triggersActionsConnectors/connectors', + id: 'management:triggersActions', path: [ - 'sharedux:management', + 'rootNav:management', 'stack_management', 'alerts_and_insights', - 'connectors', + 'management:triggersActions', ], + title: 'Mocked management:triggersActions', + deepLink: { + id: 'management:triggersActions', + title: 'Mocked management:triggersActions', + href: '/mocked/management:triggersActions', + baseUrl: '/mocked', + url: 'http://mocked/management:triggersActions', + }, }, { - id: 'reporting', - title: 'Reporting', - href: '/app/management/insightsAndAlerting/reporting', - path: ['sharedux:management', 'stack_management', 'alerts_and_insights', 'reporting'], - }, - { - id: 'machine_learning', - title: 'Machine learning', - href: '/app/management/insightsAndAlerting/jobsListLink', + id: 'management:cases', path: [ - 'sharedux:management', + 'rootNav:management', 'stack_management', 'alerts_and_insights', - 'machine_learning', + 'management:cases', ], + title: 'Mocked management:cases', + deepLink: { + id: 'management:cases', + title: 'Mocked management:cases', + href: '/mocked/management:cases', + baseUrl: '/mocked', + url: 'http://mocked/management:cases', + }, }, { - id: 'watcher', - title: 'Watcher', - href: '/app/management/insightsAndAlerting/watcher', - path: ['sharedux:management', 'stack_management', 'alerts_and_insights', 'watcher'], - }, - ], - }, - { - id: 'security', - title: 'Security', - path: ['sharedux:management', 'stack_management', 'security'], - children: [ - { - id: 'users', - title: 'Users', - href: '/app/management/security/users', - path: ['sharedux:management', 'stack_management', 'security', 'users'], - }, - { - id: 'roles', - title: 'Roles', - href: '/app/management/security/roles', - path: ['sharedux:management', 'stack_management', 'security', 'roles'], - }, - { - id: 'role_mappings', - title: 'Role mappings', - href: '/app/management/security/role_mappings', - path: ['sharedux:management', 'stack_management', 'security', 'role_mappings'], + id: 'management:triggersActionsConnectors', + path: [ + 'rootNav:management', + 'stack_management', + 'alerts_and_insights', + 'management:triggersActionsConnectors', + ], + title: 'Mocked management:triggersActionsConnectors', + deepLink: { + id: 'management:triggersActionsConnectors', + title: 'Mocked management:triggersActionsConnectors', + href: '/mocked/management:triggersActionsConnectors', + baseUrl: '/mocked', + url: 'http://mocked/management:triggersActionsConnectors', + }, }, { - id: 'api_keys', - title: 'API keys', - href: '/app/management/security/api_keys', - path: ['sharedux:management', 'stack_management', 'security', 'api_keys'], + id: 'management:jobsListLink', + path: [ + 'rootNav:management', + 'stack_management', + 'alerts_and_insights', + 'management:jobsListLink', + ], + title: 'Mocked management:jobsListLink', + deepLink: { + id: 'management:jobsListLink', + title: 'Mocked management:jobsListLink', + href: '/mocked/management:jobsListLink', + baseUrl: '/mocked', + url: 'http://mocked/management:jobsListLink', + }, }, ], }, { id: 'kibana', title: 'Kibana', - path: ['sharedux:management', 'stack_management', 'kibana'], + path: ['rootNav:management', 'stack_management', 'kibana'], children: [ { - id: 'data_views', - title: 'Data view', - href: '/app/management/kibana/dataViews', - path: ['sharedux:management', 'stack_management', 'kibana', 'data_views'], - }, - { - id: 'saved_objects', - title: 'Saved objects', - href: '/app/management/kibana/objects', - path: ['sharedux:management', 'stack_management', 'kibana', 'saved_objects'], + id: 'management:dataViews', + path: ['rootNav:management', 'stack_management', 'kibana', 'management:dataViews'], + title: 'Mocked management:dataViews', + deepLink: { + id: 'management:dataViews', + title: 'Mocked management:dataViews', + href: '/mocked/management:dataViews', + baseUrl: '/mocked', + url: 'http://mocked/management:dataViews', + }, }, { - id: 'tags', - title: 'Tags', - href: '/app/management/kibana/tags', - path: ['sharedux:management', 'stack_management', 'kibana', 'tags'], + id: 'management:objects', + path: ['rootNav:management', 'stack_management', 'kibana', 'management:objects'], + title: 'Mocked management:objects', + deepLink: { + id: 'management:objects', + title: 'Mocked management:objects', + href: '/mocked/management:objects', + baseUrl: '/mocked', + url: 'http://mocked/management:objects', + }, }, { - id: 'search_sessions', - title: 'Search sessions', - href: '/app/management/kibana/search_sessions', - path: ['sharedux:management', 'stack_management', 'kibana', 'search_sessions'], + id: 'management:tags', + path: ['rootNav:management', 'stack_management', 'kibana', 'management:tags'], + title: 'Mocked management:tags', + deepLink: { + id: 'management:tags', + title: 'Mocked management:tags', + href: '/mocked/management:tags', + baseUrl: '/mocked', + url: 'http://mocked/management:tags', + }, }, { - id: 'spaces', - title: 'Spaces', - href: '/app/management/kibana/spaces', - path: ['sharedux:management', 'stack_management', 'kibana', 'spaces'], + id: 'management:spaces', + path: ['rootNav:management', 'stack_management', 'kibana', 'management:spaces'], + title: 'Mocked management:spaces', + deepLink: { + id: 'management:spaces', + title: 'Mocked management:spaces', + href: '/mocked/management:spaces', + baseUrl: '/mocked', + url: 'http://mocked/management:spaces', + }, }, { - id: 'advanced_settings', - title: 'Advanced settings', - href: '/app/management/kibana/settings', - path: ['sharedux:management', 'stack_management', 'kibana', 'advanced_settings'], + id: 'management:settings', + path: ['rootNav:management', 'stack_management', 'kibana', 'management:settings'], + title: 'Mocked management:settings', + deepLink: { + id: 'management:settings', + title: 'Mocked management:settings', + href: '/mocked/management:settings', + baseUrl: '/mocked', + url: 'http://mocked/management:settings', + }, }, ], }, diff --git a/packages/shared-ux/chrome/navigation/mocks/src/jest.ts b/packages/shared-ux/chrome/navigation/mocks/src/jest.ts index be3e72d0c8b39..afaacdaeda62e 100644 --- a/packages/shared-ux/chrome/navigation/mocks/src/jest.ts +++ b/packages/shared-ux/chrome/navigation/mocks/src/jest.ts @@ -6,15 +6,19 @@ * Side Public License, v 1. */ +import { ChromeNavLink } from '@kbn/core-chrome-browser'; import { BehaviorSubject } from 'rxjs'; import { NavigationServices, ChromeNavigationNodeViewModel } from '../../types'; +import { navLinksMock } from './navlinks'; -export const getServicesMock = (): NavigationServices => { +export const getServicesMock = ({ + navLinks = navLinksMock, +}: { navLinks?: ChromeNavLink[] } = {}): NavigationServices => { const navigateToUrl = jest.fn().mockResolvedValue(undefined); const basePath = { prepend: jest.fn((path: string) => `/base${path}`) }; const loadingCount$ = new BehaviorSubject(0); const recentlyAccessed$ = new BehaviorSubject([]); - const navLinks$ = new BehaviorSubject([]); + const navLinks$ = new BehaviorSubject(navLinks); return { basePath, diff --git a/packages/shared-ux/chrome/navigation/mocks/src/navlinks.ts b/packages/shared-ux/chrome/navigation/mocks/src/navlinks.ts new file mode 100644 index 0000000000000..68bd7825a81f1 --- /dev/null +++ b/packages/shared-ux/chrome/navigation/mocks/src/navlinks.ts @@ -0,0 +1,81 @@ +/* + * 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 { AppDeepLinkId, ChromeNavLink } from '@kbn/core-chrome-browser'; + +const getNavLink = (id: string): ChromeNavLink => { + return { + id, + title: `Mocked ${id}`, + href: `/mocked/${id}`, + baseUrl: `/mocked`, + url: `http://mocked/${id}`, + }; +}; + +const allNavLinks: AppDeepLinkId[] = [ + 'dashboards', + 'dev_tools', + 'dev_tools:console', + 'dev_tools:grokdebugger', + 'dev_tools:painless_lab', + 'dev_tools:searchprofiler', + 'discover', + 'fleet', + 'integrations', + 'management:api_keys', + 'management:cases', + 'management:cross_cluster_replication', + 'management:dataViews', + 'management:index_lifecycle_management', + 'management:index_management', + 'management:ingest_pipelines', + 'management:jobsListLink', + 'management:objects', + 'management:pipelines', + 'management:reporting', + 'management:rollup_jobs', + 'management:settings', + 'management:snapshot_restore', + 'management:spaces', + 'management:tags', + 'management:transform', + 'management:triggersActions', + 'management:triggersActionsConnectors', + 'management:watcher', + 'ml', + 'ml:aiOps', + 'ml:analyticsMap', + 'ml:anomalyDetection', + 'ml:anomalyExplorer', + 'ml:calendarSettings', + 'ml:calendarSettings', + 'ml:changePointDetections', + 'ml:dataFrameAnalytics', + 'ml:dataVisualizer', + 'ml:explainLogRateSpikes', + 'ml:fileUpload', + 'ml:filterListsSettings', + 'ml:indexDataVisualizer', + 'ml:logPatternAnalysis', + 'ml:memoryUsage', + 'ml:modelManagement', + 'ml:nodes', + 'ml:nodesOverview', + 'ml:notifications', + 'ml:overview', + 'ml:resultExplorer', + 'ml:settings', + 'ml:singleMetricViewer', + 'monitoring', + 'osquery', + 'serverlessElasticsearch', + 'visualize', +]; + +export const navLinksMock = allNavLinks.map(getNavLink); diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_group.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_group.tsx index e28c66550034a..457de9a5c4c38 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_group.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_group.tsx @@ -105,8 +105,13 @@ function NavigationGroupComp< ChildrenId extends string = Id >(props: Props & NavigationBucketProps) { if (props.preset) { - const { id, title, link, icon, children, ...rest } = props; - return ; + return ( + + ); } const { preset, nodeDefinition, ...rest } = props; diff --git a/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx b/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx index 274e04171180e..44a02d9975a23 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx @@ -21,6 +21,7 @@ import { defaultManagementNavGroup, defaultMlNavGroup, } from '../../mocks/src/default_navigation.test.helpers'; +import { navLinksMock } from '../../mocks/src/navlinks'; const defaultProps = { homeRef: 'https://elastic.co', @@ -147,6 +148,7 @@ describe('', () => { test('should read the title from deeplink', async () => { const navLinks$: Observable = of([ + ...navLinksMock, { id: 'item1', title: 'Title from deeplink', @@ -321,6 +323,7 @@ describe('', () => { describe('builds the full navigation tree when only custom project is provided', () => { test('reading the title from config or deeplink', async () => { const navLinks$: Observable = of([ + ...navLinksMock, { id: 'item2', title: 'Title from deeplink!', From f658658012923332508d87054408009c9321c1d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Fri, 9 Jun 2023 15:21:55 +0100 Subject: [PATCH 44/60] Fix TS issue --- .../shared-ux/chrome/navigation/src/ui/navigation.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx b/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx index 141d75b52e688..dc3c23c0c4032 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx @@ -252,7 +252,7 @@ const navigationDefinition: ProjectNavigationDefinition = { ...child, children: child.children?.filter((item) => { // Hide discover and dashboard - return item.link !== 'discover' && item.link !== 'dashboard'; + return item.link !== 'discover' && item.link !== 'dashboards'; }), })) as NonEmptyArray, }, From 6e75241a9094e5a654498c190cb93adea72a2684 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Fri, 9 Jun 2023 15:36:13 +0100 Subject: [PATCH 45/60] Update serverless observability nav --- package.json | 1 + .../src/project_navigation.ts | 20 ++++++- packages/deeplinks/observability/README.md | 3 + packages/deeplinks/observability/constants.ts | 17 ++++++ .../deeplinks/observability/deep_links.ts | 58 +++++++++++++++++++ packages/deeplinks/observability/index.ts | 11 ++++ .../deeplinks/observability/jest.config.js | 13 +++++ packages/deeplinks/observability/kibana.jsonc | 5 ++ packages/deeplinks/observability/package.json | 6 ++ .../deeplinks/observability/tsconfig.json | 19 ++++++ tsconfig.base.json | 2 + x-pack/.i18nrc.json | 1 + .../components/side_navigation/index.tsx | 51 ++++++++-------- yarn.lock | 4 ++ 14 files changed, 181 insertions(+), 30 deletions(-) create mode 100644 packages/deeplinks/observability/README.md create mode 100644 packages/deeplinks/observability/constants.ts create mode 100644 packages/deeplinks/observability/deep_links.ts create mode 100644 packages/deeplinks/observability/index.ts create mode 100644 packages/deeplinks/observability/jest.config.js create mode 100644 packages/deeplinks/observability/kibana.jsonc create mode 100644 packages/deeplinks/observability/package.json create mode 100644 packages/deeplinks/observability/tsconfig.json diff --git a/package.json b/package.json index ec5435a5187dd..2cc3b833e6168 100644 --- a/package.json +++ b/package.json @@ -355,6 +355,7 @@ "@kbn/deeplinks-devtools": "link:packages/deeplinks/devtools", "@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/default-nav-analytics": "link:packages/default-nav/analytics", "@kbn/default-nav-devtools": "link:packages/default-nav/devtools", 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 9a13d3ffdbacb..22d40266cddb5 100644 --- a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts +++ b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts @@ -17,15 +17,31 @@ import type { DeepLinkId as ManagementLink, } from '@kbn/deeplinks-management'; import type { AppId as SearchApp, DeepLinkId as SearchLink } from '@kbn/deeplinks-search'; +import type { + AppId as ObservabilityApp, + DeepLinkId as ObservabilityLink, +} from '@kbn/deeplinks-observability'; import type { ChromeBreadcrumb } from './breadcrumb'; import type { ChromeNavLink } from './nav_links'; /** @public */ -export type AppId = DevToolsApp | AnalyticsApp | MlApp | ManagementApp | SearchApp; +export type AppId = + | DevToolsApp + | AnalyticsApp + | MlApp + | ManagementApp + | SearchApp + | ObservabilityApp; /** @public */ -export type AppDeepLinkId = AnalyticsDeepLink | DevToolsLink | MlLink | ManagementLink | SearchLink; +export type AppDeepLinkId = + | AnalyticsDeepLink + | DevToolsLink + | MlLink + | ManagementLink + | SearchLink + | ObservabilityLink; /** @public */ export interface ChromeProjectNavigationNode { diff --git a/packages/deeplinks/observability/README.md b/packages/deeplinks/observability/README.md new file mode 100644 index 0000000000000..106a9564f2c04 --- /dev/null +++ b/packages/deeplinks/observability/README.md @@ -0,0 +1,3 @@ +# @kbn/deeplinks-observability + +Empty package generated by @kbn/generate diff --git a/packages/deeplinks/observability/constants.ts b/packages/deeplinks/observability/constants.ts new file mode 100644 index 0000000000000..addd326de2ce3 --- /dev/null +++ b/packages/deeplinks/observability/constants.ts @@ -0,0 +1,17 @@ +/* + * 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 LOGS_APP_ID = 'logs'; + +export const OBSERVABILITY_OVERVIEW_APP_ID = 'observability-overview'; + +export const METRICS_APP_ID = 'metrics'; + +export const APM_APP_ID = 'apm'; + +export const OBSERVABILITY_ONBOARDING_APP_ID = 'observabilityOnboarding'; diff --git a/packages/deeplinks/observability/deep_links.ts b/packages/deeplinks/observability/deep_links.ts new file mode 100644 index 0000000000000..b9ea14f2f89f4 --- /dev/null +++ b/packages/deeplinks/observability/deep_links.ts @@ -0,0 +1,58 @@ +/* + * 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 { + LOGS_APP_ID, + OBSERVABILITY_OVERVIEW_APP_ID, + METRICS_APP_ID, + APM_APP_ID, + OBSERVABILITY_ONBOARDING_APP_ID, +} from './constants'; + +type LogsApp = typeof LOGS_APP_ID; +type ObservabilityOverviewApp = typeof OBSERVABILITY_OVERVIEW_APP_ID; +type MetricsApp = typeof METRICS_APP_ID; +type ApmApp = typeof APM_APP_ID; +type ObservabilityOnboardingApp = typeof OBSERVABILITY_ONBOARDING_APP_ID; + +export type AppId = + | LogsApp + | ObservabilityOverviewApp + | ObservabilityOnboardingApp + | ApmApp + | MetricsApp; + +export type LogsLinkId = 'log-categories' | 'settings' | 'anomalies' | 'stream'; + +export type ObservabilityOverviewLinkId = + | 'alerts' + | 'cases' + | 'cases_configure' + | 'cases_create' + | 'rules' + | 'slos'; + +export type MetricsLinkId = 'inventory' | 'metrics-explorer' | 'metrics-hosts' | 'settings'; + +export type ApmLinkId = + | 'services' + | 'traces' + | 'service-groups-list' + | 'service-map' + | 'dependencies' + | 'settings' + | 'storage-explorer'; + +export type LinkId = LogsLinkId | ObservabilityOverviewLinkId | MetricsLinkId | ApmLinkId; + +export type DeepLinkId = + | AppId + | `${LogsApp}:${LogsLinkId}` + | `${ObservabilityOverviewApp}:${ObservabilityOverviewLinkId}` + | `${MetricsApp}:${MetricsLinkId}` + | `${ApmApp}:${ApmLinkId}`; diff --git a/packages/deeplinks/observability/index.ts b/packages/deeplinks/observability/index.ts new file mode 100644 index 0000000000000..9292cdf77d70c --- /dev/null +++ b/packages/deeplinks/observability/index.ts @@ -0,0 +1,11 @@ +/* + * 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 { OBSERVABILITY_ONBOARDING_APP_ID } from './constants'; + +export type { AppId, DeepLinkId } from './deep_links'; diff --git a/packages/deeplinks/observability/jest.config.js b/packages/deeplinks/observability/jest.config.js new file mode 100644 index 0000000000000..b3c1ee08b66ea --- /dev/null +++ b/packages/deeplinks/observability/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/observability'], +}; diff --git a/packages/deeplinks/observability/kibana.jsonc b/packages/deeplinks/observability/kibana.jsonc new file mode 100644 index 0000000000000..4a93ff4427da8 --- /dev/null +++ b/packages/deeplinks/observability/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/deeplinks-observability", + "owner": "@elastic/apm-ui" +} diff --git a/packages/deeplinks/observability/package.json b/packages/deeplinks/observability/package.json new file mode 100644 index 0000000000000..388ae1fbea843 --- /dev/null +++ b/packages/deeplinks/observability/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/deeplinks-observability", + "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/observability/tsconfig.json b/packages/deeplinks/observability/tsconfig.json new file mode 100644 index 0000000000000..5b34775c71159 --- /dev/null +++ b/packages/deeplinks/observability/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/tsconfig.base.json b/tsconfig.base.json index c7a810042be0d..d018b1b9a580e 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -614,6 +614,8 @@ "@kbn/deeplinks-management/*": ["packages/deeplinks/management/*"], "@kbn/deeplinks-ml": ["packages/deeplinks/ml"], "@kbn/deeplinks-ml/*": ["packages/deeplinks/ml/*"], + "@kbn/deeplinks-observability": ["packages/deeplinks/observability"], + "@kbn/deeplinks-observability/*": ["packages/deeplinks/observability/*"], "@kbn/deeplinks-search": ["packages/deeplinks/search"], "@kbn/deeplinks-search/*": ["packages/deeplinks/search/*"], "@kbn/default-nav-analytics": ["packages/default-nav/analytics"], diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index 7778d9d3fee1d..ccd704093e292 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -71,6 +71,7 @@ "xpack.server": "legacy/server", "xpack.serverless": "plugins/serverless", "xpack.serverlessSearch": "plugins/serverless_search", + "xpack.serverlessObservability": "plugins/serverless_observability", "xpack.serverlessSecurity": "plugins/serverless_security", "xpack.securitySolution": "plugins/security_solution", "xpack.sessionView": "plugins/session_view", diff --git a/x-pack/plugins/serverless_observability/public/components/side_navigation/index.tsx b/x-pack/plugins/serverless_observability/public/components/side_navigation/index.tsx index 7dadce3cdf1d4..6f577fa904e7a 100644 --- a/x-pack/plugins/serverless_observability/public/components/side_navigation/index.tsx +++ b/x-pack/plugins/serverless_observability/public/components/side_navigation/index.tsx @@ -14,6 +14,7 @@ import { getPresets, } from '@kbn/shared-ux-chrome-navigation'; import React from 'react'; +import { i18n } from '@kbn/i18n'; const navigationTree: NavigationTreeDefinition = { body: [ @@ -29,11 +30,12 @@ const navigationTree: NavigationTreeDefinition = { { id: 'services-infra', children: [ - { id: 'services', title: 'Services', href: '/app/apm/services' }, + { link: 'apm:services' }, { - id: 'infra', - title: 'Infrastructure', - href: '/app/metrics/inventory', + title: i18n.translate('xpack.serverlessObservability.nav.infrastructure', { + defaultMessage: 'Infrastructure', + }), + link: 'metrics:inventory', }, ], }, @@ -41,19 +43,13 @@ const navigationTree: NavigationTreeDefinition = { id: 'alerts-cases-slos', children: [ { - id: 'alerts', - title: 'Alerts', - href: '/app/observability/alerts', + link: 'observability-overview:alerts', }, { - id: 'Cases', - title: 'Cases', - href: '/app/observability/cases', + link: 'observability-overview:cases', }, { - id: 'slos', - title: 'SLOs', - href: '/app/observability/slos', + link: 'observability-overview:slos', }, ], }, @@ -62,14 +58,13 @@ const navigationTree: NavigationTreeDefinition = { title: 'Signals', children: [ { - id: 'traces', - title: 'Traces', - href: '/app/apm/traces', + link: 'apm:traces', }, { - id: 'logs', - title: 'Logs', - href: '/app/logs/stream', + title: i18n.translate('xpack.serverlessObservability.nav.signalsLogs', { + defaultMessage: 'Logs', + }), + link: 'logs:stream', }, ], }, @@ -78,14 +73,13 @@ const navigationTree: NavigationTreeDefinition = { title: 'Toolbox', children: [ { - id: 'visualization', - title: 'Visualization', - href: '/app/visualize', + title: i18n.translate('xpack.serverlessObservability.nav.toolBoxVisualization', { + defaultMessage: 'Visualization', + }), + link: 'visualize', }, { - id: 'dashboards', - title: 'Dashboards', - href: '/app/dashboards', + link: 'dashboards', }, ], }, @@ -93,10 +87,11 @@ const navigationTree: NavigationTreeDefinition = { id: 'on-boarding', children: [ { - id: 'get-started', - title: 'Get started', + title: i18n.translate('xpack.serverlessObservability.nav.getStarted', { + defaultMessage: 'Get started', + }), icon: 'launch', - href: '/app/observabilityOnboarding', + link: 'observabilityOnboarding', }, ], }, diff --git a/yarn.lock b/yarn.lock index 2022514028eb5..8ce5e6d6a4890 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4063,6 +4063,10 @@ version "0.0.0" uid "" +"@kbn/deeplinks-observability@link:packages/deeplinks/observability": + version "0.0.0" + uid "" + "@kbn/deeplinks-search@link:packages/deeplinks/search": version "0.0.0" uid "" From 07334e8396ddeb25dfb591b0b2f4f942217d5087 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 9 Jun 2023 12:45:24 +0000 Subject: [PATCH 46/60] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- packages/core/chrome/core-chrome-browser/tsconfig.json | 3 ++- packages/deeplinks/search/tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/core/chrome/core-chrome-browser/tsconfig.json b/packages/core/chrome/core-chrome-browser/tsconfig.json index 70288b7a53a83..076e53b839e73 100644 --- a/packages/core/chrome/core-chrome-browser/tsconfig.json +++ b/packages/core/chrome/core-chrome-browser/tsconfig.json @@ -17,7 +17,8 @@ "@kbn/deeplinks-devtools", "@kbn/deeplinks-analytics", "@kbn/deeplinks-ml", - "@kbn/deeplinks-management" + "@kbn/deeplinks-management", + "@kbn/deeplinks-search" ], "exclude": [ "target/**/*", diff --git a/packages/deeplinks/search/tsconfig.json b/packages/deeplinks/search/tsconfig.json index 5b34775c71159..d1414086f2187 100644 --- a/packages/deeplinks/search/tsconfig.json +++ b/packages/deeplinks/search/tsconfig.json @@ -10,7 +10,7 @@ }, "include": [ "**/*.ts", - "**/*.tsx", + "**/*.tsx", ], "exclude": [ "target/**/*" From d2417384045621a62624b450650a1b7c14578042 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 9 Jun 2023 12:52:57 +0000 Subject: [PATCH 47/60] [CI] Auto-commit changed files from 'node scripts/generate codeowners' --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b6fa04d4830ca..70a951a95f4dc 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -310,6 +310,7 @@ packages/deeplinks/analytics @elastic/kibana-data-discovery packages/deeplinks/devtools @elastic/platform-deployment-management packages/deeplinks/management @elastic/platform-deployment-management @elastic/kibana-data-discovery packages/deeplinks/ml @elastic/ml-ui +packages/deeplinks/search @elastic/enterprise-search-frontend packages/default-nav/analytics @elastic/kibana-data-discovery packages/default-nav/devtools @elastic/platform-deployment-management packages/default-nav/management @elastic/platform-deployment-management @elastic/kibana-data-discovery From e1b3a1bf666c2f60c8f6fd6215316d6bd7f48258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Mon, 12 Jun 2023 09:34:22 +0100 Subject: [PATCH 48/60] Move nav_tree_presets out of folder --- .../core/chrome/core-chrome-browser/src/project_navigation.ts | 4 +--- .../src/ui/{nav_tree_presets/index.ts => nav_tree_presets.ts} | 0 2 files changed, 1 insertion(+), 3 deletions(-) rename packages/shared-ux/chrome/navigation/src/ui/{nav_tree_presets/index.ts => nav_tree_presets.ts} (100%) 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 22d40266cddb5..64a95f565431c 100644 --- a/packages/core/chrome/core-chrome-browser/src/project_navigation.ts +++ b/packages/core/chrome/core-chrome-browser/src/project_navigation.ts @@ -121,9 +121,7 @@ export interface NodeDefinition< /** Optional children of the navigation node */ children?: NonEmptyArray>; /** - * Temporarilly we allow href to be passed. - * Once all the deeplinks will be exposed in packages we will not allow href anymore - * and force deeplink id to be passed + * Use href for absolute links only. Internal links should use "link". */ href?: string; } diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets.ts similarity index 100% rename from packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets/index.ts rename to packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets.ts From 0348ec2adce774c61c893d541fc6a31901782f0e Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 9 Jun 2023 15:18:24 +0000 Subject: [PATCH 49/60] [CI] Auto-commit changed files from 'node scripts/lint_ts_projects --fix' --- packages/core/chrome/core-chrome-browser/tsconfig.json | 3 ++- packages/deeplinks/observability/tsconfig.json | 2 +- x-pack/plugins/serverless_observability/tsconfig.json | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/core/chrome/core-chrome-browser/tsconfig.json b/packages/core/chrome/core-chrome-browser/tsconfig.json index 076e53b839e73..ef655cc44a14d 100644 --- a/packages/core/chrome/core-chrome-browser/tsconfig.json +++ b/packages/core/chrome/core-chrome-browser/tsconfig.json @@ -18,7 +18,8 @@ "@kbn/deeplinks-analytics", "@kbn/deeplinks-ml", "@kbn/deeplinks-management", - "@kbn/deeplinks-search" + "@kbn/deeplinks-search", + "@kbn/deeplinks-observability" ], "exclude": [ "target/**/*", diff --git a/packages/deeplinks/observability/tsconfig.json b/packages/deeplinks/observability/tsconfig.json index 5b34775c71159..d1414086f2187 100644 --- a/packages/deeplinks/observability/tsconfig.json +++ b/packages/deeplinks/observability/tsconfig.json @@ -10,7 +10,7 @@ }, "include": [ "**/*.ts", - "**/*.tsx", + "**/*.tsx", ], "exclude": [ "target/**/*" diff --git a/x-pack/plugins/serverless_observability/tsconfig.json b/x-pack/plugins/serverless_observability/tsconfig.json index 7972b5ccced81..9076632868119 100644 --- a/x-pack/plugins/serverless_observability/tsconfig.json +++ b/x-pack/plugins/serverless_observability/tsconfig.json @@ -21,5 +21,6 @@ "@kbn/observability-shared-plugin", "@kbn/kibana-react-plugin", "@kbn/shared-ux-chrome-navigation", + "@kbn/i18n", ] } From 84a6997cccb5809b689baf1f0ca5db53f8c1b2e1 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 9 Jun 2023 15:24:50 +0000 Subject: [PATCH 50/60] [CI] Auto-commit changed files from 'node scripts/generate codeowners' --- .github/CODEOWNERS | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 70a951a95f4dc..1e7bbddc11323 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -310,6 +310,7 @@ packages/deeplinks/analytics @elastic/kibana-data-discovery packages/deeplinks/devtools @elastic/platform-deployment-management packages/deeplinks/management @elastic/platform-deployment-management @elastic/kibana-data-discovery packages/deeplinks/ml @elastic/ml-ui +packages/deeplinks/observability @elastic/apm-ui packages/deeplinks/search @elastic/enterprise-search-frontend packages/default-nav/analytics @elastic/kibana-data-discovery packages/default-nav/devtools @elastic/platform-deployment-management From 29a4b0afe555d5dad49c61716995b0137400a5b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Mon, 12 Jun 2023 09:51:07 +0100 Subject: [PATCH 51/60] Fix import path --- packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets.ts b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets.ts index 3626f19355f35..8c4637781dbfd 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/nav_tree_presets.ts @@ -22,7 +22,7 @@ import { type ManagementNodeDefinition, } from '@kbn/default-nav-management'; -import type { NavigationGroupPreset } from '../types'; +import type { NavigationGroupPreset } from './types'; export function getPresets(preset: 'devtools'): DevToolsNodeDefinition; export function getPresets(preset: 'management'): ManagementNodeDefinition; From 0f142312284a892d8fe46fbaaed1b9f8c5529d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Mon, 12 Jun 2023 13:16:08 +0100 Subject: [PATCH 52/60] Allow href for absolute links only --- .../src/ui/components/navigation.test.tsx | 66 ++++++++++ .../ui/components/navigation_section_ui.tsx | 23 +++- .../src/ui/default_navigation.test.tsx | 113 ++++++++++++++++++ .../src/ui/hooks/use_init_navnode.ts | 8 +- .../navigation/src/ui/navigation.stories.tsx | 18 ++- .../shared-ux/chrome/navigation/src/utils.ts | 11 ++ 6 files changed, 234 insertions(+), 5 deletions(-) create mode 100644 packages/shared-ux/chrome/navigation/src/utils.ts diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/navigation.test.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/navigation.test.tsx index 5d2efd0e48464..a41c5ed767a28 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/navigation.test.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/navigation.test.tsx @@ -445,5 +445,71 @@ describe('', () => { 'RecentThis is an exampleAnother example' ); }); + + test('should allow href for absolute links', async () => { + const onProjectNavigationChange = jest.fn(); + + render( + + + + + + + + ); + + expect(onProjectNavigationChange).toHaveBeenCalled(); + const lastCall = + onProjectNavigationChange.mock.calls[onProjectNavigationChange.mock.calls.length - 1]; + const [navTreeGenerated] = lastCall; + + expect(navTreeGenerated).toEqual({ + homeRef: 'https://elastic.co', + navigationTree: [ + { + id: 'group1', + path: ['group1'], + title: '', + children: [ + { + id: 'item1', + title: 'Item 1', + href: 'https://example.com', + path: ['group1', 'item1'], + }, + ], + }, + ], + }); + }); + + test('should throw if href is not an absolute links', async () => { + // We'll mock the console.error to avoid dumping the (expected) error in the console + // source: https://github.com/jestjs/jest/pull/5267#issuecomment-356605468 + jest.spyOn(console, 'error'); + // @ts-expect-error we're mocking the console so "mockImplementation" exists + // eslint-disable-next-line no-console + console.error.mockImplementation(() => {}); + + const onProjectNavigationChange = jest.fn(); + + const expectToThrow = () => { + render( + + + + + + + + ); + }; + + expect(expectToThrow).toThrowError('href must be an absolute URL. Node id [item1].'); + // @ts-expect-error we're mocking the console so "mockImplementation" exists + // eslint-disable-next-line no-console + console.error.mockRestore(); + }); }); }); diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx index a592e6cc539b2..c0c9d44384990 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx @@ -8,8 +8,11 @@ import React, { FC } from 'react'; import { + EuiButtonEmpty, + EuiButtonIcon, EuiCollapsibleNavGroup, EuiIcon, + EuiLink, EuiSideNav, EuiSideNavItemType, EuiText, @@ -18,6 +21,9 @@ import type { BasePathService, NavigateToUrlFn } from '../../../types/internal'; import { navigationStyles as styles } from '../../styles'; import { useNavigation as useServices } from '../../services'; import { ChromeProjectNavigationNodeEnhanced } from '../types'; +import { isAbsoluteLink } from '../../utils'; + +type RenderItem = EuiSideNavItemType['renderItem']; const navigationNodeToEuiItem = ( item: ChromeProjectNavigationNodeEnhanced, @@ -25,6 +31,21 @@ const navigationNodeToEuiItem = ( ): EuiSideNavItemType => { const href = item.deepLink?.href ?? item.href; const id = item.path ? item.path.join('.') : item.id; + const isExternal = Boolean(href) && isAbsoluteLink(href!); + + const getRenderItem = (): RenderItem | undefined => { + if (!isExternal || item.renderItem) { + return item.renderItem; + } + + return () => ( +
+ + {item.title} + +
+ ); + }; return { id, @@ -37,7 +58,7 @@ const navigationNodeToEuiItem = ( } : undefined, href, - renderItem: item.renderItem, + renderItem: getRenderItem(), items: item.children?.map((_item) => navigationNodeToEuiItem(_item, { navigateToUrl, basePath }) ), diff --git a/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx b/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx index 44a02d9975a23..aa4f12f8b2772 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx @@ -253,6 +253,119 @@ describe('', () => { }); }); + test('should allow href for absolute links', async () => { + const onProjectNavigationChange = jest.fn(); + + const navigationBody: Array> = [ + { + type: 'navGroup', + id: 'root', + children: [ + { + id: 'group1', + children: [ + { + id: 'item1', + title: 'Absolute link', + href: 'https://example.com', + }, + ], + }, + ], + }, + ]; + + render( + + + + ); + + expect(onProjectNavigationChange).toHaveBeenCalled(); + const lastCall = + onProjectNavigationChange.mock.calls[onProjectNavigationChange.mock.calls.length - 1]; + const [navTreeGenerated] = lastCall; + + expect(navTreeGenerated).toEqual({ + homeRef: 'https://elastic.co', + navigationTree: [ + { + id: 'root', + path: ['root'], + title: '', + children: [ + { + id: 'group1', + path: ['root', 'group1'], + title: '', + children: [ + { + id: 'item1', + path: ['root', 'group1', 'item1'], + title: 'Absolute link', + href: 'https://example.com', + }, + ], + }, + ], + }, + ], + }); + }); + + test('should throw if href is not an absolute links', async () => { + // We'll mock the console.error to avoid dumping the (expected) error in the console + // source: https://github.com/jestjs/jest/pull/5267#issuecomment-356605468 + jest.spyOn(console, 'error'); + // @ts-expect-error we're mocking the console so "mockImplementation" exists + // eslint-disable-next-line no-console + console.error.mockImplementation(() => {}); + + const onProjectNavigationChange = jest.fn(); + + const navigationBody: Array> = [ + { + type: 'navGroup', + id: 'root', + children: [ + { + id: 'group1', + children: [ + { + id: 'item1', + title: 'Absolute link', + href: '../dashboards', + }, + ], + }, + ], + }, + ]; + + const expectToThrow = () => { + render( + + + + ); + }; + + expect(expectToThrow).toThrowError('href must be an absolute URL. Node id [item1].'); + // @ts-expect-error we're mocking the console so "mockImplementation" exists + // eslint-disable-next-line no-console + console.error.mockRestore(); + }); + test('should render cloud link', async () => { const navigationBody: RootNavigationItemDefinition[] = [ { diff --git a/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts b/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts index bac37a5e05a88..71a9195abf97d 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts @@ -15,6 +15,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import useObservable from 'react-use/lib/useObservable'; import { useNavigation as useNavigationServices } from '../../services'; +import { isAbsoluteLink } from '../../utils'; import { ChromeProjectNavigationNodeEnhanced, NodeProps, @@ -56,13 +57,17 @@ function createInternalNavNode< deepLinks: Readonly, path: string[] | null ): ChromeProjectNavigationNodeEnhanced | null { - const { children, link, ...navNode } = _navNode; + const { children, link, href, ...navNode } = _navNode; const deepLink = deepLinks.find((dl) => dl.id === link); const isVisible = isNodeVisible({ link, deepLink }); const titleFromDeepLinkOrChildren = typeof children === 'string' ? children : deepLink?.title; const title = navNode.title ?? titleFromDeepLinkOrChildren; + if (href && !isAbsoluteLink(href)) { + throw new Error(`href must be an absolute URL. Node id [${id}].`); + } + if (!isVisible) { return null; } @@ -73,6 +78,7 @@ function createInternalNavNode< path: path ?? [id], title: title ?? '', deepLink, + href, }; } diff --git a/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx b/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx index dc3c23c0c4032..dbca88ad8e8c0 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx @@ -138,6 +138,15 @@ const simpleNavigationDefinition: ProjectNavigationDefinition = { id: 'item3', title: 'Dashboards', }, + { + id: 'item4', + title: 'External link', + href: 'https://elastic.co', + }, + { + id: 'item5', + title: 'Another link', + }, ], }, { @@ -337,15 +346,18 @@ export const WithUIComponents = (args: ChromeNavigationViewModel & NavigationSer {(navNode) => { return ( - {`Render prop: ${navNode.id} - ${navNode.title}`} +
+ {`Render prop: ${navNode.id} - ${navNode.title}`} +
); }}
- +
Title in ReactNode - +
+
diff --git a/packages/shared-ux/chrome/navigation/src/utils.ts b/packages/shared-ux/chrome/navigation/src/utils.ts new file mode 100644 index 0000000000000..9458d2b6fc283 --- /dev/null +++ b/packages/shared-ux/chrome/navigation/src/utils.ts @@ -0,0 +1,11 @@ +/* + * 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 function isAbsoluteLink(link: string) { + return link.startsWith('http://') || link.startsWith('https://'); +} From 9f1abfbc2859aad6d1c3b1b5baac805475906f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Mon, 12 Jun 2023 13:17:04 +0100 Subject: [PATCH 53/60] Remove unused model folder --- .../navigation/src/model/create_side_nav.ts | 47 ---- .../chrome/navigation/src/model/index.ts | 40 ---- .../chrome/navigation/src/model/model.ts | 80 ------- .../src/model/platform_nav/analytics.ts | 37 --- .../src/model/platform_nav/devtools.ts | 42 ---- .../model/platform_nav/machine_learning.ts | 127 ----------- .../src/model/platform_nav/management.ts | 214 ------------------ .../ui/components/navigation_section_ui.tsx | 2 - 8 files changed, 589 deletions(-) delete mode 100644 packages/shared-ux/chrome/navigation/src/model/create_side_nav.ts delete mode 100644 packages/shared-ux/chrome/navigation/src/model/index.ts delete mode 100644 packages/shared-ux/chrome/navigation/src/model/model.ts delete mode 100644 packages/shared-ux/chrome/navigation/src/model/platform_nav/analytics.ts delete mode 100644 packages/shared-ux/chrome/navigation/src/model/platform_nav/devtools.ts delete mode 100644 packages/shared-ux/chrome/navigation/src/model/platform_nav/machine_learning.ts delete mode 100644 packages/shared-ux/chrome/navigation/src/model/platform_nav/management.ts diff --git a/packages/shared-ux/chrome/navigation/src/model/create_side_nav.ts b/packages/shared-ux/chrome/navigation/src/model/create_side_nav.ts deleted file mode 100644 index a4c26a675989f..0000000000000 --- a/packages/shared-ux/chrome/navigation/src/model/create_side_nav.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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 { ChromeNavigationNodeViewModel, PlatformSectionConfig } from '../../types'; - -/** - * Navigation node parser. It filers out the nodes disabled through config and - * sets the `path` of each of the nodes. - * - * @param navItems Navigation nodes - * @param platformSectionConfig Configuration with flags to disable nodes in the navigation tree - * - * @returns The navigation tree filtered - */ -export const parseNavItems = ( - parentIds: string[] = [], - navItems?: ChromeNavigationNodeViewModel[], - platformSectionConfig?: PlatformSectionConfig -): ChromeNavigationNodeViewModel[] | undefined => { - if (!navItems) { - return undefined; - } - - return navItems.reduce((accum, item) => { - const config = platformSectionConfig?.properties?.[item.id]; - if (config?.enabled === false) { - // return accumulated set without the item that is not enabled - return accum; - } - - const path = [...parentIds, item.id].filter(Boolean).join('.'); - - let filteredItems: ChromeNavigationNodeViewModel[] | undefined; - if (item.items) { - // recursion - const nextPlatformSectionConfig = platformSectionConfig?.properties?.[item.id]; - filteredItems = parseNavItems([...parentIds, item.id], item.items, nextPlatformSectionConfig); - } - - return [...accum, { ...item, path, items: filteredItems }]; - }, []); -}; diff --git a/packages/shared-ux/chrome/navigation/src/model/index.ts b/packages/shared-ux/chrome/navigation/src/model/index.ts deleted file mode 100644 index db3e5a29951ac..0000000000000 --- a/packages/shared-ux/chrome/navigation/src/model/index.ts +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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 { BasePathService, NavigateToUrlFn } from '../../types/internal'; -import { analyticsItemSet } from './platform_nav/analytics'; -import { devtoolsItemSet } from './platform_nav/devtools'; -import { mlItemSet } from './platform_nav/machine_learning'; -import { managementItemSet } from './platform_nav/management'; - -export interface NavigationModelDeps { - basePath: BasePathService; - navigateToUrl: NavigateToUrlFn; -} - -/** - * @public - */ -export enum Platform { - Analytics = 'analytics', - MachineLearning = 'ml', - DevTools = 'devTools', - Management = 'management', -} - -/** - * @public - */ -export const navItemSet = { - [Platform.Analytics]: analyticsItemSet, - [Platform.MachineLearning]: mlItemSet, - [Platform.DevTools]: devtoolsItemSet, - [Platform.Management]: managementItemSet, -}; - -export { NavigationModel } from './model'; diff --git a/packages/shared-ux/chrome/navigation/src/model/model.ts b/packages/shared-ux/chrome/navigation/src/model/model.ts deleted file mode 100644 index 6ed5f2dc795e7..0000000000000 --- a/packages/shared-ux/chrome/navigation/src/model/model.ts +++ /dev/null @@ -1,80 +0,0 @@ -/* - * 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 { navItemSet, Platform } from '.'; -import type { ChromeNavigationNodeViewModel, PlatformId, PlatformConfigSet } from '../../types'; -import { parseNavItems } from './create_side_nav'; - -/** - * @internal - */ -export class NavigationModel { - constructor( - private platformConfig: Partial | undefined, - private solutions: ChromeNavigationNodeViewModel[] - ) {} - - public getPlatform(): Record { - return { - [Platform.Analytics]: { - id: Platform.Analytics, - icon: 'stats', - title: 'Data exploration', - items: parseNavItems( - [Platform.Analytics], - navItemSet[Platform.Analytics], - this.platformConfig?.[Platform.Analytics] - ), - }, - [Platform.MachineLearning]: { - id: Platform.MachineLearning, - icon: 'indexMapping', - title: 'Machine learning', - items: parseNavItems( - [Platform.MachineLearning], - navItemSet[Platform.MachineLearning], - this.platformConfig?.[Platform.MachineLearning] - ), - }, - [Platform.DevTools]: { - id: Platform.DevTools, - icon: 'editorCodeBlock', - title: 'Developer tools', - items: parseNavItems( - [Platform.DevTools], - navItemSet[Platform.DevTools], - this.platformConfig?.[Platform.DevTools] - ), - }, - [Platform.Management]: { - id: Platform.Management, - icon: 'gear', - title: 'Management', - items: parseNavItems( - [Platform.Management], - navItemSet[Platform.Management], - this.platformConfig?.[Platform.Management] - ), - }, - }; - } - - public getSolutions(): ChromeNavigationNodeViewModel[] { - // Allow multiple solutions' collapsible nav buckets side-by-side - return this.solutions.map((s) => ({ - id: s.id, - title: s.title, - icon: s.icon, - items: parseNavItems([s.id], s.items), - })); - } - - public isEnabled(sectionId: PlatformId) { - return this.platformConfig?.[sectionId]?.enabled !== false; - } -} diff --git a/packages/shared-ux/chrome/navigation/src/model/platform_nav/analytics.ts b/packages/shared-ux/chrome/navigation/src/model/platform_nav/analytics.ts deleted file mode 100644 index 7722a5981ba3b..0000000000000 --- a/packages/shared-ux/chrome/navigation/src/model/platform_nav/analytics.ts +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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 { ChromeNavigationNodeViewModel } from '../../../types'; - -// TODO: Declare ChromeNavigationNode[] (with "link" to app id or deeplink id) -// and then call an api on the Chrome service to convert to ChromeNavigationNodeViewModel -// with its "href", "isActive"... metadata - -export const analyticsItemSet: ChromeNavigationNodeViewModel[] = [ - { - title: '', - id: 'root', - items: [ - { - title: 'Discover', - id: 'discover', - href: '/app/discover', - }, - { - title: 'Dashboard', - id: 'dashboard', - href: '/app/dashboards', - }, - { - title: 'Visualize Library', - id: 'visualize_library', - href: '/app/visualize', - }, - ], - }, -]; diff --git a/packages/shared-ux/chrome/navigation/src/model/platform_nav/devtools.ts b/packages/shared-ux/chrome/navigation/src/model/platform_nav/devtools.ts deleted file mode 100644 index 64ef0aa26571e..0000000000000 --- a/packages/shared-ux/chrome/navigation/src/model/platform_nav/devtools.ts +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 { ChromeNavigationNodeViewModel } from '../../../types'; - -// TODO: Declare ChromeNavigationNode[] (with "link" to app id or deeplink id) -// and then call an api on the Chrome service to convert to ChromeNavigationNodeViewModel -// with its "href", "isActive"... metadata - -export const devtoolsItemSet: ChromeNavigationNodeViewModel[] = [ - { - title: '', - id: 'root', - items: [ - { - title: 'Console', - id: 'console', - href: '/app/dev_tools#/console', - }, - { - title: 'Search profiler', - id: 'search_profiler', - href: '/app/dev_tools#/searchprofiler', - }, - { - title: 'Grok debugger', - id: 'grok_debugger', - href: '/app/dev_tools#/grokdebugger', - }, - { - title: 'Painless lab', - id: 'painless_lab', - href: '/app/dev_tools#/painless_lab', - }, - ], - }, -]; diff --git a/packages/shared-ux/chrome/navigation/src/model/platform_nav/machine_learning.ts b/packages/shared-ux/chrome/navigation/src/model/platform_nav/machine_learning.ts deleted file mode 100644 index 2c205c5784632..0000000000000 --- a/packages/shared-ux/chrome/navigation/src/model/platform_nav/machine_learning.ts +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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 { ChromeNavigationNodeViewModel } from '../../../types'; - -// TODO: Declare ChromeNavigationNode[] (with "link" to app id or deeplink id) -// and then call an api on the Chrome service to convert to ChromeNavigationNodeViewModel -// with its "href", "isActive"... metadata - -export const mlItemSet: ChromeNavigationNodeViewModel[] = [ - { - title: '', - id: 'root', - items: [ - { - title: 'Overview', - id: 'overview', - href: '/app/ml/overview', - }, - { - title: 'Notifications', - id: 'notifications', - href: '/app/ml/notifications', - }, - ], - }, - { - title: 'Anomaly detection', - id: 'anomaly_detection', - items: [ - { - title: 'Jobs', - id: 'jobs', - href: '/app/ml/jobs', - }, - { - title: 'Anomaly explorer', - id: 'explorer', - href: '/app/ml/explorer', - }, - { - title: 'Single metric viewer', - id: 'single_metric_viewer', - href: '/app/ml/timeseriesexplorer', - }, - { - title: 'Settings', - id: 'settings', - href: '/app/ml/settings', - }, - ], - }, - { - title: 'Data frame analytics', - id: 'data_frame_analytics', - items: [ - { - title: 'Jobs', - id: 'jobs', - href: '/app/ml/data_frame_analytics', - }, - { - title: 'Results explorer', - id: 'results_explorer', - href: '/app/ml/data_frame_analytics/exploration', - }, - { - title: 'Analytics map', - id: 'analytics_map', - href: '/app/ml/data_frame_analytics/map', - }, - ], - }, - { - title: 'Model management', - id: 'model_management', - items: [ - { - title: 'Trained models', - id: 'trained_models', - href: '/app/ml/trained_models', - }, - { - title: 'Nodes', - id: 'nodes', - href: '/app/ml/nodes', - }, - ], - }, - { - title: 'Data visualizer', - id: 'data_visualizer', - items: [ - { - title: 'File', - id: 'file', - href: '/app/ml/filedatavisualizer', - }, - { - title: 'Data view', - id: 'data_view', - href: '/app/ml/datavisualizer_index_select', - }, - ], - }, - { - title: 'AIOps labs', - id: 'aiops_labs', - items: [ - { - title: 'Explain log rate spikes', - id: 'explain_log_rate_spikes', - href: '/app/ml/aiops/explain_log_rate_spikes_index_select', - }, - { - title: 'Log pattern analysis', - id: 'log_pattern_analysis', - href: '/app/ml/aiops/log_categorization_index_select', - }, - ], - }, -]; diff --git a/packages/shared-ux/chrome/navigation/src/model/platform_nav/management.ts b/packages/shared-ux/chrome/navigation/src/model/platform_nav/management.ts deleted file mode 100644 index a481c5458c693..0000000000000 --- a/packages/shared-ux/chrome/navigation/src/model/platform_nav/management.ts +++ /dev/null @@ -1,214 +0,0 @@ -/* - * 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 { ChromeNavigationNodeViewModel } from '../../../types'; - -// TODO: Declare ChromeNavigationNode[] (with "link" to app id or deeplink id) -// and then call an api on the Chrome service to convert to ChromeNavigationNodeViewModel -// with its "href", "isActive"... metadata - -export const managementItemSet: ChromeNavigationNodeViewModel[] = [ - { - title: '', - id: 'root', - items: [ - { - title: 'Stack monitoring', - id: 'stack_monitoring', - href: '/app/monitoring', - }, - ], - }, - { - title: 'Integration management', - id: 'integration_management', - items: [ - { - title: 'Integrations', - id: 'integrations', - href: '/app/integrations', - }, - { - title: 'Fleet', - id: 'fleet', - href: '/app/fleet', - }, - { - title: 'Osquery', - id: 'osquery', - href: '/app/osquery', - }, - ], - }, - { - title: 'Stack management', - id: 'stack_management', - items: [ - { - title: 'Ingest', - id: 'ingest', - items: [ - { - title: 'Ingest pipelines', - id: 'ingest_pipelines', - href: '/app/management/ingest/ingest_pipelines', - }, - { - title: 'Logstash pipelines', - id: 'logstash_pipelines', - href: '/app/management/ingest/pipelines', - }, - ], - }, - { - title: 'Data', - id: 'data', - items: [ - { - title: 'Index management', - id: 'index_management', - href: '/app/management/data/index_management', - }, - { - title: 'Index lifecycle policies', - id: 'index_lifecycle_policies', - href: '/app/management/data/index_lifecycle_management', - }, - { - title: 'Snapshot and restore', - id: 'snapshot_and_restore', - href: 'app/management/data/snapshot_restore', - }, - { - title: 'Rollup jobs', - id: 'rollup_jobs', - href: '/app/management/data/rollup_jobs', - }, - { - title: 'Transforms', - id: 'transforms', - href: '/app/management/data/transform', - }, - { - title: 'Cross-cluster replication', - id: 'cross_cluster_replication', - href: '/app/management/data/cross_cluster_replication', - }, - { - title: 'Remote clusters', - id: 'remote_clusters', - href: '/app/management/data/remote_clusters', - }, - ], - }, - { - title: 'Alerts and insights', - id: 'alerts_and_insights', - items: [ - { - title: 'Rules', - id: 'rules', - href: '/app/management/insightsAndAlerting/triggersActions/rules', - }, - { - title: 'Cases', - id: 'cases', - href: '/app/management/insightsAndAlerting/cases', - }, - { - title: 'Connectors', - id: 'connectors', - href: '/app/management/insightsAndAlerting/triggersActionsConnectors/connectors', - }, - { - title: 'Reporting', - id: 'reporting', - href: '/app/management/insightsAndAlerting/reporting', - }, - { - title: 'Machine learning', - id: 'machine_learning', - href: '/app/management/insightsAndAlerting/jobsListLink', - }, - { - title: 'Watcher', - id: 'watcher', - href: '/app/management/insightsAndAlerting/watcher', - }, - ], - }, - { - title: 'Security', - id: 'security', - items: [ - { - title: 'Users', - id: 'users', - href: '/app/management/security/users', - }, - { - title: 'Roles', - id: 'roles', - href: '/app/management/security/roles', - }, - { - title: 'Role mappings', - id: 'role_mappings', - href: '/app/management/security/role_mappings', - }, - { - title: 'API keys', - id: 'api_keys', - href: '/app/management/security/api_keys', - }, - ], - }, - { - title: 'Kibana', - id: 'kibana', - items: [ - { - title: 'Data view', - id: 'data_views', - href: '/app/management/kibana/dataViews', - }, - { - title: 'Saved objects', - id: 'saved_objects', - href: '/app/management/kibana/objects', - }, - { - title: 'Tags', - id: 'tags', - href: '/app/management/kibana/tags', - }, - { - title: 'Search sessions', - id: 'search_sessions', - href: '/app/management/kibana/search_sessions', - }, - { - title: 'Spaces', - id: 'spaces', - href: '/app/management/kibana/spaces', - }, - { - title: 'Advanced settings', - id: 'advanced_settings', - href: '/app/management/kibana/settings', - }, - ], - }, - { - title: 'Upgrade assistant', - id: 'upgrade_assistant', - href: '/app/management/stack/upgrade_assistant', - }, - ], - }, -]; diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx index c0c9d44384990..7289ba4af4fc2 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx @@ -8,8 +8,6 @@ import React, { FC } from 'react'; import { - EuiButtonEmpty, - EuiButtonIcon, EuiCollapsibleNavGroup, EuiIcon, EuiLink, From df15ed9be8c87187e26d0a691c5ec7696a9514c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Mon, 12 Jun 2023 13:34:35 +0100 Subject: [PATCH 54/60] Use deeplink url instead of href --- .../navigation/src/ui/components/navigation_section_ui.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx index 7289ba4af4fc2..4af023c57e2e4 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx @@ -27,7 +27,7 @@ const navigationNodeToEuiItem = ( item: ChromeProjectNavigationNodeEnhanced, { navigateToUrl, basePath }: { navigateToUrl: NavigateToUrlFn; basePath: BasePathService } ): EuiSideNavItemType => { - const href = item.deepLink?.href ?? item.href; + const href = item.deepLink?.url ?? item.href; const id = item.path ? item.path.join('.') : item.id; const isExternal = Boolean(href) && isAbsoluteLink(href!); @@ -52,7 +52,7 @@ const navigationNodeToEuiItem = ( href !== undefined ? (event: React.MouseEvent) => { event.preventDefault(); - navigateToUrl(basePath.prepend(href!)); + navigateToUrl(href); } : undefined, href, From e526ec89972598528955557293f23da91a280f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Mon, 12 Jun 2023 15:56:53 +0100 Subject: [PATCH 55/60] Hidden deeplink marked as hidden --- .../chrome/navigation/src/ui/hooks/use_init_navnode.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts b/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts index 71a9195abf97d..f5bc9ebf35fb9 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts +++ b/packages/shared-ux/chrome/navigation/src/ui/hooks/use_init_navnode.ts @@ -44,6 +44,11 @@ function isNodeVisible({ link, deepLink }: { link?: string; deepLink?: ChromeNav // If a link is provided, but no deepLink is found, don't render anything return false; } + + if (deepLink) { + return !deepLink.hidden; + } + return true; } From 6d3e67315eaff0813dc7b75d037327e1cbd1d65c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Tue, 13 Jun 2023 10:29:51 +0100 Subject: [PATCH 56/60] Update mock deeplink href and url --- .../chrome/navigation/mocks/index.ts | 1 + .../src/default_navigation.test.helpers.ts | 302 +++++++++--------- .../chrome/navigation/mocks/src/navlinks.ts | 6 +- 3 files changed, 155 insertions(+), 154 deletions(-) diff --git a/packages/shared-ux/chrome/navigation/mocks/index.ts b/packages/shared-ux/chrome/navigation/mocks/index.ts index 9cb459278d7ee..81c4cf165ee91 100644 --- a/packages/shared-ux/chrome/navigation/mocks/index.ts +++ b/packages/shared-ux/chrome/navigation/mocks/index.ts @@ -19,3 +19,4 @@ export { defaultManagementNavGroup, defaultMlNavGroup, } from './src/default_navigation.test.helpers'; +export { navLinksMock } from './src/navlinks'; diff --git a/packages/shared-ux/chrome/navigation/mocks/src/default_navigation.test.helpers.ts b/packages/shared-ux/chrome/navigation/mocks/src/default_navigation.test.helpers.ts index 352ce20128199..f850b79a588c7 100644 --- a/packages/shared-ux/chrome/navigation/mocks/src/default_navigation.test.helpers.ts +++ b/packages/shared-ux/chrome/navigation/mocks/src/default_navigation.test.helpers.ts @@ -27,37 +27,37 @@ export const defaultAnalyticsNavGroup = { { id: 'discover', path: ['rootNav:analytics', 'root', 'discover'], - title: 'Mocked discover', + title: 'Deeplink discover', deepLink: { id: 'discover', - title: 'Mocked discover', - href: '/mocked/discover', + title: 'Deeplink discover', + href: 'http://mocked/discover', baseUrl: '/mocked', - url: 'http://mocked/discover', + url: '/mocked/discover', }, }, { id: 'dashboards', path: ['rootNav:analytics', 'root', 'dashboards'], - title: 'Mocked dashboards', + title: 'Deeplink dashboards', deepLink: { id: 'dashboards', - title: 'Mocked dashboards', - href: '/mocked/dashboards', + title: 'Deeplink dashboards', + href: 'http://mocked/dashboards', baseUrl: '/mocked', - url: 'http://mocked/dashboards', + url: '/mocked/dashboards', }, }, { id: 'visualize', path: ['rootNav:analytics', 'root', 'visualize'], - title: 'Mocked visualize', + title: 'Deeplink visualize', deepLink: { id: 'visualize', - title: 'Mocked visualize', - href: '/mocked/visualize', + title: 'Deeplink visualize', + href: 'http://mocked/visualize', baseUrl: '/mocked', - url: 'http://mocked/visualize', + url: '/mocked/visualize', }, }, ], @@ -79,25 +79,25 @@ export const defaultMlNavGroup = { { id: 'ml:overview', path: ['rootNav:ml', 'root', 'ml:overview'], - title: 'Mocked ml:overview', + title: 'Deeplink ml:overview', deepLink: { id: 'ml:overview', - title: 'Mocked ml:overview', - href: '/mocked/ml:overview', + title: 'Deeplink ml:overview', + href: 'http://mocked/ml:overview', baseUrl: '/mocked', - url: 'http://mocked/ml:overview', + url: '/mocked/ml:overview', }, }, { id: 'ml:notifications', path: ['rootNav:ml', 'root', 'ml:notifications'], - title: 'Mocked ml:notifications', + title: 'Deeplink ml:notifications', deepLink: { id: 'ml:notifications', - title: 'Mocked ml:notifications', - href: '/mocked/ml:notifications', + title: 'Deeplink ml:notifications', + href: 'http://mocked/ml:notifications', baseUrl: '/mocked', - url: 'http://mocked/ml:notifications', + url: '/mocked/ml:notifications', }, }, ], @@ -113,46 +113,46 @@ export const defaultMlNavGroup = { path: ['rootNav:ml', 'anomaly_detection', 'ml:anomalyDetection'], deepLink: { id: 'ml:anomalyDetection', - title: 'Mocked ml:anomalyDetection', - href: '/mocked/ml:anomalyDetection', + title: 'Deeplink ml:anomalyDetection', + href: 'http://mocked/ml:anomalyDetection', baseUrl: '/mocked', - url: 'http://mocked/ml:anomalyDetection', + url: '/mocked/ml:anomalyDetection', }, }, { id: 'ml:anomalyExplorer', path: ['rootNav:ml', 'anomaly_detection', 'ml:anomalyExplorer'], - title: 'Mocked ml:anomalyExplorer', + title: 'Deeplink ml:anomalyExplorer', deepLink: { id: 'ml:anomalyExplorer', - title: 'Mocked ml:anomalyExplorer', - href: '/mocked/ml:anomalyExplorer', + title: 'Deeplink ml:anomalyExplorer', + href: 'http://mocked/ml:anomalyExplorer', baseUrl: '/mocked', - url: 'http://mocked/ml:anomalyExplorer', + url: '/mocked/ml:anomalyExplorer', }, }, { id: 'ml:singleMetricViewer', path: ['rootNav:ml', 'anomaly_detection', 'ml:singleMetricViewer'], - title: 'Mocked ml:singleMetricViewer', + title: 'Deeplink ml:singleMetricViewer', deepLink: { id: 'ml:singleMetricViewer', - title: 'Mocked ml:singleMetricViewer', - href: '/mocked/ml:singleMetricViewer', + title: 'Deeplink ml:singleMetricViewer', + href: 'http://mocked/ml:singleMetricViewer', baseUrl: '/mocked', - url: 'http://mocked/ml:singleMetricViewer', + url: '/mocked/ml:singleMetricViewer', }, }, { id: 'ml:settings', path: ['rootNav:ml', 'anomaly_detection', 'ml:settings'], - title: 'Mocked ml:settings', + title: 'Deeplink ml:settings', deepLink: { id: 'ml:settings', - title: 'Mocked ml:settings', - href: '/mocked/ml:settings', + title: 'Deeplink ml:settings', + href: 'http://mocked/ml:settings', baseUrl: '/mocked', - url: 'http://mocked/ml:settings', + url: '/mocked/ml:settings', }, }, ], @@ -168,34 +168,34 @@ export const defaultMlNavGroup = { path: ['rootNav:ml', 'data_frame_analytics', 'ml:dataFrameAnalytics'], deepLink: { id: 'ml:dataFrameAnalytics', - title: 'Mocked ml:dataFrameAnalytics', - href: '/mocked/ml:dataFrameAnalytics', + title: 'Deeplink ml:dataFrameAnalytics', + href: 'http://mocked/ml:dataFrameAnalytics', baseUrl: '/mocked', - url: 'http://mocked/ml:dataFrameAnalytics', + url: '/mocked/ml:dataFrameAnalytics', }, }, { id: 'ml:resultExplorer', path: ['rootNav:ml', 'data_frame_analytics', 'ml:resultExplorer'], - title: 'Mocked ml:resultExplorer', + title: 'Deeplink ml:resultExplorer', deepLink: { id: 'ml:resultExplorer', - title: 'Mocked ml:resultExplorer', - href: '/mocked/ml:resultExplorer', + title: 'Deeplink ml:resultExplorer', + href: 'http://mocked/ml:resultExplorer', baseUrl: '/mocked', - url: 'http://mocked/ml:resultExplorer', + url: '/mocked/ml:resultExplorer', }, }, { id: 'ml:analyticsMap', path: ['rootNav:ml', 'data_frame_analytics', 'ml:analyticsMap'], - title: 'Mocked ml:analyticsMap', + title: 'Deeplink ml:analyticsMap', deepLink: { id: 'ml:analyticsMap', - title: 'Mocked ml:analyticsMap', - href: '/mocked/ml:analyticsMap', + title: 'Deeplink ml:analyticsMap', + href: 'http://mocked/ml:analyticsMap', baseUrl: '/mocked', - url: 'http://mocked/ml:analyticsMap', + url: '/mocked/ml:analyticsMap', }, }, ], @@ -208,25 +208,25 @@ export const defaultMlNavGroup = { { id: 'ml:nodesOverview', path: ['rootNav:ml', 'model_management', 'ml:nodesOverview'], - title: 'Mocked ml:nodesOverview', + title: 'Deeplink ml:nodesOverview', deepLink: { id: 'ml:nodesOverview', - title: 'Mocked ml:nodesOverview', - href: '/mocked/ml:nodesOverview', + title: 'Deeplink ml:nodesOverview', + href: 'http://mocked/ml:nodesOverview', baseUrl: '/mocked', - url: 'http://mocked/ml:nodesOverview', + url: '/mocked/ml:nodesOverview', }, }, { id: 'ml:nodes', path: ['rootNav:ml', 'model_management', 'ml:nodes'], - title: 'Mocked ml:nodes', + title: 'Deeplink ml:nodes', deepLink: { id: 'ml:nodes', - title: 'Mocked ml:nodes', - href: '/mocked/ml:nodes', + title: 'Deeplink ml:nodes', + href: 'http://mocked/ml:nodes', baseUrl: '/mocked', - url: 'http://mocked/ml:nodes', + url: '/mocked/ml:nodes', }, }, ], @@ -242,10 +242,10 @@ export const defaultMlNavGroup = { path: ['rootNav:ml', 'data_visualizer', 'ml:fileUpload'], deepLink: { id: 'ml:fileUpload', - title: 'Mocked ml:fileUpload', - href: '/mocked/ml:fileUpload', + title: 'Deeplink ml:fileUpload', + href: 'http://mocked/ml:fileUpload', baseUrl: '/mocked', - url: 'http://mocked/ml:fileUpload', + url: '/mocked/ml:fileUpload', }, }, { @@ -254,10 +254,10 @@ export const defaultMlNavGroup = { path: ['rootNav:ml', 'data_visualizer', 'ml:indexDataVisualizer'], deepLink: { id: 'ml:indexDataVisualizer', - title: 'Mocked ml:indexDataVisualizer', - href: '/mocked/ml:indexDataVisualizer', + title: 'Deeplink ml:indexDataVisualizer', + href: 'http://mocked/ml:indexDataVisualizer', baseUrl: '/mocked', - url: 'http://mocked/ml:indexDataVisualizer', + url: '/mocked/ml:indexDataVisualizer', }, }, ], @@ -273,22 +273,22 @@ export const defaultMlNavGroup = { path: ['rootNav:ml', 'aiops_labs', 'ml:explainLogRateSpikes'], deepLink: { id: 'ml:explainLogRateSpikes', - title: 'Mocked ml:explainLogRateSpikes', - href: '/mocked/ml:explainLogRateSpikes', + title: 'Deeplink ml:explainLogRateSpikes', + href: 'http://mocked/ml:explainLogRateSpikes', baseUrl: '/mocked', - url: 'http://mocked/ml:explainLogRateSpikes', + url: '/mocked/ml:explainLogRateSpikes', }, }, { id: 'ml:logPatternAnalysis', path: ['rootNav:ml', 'aiops_labs', 'ml:logPatternAnalysis'], - title: 'Mocked ml:logPatternAnalysis', + title: 'Deeplink ml:logPatternAnalysis', deepLink: { id: 'ml:logPatternAnalysis', - title: 'Mocked ml:logPatternAnalysis', - href: '/mocked/ml:logPatternAnalysis', + title: 'Deeplink ml:logPatternAnalysis', + href: 'http://mocked/ml:logPatternAnalysis', baseUrl: '/mocked', - url: 'http://mocked/ml:logPatternAnalysis', + url: '/mocked/ml:logPatternAnalysis', }, }, ], @@ -310,49 +310,49 @@ export const defaultDevtoolsNavGroup = { { id: 'dev_tools:console', path: ['rootNav:devtools', 'root', 'dev_tools:console'], - title: 'Mocked dev_tools:console', + title: 'Deeplink dev_tools:console', deepLink: { id: 'dev_tools:console', - title: 'Mocked dev_tools:console', - href: '/mocked/dev_tools:console', + title: 'Deeplink dev_tools:console', + href: 'http://mocked/dev_tools:console', baseUrl: '/mocked', - url: 'http://mocked/dev_tools:console', + url: '/mocked/dev_tools:console', }, }, { id: 'dev_tools:searchprofiler', path: ['rootNav:devtools', 'root', 'dev_tools:searchprofiler'], - title: 'Mocked dev_tools:searchprofiler', + title: 'Deeplink dev_tools:searchprofiler', deepLink: { id: 'dev_tools:searchprofiler', - title: 'Mocked dev_tools:searchprofiler', - href: '/mocked/dev_tools:searchprofiler', + title: 'Deeplink dev_tools:searchprofiler', + href: 'http://mocked/dev_tools:searchprofiler', baseUrl: '/mocked', - url: 'http://mocked/dev_tools:searchprofiler', + url: '/mocked/dev_tools:searchprofiler', }, }, { id: 'dev_tools:grokdebugger', path: ['rootNav:devtools', 'root', 'dev_tools:grokdebugger'], - title: 'Mocked dev_tools:grokdebugger', + title: 'Deeplink dev_tools:grokdebugger', deepLink: { id: 'dev_tools:grokdebugger', - title: 'Mocked dev_tools:grokdebugger', - href: '/mocked/dev_tools:grokdebugger', + title: 'Deeplink dev_tools:grokdebugger', + href: 'http://mocked/dev_tools:grokdebugger', baseUrl: '/mocked', - url: 'http://mocked/dev_tools:grokdebugger', + url: '/mocked/dev_tools:grokdebugger', }, }, { id: 'dev_tools:painless_lab', path: ['rootNav:devtools', 'root', 'dev_tools:painless_lab'], - title: 'Mocked dev_tools:painless_lab', + title: 'Deeplink dev_tools:painless_lab', deepLink: { id: 'dev_tools:painless_lab', - title: 'Mocked dev_tools:painless_lab', - href: '/mocked/dev_tools:painless_lab', + title: 'Deeplink dev_tools:painless_lab', + href: 'http://mocked/dev_tools:painless_lab', baseUrl: '/mocked', - url: 'http://mocked/dev_tools:painless_lab', + url: '/mocked/dev_tools:painless_lab', }, }, ], @@ -374,13 +374,13 @@ export const defaultManagementNavGroup = { { id: 'monitoring', path: ['rootNav:management', 'root', 'monitoring'], - title: 'Mocked monitoring', + title: 'Deeplink monitoring', deepLink: { id: 'monitoring', - title: 'Mocked monitoring', - href: '/mocked/monitoring', + title: 'Deeplink monitoring', + href: 'http://mocked/monitoring', baseUrl: '/mocked', - url: 'http://mocked/monitoring', + url: '/mocked/monitoring', }, }, ], @@ -393,37 +393,37 @@ export const defaultManagementNavGroup = { { id: 'integrations', path: ['rootNav:management', 'integration_management', 'integrations'], - title: 'Mocked integrations', + title: 'Deeplink integrations', deepLink: { id: 'integrations', - title: 'Mocked integrations', - href: '/mocked/integrations', + title: 'Deeplink integrations', + href: 'http://mocked/integrations', baseUrl: '/mocked', - url: 'http://mocked/integrations', + url: '/mocked/integrations', }, }, { id: 'fleet', path: ['rootNav:management', 'integration_management', 'fleet'], - title: 'Mocked fleet', + title: 'Deeplink fleet', deepLink: { id: 'fleet', - title: 'Mocked fleet', - href: '/mocked/fleet', + title: 'Deeplink fleet', + href: 'http://mocked/fleet', baseUrl: '/mocked', - url: 'http://mocked/fleet', + url: '/mocked/fleet', }, }, { id: 'osquery', path: ['rootNav:management', 'integration_management', 'osquery'], - title: 'Mocked osquery', + title: 'Deeplink osquery', deepLink: { id: 'osquery', - title: 'Mocked osquery', - href: '/mocked/osquery', + title: 'Deeplink osquery', + href: 'http://mocked/osquery', baseUrl: '/mocked', - url: 'http://mocked/osquery', + url: '/mocked/osquery', }, }, ], @@ -446,25 +446,25 @@ export const defaultManagementNavGroup = { 'ingest', 'management:ingest_pipelines', ], - title: 'Mocked management:ingest_pipelines', + title: 'Deeplink management:ingest_pipelines', deepLink: { id: 'management:ingest_pipelines', - title: 'Mocked management:ingest_pipelines', - href: '/mocked/management:ingest_pipelines', + title: 'Deeplink management:ingest_pipelines', + href: 'http://mocked/management:ingest_pipelines', baseUrl: '/mocked', - url: 'http://mocked/management:ingest_pipelines', + url: '/mocked/management:ingest_pipelines', }, }, { id: 'management:pipelines', path: ['rootNav:management', 'stack_management', 'ingest', 'management:pipelines'], - title: 'Mocked management:pipelines', + title: 'Deeplink management:pipelines', deepLink: { id: 'management:pipelines', - title: 'Mocked management:pipelines', - href: '/mocked/management:pipelines', + title: 'Deeplink management:pipelines', + href: 'http://mocked/management:pipelines', baseUrl: '/mocked', - url: 'http://mocked/management:pipelines', + url: '/mocked/management:pipelines', }, }, ], @@ -482,25 +482,25 @@ export const defaultManagementNavGroup = { 'data', 'management:index_management', ], - title: 'Mocked management:index_management', + title: 'Deeplink management:index_management', deepLink: { id: 'management:index_management', - title: 'Mocked management:index_management', - href: '/mocked/management:index_management', + title: 'Deeplink management:index_management', + href: 'http://mocked/management:index_management', baseUrl: '/mocked', - url: 'http://mocked/management:index_management', + url: '/mocked/management:index_management', }, }, { id: 'management:transform', path: ['rootNav:management', 'stack_management', 'data', 'management:transform'], - title: 'Mocked management:transform', + title: 'Deeplink management:transform', deepLink: { id: 'management:transform', - title: 'Mocked management:transform', - href: '/mocked/management:transform', + title: 'Deeplink management:transform', + href: 'http://mocked/management:transform', baseUrl: '/mocked', - url: 'http://mocked/management:transform', + url: '/mocked/management:transform', }, }, ], @@ -518,13 +518,13 @@ export const defaultManagementNavGroup = { 'alerts_and_insights', 'management:triggersActions', ], - title: 'Mocked management:triggersActions', + title: 'Deeplink management:triggersActions', deepLink: { id: 'management:triggersActions', - title: 'Mocked management:triggersActions', - href: '/mocked/management:triggersActions', + title: 'Deeplink management:triggersActions', + href: 'http://mocked/management:triggersActions', baseUrl: '/mocked', - url: 'http://mocked/management:triggersActions', + url: '/mocked/management:triggersActions', }, }, { @@ -535,13 +535,13 @@ export const defaultManagementNavGroup = { 'alerts_and_insights', 'management:cases', ], - title: 'Mocked management:cases', + title: 'Deeplink management:cases', deepLink: { id: 'management:cases', - title: 'Mocked management:cases', - href: '/mocked/management:cases', + title: 'Deeplink management:cases', + href: 'http://mocked/management:cases', baseUrl: '/mocked', - url: 'http://mocked/management:cases', + url: '/mocked/management:cases', }, }, { @@ -552,13 +552,13 @@ export const defaultManagementNavGroup = { 'alerts_and_insights', 'management:triggersActionsConnectors', ], - title: 'Mocked management:triggersActionsConnectors', + title: 'Deeplink management:triggersActionsConnectors', deepLink: { id: 'management:triggersActionsConnectors', - title: 'Mocked management:triggersActionsConnectors', - href: '/mocked/management:triggersActionsConnectors', + title: 'Deeplink management:triggersActionsConnectors', + href: 'http://mocked/management:triggersActionsConnectors', baseUrl: '/mocked', - url: 'http://mocked/management:triggersActionsConnectors', + url: '/mocked/management:triggersActionsConnectors', }, }, { @@ -569,13 +569,13 @@ export const defaultManagementNavGroup = { 'alerts_and_insights', 'management:jobsListLink', ], - title: 'Mocked management:jobsListLink', + title: 'Deeplink management:jobsListLink', deepLink: { id: 'management:jobsListLink', - title: 'Mocked management:jobsListLink', - href: '/mocked/management:jobsListLink', + title: 'Deeplink management:jobsListLink', + href: 'http://mocked/management:jobsListLink', baseUrl: '/mocked', - url: 'http://mocked/management:jobsListLink', + url: '/mocked/management:jobsListLink', }, }, ], @@ -588,61 +588,61 @@ export const defaultManagementNavGroup = { { id: 'management:dataViews', path: ['rootNav:management', 'stack_management', 'kibana', 'management:dataViews'], - title: 'Mocked management:dataViews', + title: 'Deeplink management:dataViews', deepLink: { id: 'management:dataViews', - title: 'Mocked management:dataViews', - href: '/mocked/management:dataViews', + title: 'Deeplink management:dataViews', + href: 'http://mocked/management:dataViews', baseUrl: '/mocked', - url: 'http://mocked/management:dataViews', + url: '/mocked/management:dataViews', }, }, { id: 'management:objects', path: ['rootNav:management', 'stack_management', 'kibana', 'management:objects'], - title: 'Mocked management:objects', + title: 'Deeplink management:objects', deepLink: { id: 'management:objects', - title: 'Mocked management:objects', - href: '/mocked/management:objects', + title: 'Deeplink management:objects', + href: 'http://mocked/management:objects', baseUrl: '/mocked', - url: 'http://mocked/management:objects', + url: '/mocked/management:objects', }, }, { id: 'management:tags', path: ['rootNav:management', 'stack_management', 'kibana', 'management:tags'], - title: 'Mocked management:tags', + title: 'Deeplink management:tags', deepLink: { id: 'management:tags', - title: 'Mocked management:tags', - href: '/mocked/management:tags', + title: 'Deeplink management:tags', + href: 'http://mocked/management:tags', baseUrl: '/mocked', - url: 'http://mocked/management:tags', + url: '/mocked/management:tags', }, }, { id: 'management:spaces', path: ['rootNav:management', 'stack_management', 'kibana', 'management:spaces'], - title: 'Mocked management:spaces', + title: 'Deeplink management:spaces', deepLink: { id: 'management:spaces', - title: 'Mocked management:spaces', - href: '/mocked/management:spaces', + title: 'Deeplink management:spaces', + href: 'http://mocked/management:spaces', baseUrl: '/mocked', - url: 'http://mocked/management:spaces', + url: '/mocked/management:spaces', }, }, { id: 'management:settings', path: ['rootNav:management', 'stack_management', 'kibana', 'management:settings'], - title: 'Mocked management:settings', + title: 'Deeplink management:settings', deepLink: { id: 'management:settings', - title: 'Mocked management:settings', - href: '/mocked/management:settings', + title: 'Deeplink management:settings', + href: 'http://mocked/management:settings', baseUrl: '/mocked', - url: 'http://mocked/management:settings', + url: '/mocked/management:settings', }, }, ], diff --git a/packages/shared-ux/chrome/navigation/mocks/src/navlinks.ts b/packages/shared-ux/chrome/navigation/mocks/src/navlinks.ts index 68bd7825a81f1..a002f072770a8 100644 --- a/packages/shared-ux/chrome/navigation/mocks/src/navlinks.ts +++ b/packages/shared-ux/chrome/navigation/mocks/src/navlinks.ts @@ -11,10 +11,10 @@ import type { AppDeepLinkId, ChromeNavLink } from '@kbn/core-chrome-browser'; const getNavLink = (id: string): ChromeNavLink => { return { id, - title: `Mocked ${id}`, - href: `/mocked/${id}`, + title: `Deeplink ${id}`, + href: `http://mocked/${id}`, baseUrl: `/mocked`, - url: `http://mocked/${id}`, + url: `/mocked/${id}`, }; }; From d4d285fabeea825fe54de1bea171000d00ad1f39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Tue, 13 Jun 2023 10:32:07 +0100 Subject: [PATCH 57/60] Update stories to add mocked deeplinks --- .../chrome/navigation/src/ui/navigation.stories.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx b/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx index dbca88ad8e8c0..21b59cf7521f6 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/navigation.stories.tsx @@ -24,7 +24,7 @@ import { EuiTitle, } from '@elastic/eui'; import { css } from '@emotion/react'; -import { NavigationStorybookMock } from '../../mocks'; +import { NavigationStorybookMock, navLinksMock } from '../../mocks'; import mdx from '../../README.mdx'; import { NavigationProvider } from '../services'; import { DefaultNavigation } from './default_navigation'; @@ -175,7 +175,7 @@ const simpleNavigationDefinition: ProjectNavigationDefinition = { export const SimpleObjectDefinition = (args: ChromeNavigationViewModel & NavigationServices) => { const services = storybookMock.getServices({ ...args, - navLinks$: of(deepLinks), + navLinks$: of([...navLinksMock, ...deepLinks]), onProjectNavigationChange: (updated) => { action('Update chrome navigation')(JSON.stringify(updated, null, 2)); }, @@ -295,7 +295,7 @@ const navigationDefinition: ProjectNavigationDefinition = { export const ComplexObjectDefinition = (args: ChromeNavigationViewModel & NavigationServices) => { const services = storybookMock.getServices({ ...args, - navLinks$: of(deepLinks), + navLinks$: of([...navLinksMock, ...deepLinks]), onProjectNavigationChange: (updated) => { action('Update chrome navigation')(JSON.stringify(updated, null, 2)); }, @@ -317,7 +317,7 @@ export const ComplexObjectDefinition = (args: ChromeNavigationViewModel & Naviga export const WithUIComponents = (args: ChromeNavigationViewModel & NavigationServices) => { const services = storybookMock.getServices({ ...args, - navLinks$: of(deepLinks), + navLinks$: of([...navLinksMock, ...deepLinks]), onProjectNavigationChange: (updated) => { action('Update chrome navigation')(JSON.stringify(updated, null, 2)); }, @@ -385,7 +385,7 @@ export const MinimalUIAndCustomCloudLink = ( ) => { const services = storybookMock.getServices({ ...args, - navLinks$: of(deepLinks), + navLinks$: of([...navLinksMock, ...deepLinks]), onProjectNavigationChange: (updated) => { action('Update chrome navigation')(JSON.stringify(updated, null, 2)); }, @@ -453,7 +453,7 @@ export default { export const CreativeUI = (args: ChromeNavigationViewModel & NavigationServices) => { const services = storybookMock.getServices({ ...args, - navLinks$: of(deepLinks), + navLinks$: of([...navLinksMock, ...deepLinks]), onProjectNavigationChange: (updated) => { action('Update chrome navigation')(JSON.stringify(updated, null, 2)); }, From 98ca9ae78775fd3ec684984473c5533b735cdb83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Tue, 13 Jun 2023 11:50:11 +0100 Subject: [PATCH 58/60] Don't render group that don't have a link or children with links --- .../src/ui/components/navigation.test.tsx | 92 ++++++++++++++++++- .../ui/components/navigation_section_ui.tsx | 38 +++++++- .../src/ui/default_navigation.test.tsx | 8 ++ 3 files changed, 130 insertions(+), 8 deletions(-) diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/navigation.test.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/navigation.test.tsx index a41c5ed767a28..46a56dc4cc363 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/navigation.test.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/navigation.test.tsx @@ -32,12 +32,12 @@ describe('', () => { - - + + - + - + @@ -72,11 +72,13 @@ describe('', () => { { id: 'item1', title: 'Item 1', + href: 'https://foo', path: ['group1', 'item1'], }, { id: 'item2', title: 'Item 2', + href: 'https://foo', path: ['group1', 'item2'], }, { @@ -86,6 +88,7 @@ describe('', () => { children: [ { id: 'item1', + href: 'https://foo', title: 'Group 1A Item 1', path: ['group1', 'group1A', 'item1'], }, @@ -97,6 +100,7 @@ describe('', () => { { id: 'item1', title: 'Group 1A_1 Item 1', + href: 'https://foo', path: ['group1', 'group1A', 'group1A_1', 'item1'], }, ], @@ -275,6 +279,83 @@ describe('', () => { }); }); + test('should not render the group if it does not have children AND no href or deeplink', async () => { + const navLinks$: Observable = of([ + { + id: 'item1', + title: 'Title from deeplink', + baseUrl: '', + url: '', + href: '', + }, + ]); + const onProjectNavigationChange = jest.fn(); + + const { queryByTestId } = render( + + + + + id="item1" link="notRegistered" /> + + + id="item1" link="item1" /> + + + + + ); + + expect(await queryByTestId('nav-group-root.group1')).toBeNull(); + expect(await queryByTestId('nav-item-root.group2.item1')).toBeVisible(); + + expect(onProjectNavigationChange).toHaveBeenCalled(); + const lastCall = + onProjectNavigationChange.mock.calls[onProjectNavigationChange.mock.calls.length - 1]; + const [navTree] = lastCall; + + expect(navTree).toEqual({ + homeRef: 'https://elastic.co', + navigationTree: [ + { + id: 'root', + path: ['root'], + title: '', + children: [ + { + id: 'group1', + path: ['root', 'group1'], + title: '', + }, + { + id: 'group2', + path: ['root', 'group2'], + title: '', + children: [ + { + id: 'item1', + path: ['root', 'group2', 'item1'], + title: 'Title from deeplink', + deepLink: { + id: 'item1', + title: 'Title from deeplink', + baseUrl: '', + url: '', + href: '', + }, + }, + ], + }, + ], + }, + ], + }); + }); + test('should render custom react element', async () => { const navLinks$: Observable = of([ { @@ -300,7 +381,7 @@ describe('', () => { link="item1">
Custom element
- + {(navNode) =>
{navNode.title}
}
@@ -348,6 +429,7 @@ describe('', () => { }, { id: 'item2', + href: 'http://foo', path: ['root', 'group1', 'item2'], title: 'Children prop', renderItem: expect.any(Function), diff --git a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx index 4af023c57e2e4..c0b18fd60e7eb 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/components/navigation_section_ui.tsx @@ -30,6 +30,7 @@ const navigationNodeToEuiItem = ( const href = item.deepLink?.url ?? item.href; const id = item.path ? item.path.join('.') : item.id; const isExternal = Boolean(href) && isAbsoluteLink(href!); + const dataTestSubj = `nav-item-${id}`; const getRenderItem = (): RenderItem | undefined => { if (!isExternal || item.renderItem) { @@ -37,7 +38,7 @@ const navigationNodeToEuiItem = ( } return () => ( -
+
{item.title} @@ -60,7 +61,7 @@ const navigationNodeToEuiItem = ( items: item.children?.map((_item) => navigationNodeToEuiItem(_item, { navigateToUrl, basePath }) ), - ['data-test-subj']: `nav-item-${id}`, + ['data-test-subj']: dataTestSubj, ...(item.icon && { icon: , }), @@ -81,6 +82,35 @@ export const NavigationSectionUI: FC = ({ const { id, title, icon } = navNode; const { navigateToUrl, basePath } = useServices(); + // If the item has no link and no cildren, we don't want to render it + const itemHasLinkOrChildren = (item: ChromeProjectNavigationNodeEnhanced) => { + const hasLink = Boolean(item.deepLink) || Boolean(item.href); + if (hasLink) { + return true; + } + const hasChildren = Boolean(item.children?.length); + if (hasChildren) { + return item.children!.some(itemHasLinkOrChildren); + } + return false; + }; + + const filteredItems = items.filter(itemHasLinkOrChildren).map((item) => { + if (item.children) { + return { + ...item, + children: item.children.filter(itemHasLinkOrChildren), + }; + } + return item; + }); + + const groupHasLink = Boolean(navNode.deepLink) || Boolean(navNode.href); + + if (!groupHasLink && !filteredItems.some(itemHasLinkOrChildren)) { + return null; + } + return ( = ({ > navigationNodeToEuiItem(item, { navigateToUrl, basePath }))} + items={filteredItems.map((item) => + navigationNodeToEuiItem(item, { navigateToUrl, basePath }) + )} css={styles.euiSideNavItems} /> diff --git a/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx b/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx index aa4f12f8b2772..91e3ed5ca28e3 100644 --- a/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx +++ b/packages/shared-ux/chrome/navigation/src/ui/default_navigation.test.tsx @@ -42,10 +42,12 @@ describe('', () => { { id: 'item1', title: 'Item 1', + href: 'http://foo', }, { id: 'item2', title: 'Item 2', + href: 'http://foo', }, { id: 'group1A', @@ -54,6 +56,7 @@ describe('', () => { { id: 'item1', title: 'Group 1A Item 1', + href: 'http://foo', }, { id: 'group1A_1', @@ -62,6 +65,7 @@ describe('', () => { { id: 'item1', title: 'Group 1A_1 Item 1', + href: 'http://foo', }, ], }, @@ -109,11 +113,13 @@ describe('', () => { { id: 'item1', title: 'Item 1', + href: 'http://foo', path: ['group1', 'item1'], }, { id: 'item2', title: 'Item 2', + href: 'http://foo', path: ['group1', 'item2'], }, { @@ -124,6 +130,7 @@ describe('', () => { { id: 'item1', title: 'Group 1A Item 1', + href: 'http://foo', path: ['group1', 'group1A', 'item1'], }, { @@ -134,6 +141,7 @@ describe('', () => { { id: 'item1', title: 'Group 1A_1 Item 1', + href: 'http://foo', path: ['group1', 'group1A', 'group1A_1', 'item1'], }, ], From 7686eb29ca3efabba52efde9e583cb42c1e84f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Tue, 13 Jun 2023 15:23:50 +0100 Subject: [PATCH 59/60] Mark apm Services deeplink visible in side nav --- x-pack/plugins/apm/public/plugin.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/plugins/apm/public/plugin.ts b/x-pack/plugins/apm/public/plugin.ts index 71aceed2b92dd..0c2f4387c924e 100644 --- a/x-pack/plugins/apm/public/plugin.ts +++ b/x-pack/plugins/apm/public/plugin.ts @@ -11,6 +11,7 @@ import { map } from 'rxjs/operators'; import { UsageCollectionStart } from '@kbn/usage-collection-plugin/public'; import { AppMountParameters, + AppNavLinkStatus, CoreSetup, CoreStart, DEFAULT_APP_CATEGORIES, @@ -330,6 +331,7 @@ export class ApmPlugin implements Plugin { id: 'services', title: servicesTitle, path: '/services', + navLinkStatus: AppNavLinkStatus.visible, }, { id: 'traces', title: tracesTitle, path: '/traces' }, { id: 'service-map', title: serviceMapTitle, path: '/service-map' }, From 8bb98a5bdb3de9795b24eaa53b1474857b50c125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loix?= Date: Tue, 13 Jun 2023 16:57:15 +0100 Subject: [PATCH 60/60] Revert "Mark apm Services deeplink visible in side nav" This reverts commit 7686eb29ca3efabba52efde9e583cb42c1e84f68. --- x-pack/plugins/apm/public/plugin.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/x-pack/plugins/apm/public/plugin.ts b/x-pack/plugins/apm/public/plugin.ts index 0c2f4387c924e..71aceed2b92dd 100644 --- a/x-pack/plugins/apm/public/plugin.ts +++ b/x-pack/plugins/apm/public/plugin.ts @@ -11,7 +11,6 @@ import { map } from 'rxjs/operators'; import { UsageCollectionStart } from '@kbn/usage-collection-plugin/public'; import { AppMountParameters, - AppNavLinkStatus, CoreSetup, CoreStart, DEFAULT_APP_CATEGORIES, @@ -331,7 +330,6 @@ export class ApmPlugin implements Plugin { id: 'services', title: servicesTitle, path: '/services', - navLinkStatus: AppNavLinkStatus.visible, }, { id: 'traces', title: tracesTitle, path: '/traces' }, { id: 'service-map', title: serviceMapTitle, path: '/service-map' },