From a947e9262f04018a57c34930566ff16e9a359572 Mon Sep 17 00:00:00 2001 From: neptunian Date: Thu, 19 Sep 2024 14:35:19 -0400 Subject: [PATCH 1/7] new data usage plugin --- package.json | 1 + .../cards_navigation/src/consts.tsx | 8 ++ .../cards_navigation/src/types.ts | 1 + tsconfig.base.json | 2 + x-pack/plugins/data_usage/README.md | 3 + x-pack/plugins/data_usage/common/index.ts | 13 +++ x-pack/plugins/data_usage/jest.config.js | 15 ++++ x-pack/plugins/data_usage/kibana.jsonc | 16 ++++ .../plugins/data_usage/public/application.tsx | 83 +++++++++++++++++++ x-pack/plugins/data_usage/public/index.ts | 26 ++++++ x-pack/plugins/data_usage/public/plugin.ts | 61 ++++++++++++++ x-pack/plugins/data_usage/public/types.ts | 27 ++++++ .../data_usage/public/utils/use_kibana.tsx | 53 ++++++++++++ x-pack/plugins/data_usage/server/config.ts | 14 ++++ x-pack/plugins/data_usage/server/index.ts | 36 ++++++++ x-pack/plugins/data_usage/server/plugin.ts | 41 +++++++++ x-pack/plugins/data_usage/server/types.ts | 16 ++++ x-pack/plugins/data_usage/tsconfig.json | 22 +++++ yarn.lock | 4 + 19 files changed, 442 insertions(+) create mode 100755 x-pack/plugins/data_usage/README.md create mode 100644 x-pack/plugins/data_usage/common/index.ts create mode 100644 x-pack/plugins/data_usage/jest.config.js create mode 100644 x-pack/plugins/data_usage/kibana.jsonc create mode 100644 x-pack/plugins/data_usage/public/application.tsx create mode 100644 x-pack/plugins/data_usage/public/index.ts create mode 100644 x-pack/plugins/data_usage/public/plugin.ts create mode 100644 x-pack/plugins/data_usage/public/types.ts create mode 100644 x-pack/plugins/data_usage/public/utils/use_kibana.tsx create mode 100644 x-pack/plugins/data_usage/server/config.ts create mode 100644 x-pack/plugins/data_usage/server/index.ts create mode 100644 x-pack/plugins/data_usage/server/plugin.ts create mode 100644 x-pack/plugins/data_usage/server/types.ts create mode 100644 x-pack/plugins/data_usage/tsconfig.json diff --git a/package.json b/package.json index 49b45c263c020..e128e63105594 100644 --- a/package.json +++ b/package.json @@ -415,6 +415,7 @@ "@kbn/data-search-plugin": "link:test/plugin_functional/plugins/data_search", "@kbn/data-service": "link:packages/kbn-data-service", "@kbn/data-stream-adapter": "link:packages/kbn-data-stream-adapter", + "@kbn/data-usage-plugin": "link:x-pack/plugins/data_usage", "@kbn/data-view-editor-plugin": "link:src/plugins/data_view_editor", "@kbn/data-view-field-editor-example-plugin": "link:examples/data_view_field_editor_example", "@kbn/data-view-field-editor-plugin": "link:src/plugins/data_view_field_editor", diff --git a/packages/kbn-management/cards_navigation/src/consts.tsx b/packages/kbn-management/cards_navigation/src/consts.tsx index 73bc2638c4e98..16e655c5510ad 100644 --- a/packages/kbn-management/cards_navigation/src/consts.tsx +++ b/packages/kbn-management/cards_navigation/src/consts.tsx @@ -72,6 +72,14 @@ export const appDefinitions: Record = { icon: 'documents', }, + [AppIds.DATA_USAGE]: { + category: appCategories.DATA, + description: i18n.translate('management.landing.withCardNavigation.dataUsageDescription', { + defaultMessage: 'View data usage and retention.', + }), + icon: 'documents', + }, + [AppIds.RULES]: { category: appCategories.ALERTS, description: i18n.translate('management.landing.withCardNavigation.rulesDescription', { diff --git a/packages/kbn-management/cards_navigation/src/types.ts b/packages/kbn-management/cards_navigation/src/types.ts index e53aadabc9eaa..5c14bc0755f1c 100644 --- a/packages/kbn-management/cards_navigation/src/types.ts +++ b/packages/kbn-management/cards_navigation/src/types.ts @@ -31,6 +31,7 @@ export enum AppIds { API_KEYS = 'api_keys', DATA_QUALITY = 'data_quality', SPACES = 'spaces', + DATA_USAGE = 'data_usage', } // Create new type that is a union of all the appId values diff --git a/tsconfig.base.json b/tsconfig.base.json index ae8b6c2c2a95f..d3269193d313f 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -690,6 +690,8 @@ "@kbn/data-service/*": ["packages/kbn-data-service/*"], "@kbn/data-stream-adapter": ["packages/kbn-data-stream-adapter"], "@kbn/data-stream-adapter/*": ["packages/kbn-data-stream-adapter/*"], + "@kbn/data-usage-plugin": ["x-pack/plugins/data_usage"], + "@kbn/data-usage-plugin/*": ["x-pack/plugins/data_usage/*"], "@kbn/data-view-editor-plugin": ["src/plugins/data_view_editor"], "@kbn/data-view-editor-plugin/*": ["src/plugins/data_view_editor/*"], "@kbn/data-view-field-editor-example-plugin": ["examples/data_view_field_editor_example"], diff --git a/x-pack/plugins/data_usage/README.md b/x-pack/plugins/data_usage/README.md new file mode 100755 index 0000000000000..7c0056ff5780d --- /dev/null +++ b/x-pack/plugins/data_usage/README.md @@ -0,0 +1,3 @@ +# dataUsage +Serverless only plugin for users to view data usage + diff --git a/x-pack/plugins/data_usage/common/index.ts b/x-pack/plugins/data_usage/common/index.ts new file mode 100644 index 0000000000000..4b6f899b58d37 --- /dev/null +++ b/x-pack/plugins/data_usage/common/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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { i18n } from '@kbn/i18n'; + +export const PLUGIN_ID = 'data_usage'; +export const PLUGIN_NAME = i18n.translate('xpack.dataUsage.name', { + defaultMessage: 'Data Usage', +}); diff --git a/x-pack/plugins/data_usage/jest.config.js b/x-pack/plugins/data_usage/jest.config.js new file mode 100644 index 0000000000000..f73ddf7ec31ee --- /dev/null +++ b/x-pack/plugins/data_usage/jest.config.js @@ -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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../..', + roots: ['/x-pack/plugins/data_usage'], + coverageDirectory: '/target/kibana-coverage/jest/x-pack/plugins/data_usage', + coverageReporters: ['text', 'html'], + collectCoverageFrom: ['/x-pack/plugins/datas_usage/{common,public}/**/*.{ts,tsx}'], +}; diff --git a/x-pack/plugins/data_usage/kibana.jsonc b/x-pack/plugins/data_usage/kibana.jsonc new file mode 100644 index 0000000000000..9b0f2d193925e --- /dev/null +++ b/x-pack/plugins/data_usage/kibana.jsonc @@ -0,0 +1,16 @@ +{ + "type": "plugin", + "id": "@kbn/data-usage-plugin", + "owner": ["@elastic/obs-ai-assistant", "@elastic/security-solution"], + "plugin": { + "id": "dataUsage", + "server": true, + "browser": true, + "configPath": ["xpack", "dataUsage"], + "requiredPlugins": ["home", "management", "features", "share"], + "optionalPlugins": [], + "requiredBundles": [ + "kibanaReact", + ], + } +} diff --git a/x-pack/plugins/data_usage/public/application.tsx b/x-pack/plugins/data_usage/public/application.tsx new file mode 100644 index 0000000000000..2840352aebd13 --- /dev/null +++ b/x-pack/plugins/data_usage/public/application.tsx @@ -0,0 +1,83 @@ +/* + * 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. + */ + +import { CoreStart } from '@kbn/core/public'; +import { ManagementAppMountParams } from '@kbn/management-plugin/public'; +import React from 'react'; +import ReactDOM from 'react-dom'; +import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; +import { Route, Router, Routes } from '@kbn/shared-ux-router'; +import { useExecutionContext } from '@kbn/kibana-react-plugin/public'; +import { PerformanceContextProvider } from '@kbn/ebt-tools'; +import { useKibanaContextForPluginProvider } from './utils/use_kibana'; +import { AppPluginStartDependencies, DataUsagePluginStart } from './types'; +import { PLUGIN_ID } from '../common'; + +export const renderApp = ( + core: CoreStart, + plugins: AppPluginStartDependencies, + pluginStart: DataUsagePluginStart, + params: ManagementAppMountParams +) => { + ReactDOM.render( + , + params.element + ); + + return () => { + ReactDOM.unmountComponentAtNode(params.element); + }; +}; + +const AppWithExecutionContext = ({ + core, + params, +}: { + core: CoreStart; + params: ManagementAppMountParams; +}) => { + const { executionContext } = core; + + useExecutionContext(executionContext, { + type: 'application', + page: PLUGIN_ID, + }); + + return ( + + + +
Data Usage
} /> +
+
+
+ ); +}; + +interface AppProps { + core: CoreStart; + plugins: AppPluginStartDependencies; + pluginStart: DataUsagePluginStart; + params: ManagementAppMountParams; +} + +const App = ({ core, plugins, pluginStart, params }: AppProps) => { + const KibanaContextProviderForPlugin = useKibanaContextForPluginProvider( + core, + plugins, + pluginStart, + params + ); + + return ( + + + + + + ); +}; diff --git a/x-pack/plugins/data_usage/public/index.ts b/x-pack/plugins/data_usage/public/index.ts new file mode 100644 index 0000000000000..50f14073e14ae --- /dev/null +++ b/x-pack/plugins/data_usage/public/index.ts @@ -0,0 +1,26 @@ +/* + * 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. + */ + +import type { PluginInitializer, PluginInitializerContext } from '@kbn/core/public'; +import type { + DataUsagePublicSetup, + DataUsagePublicStart, + DataUsageSetupDependencies, + DataUsageStartDependencies, + ConfigSchema, +} from './types'; +import { DataUsagePlugin } from './plugin'; + +export type { DataUsagePublicSetup, DataUsagePublicStart } from './types'; + +export const plugin: PluginInitializer< + DataUsagePublicSetup, + DataUsagePublicStart, + DataUsageSetupDependencies, + DataUsageStartDependencies +> = (pluginInitializerContext: PluginInitializerContext) => + new DataUsagePlugin(pluginInitializerContext); diff --git a/x-pack/plugins/data_usage/public/plugin.ts b/x-pack/plugins/data_usage/public/plugin.ts new file mode 100644 index 0000000000000..e32f81dcd0e86 --- /dev/null +++ b/x-pack/plugins/data_usage/public/plugin.ts @@ -0,0 +1,61 @@ +/* + * 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. + */ + +import { CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; +import { ManagementAppMountParams } from '@kbn/management-plugin/public'; +import type { PluginInitializerContext } from '@kbn/core/public'; +import { + DataUsagePublicSetup, + DataUsagePublicStart, + DataUsageStartDependencies, + DataUsageSetupDependencies, +} from './types'; +import { PLUGIN_ID, PLUGIN_NAME } from '../common'; + +export class DataUsagePlugin + implements + Plugin< + DataUsagePublicSetup, + DataUsagePublicStart, + DataUsageSetupDependencies, + DataUsageStartDependencies + > +{ + private isServerless: boolean = false; + constructor(initializerContext: PluginInitializerContext) { + this.isServerless = initializerContext.env.packageInfo.buildFlavor === 'serverless'; + } + public setup( + core: CoreSetup, + plugins: DataUsageSetupDependencies + ): DataUsagePublicSetup { + const { management } = plugins; + if (!this.isServerless) return {}; + management.sections.section.data.registerApp({ + id: PLUGIN_ID, + title: PLUGIN_NAME, + order: 6, + keywords: ['data usage', 'usage'], + async mount(params: ManagementAppMountParams) { + const [{ renderApp }, [coreStart, pluginsStartDeps, pluginStart]] = await Promise.all([ + import('./application'), + core.getStartServices(), + ]); + + return renderApp(coreStart, pluginsStartDeps, pluginStart, params); + }, + }); + + return {}; + } + + public start(_core: CoreStart): DataUsagePublicStart { + return {}; + } + + public stop() {} +} diff --git a/x-pack/plugins/data_usage/public/types.ts b/x-pack/plugins/data_usage/public/types.ts new file mode 100644 index 0000000000000..e65865dc31821 --- /dev/null +++ b/x-pack/plugins/data_usage/public/types.ts @@ -0,0 +1,27 @@ +/* + * 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. + */ + +import { ManagementSetup, ManagementStart } from '@kbn/management-plugin/public'; +import { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public'; + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface DataUsagePublicSetup {} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface DataUsagePublicStart {} + +export interface DataUsageSetupDependencies { + management: ManagementSetup; + share: SharePluginSetup; +} + +export interface DataUsageStartDependencies { + management: ManagementStart; + share: SharePluginStart; +} +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface ConfigSchema {} diff --git a/x-pack/plugins/data_usage/public/utils/use_kibana.tsx b/x-pack/plugins/data_usage/public/utils/use_kibana.tsx new file mode 100644 index 0000000000000..f24a5337e4931 --- /dev/null +++ b/x-pack/plugins/data_usage/public/utils/use_kibana.tsx @@ -0,0 +1,53 @@ +/* + * 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. + */ + +import { CoreStart } from '@kbn/core/public'; +import { + createKibanaReactContext, + KibanaReactContextValue, + useKibana, +} from '@kbn/kibana-react-plugin/public'; +import { ManagementAppMountParams } from '@kbn/management-plugin/public'; +import { useMemo } from 'react'; +import { AppPluginStartDependencies, DataUsagePluginStart } from '../types'; + +export type PluginKibanaContextValue = CoreStart & + AppPluginStartDependencies & + DataUsagePluginStart & { + appParams: ManagementAppMountParams; + }; + +export const createKibanaContextForPlugin = ( + core: CoreStart, + plugins: AppPluginStartDependencies, + pluginStart: DataUsagePluginStart, + appParams: ManagementAppMountParams +) => { + return createKibanaReactContext({ + ...core, + ...plugins, + ...pluginStart, + appParams, + }); +}; + +export const useKibanaContextForPlugin = + useKibana as () => KibanaReactContextValue; + +export const useKibanaContextForPluginProvider = ( + core: CoreStart, + plugins: AppPluginStartDependencies, + pluginStart: DataUsagePluginStart, + appParams: ManagementAppMountParams +) => { + const { Provider } = useMemo( + () => createKibanaContextForPlugin(core, plugins, pluginStart, appParams), + [appParams, core, pluginStart, plugins] + ); + + return Provider; +}; diff --git a/x-pack/plugins/data_usage/server/config.ts b/x-pack/plugins/data_usage/server/config.ts new file mode 100644 index 0000000000000..6453cce4f4d56 --- /dev/null +++ b/x-pack/plugins/data_usage/server/config.ts @@ -0,0 +1,14 @@ +/* + * 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. + */ + +import { schema, type TypeOf } from '@kbn/config-schema'; + +export const config = schema.object({ + enabled: schema.boolean({ defaultValue: false }), +}); + +export type DataUsageConfig = TypeOf; diff --git a/x-pack/plugins/data_usage/server/index.ts b/x-pack/plugins/data_usage/server/index.ts new file mode 100644 index 0000000000000..3aa49a184d003 --- /dev/null +++ b/x-pack/plugins/data_usage/server/index.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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import type { + PluginInitializer, + PluginInitializerContext, + PluginConfigDescriptor, +} from '@kbn/core/server'; +import { DataUsageConfig } from './config'; + +import { DataUsagePlugin } from './plugin'; +import type { + DataUsageServerSetup, + DataUsageServerStart, + DataUsageSetupDependencies, + DataUsageStartDependencies, +} from './types'; + +import { config as configSchema } from './config'; + +export type { DataUsageServerSetup, DataUsageServerStart }; + +export const config: PluginConfigDescriptor = { + schema: configSchema, +}; + +export const plugin: PluginInitializer< + DataUsageServerSetup, + DataUsageServerStart, + DataUsageSetupDependencies, + DataUsageStartDependencies +> = async (pluginInitializerContext: PluginInitializerContext) => + await new DataUsagePlugin(pluginInitializerContext); diff --git a/x-pack/plugins/data_usage/server/plugin.ts b/x-pack/plugins/data_usage/server/plugin.ts new file mode 100644 index 0000000000000..41c2ea67117b7 --- /dev/null +++ b/x-pack/plugins/data_usage/server/plugin.ts @@ -0,0 +1,41 @@ +/* + * 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. + */ + +import type { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from '@kbn/core/server'; +import type { Logger } from '@kbn/logging'; +import { DataUsageConfig } from './config'; +import type { + DataUsageServerSetup, + DataUsageServerStart, + DataUsageSetupDependencies, + DataUsageStartDependencies, +} from './types'; + +export class DataUsagePlugin + implements + Plugin< + DataUsageServerSetup, + DataUsageServerStart, + DataUsageSetupDependencies, + DataUsageStartDependencies + > +{ + logger: Logger; + constructor(context: PluginInitializerContext) { + this.logger = context.logger.get(); + } + // TODO: check for serverless + setup(coreSetup: CoreSetup, pluginsSetup: DataUsageSetupDependencies): DataUsageServerSetup { + return {}; + } + + start(coreStart: CoreStart, pluginsStart: DataUsageStartDependencies): DataUsageServerStart { + return {}; + } + + public stop() {} +} diff --git a/x-pack/plugins/data_usage/server/types.ts b/x-pack/plugins/data_usage/server/types.ts new file mode 100644 index 0000000000000..9f43ae2d3c298 --- /dev/null +++ b/x-pack/plugins/data_usage/server/types.ts @@ -0,0 +1,16 @@ +/* + * 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. + */ + +/* eslint-disable @typescript-eslint/no-empty-interface*/ + +export interface DataUsageSetupDependencies {} + +export interface DataUsageStartDependencies {} + +export interface DataUsageServerSetup {} + +export interface DataUsageServerStart {} diff --git a/x-pack/plugins/data_usage/tsconfig.json b/x-pack/plugins/data_usage/tsconfig.json new file mode 100644 index 0000000000000..8aa6ac2ceb7c9 --- /dev/null +++ b/x-pack/plugins/data_usage/tsconfig.json @@ -0,0 +1,22 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types" + }, + "include": [ + "index.ts", + "common/**/*", + "public/**/*", + "server/**/*", + "../../../typings/**/*" + ], + "kbn_references": [ + "@kbn/core", + "@kbn/i18n", + "@kbn/io-ts-utils", + "@kbn/kibana-react-plugin", + "@kbn/kibana-utils-plugin", + "@kbn/i18n-react", + ], + "exclude": ["target/**/*"] +} diff --git a/yarn.lock b/yarn.lock index 13852c94782c1..e08c8365eab51 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4658,6 +4658,10 @@ version "0.0.0" uid "" +"@kbn/data-usage-plugin@link:x-pack/plugins/data_usage": + version "0.0.0" + uid "" + "@kbn/data-view-editor-plugin@link:src/plugins/data_view_editor": version "0.0.0" uid "" From bcd272920746225c71d1e992f1a88ba1037c33f5 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 19 Sep 2024 18:50:07 +0000 Subject: [PATCH 2/7] [CI] Auto-commit changed files from 'node scripts/lint_packages --fix' --- .github/CODEOWNERS | 1 + docs/developer/plugin-list.asciidoc | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 76dccf659fb54..0a7d4c318f85f 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -348,6 +348,7 @@ x-pack/plugins/data_quality @elastic/obs-ux-logs-team test/plugin_functional/plugins/data_search @elastic/kibana-data-discovery packages/kbn-data-service @elastic/kibana-visualizations @elastic/kibana-data-discovery packages/kbn-data-stream-adapter @elastic/security-threat-hunting-explore +x-pack/plugins/data_usage @elastic/obs-ai-assistant @elastic/security-solution src/plugins/data_view_editor @elastic/kibana-data-discovery examples/data_view_field_editor_example @elastic/kibana-data-discovery src/plugins/data_view_field_editor @elastic/kibana-data-discovery diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 7e31cd50aeb81..42cc79a9fda9b 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -536,6 +536,10 @@ Plugin server-side only. Plugin has three main functions: |In order to make ongoing maintenance of log collection easy we want to introduce the concept of data set quality, where users can easily get an overview on the data sets they have with information such as integration, size, last activity, among others. +|{kib-repo}blob/{branch}/x-pack/plugins/data_usage/README.md[dataUsage] +|Serverless only plugin for users to view data usage + + |{kib-repo}blob/{branch}/x-pack/plugins/data_visualizer/README.md[dataVisualizer] |The data_visualizer plugin enables you to explore the fields in your data. From f34dcbe963a7190d7727c5d6e9176f88ea54f386 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 19 Sep 2024 19:08:07 +0000 Subject: [PATCH 3/7] [CI] Auto-commit changed files from 'node scripts/yarn_deduplicate' --- x-pack/plugins/data_usage/tsconfig.json | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/data_usage/tsconfig.json b/x-pack/plugins/data_usage/tsconfig.json index 8aa6ac2ceb7c9..ebc023568cf88 100644 --- a/x-pack/plugins/data_usage/tsconfig.json +++ b/x-pack/plugins/data_usage/tsconfig.json @@ -13,10 +13,14 @@ "kbn_references": [ "@kbn/core", "@kbn/i18n", - "@kbn/io-ts-utils", "@kbn/kibana-react-plugin", - "@kbn/kibana-utils-plugin", - "@kbn/i18n-react", + "@kbn/management-plugin", + "@kbn/react-kibana-context-render", + "@kbn/shared-ux-router", + "@kbn/ebt-tools", + "@kbn/share-plugin", + "@kbn/config-schema", + "@kbn/logging", ], "exclude": ["target/**/*"] } From e1a5b3270240b2c5e5dc080743e1579646e68e2c Mon Sep 17 00:00:00 2001 From: neptunian Date: Thu, 19 Sep 2024 15:47:43 -0400 Subject: [PATCH 4/7] add size limit --- packages/kbn-optimizer/limits.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index a7d94a423d606..91ad88b8a5294 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -28,6 +28,7 @@ pageLoadAssetSize: dashboardEnhanced: 65646 data: 454087 dataQuality: 19384 + dataUsage: 30000 datasetQuality: 52000 dataViewEditor: 28082 dataViewFieldEditor: 42021 From d1152ce87a70eca5f7d2f6e7a577f92fa20acb2c Mon Sep 17 00:00:00 2001 From: neptunian Date: Thu, 19 Sep 2024 16:09:44 -0400 Subject: [PATCH 5/7] add to .i18nrc.json --- x-pack/.i18nrc.json | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index a36cc693a6b71..00290ad234e82 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -31,6 +31,7 @@ "xpack.dashboard": "plugins/dashboard_enhanced", "xpack.dataQuality": "plugins/data_quality", "xpack.datasetQuality": "plugins/observability_solution/dataset_quality", + "xpack.dataUsage": "plugins/observability_solution/data_usage", "xpack.discover": "plugins/discover_enhanced", "xpack.crossClusterReplication": "plugins/cross_cluster_replication", "xpack.elasticAssistant": "packages/kbn-elastic-assistant", From c5c8d50f78ea759abb97e6824d4c16e48de2c38f Mon Sep 17 00:00:00 2001 From: neptunian Date: Thu, 19 Sep 2024 16:11:01 -0400 Subject: [PATCH 6/7] remove o11y path from i18nrc path --- x-pack/.i18nrc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index 00290ad234e82..8082fa6f8ede2 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -31,7 +31,7 @@ "xpack.dashboard": "plugins/dashboard_enhanced", "xpack.dataQuality": "plugins/data_quality", "xpack.datasetQuality": "plugins/observability_solution/dataset_quality", - "xpack.dataUsage": "plugins/observability_solution/data_usage", + "xpack.dataUsage": "plugins/data_usage", "xpack.discover": "plugins/discover_enhanced", "xpack.crossClusterReplication": "plugins/cross_cluster_replication", "xpack.elasticAssistant": "packages/kbn-elastic-assistant", From bd5eeecc4ee1955c6560caf72188cb1bc96da089 Mon Sep 17 00:00:00 2001 From: neptunian Date: Thu, 19 Sep 2024 18:36:32 -0400 Subject: [PATCH 7/7] fixes and renaming --- packages/kbn-optimizer/limits.yml | 2 +- x-pack/plugins/data_usage/public/application.tsx | 10 +++++----- x-pack/plugins/data_usage/public/index.ts | 3 +-- x-pack/plugins/data_usage/public/plugin.ts | 6 ------ .../plugins/data_usage/public/utils/use_kibana.tsx | 14 +++++++------- x-pack/plugins/data_usage/server/plugin.ts | 1 - 6 files changed, 14 insertions(+), 22 deletions(-) diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index 91ad88b8a5294..a9ac21100f865 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -28,8 +28,8 @@ pageLoadAssetSize: dashboardEnhanced: 65646 data: 454087 dataQuality: 19384 - dataUsage: 30000 datasetQuality: 52000 + dataUsage: 30000 dataViewEditor: 28082 dataViewFieldEditor: 42021 dataViewManagement: 5300 diff --git a/x-pack/plugins/data_usage/public/application.tsx b/x-pack/plugins/data_usage/public/application.tsx index 2840352aebd13..1e6c35c4b8f0a 100644 --- a/x-pack/plugins/data_usage/public/application.tsx +++ b/x-pack/plugins/data_usage/public/application.tsx @@ -14,13 +14,13 @@ import { Route, Router, Routes } from '@kbn/shared-ux-router'; import { useExecutionContext } from '@kbn/kibana-react-plugin/public'; import { PerformanceContextProvider } from '@kbn/ebt-tools'; import { useKibanaContextForPluginProvider } from './utils/use_kibana'; -import { AppPluginStartDependencies, DataUsagePluginStart } from './types'; +import { DataUsageStartDependencies, DataUsagePublicStart } from './types'; import { PLUGIN_ID } from '../common'; export const renderApp = ( core: CoreStart, - plugins: AppPluginStartDependencies, - pluginStart: DataUsagePluginStart, + plugins: DataUsageStartDependencies, + pluginStart: DataUsagePublicStart, params: ManagementAppMountParams ) => { ReactDOM.render( @@ -60,8 +60,8 @@ const AppWithExecutionContext = ({ interface AppProps { core: CoreStart; - plugins: AppPluginStartDependencies; - pluginStart: DataUsagePluginStart; + plugins: DataUsageStartDependencies; + pluginStart: DataUsagePublicStart; params: ManagementAppMountParams; } diff --git a/x-pack/plugins/data_usage/public/index.ts b/x-pack/plugins/data_usage/public/index.ts index 50f14073e14ae..e18b801a6a38f 100644 --- a/x-pack/plugins/data_usage/public/index.ts +++ b/x-pack/plugins/data_usage/public/index.ts @@ -22,5 +22,4 @@ export const plugin: PluginInitializer< DataUsagePublicStart, DataUsageSetupDependencies, DataUsageStartDependencies -> = (pluginInitializerContext: PluginInitializerContext) => - new DataUsagePlugin(pluginInitializerContext); +> = (pluginInitializerContext: PluginInitializerContext) => new DataUsagePlugin(); diff --git a/x-pack/plugins/data_usage/public/plugin.ts b/x-pack/plugins/data_usage/public/plugin.ts index e32f81dcd0e86..aa3b02c2b671b 100644 --- a/x-pack/plugins/data_usage/public/plugin.ts +++ b/x-pack/plugins/data_usage/public/plugin.ts @@ -7,7 +7,6 @@ import { CoreSetup, CoreStart, Plugin } from '@kbn/core/public'; import { ManagementAppMountParams } from '@kbn/management-plugin/public'; -import type { PluginInitializerContext } from '@kbn/core/public'; import { DataUsagePublicSetup, DataUsagePublicStart, @@ -25,16 +24,11 @@ export class DataUsagePlugin DataUsageStartDependencies > { - private isServerless: boolean = false; - constructor(initializerContext: PluginInitializerContext) { - this.isServerless = initializerContext.env.packageInfo.buildFlavor === 'serverless'; - } public setup( core: CoreSetup, plugins: DataUsageSetupDependencies ): DataUsagePublicSetup { const { management } = plugins; - if (!this.isServerless) return {}; management.sections.section.data.registerApp({ id: PLUGIN_ID, title: PLUGIN_NAME, diff --git a/x-pack/plugins/data_usage/public/utils/use_kibana.tsx b/x-pack/plugins/data_usage/public/utils/use_kibana.tsx index f24a5337e4931..9575a8b8bbd21 100644 --- a/x-pack/plugins/data_usage/public/utils/use_kibana.tsx +++ b/x-pack/plugins/data_usage/public/utils/use_kibana.tsx @@ -13,18 +13,18 @@ import { } from '@kbn/kibana-react-plugin/public'; import { ManagementAppMountParams } from '@kbn/management-plugin/public'; import { useMemo } from 'react'; -import { AppPluginStartDependencies, DataUsagePluginStart } from '../types'; +import { DataUsageStartDependencies, DataUsagePublicStart } from '../types'; export type PluginKibanaContextValue = CoreStart & - AppPluginStartDependencies & - DataUsagePluginStart & { + DataUsageStartDependencies & + DataUsagePublicStart & { appParams: ManagementAppMountParams; }; export const createKibanaContextForPlugin = ( core: CoreStart, - plugins: AppPluginStartDependencies, - pluginStart: DataUsagePluginStart, + plugins: DataUsageStartDependencies, + pluginStart: DataUsagePublicStart, appParams: ManagementAppMountParams ) => { return createKibanaReactContext({ @@ -40,8 +40,8 @@ export const useKibanaContextForPlugin = export const useKibanaContextForPluginProvider = ( core: CoreStart, - plugins: AppPluginStartDependencies, - pluginStart: DataUsagePluginStart, + plugins: DataUsageStartDependencies, + pluginStart: DataUsagePublicStart, appParams: ManagementAppMountParams ) => { const { Provider } = useMemo( diff --git a/x-pack/plugins/data_usage/server/plugin.ts b/x-pack/plugins/data_usage/server/plugin.ts index 41c2ea67117b7..8ab49d5104fff 100644 --- a/x-pack/plugins/data_usage/server/plugin.ts +++ b/x-pack/plugins/data_usage/server/plugin.ts @@ -28,7 +28,6 @@ export class DataUsagePlugin constructor(context: PluginInitializerContext) { this.logger = context.logger.get(); } - // TODO: check for serverless setup(coreSetup: CoreSetup, pluginsSetup: DataUsageSetupDependencies): DataUsageServerSetup { return {}; }