From 4edb583c189b705e00dc388428fc1669ae0882df Mon Sep 17 00:00:00 2001 From: Anton Dosov Date: Mon, 17 Apr 2023 16:25:58 +0200 Subject: [PATCH] [Content Management] Remove dep from content_management -> saved_object_finder (#155013) ## Summary Follow up https://github.com/elastic/kibana/pull/154819, @mattkime pointed out a problem that cm can't depend on saved_object_finder https://github.com/elastic/kibana/pull/154819/files#diff-635bc20df585b656afebba3ebf338ff997e735df933f704cc5f253a74b3503ddR17 --- .github/CODEOWNERS | 1 + package.json | 1 + packages/kbn-saved-objects-settings/README.md | 3 +++ packages/kbn-saved-objects-settings/index.ts | 10 ++++++++++ .../kbn-saved-objects-settings/jest.config.js | 13 +++++++++++++ .../kbn-saved-objects-settings/kibana.jsonc | 5 +++++ .../kbn-saved-objects-settings/package.json | 6 ++++++ .../kbn-saved-objects-settings/tsconfig.json | 17 +++++++++++++++++ .../server/rpc/routes/routes.ts | 2 +- src/plugins/content_management/tsconfig.json | 2 +- .../saved_objects_finder/common/index.ts | 3 +-- src/plugins/saved_objects_finder/tsconfig.json | 1 + tsconfig.base.json | 2 ++ yarn.lock | 4 ++++ 14 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 packages/kbn-saved-objects-settings/README.md create mode 100644 packages/kbn-saved-objects-settings/index.ts create mode 100644 packages/kbn-saved-objects-settings/jest.config.js create mode 100644 packages/kbn-saved-objects-settings/kibana.jsonc create mode 100644 packages/kbn-saved-objects-settings/package.json create mode 100644 packages/kbn-saved-objects-settings/tsconfig.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 26be09f9bb2f0..a6a4ed6d9b210 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -529,6 +529,7 @@ test/plugin_functional/plugins/saved_objects_hidden_from_http_apis_type @elastic test/plugin_functional/plugins/saved_objects_hidden_type @elastic/kibana-core src/plugins/saved_objects_management @elastic/kibana-core src/plugins/saved_objects @elastic/kibana-core +packages/kbn-saved-objects-settings @elastic/appex-sharedux src/plugins/saved_objects_tagging_oss @elastic/appex-sharedux x-pack/plugins/saved_objects_tagging @elastic/appex-sharedux src/plugins/saved_search @elastic/kibana-data-discovery diff --git a/package.json b/package.json index 2b2f4ff6326f1..83660bd976f88 100644 --- a/package.json +++ b/package.json @@ -531,6 +531,7 @@ "@kbn/saved-objects-hidden-type-plugin": "link:test/plugin_functional/plugins/saved_objects_hidden_type", "@kbn/saved-objects-management-plugin": "link:src/plugins/saved_objects_management", "@kbn/saved-objects-plugin": "link:src/plugins/saved_objects", + "@kbn/saved-objects-settings": "link:packages/kbn-saved-objects-settings", "@kbn/saved-objects-tagging-oss-plugin": "link:src/plugins/saved_objects_tagging_oss", "@kbn/saved-objects-tagging-plugin": "link:x-pack/plugins/saved_objects_tagging", "@kbn/saved-search-plugin": "link:src/plugins/saved_search", diff --git a/packages/kbn-saved-objects-settings/README.md b/packages/kbn-saved-objects-settings/README.md new file mode 100644 index 0000000000000..48e2630354b02 --- /dev/null +++ b/packages/kbn-saved-objects-settings/README.md @@ -0,0 +1,3 @@ +# @kbn/saved-objects-settings + +Contains constants for some of saved objects related ui settings that had to be re-used between plugins without causing circular dependencies. diff --git a/packages/kbn-saved-objects-settings/index.ts b/packages/kbn-saved-objects-settings/index.ts new file mode 100644 index 0000000000000..f2a1aa7c06e54 --- /dev/null +++ b/packages/kbn-saved-objects-settings/index.ts @@ -0,0 +1,10 @@ +/* + * 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 PER_PAGE_SETTING = 'savedObjects:perPage'; +export const LISTING_LIMIT_SETTING = 'savedObjects:listingLimit'; diff --git a/packages/kbn-saved-objects-settings/jest.config.js b/packages/kbn-saved-objects-settings/jest.config.js new file mode 100644 index 0000000000000..562e1f12ecceb --- /dev/null +++ b/packages/kbn-saved-objects-settings/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/jest_node', + rootDir: '../..', + roots: ['/packages/kbn-saved-objects-settings'], +}; diff --git a/packages/kbn-saved-objects-settings/kibana.jsonc b/packages/kbn-saved-objects-settings/kibana.jsonc new file mode 100644 index 0000000000000..40486e1ef0cf1 --- /dev/null +++ b/packages/kbn-saved-objects-settings/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-common", + "id": "@kbn/saved-objects-settings", + "owner": "@elastic/appex-sharedux" +} diff --git a/packages/kbn-saved-objects-settings/package.json b/packages/kbn-saved-objects-settings/package.json new file mode 100644 index 0000000000000..38ef61439d47d --- /dev/null +++ b/packages/kbn-saved-objects-settings/package.json @@ -0,0 +1,6 @@ +{ + "name": "@kbn/saved-objects-settings", + "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/kbn-saved-objects-settings/tsconfig.json b/packages/kbn-saved-objects-settings/tsconfig.json new file mode 100644 index 0000000000000..2f9ddddbeea23 --- /dev/null +++ b/packages/kbn-saved-objects-settings/tsconfig.json @@ -0,0 +1,17 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node" + ] + }, + "include": [ + "**/*.ts", + ], + "exclude": [ + "target/**/*" + ], + "kbn_references": [] +} diff --git a/src/plugins/content_management/server/rpc/routes/routes.ts b/src/plugins/content_management/server/rpc/routes/routes.ts index 6d40e37d533c8..ea529aae11188 100644 --- a/src/plugins/content_management/server/rpc/routes/routes.ts +++ b/src/plugins/content_management/server/rpc/routes/routes.ts @@ -8,7 +8,7 @@ import { schema } from '@kbn/config-schema'; import type { IRouter } from '@kbn/core/server'; -import { LISTING_LIMIT_SETTING, PER_PAGE_SETTING } from '@kbn/saved-objects-finder-plugin/common'; +import { LISTING_LIMIT_SETTING, PER_PAGE_SETTING } from '@kbn/saved-objects-settings'; import { ProcedureName } from '../../../common'; import type { ContentRegistry } from '../../core'; import { MSearchService } from '../../core/msearch'; diff --git a/src/plugins/content_management/tsconfig.json b/src/plugins/content_management/tsconfig.json index 93aacaecff0c9..dd87f182de476 100644 --- a/src/plugins/content_management/tsconfig.json +++ b/src/plugins/content_management/tsconfig.json @@ -14,7 +14,7 @@ "@kbn/object-versioning", "@kbn/core-saved-objects-api-server-mocks", "@kbn/core-saved-objects-api-server", - "@kbn/saved-objects-finder-plugin", + "@kbn/saved-objects-settings", ], "exclude": [ "target/**/*", diff --git a/src/plugins/saved_objects_finder/common/index.ts b/src/plugins/saved_objects_finder/common/index.ts index 056d0b4638efc..8a0964edc100b 100644 --- a/src/plugins/saved_objects_finder/common/index.ts +++ b/src/plugins/saved_objects_finder/common/index.ts @@ -6,6 +6,5 @@ * Side Public License, v 1. */ -export const PER_PAGE_SETTING = 'savedObjects:perPage'; -export const LISTING_LIMIT_SETTING = 'savedObjects:listingLimit'; +export { PER_PAGE_SETTING, LISTING_LIMIT_SETTING } from '@kbn/saved-objects-settings'; export type { SavedObjectCommon, FindQueryHTTP, FindResponseHTTP, FinderAttributes } from './types'; diff --git a/src/plugins/saved_objects_finder/tsconfig.json b/src/plugins/saved_objects_finder/tsconfig.json index 813379f02a313..217f4f7f0dbe3 100644 --- a/src/plugins/saved_objects_finder/tsconfig.json +++ b/src/plugins/saved_objects_finder/tsconfig.json @@ -14,6 +14,7 @@ "@kbn/config-schema", "@kbn/core-ui-settings-browser", "@kbn/core-http-browser", + "@kbn/saved-objects-settings", ], "exclude": [ "target/**/*", diff --git a/tsconfig.base.json b/tsconfig.base.json index 85fa70f831719..71c2a3d250a51 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1052,6 +1052,8 @@ "@kbn/saved-objects-management-plugin/*": ["src/plugins/saved_objects_management/*"], "@kbn/saved-objects-plugin": ["src/plugins/saved_objects"], "@kbn/saved-objects-plugin/*": ["src/plugins/saved_objects/*"], + "@kbn/saved-objects-settings": ["packages/kbn-saved-objects-settings"], + "@kbn/saved-objects-settings/*": ["packages/kbn-saved-objects-settings/*"], "@kbn/saved-objects-tagging-oss-plugin": ["src/plugins/saved_objects_tagging_oss"], "@kbn/saved-objects-tagging-oss-plugin/*": ["src/plugins/saved_objects_tagging_oss/*"], "@kbn/saved-objects-tagging-plugin": ["x-pack/plugins/saved_objects_tagging"], diff --git a/yarn.lock b/yarn.lock index c480dd98324b0..365c976479508 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4841,6 +4841,10 @@ version "0.0.0" uid "" +"@kbn/saved-objects-settings@link:packages/kbn-saved-objects-settings": + version "0.0.0" + uid "" + "@kbn/saved-objects-tagging-oss-plugin@link:src/plugins/saved_objects_tagging_oss": version "0.0.0" uid ""