diff --git a/package.json b/package.json index 74e36e83621af..6230be14c7848 100644 --- a/package.json +++ b/package.json @@ -629,6 +629,7 @@ "@kbn/response-stream-plugin": "link:examples/response_stream", "@kbn/rison": "link:packages/kbn-rison", "@kbn/rollup-plugin": "link:x-pack/plugins/rollup", + "@kbn/router-utils": "link:packages/kbn-router-utils", "@kbn/routing-example-plugin": "link:examples/routing_example", "@kbn/rrule": "link:packages/kbn-rrule", "@kbn/rule-data-utils": "link:packages/kbn-rule-data-utils", diff --git a/packages/kbn-router-utils/README.md b/packages/kbn-router-utils/README.md new file mode 100644 index 0000000000000..970fea12dbb4e --- /dev/null +++ b/packages/kbn-router-utils/README.md @@ -0,0 +1,3 @@ +# @kbn/router-utils + +This package provides util functions when working with the router. diff --git a/packages/kbn-router-utils/index.ts b/packages/kbn-router-utils/index.ts new file mode 100644 index 0000000000000..f5ed5ed7e7604 --- /dev/null +++ b/packages/kbn-router-utils/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 { getRouterLinkProps } from './src/get_router_link_props'; diff --git a/packages/kbn-router-utils/jest.config.js b/packages/kbn-router-utils/jest.config.js new file mode 100644 index 0000000000000..32497360f9419 --- /dev/null +++ b/packages/kbn-router-utils/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/kbn-router-utils'], +}; diff --git a/packages/kbn-router-utils/kibana.jsonc b/packages/kbn-router-utils/kibana.jsonc new file mode 100644 index 0000000000000..c255dacb11c70 --- /dev/null +++ b/packages/kbn-router-utils/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/router-utils", + "owner": "@elastic/obs-ux-logs-team" +} diff --git a/packages/kbn-router-utils/package.json b/packages/kbn-router-utils/package.json new file mode 100644 index 0000000000000..d84ddd2c06bc2 --- /dev/null +++ b/packages/kbn-router-utils/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/router-utils", + "private": true, + "version": "1.0.0", + "license": "SSPL-1.0 OR Elastic License 2.0" +} \ No newline at end of file diff --git a/x-pack/plugins/observability_shared/public/utils/get_router_link_props.ts b/packages/kbn-router-utils/src/get_router_link_props/index.ts similarity index 83% rename from x-pack/plugins/observability_shared/public/utils/get_router_link_props.ts rename to packages/kbn-router-utils/src/get_router_link_props/index.ts index a325df1a7e86f..98f2c976ac8bd 100644 --- a/x-pack/plugins/observability_shared/public/utils/get_router_link_props.ts +++ b/packages/kbn-router-utils/src/get_router_link_props/index.ts @@ -1,8 +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; you may not use this file except in compliance with the Elastic License - * 2.0. + * 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. */ interface GetRouterLinkPropsDeps { diff --git a/packages/kbn-router-utils/tsconfig.json b/packages/kbn-router-utils/tsconfig.json new file mode 100644 index 0000000000000..dad708677fd87 --- /dev/null +++ b/packages/kbn-router-utils/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 e634fe61248a1..1ab03fcac05c9 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1246,6 +1246,8 @@ "@kbn/rison/*": ["packages/kbn-rison/*"], "@kbn/rollup-plugin": ["x-pack/plugins/rollup"], "@kbn/rollup-plugin/*": ["x-pack/plugins/rollup/*"], + "@kbn/router-utils": ["packages/kbn-router-utils"], + "@kbn/router-utils/*": ["packages/kbn-router-utils/*"], "@kbn/routing-example-plugin": ["examples/routing_example"], "@kbn/routing-example-plugin/*": ["examples/routing_example/*"], "@kbn/rrule": ["packages/kbn-rrule"], diff --git a/x-pack/plugins/dataset_quality/public/components/log_explorer_link.tsx b/x-pack/plugins/dataset_quality/public/components/log_explorer_link.tsx index 7aaf3a9493201..16559cbdf2de4 100644 --- a/x-pack/plugins/dataset_quality/public/components/log_explorer_link.tsx +++ b/x-pack/plugins/dataset_quality/public/components/log_explorer_link.tsx @@ -7,7 +7,7 @@ import { EuiLink } from '@elastic/eui'; import React from 'react'; -import { getRouterLinkProps } from '@kbn/observability-shared-plugin/public'; +import { getRouterLinkProps } from '@kbn/router-utils'; import { SingleDatasetLocatorParams, SINGLE_DATASET_LOCATOR_ID, diff --git a/x-pack/plugins/dataset_quality/tsconfig.json b/x-pack/plugins/dataset_quality/tsconfig.json index e6b7c50407f03..65f77bac100aa 100644 --- a/x-pack/plugins/dataset_quality/tsconfig.json +++ b/x-pack/plugins/dataset_quality/tsconfig.json @@ -26,7 +26,8 @@ "@kbn/io-ts-utils", "@kbn/observability-plugin", "@kbn/es-types", - "@kbn/deeplinks-observability" + "@kbn/deeplinks-observability", + "@kbn/router-utils", ], "exclude": [ "target/**/*", diff --git a/x-pack/plugins/log_explorer/public/components/dataset_selector/sub_components/esql_selector.tsx b/x-pack/plugins/log_explorer/public/components/dataset_selector/sub_components/esql_selector.tsx index c02d0c5125372..65ca1f1fd22e8 100644 --- a/x-pack/plugins/log_explorer/public/components/dataset_selector/sub_components/esql_selector.tsx +++ b/x-pack/plugins/log_explorer/public/components/dataset_selector/sub_components/esql_selector.tsx @@ -6,8 +6,8 @@ */ import { EuiBadge, EuiButton, EuiHorizontalRule } from '@elastic/eui'; -import { getRouterLinkProps } from '@kbn/observability-shared-plugin/public'; import React from 'react'; +import { getRouterLinkProps } from '@kbn/router-utils'; import { DiscoverEsqlUrlProps } from '../../../hooks/use_esql'; import { technicalPreview, tryEsql } from '../constants'; diff --git a/x-pack/plugins/log_explorer/tsconfig.json b/x-pack/plugins/log_explorer/tsconfig.json index 2e74959d2c014..4f8cd2ecb3d13 100644 --- a/x-pack/plugins/log_explorer/tsconfig.json +++ b/x-pack/plugins/log_explorer/tsconfig.json @@ -40,7 +40,8 @@ "@kbn/xstate-utils", "@kbn/ecs", "@kbn/react-field", - "@kbn/observability-shared-plugin" + "@kbn/observability-shared-plugin", + "@kbn/router-utils", ], "exclude": [ "target/**/*" diff --git a/x-pack/plugins/observability_log_explorer/public/components/discover_link.tsx b/x-pack/plugins/observability_log_explorer/public/components/discover_link.tsx index acb6151a214fe..d2195124bc292 100644 --- a/x-pack/plugins/observability_log_explorer/public/components/discover_link.tsx +++ b/x-pack/plugins/observability_log_explorer/public/components/discover_link.tsx @@ -13,7 +13,7 @@ import { getDiscoverColumnsFromDisplayOptions, getDiscoverFiltersFromState, } from '@kbn/log-explorer-plugin/public'; -import { getRouterLinkProps } from '@kbn/observability-shared-plugin/public'; +import { getRouterLinkProps } from '@kbn/router-utils'; import { MatchedStateFromActor } from '@kbn/xstate-utils'; import { useActor } from '@xstate/react'; import React, { useMemo } from 'react'; diff --git a/x-pack/plugins/observability_log_explorer/public/components/onboarding_link.tsx b/x-pack/plugins/observability_log_explorer/public/components/onboarding_link.tsx index 7c459e4a4342c..261405c766024 100644 --- a/x-pack/plugins/observability_log_explorer/public/components/onboarding_link.tsx +++ b/x-pack/plugins/observability_log_explorer/public/components/onboarding_link.tsx @@ -10,7 +10,7 @@ import { ObservabilityOnboardingLocatorParams, OBSERVABILITY_ONBOARDING_LOCATOR, } from '@kbn/deeplinks-observability/locators'; -import { getRouterLinkProps } from '@kbn/observability-shared-plugin/public'; +import { getRouterLinkProps } from '@kbn/router-utils'; import { BrowserUrlService } from '@kbn/share-plugin/public'; import React from 'react'; import { onboardingLinkTitle } from '../../common/translations'; diff --git a/x-pack/plugins/observability_log_explorer/tsconfig.json b/x-pack/plugins/observability_log_explorer/tsconfig.json index be61fb9926a8c..0c03040b4203b 100644 --- a/x-pack/plugins/observability_log_explorer/tsconfig.json +++ b/x-pack/plugins/observability_log_explorer/tsconfig.json @@ -35,7 +35,8 @@ "@kbn/shared-ux-router", "@kbn/shared-ux-utility", "@kbn/ui-theme", - "@kbn/xstate-utils" + "@kbn/xstate-utils", + "@kbn/router-utils", ], "exclude": [ "target/**/*" diff --git a/x-pack/plugins/observability_shared/public/index.ts b/x-pack/plugins/observability_shared/public/index.ts index 5f999bbfd2de7..ecd00f627321b 100644 --- a/x-pack/plugins/observability_shared/public/index.ts +++ b/x-pack/plugins/observability_shared/public/index.ts @@ -67,8 +67,6 @@ export type { ApmIndicesConfig, UXMetrics } from './types'; export { noCasesPermissions, allCasesPermissions } from './utils/cases_permissions'; -export { getRouterLinkProps } from './utils/get_router_link_props'; - export { type ObservabilityActionContextMenuItemProps, getContextMenuItemsFromActions, diff --git a/yarn.lock b/yarn.lock index 1bcbde9d29c4a..66471e6c1b176 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5427,6 +5427,10 @@ version "0.0.0" uid "" +"@kbn/router-utils@link:packages/kbn-router-utils": + version "0.0.0" + uid "" + "@kbn/routing-example-plugin@link:examples/routing_example": version "0.0.0" uid ""