Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SharedUxChromeNavigation] Use deeplink id instead of href #159125

Merged
merged 66 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
f44964b
Sort imports
sebelga Jun 5, 2023
898b805
Add devTools deeplinks
sebelga Jun 1, 2023
4d96353
Add analytics deeplink ids and update TS types
sebelga Jun 5, 2023
4a1a7f3
Replace ChromeProjectNavigationLink with AppDeepLinkId & AppId
sebelga Jun 5, 2023
39a2334
Update package.json and tsconfig.base.jfon
sebelga Jun 5, 2023
3f4fb41
Add generic to AppDeepLink to define ids
sebelga Jun 5, 2023
553dec8
Add machine learning deeplinks
sebelga Jun 5, 2023
015c81a
Move ml default navigation to the deeplinks package
sebelga Jun 5, 2023
9b785f8
Update types
sebelga Jun 6, 2023
0a3d98d
Move analytics default navigation to package
sebelga Jun 6, 2023
d051dd2
Add i18n to defaultNavigation ml
sebelga Jun 6, 2023
04228b5
Move devtools default navigation to package
sebelga Jun 6, 2023
8421ee4
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 6, 2023
8fba7f8
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jun 6, 2023
496e525
Move NodeDefinition and NodeDefinitionWithChildren to core-chrome-bro…
sebelga Jun 6, 2023
9bbbd9c
Create default-nav packages to avoid circular dependencies
sebelga Jun 6, 2023
cbf36bc
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 6, 2023
87b16fd
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 6, 2023
23548ca
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jun 6, 2023
0a2657d
Only expose deepLink ids from dev tool package
sebelga Jun 7, 2023
15248fa
Update imports
sebelga Jun 7, 2023
f500afe
Only expose deepLink ids from dev tool package (2)
sebelga Jun 7, 2023
0318001
Clear kbn_references
sebelga Jun 7, 2023
e51cc59
Update stories path
sebelga Jun 7, 2023
8552514
Create deeplinks package for management
sebelga Jun 7, 2023
46f7609
Create deeplinks package for management (2)
sebelga Jun 7, 2023
bb0a091
Create default nav package for management
sebelga Jun 7, 2023
2759c63
Create default nav package for management (2)
sebelga Jun 7, 2023
9ddb14c
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 7, 2023
d2b0c6c
Update kbn_references
sebelga Jun 7, 2023
0da001a
WIP management deep links
sebelga Jun 7, 2023
43c5ffa
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 7, 2023
a6597f9
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jun 7, 2023
891d550
Fix TS issues
sebelga Jun 7, 2023
90abdc6
Update management deeplinks
sebelga Jun 7, 2023
7c345cc
Fix TS issues
sebelga Jun 7, 2023
582ab5a
Fix i18n
sebelga Jun 8, 2023
ba675f5
Fix i18n issue
sebelga Jun 9, 2023
7e86d83
Fix dashboard app id
sebelga Jun 9, 2023
0b45a40
Update search navigation
sebelga Jun 9, 2023
060974c
Add deeplink package for search
sebelga Jun 9, 2023
61a02e1
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 9, 2023
61f0001
Fix jest tests
sebelga Jun 9, 2023
f658658
Fix TS issue
sebelga Jun 9, 2023
6e75241
Update serverless observability nav
sebelga Jun 9, 2023
07334e8
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 9, 2023
d241738
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jun 9, 2023
e1b3a1b
Move nav_tree_presets out of folder
sebelga Jun 12, 2023
0348ec2
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jun 9, 2023
84a6997
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jun 9, 2023
29a4b0a
Fix import path
sebelga Jun 12, 2023
0f14231
Allow href for absolute links only
sebelga Jun 12, 2023
9f1abfb
Remove unused model folder
sebelga Jun 12, 2023
df15ed9
Use deeplink url instead of href
sebelga Jun 12, 2023
e526ec8
Hidden deeplink marked as hidden
sebelga Jun 12, 2023
4bd600f
Merge branch 'main' into sharedux-chrome-nav/deeplinks-packages
sebelga Jun 12, 2023
08c1eef
Merge branch 'main' into sharedux-chrome-nav/deeplinks-packages
sebelga Jun 12, 2023
6d3e673
Update mock deeplink href and url
sebelga Jun 13, 2023
d4d285f
Update stories to add mocked deeplinks
sebelga Jun 13, 2023
98ca9ae
Don't render group that don't have a link or children with links
sebelga Jun 13, 2023
a67f6a2
Merge remote-tracking branch 'upstream/main' into sharedux-chrome-nav…
sebelga Jun 13, 2023
dc87c6a
Merge branch 'sharedux-chrome-nav/deeplinks-packages' of github.com:s…
sebelga Jun 13, 2023
151cf15
Merge remote-tracking branch 'upstream/main' into sharedux-chrome-nav…
sebelga Jun 13, 2023
7686eb2
Mark apm Services deeplink visible in side nav
sebelga Jun 13, 2023
8bb98a5
Revert "Mark apm Services deeplink visible in side nav"
sebelga Jun 13, 2023
a35f4ce
Merge branch 'main' into sharedux-chrome-nav/deeplinks-packages
sebelga Jun 13, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,16 @@ 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/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
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
packages/kbn-dev-proc-runner @elastic/kibana-operations
Expand Down
1 change: 1 addition & 0 deletions .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"data": "src/plugins/data",
"observabilityAlertDetails": "x-pack/packages/observability/alert_details",
"dataViews": "src/plugins/data_views",
"defaultNavigation": "packages/default-nav",
"devTools": "src/plugins/dev_tools",
"discover": "src/plugins/discover",
"savedSearch": "src/plugins/saved_search",
Expand Down
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,16 @@
"@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/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",
"@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",
"@kbn/discover-enhanced-plugin": "link:x-pack/plugins/discover_enhanced",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ export type PublicAppDeepLinkInfo = Omit<
* user-accessible.
* @public
*/
export type AppDeepLink = {
export type AppDeepLink<Id extends string = string> = {
/** 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. */
Expand All @@ -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<AppDeepLink<Id>>;
}
| {
/** 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<AppDeepLink<Id>>;
}
);

Expand Down
5 changes: 4 additions & 1 deletion packages/core/chrome/core-chrome-browser/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
*/

export type {
AppDeepLinkId,
AppId,
ChromeBadge,
ChromeBreadcrumb,
ChromeBreadcrumbsAppendExtension,
Expand All @@ -29,11 +31,12 @@ export type {
ChromeStart,
ChromeStyle,
ChromeUserBanner,
ChromeProjectNavigationLink,
ChromeProjectNavigation,
ChromeProjectNavigationNode,
SideNavCompProps,
SideNavComponent,
ChromeProjectBreadcrumb,
ChromeSetProjectBreadcrumbsParams,
NodeDefinition,
NodeDefinitionWithChildren,
} from './src';
5 changes: 4 additions & 1 deletion packages/core/chrome/core-chrome-browser/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ export type { ChromeBadge, ChromeUserBanner, ChromeStyle } from './types';
export type {
ChromeProjectNavigation,
ChromeProjectNavigationNode,
ChromeProjectNavigationLink,
AppDeepLinkId,
AppId,
SideNavCompProps,
SideNavComponent,
ChromeSetProjectBreadcrumbsParams,
ChromeProjectBreadcrumb,
NodeDefinition,
NodeDefinitionWithChildren,
} from './project_navigation';
92 changes: 77 additions & 15 deletions packages/core/chrome/core-chrome-browser/src/project_navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,43 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

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 { AppId as MlApp, DeepLinkId as MlLink } from '@kbn/deeplinks-ml';
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 {
AppId as ObservabilityApp,
DeepLinkId as ObservabilityLink,
} from '@kbn/deeplinks-observability';

import type { ChromeBreadcrumb } from './breadcrumb';
import type { ChromeNavLink } from './nav_links';

/** @internal */
type AppId = string;

/** @internal */
type DeepLinkId = string;

/** @internal */
export type AppDeepLinkId = `${AppId}:${DeepLinkId}`;
/** @public */
export type AppId =
| DevToolsApp
| AnalyticsApp
| MlApp
| ManagementApp
| SearchApp
| ObservabilityApp;

/**
* @public
*
* App id or deeplink id
*/
export type ChromeProjectNavigationLink = AppId | AppDeepLinkId;
/** @public */
export type AppDeepLinkId =
| AnalyticsDeepLink
| DevToolsLink
| MlLink
| ManagementLink
| SearchLink
| ObservabilityLink;

/** @public */
export interface ChromeProjectNavigationNode {
Expand Down Expand Up @@ -77,3 +94,48 @@ export type ChromeProjectBreadcrumb = ChromeBreadcrumb;
export interface ChromeSetProjectBreadcrumbsParams {
absolute: boolean;
}

type NonEmptyArray<T> = [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<
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved the NodeDefinition and NodeDefinitionWithChildren from the shared-ux/chrome/navigation package to avoid a circular dependency.

LinkId extends AppDeepLinkId = AppDeepLinkId,
Id extends string = string,
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<NodeDefinition<LinkId, Id, ChildrenId>>;
/**
* Use href for absolute links only. Internal links should use "link".
*/
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 = string,
ChildrenID extends string = Id
> = NodeDefinition<LinkId, Id, ChildrenID> & {
children: Required<NodeDefinition<LinkId, Id, ChildrenID>>['children'];
};
8 changes: 7 additions & 1 deletion packages/core/chrome/core-chrome-browser/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
],
"kbn_references": [
"@kbn/core-mount-utils-browser",
"@kbn/core-application-common"
"@kbn/core-application-common",
"@kbn/deeplinks-devtools",
"@kbn/deeplinks-analytics",
"@kbn/deeplinks-ml",
"@kbn/deeplinks-management",
"@kbn/deeplinks-search",
"@kbn/deeplinks-observability"
],
"exclude": [
"target/**/*",
Expand Down
3 changes: 3 additions & 0 deletions packages/deeplinks/analytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/deeplinks-analytics

Empty package generated by @kbn/generate
13 changes: 13 additions & 0 deletions packages/deeplinks/analytics/constants.ts
Original file line number Diff line number Diff line change
@@ -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 = 'dashboards';

export const VISUALIZE_APP_ID = 'visualize';
13 changes: 13 additions & 0 deletions packages/deeplinks/analytics/deep_links.ts
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 11 additions & 0 deletions packages/deeplinks/analytics/index.ts
Original file line number Diff line number Diff line change
@@ -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 { DASHBOARD_APP_ID, DISCOVER_APP_ID, VISUALIZE_APP_ID } from './constants';

export type { AppId, DeepLinkId } from './deep_links';
13 changes: 13 additions & 0 deletions packages/deeplinks/analytics/jest.config.js
Original file line number Diff line number Diff line change
@@ -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: ['<rootDir>/packages/deeplinks/analytics'],
};
5 changes: 5 additions & 0 deletions packages/deeplinks/analytics/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/deeplinks-analytics",
"owner": "@elastic/kibana-data-discovery"
}
6 changes: 6 additions & 0 deletions packages/deeplinks/analytics/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@kbn/deeplinks-analytics",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0"
}
20 changes: 20 additions & 0 deletions packages/deeplinks/analytics/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"outDir": "target/types",
"types": [
"jest",
"node",
"react"
]
},
"include": [
"**/*.ts",
"**/*.tsx",
],
"exclude": [
"target/**/*"
],
"kbn_references": [
]
}
3 changes: 3 additions & 0 deletions packages/deeplinks/devtools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/deeplinks-devtools

Empty package generated by @kbn/generate
12 changes: 12 additions & 0 deletions packages/deeplinks/devtools/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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 { LinkId } from './deep_links';

export const DEV_TOOLS_APP_ID = 'dev_tools';

export const deepLinkIds: LinkId[] = ['searchprofiler', 'painless_lab', 'grokdebugger', 'console'];
15 changes: 15 additions & 0 deletions packages/deeplinks/devtools/deep_links.ts
Original file line number Diff line number Diff line change
@@ -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}`;
11 changes: 11 additions & 0 deletions packages/deeplinks/devtools/index.ts
Original file line number Diff line number Diff line change
@@ -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';
13 changes: 13 additions & 0 deletions packages/deeplinks/devtools/jest.config.js
Original file line number Diff line number Diff line change
@@ -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: ['<rootDir>/packages/deeplinks/devtools'],
};
5 changes: 5 additions & 0 deletions packages/deeplinks/devtools/kibana.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "shared-common",
"id": "@kbn/deeplinks-devtools",
"owner": "@elastic/platform-deployment-management"
}
6 changes: 6 additions & 0 deletions packages/deeplinks/devtools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "@kbn/deeplinks-devtools",
"private": true,
"version": "1.0.0",
"license": "SSPL-1.0 OR Elastic License 2.0"
}
Loading