From d39739ee85792cdb88d9791eb506edacc6a99bac Mon Sep 17 00:00:00 2001 From: Yngrid Coello Date: Wed, 29 May 2024 16:06:43 +0200 Subject: [PATCH] [Dataset quality] Move page to stack management > Data (#184122) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Relates to https://github.com/elastic/kibana/issues/183406. ## 📝 Summary This PR creates a new plugin `data_quality` in order to register dataset quality as a Stack management page under data section. For now there is no reference to this new page in the sideNav in stateful or serverless. In order to navigate to this new page you can use the url `/app/management/data/data_quality` Changes included in this PR: - New plugin created - Plugin registered in stack management, data section - Dataset quality plugin is instantiated and the state is in sync with URL - Removed references to dataset quality in Logs explorer ## 🎥 Demo https://github.com/elastic/kibana/assets/1313018/501c9c47-4a1b-4f91-9be6-d022a821e88e ## 🙅🏼 Missing - Dataset quality locator - There are still references to logs explorer (table and flyout) that will be handled in a follow up PR. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .github/CODEOWNERS | 1 + docs/developer/plugin-list.asciidoc | 4 + package.json | 1 + packages/deeplinks/management/deep_links.ts | 1 + packages/kbn-optimizer/limits.yml | 1 + .../management_sidebar_nav.tsx | 7 +- tsconfig.base.json | 2 + x-pack/.i18nrc.json | 1 + x-pack/plugins/data_quality/README.md | 2 + x-pack/plugins/data_quality/common/index.ts | 15 ++ .../data_quality/common/url_schema/common.ts | 8 + .../data_quality/common/url_schema/index.ts | 9 ++ .../common/url_schema}/url_schema_v1.ts | 0 .../common/utils/deep_compact_object.ts | 15 ++ x-pack/plugins/data_quality/kibana.jsonc | 24 +++ .../data_quality/public/application.tsx | 63 ++++++++ x-pack/plugins/data_quality/public/index.ts | 13 ++ x-pack/plugins/data_quality/public/plugin.ts | 56 +++++++ .../public/routes/dataset_quality/context.tsx | 78 ++++++++++ .../public/routes/dataset_quality/index.tsx | 65 ++++++++ .../routes/dataset_quality}/url_schema_v1.ts | 3 +- .../url_state_storage_service.ts | 55 +++++++ .../data_quality/public/routes/index.tsx | 8 + x-pack/plugins/data_quality/public/types.ts | 24 +++ .../public/utils/kbn_url_state_context.ts | 35 +++++ .../public/utils/use_breadcrumbs.tsx | 25 +++ .../data_quality/public/utils/use_kibana.tsx | 53 +++++++ .../server/index.ts} | 7 +- x-pack/plugins/data_quality/server/plugin.ts | 35 +++++ x-pack/plugins/data_quality/server/types.ts | 12 ++ x-pack/plugins/data_quality/tsconfig.json | 29 ++++ .../common/index.ts | 2 - .../locators/dataset_quality_locator.ts | 29 ---- .../common/locators/index.ts | 3 - .../common/locators/locators.test.ts | 40 ----- .../common/locators/types.ts | 4 - .../construct_dataset_quality_locator_path.ts | 47 ------ .../common/locators/utils/index.ts | 1 - .../common/translations.ts | 7 - .../common/url_schema/common.ts | 1 - .../common/url_schema/index.ts | 6 +- .../observability_logs_explorer/kibana.jsonc | 3 +- .../observability_logs_explorer.tsx | 7 +- .../components/dataset_quality_link.tsx | 98 ------------ .../public/plugin.ts | 7 - .../routes/main/dataset_quality_route.tsx | 108 ------------- .../public/routes/main/index.tsx | 1 - .../dataset_quality/src/controller_service.ts | 70 --------- .../dataset_quality/src/provider.ts | 30 ---- .../dataset_quality/src/state_machine.ts | 146 ------------------ .../dataset_quality/src/types.ts | 54 ------- .../src/url_state_storage_service.ts | 75 --------- .../public/types.ts | 2 - .../observability_logs_explorer/tsconfig.json | 1 - .../translations/translations/fr-FR.json | 1 - .../translations/translations/ja-JP.json | 1 - .../translations/translations/zh-CN.json | 1 - .../page_objects/dataset_quality.ts | 10 +- x-pack/test/tsconfig.json | 3 +- yarn.lock | 4 + 60 files changed, 659 insertions(+), 755 deletions(-) create mode 100755 x-pack/plugins/data_quality/README.md create mode 100644 x-pack/plugins/data_quality/common/index.ts create mode 100644 x-pack/plugins/data_quality/common/url_schema/common.ts create mode 100644 x-pack/plugins/data_quality/common/url_schema/index.ts rename x-pack/plugins/{observability_solution/observability_logs_explorer/common/url_schema/dataset_quality => data_quality/common/url_schema}/url_schema_v1.ts (100%) create mode 100644 x-pack/plugins/data_quality/common/utils/deep_compact_object.ts create mode 100644 x-pack/plugins/data_quality/kibana.jsonc create mode 100644 x-pack/plugins/data_quality/public/application.tsx create mode 100644 x-pack/plugins/data_quality/public/index.ts create mode 100644 x-pack/plugins/data_quality/public/plugin.ts create mode 100644 x-pack/plugins/data_quality/public/routes/dataset_quality/context.tsx create mode 100644 x-pack/plugins/data_quality/public/routes/dataset_quality/index.tsx rename x-pack/plugins/{observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src => data_quality/public/routes/dataset_quality}/url_schema_v1.ts (92%) create mode 100644 x-pack/plugins/data_quality/public/routes/dataset_quality/url_state_storage_service.ts create mode 100644 x-pack/plugins/data_quality/public/routes/index.tsx create mode 100644 x-pack/plugins/data_quality/public/types.ts create mode 100644 x-pack/plugins/data_quality/public/utils/kbn_url_state_context.ts create mode 100644 x-pack/plugins/data_quality/public/utils/use_breadcrumbs.tsx create mode 100644 x-pack/plugins/data_quality/public/utils/use_kibana.tsx rename x-pack/plugins/{observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/defaults.ts => data_quality/server/index.ts} (59%) create mode 100644 x-pack/plugins/data_quality/server/plugin.ts create mode 100644 x-pack/plugins/data_quality/server/types.ts create mode 100644 x-pack/plugins/data_quality/tsconfig.json delete mode 100644 x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/dataset_quality_locator.ts delete mode 100644 x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/utils/construct_dataset_quality_locator_path.ts delete mode 100644 x-pack/plugins/observability_solution/observability_logs_explorer/public/components/dataset_quality_link.tsx delete mode 100644 x-pack/plugins/observability_solution/observability_logs_explorer/public/routes/main/dataset_quality_route.tsx delete mode 100644 x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/controller_service.ts delete mode 100644 x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/provider.ts delete mode 100644 x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/state_machine.ts delete mode 100644 x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/types.ts delete mode 100644 x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/url_state_storage_service.ts diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 479cf4473b1d3..8a09ab169b3b4 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -337,6 +337,7 @@ x-pack/plugins/dashboard_enhanced @elastic/kibana-presentation src/plugins/dashboard @elastic/kibana-presentation x-pack/packages/kbn-data-forge @elastic/obs-ux-management-team src/plugins/data @elastic/kibana-visualizations @elastic/kibana-data-discovery +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 diff --git a/docs/developer/plugin-list.asciidoc b/docs/developer/plugin-list.asciidoc index 5b6b7e4014bc7..178aa842fb2a8 100644 --- a/docs/developer/plugin-list.asciidoc +++ b/docs/developer/plugin-list.asciidoc @@ -531,6 +531,10 @@ Plugin server-side only. Plugin has three main functions: |Adds drilldown capabilities to dashboard. Owned by the Kibana App team. +|{kib-repo}blob/{branch}/x-pack/plugins/data_quality/README.md[dataQuality] +|Page where users can see the quality of their log datasets. + + |{kib-repo}blob/{branch}/x-pack/plugins/observability_solution/dataset_quality/README.md[datasetQuality] |In order to make ongoing maintenance of log collection easy we want to introduce the concept of dataset quality, where users can easily get an overview on the datasets they have with information such as integration, size, last activity, among others. diff --git a/package.json b/package.json index bc8ee19406ac1..46a7cbc47311d 100644 --- a/package.json +++ b/package.json @@ -391,6 +391,7 @@ "@kbn/dashboard-plugin": "link:src/plugins/dashboard", "@kbn/data-forge": "link:x-pack/packages/kbn-data-forge", "@kbn/data-plugin": "link:src/plugins/data", + "@kbn/data-quality-plugin": "link:x-pack/plugins/data_quality", "@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", diff --git a/packages/deeplinks/management/deep_links.ts b/packages/deeplinks/management/deep_links.ts index bb0dda17f6ce9..b5770256cd71d 100644 --- a/packages/deeplinks/management/deep_links.ts +++ b/packages/deeplinks/management/deep_links.ts @@ -34,6 +34,7 @@ export type ManagementId = | 'cases' | 'cross_cluster_replication' | 'dataViews' + | 'data_quality' | 'filesManagement' | 'license_management' | 'index_lifecycle_management' diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index 47d3d0c55c290..a4e08a8b20a81 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -28,6 +28,7 @@ pageLoadAssetSize: dashboard: 52967 dashboardEnhanced: 65646 data: 454087 + dataQuality: 19384 datasetQuality: 50624 dataViewEditor: 28082 dataViewFieldEditor: 27000 diff --git a/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx b/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx index 1dfe5ef633d71..d6aaf8e657ad9 100644 --- a/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx +++ b/src/plugins/management/public/components/management_sidebar_nav/management_sidebar_nav.tsx @@ -32,13 +32,16 @@ export const managementSidebarNav = ({ const sortedManagementSections = sortBy(managementSections, 'order'); return sortedManagementSections.reduce>>((acc, section) => { - const apps = sortBy(section.getAppsEnabled(), 'order'); + const apps = sortBy( + section.getAppsEnabled().filter((app) => !app.hideFromSidebar), + 'order' + ); if (apps.length) { if (!section.hideFromSidebar) { acc.push({ ...createNavItem(section, { - items: appsToNavItems(apps.filter((app) => !app.hideFromSidebar)), + items: appsToNavItems(apps), }), }); } diff --git a/tsconfig.base.json b/tsconfig.base.json index 12d8ad5d63ae1..9b141fb1991cf 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -668,6 +668,8 @@ "@kbn/data-forge/*": ["x-pack/packages/kbn-data-forge/*"], "@kbn/data-plugin": ["src/plugins/data"], "@kbn/data-plugin/*": ["src/plugins/data/*"], + "@kbn/data-quality-plugin": ["x-pack/plugins/data_quality"], + "@kbn/data-quality-plugin/*": ["x-pack/plugins/data_quality/*"], "@kbn/data-search-plugin": ["test/plugin_functional/plugins/data_search"], "@kbn/data-search-plugin/*": ["test/plugin_functional/plugins/data_search/*"], "@kbn/data-service": ["packages/kbn-data-service"], diff --git a/x-pack/.i18nrc.json b/x-pack/.i18nrc.json index 36885e2574f63..2de23279fac72 100644 --- a/x-pack/.i18nrc.json +++ b/x-pack/.i18nrc.json @@ -24,6 +24,7 @@ "xpack.csp": "plugins/cloud_security_posture", "xpack.customBranding": "plugins/custom_branding", "xpack.dashboard": "plugins/dashboard_enhanced", + "xpack.dataQuality": "plugins/data_quality", "xpack.datasetQuality": "plugins/observability_solution/dataset_quality", "xpack.discover": "plugins/discover_enhanced", "xpack.crossClusterReplication": "plugins/cross_cluster_replication", diff --git a/x-pack/plugins/data_quality/README.md b/x-pack/plugins/data_quality/README.md new file mode 100755 index 0000000000000..31582a332a2fd --- /dev/null +++ b/x-pack/plugins/data_quality/README.md @@ -0,0 +1,2 @@ +# dataQuality +Page where users can see the quality of their log datasets. diff --git a/x-pack/plugins/data_quality/common/index.ts b/x-pack/plugins/data_quality/common/index.ts new file mode 100644 index 0000000000000..25831a8bd3d3c --- /dev/null +++ b/x-pack/plugins/data_quality/common/index.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; 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_quality'; +export const PLUGIN_NAME = i18n.translate('xpack.dataQuality.name', { + defaultMessage: 'Logs data quality', +}); + +export { DATA_QUALITY_URL_STATE_KEY, datasetQualityUrlSchemaV1 } from './url_schema'; diff --git a/x-pack/plugins/data_quality/common/url_schema/common.ts b/x-pack/plugins/data_quality/common/url_schema/common.ts new file mode 100644 index 0000000000000..cf7998f4a1a54 --- /dev/null +++ b/x-pack/plugins/data_quality/common/url_schema/common.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export const DATA_QUALITY_URL_STATE_KEY = 'pageState'; diff --git a/x-pack/plugins/data_quality/common/url_schema/index.ts b/x-pack/plugins/data_quality/common/url_schema/index.ts new file mode 100644 index 0000000000000..d3b092e0b0ac8 --- /dev/null +++ b/x-pack/plugins/data_quality/common/url_schema/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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { DATA_QUALITY_URL_STATE_KEY } from './common'; +export * as datasetQualityUrlSchemaV1 from './url_schema_v1'; diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/common/url_schema/dataset_quality/url_schema_v1.ts b/x-pack/plugins/data_quality/common/url_schema/url_schema_v1.ts similarity index 100% rename from x-pack/plugins/observability_solution/observability_logs_explorer/common/url_schema/dataset_quality/url_schema_v1.ts rename to x-pack/plugins/data_quality/common/url_schema/url_schema_v1.ts diff --git a/x-pack/plugins/data_quality/common/utils/deep_compact_object.ts b/x-pack/plugins/data_quality/common/utils/deep_compact_object.ts new file mode 100644 index 0000000000000..eed8b1b83e1f4 --- /dev/null +++ b/x-pack/plugins/data_quality/common/utils/deep_compact_object.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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { isEmpty, isPlainObject, isUndefined } from 'lodash'; + +export const deepCompactObject = >(obj: Value): Value => + Object.fromEntries( + Object.entries(obj) + .map(([key, value]) => [key, isPlainObject(value) ? deepCompactObject(value) : value]) + .filter(([, value]) => !isUndefined(value) && !(isPlainObject(value) && isEmpty(value))) + ); diff --git a/x-pack/plugins/data_quality/kibana.jsonc b/x-pack/plugins/data_quality/kibana.jsonc new file mode 100644 index 0000000000000..2ca3c71168d52 --- /dev/null +++ b/x-pack/plugins/data_quality/kibana.jsonc @@ -0,0 +1,24 @@ +{ + "type": "plugin", + "id": "@kbn/data-quality-plugin", + "owner": "@elastic/obs-ux-logs-team", + "plugin": { + "id": "dataQuality", + "server": true, + "browser": true, + "configPath": ["xpack", "data_quality"], + "requiredPlugins": [ + "datasetQuality", + "management", + "features", + ], + "optionalPlugins": [], + "requiredBundles": [ + "kibanaReact", + "kibanaUtils", + ], + "extraPublicDirs": [ + "common", + ] + } +} diff --git a/x-pack/plugins/data_quality/public/application.tsx b/x-pack/plugins/data_quality/public/application.tsx new file mode 100644 index 0000000000000..32ddc64eb00e1 --- /dev/null +++ b/x-pack/plugins/data_quality/public/application.tsx @@ -0,0 +1,63 @@ +/* + * 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 { KbnUrlStateStorageFromRouterProvider } from './utils/kbn_url_state_context'; +import { useKibanaContextForPluginProvider } from './utils/use_kibana'; +import { AppPluginStartDependencies, DataQualityPluginStart } from './types'; +import { DatasetQualityRoute } from './routes'; + +export const renderApp = ( + core: CoreStart, + plugins: AppPluginStartDependencies, + pluginStart: DataQualityPluginStart, + params: ManagementAppMountParams +) => { + ReactDOM.render( + , + params.element + ); + + return () => { + ReactDOM.unmountComponentAtNode(params.element); + }; +}; + +interface AppProps { + core: CoreStart; + plugins: AppPluginStartDependencies; + pluginStart: DataQualityPluginStart; + params: ManagementAppMountParams; +} + +const App = ({ core, plugins, pluginStart, params }: AppProps) => { + const KibanaContextProviderForPlugin = useKibanaContextForPluginProvider( + core, + plugins, + pluginStart, + params + ); + + return ( + + + + + + } /> + + + + + + ); +}; diff --git a/x-pack/plugins/data_quality/public/index.ts b/x-pack/plugins/data_quality/public/index.ts new file mode 100644 index 0000000000000..233886ab18d7b --- /dev/null +++ b/x-pack/plugins/data_quality/public/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 { DataQualityPlugin } from './plugin'; + +export function plugin() { + return new DataQualityPlugin(); +} +export type { DataQualityPluginSetup, DataQualityPluginStart } from './types'; diff --git a/x-pack/plugins/data_quality/public/plugin.ts b/x-pack/plugins/data_quality/public/plugin.ts new file mode 100644 index 0000000000000..7063b39b09233 --- /dev/null +++ b/x-pack/plugins/data_quality/public/plugin.ts @@ -0,0 +1,56 @@ +/* + * 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 { + DataQualityPluginSetup, + DataQualityPluginStart, + AppPluginStartDependencies, + AppPluginSetupDependencies, +} from './types'; +import { PLUGIN_ID, PLUGIN_NAME } from '../common'; + +export class DataQualityPlugin + implements + Plugin< + DataQualityPluginSetup, + DataQualityPluginStart, + AppPluginSetupDependencies, + AppPluginStartDependencies + > +{ + public setup( + core: CoreSetup, + plugins: AppPluginSetupDependencies + ): DataQualityPluginSetup { + const { management } = plugins; + + management.sections.section.data.registerApp({ + id: PLUGIN_ID, + title: PLUGIN_NAME, + order: 2, + async mount(params: ManagementAppMountParams) { + const [{ renderApp }, [coreStart, pluginsStartDeps, pluginStart]] = await Promise.all([ + import('./application'), + core.getStartServices(), + ]); + + return renderApp(coreStart, pluginsStartDeps, pluginStart, params); + }, + hideFromSidebar: true, + }); + + return {}; + } + + public start(_core: CoreStart): DataQualityPluginStart { + return {}; + } + + public stop() {} +} diff --git a/x-pack/plugins/data_quality/public/routes/dataset_quality/context.tsx b/x-pack/plugins/data_quality/public/routes/dataset_quality/context.tsx new file mode 100644 index 0000000000000..faa43d90de2db --- /dev/null +++ b/x-pack/plugins/data_quality/public/routes/dataset_quality/context.tsx @@ -0,0 +1,78 @@ +/* + * 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 { IToasts } from '@kbn/core-notifications-browser'; +import { DatasetQualityPluginStart } from '@kbn/dataset-quality-plugin/public'; +import { DatasetQualityController } from '@kbn/dataset-quality-plugin/public/controller'; +import { IKbnUrlStateStorage } from '@kbn/kibana-utils-plugin/public'; +import React, { createContext, useContext, useEffect, useState } from 'react'; +import { + getDatasetQualityStateFromUrl, + updateUrlFromDatasetQualityState, +} from './url_state_storage_service'; + +const DatasetQualityContext = createContext<{ controller?: DatasetQualityController }>({}); + +interface ContextProps { + children: JSX.Element; + urlStateStorageContainer: IKbnUrlStateStorage; + toastsService: IToasts; + datasetQuality: DatasetQualityPluginStart; +} + +export function DatasetQualityContextProvider({ + children, + urlStateStorageContainer, + toastsService, + datasetQuality, +}: ContextProps) { + const [controller, setController] = useState(); + + useEffect(() => { + async function getDatasetQualityController() { + const initialState = getDatasetQualityStateFromUrl({ + urlStateStorageContainer, + toastsService, + }); + + const datasetQualityController = await datasetQuality.createDatasetQualityController({ + initialState, + }); + datasetQualityController.service.start(); + setController(datasetQualityController); + + const datasetQualityStateSubscription = datasetQualityController.state$.subscribe((state) => { + updateUrlFromDatasetQualityState({ + urlStateStorageContainer, + datasetQualityState: state, + }); + }); + + return () => { + datasetQualityController.service.stop(); + datasetQualityStateSubscription.unsubscribe(); + }; + } + getDatasetQualityController(); + }, [datasetQuality, toastsService, urlStateStorageContainer]); + + return ( + + {children} + + ); +} + +export const useDatasetQualityContext = () => { + const context = useContext(DatasetQualityContext); + if (context === undefined) { + throw new Error( + 'useDatasetQualityContext must be used within a ' + ); + } + return context; +}; diff --git a/x-pack/plugins/data_quality/public/routes/dataset_quality/index.tsx b/x-pack/plugins/data_quality/public/routes/dataset_quality/index.tsx new file mode 100644 index 0000000000000..6dfb2a5d052fe --- /dev/null +++ b/x-pack/plugins/data_quality/public/routes/dataset_quality/index.tsx @@ -0,0 +1,65 @@ +/* + * 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 { EuiEmptyPrompt, EuiLoadingLogo } from '@elastic/eui'; +import { DatasetQualityController } from '@kbn/dataset-quality-plugin/public/controller'; +import React from 'react'; +import { FormattedMessage } from '@kbn/i18n-react'; +import { PLUGIN_NAME } from '../../../common'; +import { useKbnUrlStateStorageFromRouterContext } from '../../utils/kbn_url_state_context'; +import { useBreadcrumbs } from '../../utils/use_breadcrumbs'; +import { useKibanaContextForPlugin } from '../../utils/use_kibana'; +import { DatasetQualityContextProvider, useDatasetQualityContext } from './context'; + +export const DatasetQualityRoute = () => { + const urlStateStorageContainer = useKbnUrlStateStorageFromRouterContext(); + const { + services: { chrome, datasetQuality, notifications, appParams }, + } = useKibanaContextForPlugin(); + + useBreadcrumbs(PLUGIN_NAME, appParams, chrome); + + return ( + + + + ); +}; + +const ConnectedContent = React.memo(() => { + const { controller } = useDatasetQualityContext(); + + return controller ? ( + + ) : ( + <> + } + title={ + + } + /> + + ); +}); + +const InitializedContent = React.memo( + ({ datasetQualityController }: { datasetQualityController: DatasetQualityController }) => { + const { + services: { datasetQuality }, + } = useKibanaContextForPlugin(); + + return ; + } +); diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/url_schema_v1.ts b/x-pack/plugins/data_quality/public/routes/dataset_quality/url_schema_v1.ts similarity index 92% rename from x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/url_schema_v1.ts rename to x-pack/plugins/data_quality/public/routes/dataset_quality/url_schema_v1.ts index d49ab302e1908..3ede6fc145186 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/url_schema_v1.ts +++ b/x-pack/plugins/data_quality/public/routes/dataset_quality/url_schema_v1.ts @@ -10,7 +10,8 @@ import { DatasetQualityPublicStateUpdate, } from '@kbn/dataset-quality-plugin/public/controller'; import * as rt from 'io-ts'; -import { datasetQualityUrlSchemaV1, deepCompactObject } from '../../../../common'; +import { deepCompactObject } from '../../../common/utils/deep_compact_object'; +import { datasetQualityUrlSchemaV1 } from '../../../common/url_schema'; export const getStateFromUrlValue = ( urlValue: datasetQualityUrlSchemaV1.UrlSchema diff --git a/x-pack/plugins/data_quality/public/routes/dataset_quality/url_state_storage_service.ts b/x-pack/plugins/data_quality/public/routes/dataset_quality/url_state_storage_service.ts new file mode 100644 index 0000000000000..22a7ed6225fcf --- /dev/null +++ b/x-pack/plugins/data_quality/public/routes/dataset_quality/url_state_storage_service.ts @@ -0,0 +1,55 @@ +/* + * 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 { IToasts } from '@kbn/core-notifications-browser'; +import { DatasetQualityPublicState } from '@kbn/dataset-quality-plugin/public/controller'; +import { createPlainError, formatErrors } from '@kbn/io-ts-utils'; +import { IKbnUrlStateStorage, withNotifyOnErrors } from '@kbn/kibana-utils-plugin/public'; +import * as Either from 'fp-ts/lib/Either'; +import * as rt from 'io-ts'; +import { DATA_QUALITY_URL_STATE_KEY } from '../../../common/url_schema'; +import * as urlSchemaV1 from './url_schema_v1'; + +export const updateUrlFromDatasetQualityState = ({ + urlStateStorageContainer, + datasetQualityState, +}: { + urlStateStorageContainer: IKbnUrlStateStorage; + datasetQualityState?: DatasetQualityPublicState; +}) => { + if (!datasetQualityState) { + return; + } + + const encodedUrlStateValues = urlSchemaV1.stateFromUntrustedUrlRT.encode(datasetQualityState); + + urlStateStorageContainer.set(DATA_QUALITY_URL_STATE_KEY, encodedUrlStateValues, { + replace: true, + }); +}; + +export const getDatasetQualityStateFromUrl = ({ + toastsService, + urlStateStorageContainer, +}: { + toastsService: IToasts; + urlStateStorageContainer: IKbnUrlStateStorage; +}): Partial | undefined => { + const urlStateValues = + urlStateStorageContainer.get(DATA_QUALITY_URL_STATE_KEY) ?? undefined; + + const stateValuesE = rt + .union([rt.undefined, urlSchemaV1.stateFromUntrustedUrlRT]) + .decode(urlStateValues); + + if (Either.isLeft(stateValuesE)) { + withNotifyOnErrors(toastsService).onGetError(createPlainError(formatErrors(stateValuesE.left))); + return undefined; + } else { + return stateValuesE.right; + } +}; diff --git a/x-pack/plugins/data_quality/public/routes/index.tsx b/x-pack/plugins/data_quality/public/routes/index.tsx new file mode 100644 index 0000000000000..1a8591d0d3c86 --- /dev/null +++ b/x-pack/plugins/data_quality/public/routes/index.tsx @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export * from './dataset_quality'; diff --git a/x-pack/plugins/data_quality/public/types.ts b/x-pack/plugins/data_quality/public/types.ts new file mode 100644 index 0000000000000..7e695b9a20d08 --- /dev/null +++ b/x-pack/plugins/data_quality/public/types.ts @@ -0,0 +1,24 @@ +/* + * 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 { DatasetQualityPluginStart } from '@kbn/dataset-quality-plugin/public'; +import { ManagementSetup, ManagementStart } from '@kbn/management-plugin/public'; + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface DataQualityPluginSetup {} + +// eslint-disable-next-line @typescript-eslint/no-empty-interface +export interface DataQualityPluginStart {} + +export interface AppPluginSetupDependencies { + management: ManagementSetup; +} + +export interface AppPluginStartDependencies { + datasetQuality: DatasetQualityPluginStart; + management: ManagementStart; +} diff --git a/x-pack/plugins/data_quality/public/utils/kbn_url_state_context.ts b/x-pack/plugins/data_quality/public/utils/kbn_url_state_context.ts new file mode 100644 index 0000000000000..167af63d0d9e6 --- /dev/null +++ b/x-pack/plugins/data_quality/public/utils/kbn_url_state_context.ts @@ -0,0 +1,35 @@ +/* + * 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 { createKbnUrlStateStorage, withNotifyOnErrors } from '@kbn/kibana-utils-plugin/public'; +import createContainer from 'constate'; +import { useState } from 'react'; +import { useKibanaContextForPlugin } from './use_kibana'; + +const useKbnUrlStateStorageFromRouter = () => { + const { + services: { + appParams: { history }, + notifications: { toasts }, + uiSettings, + }, + } = useKibanaContextForPlugin(); + + const [urlStateStorage] = useState(() => + createKbnUrlStateStorage({ + history, + useHash: uiSettings.get('state:storeInSessionStorage'), + useHashQuery: false, + ...withNotifyOnErrors(toasts), + }) + ); + + return urlStateStorage; +}; + +export const [KbnUrlStateStorageFromRouterProvider, useKbnUrlStateStorageFromRouterContext] = + createContainer(useKbnUrlStateStorageFromRouter); diff --git a/x-pack/plugins/data_quality/public/utils/use_breadcrumbs.tsx b/x-pack/plugins/data_quality/public/utils/use_breadcrumbs.tsx new file mode 100644 index 0000000000000..3bf83bcf03352 --- /dev/null +++ b/x-pack/plugins/data_quality/public/utils/use_breadcrumbs.tsx @@ -0,0 +1,25 @@ +/* + * 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 { ChromeStart } from '@kbn/core-chrome-browser'; + +import { ManagementAppMountParams } from '@kbn/management-plugin/public'; +import { useEffect } from 'react'; + +export const useBreadcrumbs = ( + breadcrumb: string, + params: ManagementAppMountParams, + chromeService: ChromeStart +) => { + const { docTitle } = chromeService; + + docTitle.change(breadcrumb); + + useEffect(() => { + params.setBreadcrumbs([{ text: breadcrumb }]); + }, [breadcrumb, params]); +}; diff --git a/x-pack/plugins/data_quality/public/utils/use_kibana.tsx b/x-pack/plugins/data_quality/public/utils/use_kibana.tsx new file mode 100644 index 0000000000000..78dab20ccf68a --- /dev/null +++ b/x-pack/plugins/data_quality/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, DataQualityPluginStart } from '../types'; + +export type PluginKibanaContextValue = CoreStart & + AppPluginStartDependencies & + DataQualityPluginStart & { + appParams: ManagementAppMountParams; + }; + +export const createKibanaContextForPlugin = ( + core: CoreStart, + plugins: AppPluginStartDependencies, + pluginStart: DataQualityPluginStart, + appParams: ManagementAppMountParams +) => { + return createKibanaReactContext({ + ...core, + ...plugins, + ...pluginStart, + appParams, + }); +}; + +export const useKibanaContextForPlugin = + useKibana as () => KibanaReactContextValue; + +export const useKibanaContextForPluginProvider = ( + core: CoreStart, + plugins: AppPluginStartDependencies, + pluginStart: DataQualityPluginStart, + appParams: ManagementAppMountParams +) => { + const { Provider } = useMemo( + () => createKibanaContextForPlugin(core, plugins, pluginStart, appParams), + [appParams, core, pluginStart, plugins] + ); + + return Provider; +}; diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/defaults.ts b/x-pack/plugins/data_quality/server/index.ts similarity index 59% rename from x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/defaults.ts rename to x-pack/plugins/data_quality/server/index.ts index 364049ad3f1c2..2165ca23d9f2e 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/defaults.ts +++ b/x-pack/plugins/data_quality/server/index.ts @@ -5,8 +5,7 @@ * 2.0. */ -import { CommonObservabilityDatasetQualityContext } from './types'; - -export const DEFAULT_CONTEXT: CommonObservabilityDatasetQualityContext = { - initialDatasetQualityState: {}, +export const plugin = async () => { + const { DataQualityPlugin } = await import('./plugin'); + return new DataQualityPlugin(); }; diff --git a/x-pack/plugins/data_quality/server/plugin.ts b/x-pack/plugins/data_quality/server/plugin.ts new file mode 100644 index 0000000000000..4977e6f09a5c1 --- /dev/null +++ b/x-pack/plugins/data_quality/server/plugin.ts @@ -0,0 +1,35 @@ +/* + * 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, Plugin } from '@kbn/core/server'; +import { PLUGIN_ID } from '../common'; + +import { Dependencies } from './types'; + +export class DataQualityPlugin implements Plugin { + public setup(coreSetup: CoreSetup, { features }: Dependencies) { + features.registerElasticsearchFeature({ + id: PLUGIN_ID, + management: { + data: [PLUGIN_ID], + }, + privileges: [ + { + ui: [], + requiredClusterPrivileges: [], + requiredIndexPrivileges: { + ['logs-*-*']: ['read'], + }, + }, + ], + }); + } + + public start() {} + + public stop() {} +} diff --git a/x-pack/plugins/data_quality/server/types.ts b/x-pack/plugins/data_quality/server/types.ts new file mode 100644 index 0000000000000..7ae5c3b36b2c2 --- /dev/null +++ b/x-pack/plugins/data_quality/server/types.ts @@ -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; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { PluginSetupContract as FeaturesPluginSetup } from '@kbn/features-plugin/server'; + +export interface Dependencies { + features: FeaturesPluginSetup; +} diff --git a/x-pack/plugins/data_quality/tsconfig.json b/x-pack/plugins/data_quality/tsconfig.json new file mode 100644 index 0000000000000..0ad84ba9d1dd4 --- /dev/null +++ b/x-pack/plugins/data_quality/tsconfig.json @@ -0,0 +1,29 @@ +{ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types" + }, + "include": [ + "index.ts", + "common/**/*", + "public/**/*", + "server/**/*", + "../../../typings/**/*" + ], + "kbn_references": [ + "@kbn/core", + "@kbn/dataset-quality-plugin", + "@kbn/i18n", + "@kbn/io-ts-utils", + "@kbn/kibana-react-plugin", + "@kbn/kibana-utils-plugin", + "@kbn/management-plugin", + "@kbn/react-kibana-context-render", + "@kbn/shared-ux-router", + "@kbn/core-notifications-browser", + "@kbn/i18n-react", + "@kbn/core-chrome-browser", + "@kbn/features-plugin", + ], + "exclude": ["target/**/*"] +} diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/common/index.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/common/index.ts index 62dd4e0333896..fe0712ce338c2 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/common/index.ts +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/common/index.ts @@ -12,9 +12,7 @@ export { } from './locators'; export { OBSERVABILITY_LOGS_EXPLORER_URL_STATE_KEY, - OBSERVABILITY_DATASET_QUALITY_URL_STATE_KEY, logsExplorerUrlSchemaV1, logsExplorerUrlSchemaV2, - datasetQualityUrlSchemaV1, } from './url_schema'; export { deepCompactObject } from './utils/deep_compact_object'; diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/dataset_quality_locator.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/dataset_quality_locator.ts deleted file mode 100644 index 33ea5616d2543..0000000000000 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/dataset_quality_locator.ts +++ /dev/null @@ -1,29 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import type { LocatorDefinition, LocatorPublic } from '@kbn/share-plugin/public'; -import { - DatasetQualityLocatorParams, - DATASET_QUALITY_LOCATOR_ID, -} from '@kbn/deeplinks-observability/locators'; -import { DatasetQualityLocatorDependencies } from './types'; -import { constructDatasetQualityLocatorPath } from './utils'; - -export type DatasetQualityLocator = LocatorPublic; - -export class DatasetQualityLocatorDefinition - implements LocatorDefinition -{ - public readonly id = DATASET_QUALITY_LOCATOR_ID; - - constructor(protected readonly deps: DatasetQualityLocatorDependencies) {} - - public readonly getLocation = async (params: DatasetQualityLocatorParams) => { - const { useHash } = this.deps; - return constructDatasetQualityLocatorPath({ useHash, locatorParams: params }); - }; -} diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/index.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/index.ts index 0c7fda1cd0f70..6692c6d30cea9 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/index.ts +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/index.ts @@ -9,9 +9,7 @@ export type { ObservabilityLogsExplorerLocationState } from '@kbn/deeplinks-obse import { AllDatasetsLocator } from './all_datasets_locator'; import { DataViewLocator } from './data_view_locator'; import { SingleDatasetLocator } from './single_dataset_locator'; -import { DatasetQualityLocator } from './dataset_quality_locator'; -export * from './dataset_quality_locator'; export * from './single_dataset_locator'; export * from './all_datasets_locator'; export * from './utils'; @@ -20,5 +18,4 @@ export interface ObservabilityLogsExplorerLocators { allDatasetsLocator: AllDatasetsLocator; dataViewLocator: DataViewLocator; singleDatasetLocator: SingleDatasetLocator; - datasetQualityLocator: DatasetQualityLocator; } diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/locators.test.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/locators.test.ts index 6761953c62325..0c38eed85694d 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/locators.test.ts +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/locators.test.ts @@ -11,7 +11,6 @@ import { SingleDatasetLocatorParams, ObsLogsExplorerDataViewLocatorParams, } from '@kbn/deeplinks-observability/locators'; -import { DatasetQualityLocatorDefinition } from './dataset_quality_locator'; import { AllDatasetsLocatorDefinition } from './all_datasets_locator'; import { DataViewLocatorDefinition } from './data_view_locator'; import { SingleDatasetLocatorDefinition } from './single_dataset_locator'; @@ -24,13 +23,11 @@ const setup = async () => { const allDatasetsLocator = new AllDatasetsLocatorDefinition(dep); const dataViewLocator = new DataViewLocatorDefinition(dep); const singleDatasetLocator = new SingleDatasetLocatorDefinition(dep); - const datasetQualityLocator = new DatasetQualityLocatorDefinition(dep); return { allDatasetsLocator, dataViewLocator, singleDatasetLocator, - datasetQualityLocator, }; }; @@ -426,41 +423,4 @@ describe('Observability Logs Explorer Locators', () => { ); }); }); - - describe('Dataset Quality Locator', () => { - it('should create a link with correct path and no state', async () => { - const { datasetQualityLocator } = await setup(); - const location = await datasetQualityLocator.getLocation({}); - - expect(location).toMatchObject({ - app: OBSERVABILITY_LOGS_EXPLORER_APP_ID, - path: '/dataset-quality?pageState=(v:1)', - state: {}, - }); - }); - - it('should create a link with correct timeRange', async () => { - const refresh = { - pause: false, - value: 0, - }; - const locatorParams = { - filters: { - timeRange: { - ...timeRange, - refresh, - }, - }, - }; - const { datasetQualityLocator } = await setup(); - - const location = await datasetQualityLocator.getLocation(locatorParams); - - expect(location).toMatchObject({ - app: OBSERVABILITY_LOGS_EXPLORER_APP_ID, - path: '/dataset-quality?pageState=(filters:(timeRange:(from:now-30m,refresh:(pause:!f,value:0),to:now)),v:1)', - state: {}, - }); - }); - }); }); diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/types.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/types.ts index b6b9364a2aee3..4c80bcf31c2a6 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/types.ts +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/types.ts @@ -7,7 +7,3 @@ export interface ObsLogsExplorerLocatorDependencies { useHash: boolean; } - -export interface DatasetQualityLocatorDependencies { - useHash: boolean; -} diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/utils/construct_dataset_quality_locator_path.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/utils/construct_dataset_quality_locator_path.ts deleted file mode 100644 index e38ffe33bc822..0000000000000 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/utils/construct_dataset_quality_locator_path.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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { DatasetQualityLocatorParams } from '@kbn/deeplinks-observability/locators'; -import { setStateToKbnUrl } from '@kbn/kibana-utils-plugin/common'; -import { OBSERVABILITY_LOGS_EXPLORER_APP_ID } from '@kbn/deeplinks-observability'; -import { - OBSERVABILITY_DATASET_QUALITY_URL_STATE_KEY, - datasetQualityUrlSchemaV1, -} from '../../url_schema'; -import { deepCompactObject } from '../../utils/deep_compact_object'; - -interface LocatorPathConstructionParams { - locatorParams: DatasetQualityLocatorParams; - useHash: boolean; -} - -export const constructDatasetQualityLocatorPath = async (params: LocatorPathConstructionParams) => { - const { - locatorParams: { filters }, - useHash, - } = params; - - const pageState = datasetQualityUrlSchemaV1.urlSchemaRT.encode( - deepCompactObject({ - v: 1, - filters, - }) - ); - - const path = setStateToKbnUrl( - OBSERVABILITY_DATASET_QUALITY_URL_STATE_KEY, - pageState, - { useHash, storeInHashQuery: false }, - '/dataset-quality' - ); - - return { - app: OBSERVABILITY_LOGS_EXPLORER_APP_ID, - path, - state: {}, - }; -}; diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/utils/index.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/utils/index.ts index 23c6a9b59c2d2..6e5aad44fbe9a 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/utils/index.ts +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/common/locators/utils/index.ts @@ -6,4 +6,3 @@ */ export * from './construct_locator_path'; -export * from './construct_dataset_quality_locator_path'; diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/common/translations.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/common/translations.ts index 6b245fb7c7af7..0f054d6ccc705 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/common/translations.ts +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/common/translations.ts @@ -54,13 +54,6 @@ export const feedbackLinkTitle = i18n.translate( } ); -export const datasetQualityLinkTitle = i18n.translate( - 'xpack.observabilityLogsExplorer.datasetQualityLinkTitle', - { - defaultMessage: 'Datasets', - } -); - export const createSLoLabel = i18n.translate('xpack.observabilityLogsExplorer.createSlo', { defaultMessage: 'Create SLO', }); diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/common/url_schema/common.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/common/url_schema/common.ts index f1fd80cbb9b5e..22b00ded2e180 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/common/url_schema/common.ts +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/common/url_schema/common.ts @@ -6,4 +6,3 @@ */ export const OBSERVABILITY_LOGS_EXPLORER_URL_STATE_KEY = 'pageState'; -export const OBSERVABILITY_DATASET_QUALITY_URL_STATE_KEY = 'pageState'; diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/common/url_schema/index.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/common/url_schema/index.ts index 269b95778bafa..42d70d1549bb7 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/common/url_schema/index.ts +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/common/url_schema/index.ts @@ -5,10 +5,6 @@ * 2.0. */ -export { - OBSERVABILITY_LOGS_EXPLORER_URL_STATE_KEY, - OBSERVABILITY_DATASET_QUALITY_URL_STATE_KEY, -} from './common'; +export { OBSERVABILITY_LOGS_EXPLORER_URL_STATE_KEY } from './common'; export * as logsExplorerUrlSchemaV1 from './logs_explorer/url_schema_v1'; export * as logsExplorerUrlSchemaV2 from './logs_explorer/url_schema_v2'; -export * as datasetQualityUrlSchemaV1 from './dataset_quality/url_schema_v1'; diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/kibana.jsonc b/x-pack/plugins/observability_solution/observability_logs_explorer/kibana.jsonc index bfb6a561a1db0..c153124e5bd68 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/kibana.jsonc +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/kibana.jsonc @@ -19,8 +19,7 @@ "observabilityShared", "slo", "share", - "kibanaUtils", - "datasetQuality" + "kibanaUtils" ], "optionalPlugins": [ "serverless", diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/applications/observability_logs_explorer.tsx b/x-pack/plugins/observability_solution/observability_logs_explorer/public/applications/observability_logs_explorer.tsx index 3154c7c09cc8e..cdcb82635f068 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/applications/observability_logs_explorer.tsx +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/public/applications/observability_logs_explorer.tsx @@ -11,7 +11,7 @@ import { KibanaRenderContextProvider } from '@kbn/react-kibana-context-render'; import { Route, Router, Routes } from '@kbn/shared-ux-router'; import React from 'react'; import ReactDOM from 'react-dom'; -import { DatasetQualityRoute, ObservabilityLogsExplorerMainRoute } from '../routes/main'; +import { ObservabilityLogsExplorerMainRoute } from '../routes/main'; import { NotFoundPage } from '../routes/not_found'; import { ObservabilityLogsExplorerAppMountParameters, @@ -79,11 +79,6 @@ export const ObservabilityLogsExplorerApp = ({ exact={true} render={() => } /> - } - /> } /> diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/components/dataset_quality_link.tsx b/x-pack/plugins/observability_solution/observability_logs_explorer/public/components/dataset_quality_link.tsx deleted file mode 100644 index 5d74e6de37a19..0000000000000 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/components/dataset_quality_link.tsx +++ /dev/null @@ -1,98 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { EuiHeaderLink } from '@elastic/eui'; -import { - DatasetQualityLocatorParams, - DATASET_QUALITY_LOCATOR_ID, -} from '@kbn/deeplinks-observability/locators'; -import { LogsExplorerPublicState } from '@kbn/logs-explorer-plugin/public'; -import { getRouterLinkProps } from '@kbn/router-utils'; -import { BrowserUrlService } from '@kbn/share-plugin/public'; -import { MatchedStateFromActor } from '@kbn/xstate-utils'; -import { useActor } from '@xstate/react'; -import React from 'react'; -import { datasetQualityLinkTitle } from '../../common/translations'; -import { - ObservabilityLogsExplorerService, - useObservabilityLogsExplorerPageStateContext, -} from '../state_machines/observability_logs_explorer/src'; -import { useKibanaContextForPlugin } from '../utils/use_kibana'; - -export const ConnectedDatasetQualityLink = React.memo(() => { - const { - services: { - share: { url }, - }, - } = useKibanaContextForPlugin(); - const [pageState] = useActor(useObservabilityLogsExplorerPageStateContext()); - - if (pageState.matches({ initialized: 'validLogsExplorerState' })) { - return ; - } else { - return ; - } -}); - -type InitializedPageState = MatchedStateFromActor< - ObservabilityLogsExplorerService, - { initialized: 'validLogsExplorerState' } ->; - -const constructLocatorParams = ( - logsExplorerState: LogsExplorerPublicState -): DatasetQualityLocatorParams => { - const { time, refreshInterval } = logsExplorerState; - const locatorParams: DatasetQualityLocatorParams = { - filters: { - timeRange: { - ...(time ?? { from: 'now-24h', to: 'now' }), - refresh: refreshInterval ?? { pause: false, value: 60000 }, - }, - }, - }; - - return locatorParams; -}; - -export const DatasetQualityLink = React.memo( - ({ - urlService, - pageState, - }: { - urlService: BrowserUrlService; - pageState?: InitializedPageState; - }) => { - const locator = urlService.locators.get( - DATASET_QUALITY_LOCATOR_ID - ); - const locatorParams: DatasetQualityLocatorParams = pageState - ? constructLocatorParams(pageState.context.logsExplorerState) - : {}; - - const datasetQualityUrl = locator?.useUrl(locatorParams); - - const navigateToDatasetQuality = () => { - locator?.navigate(locatorParams); - }; - - const datasetQualityLinkProps = getRouterLinkProps({ - href: datasetQualityUrl, - onClick: navigateToDatasetQuality, - }); - - return ( - - {datasetQualityLinkTitle} - - ); - } -); diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/plugin.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/public/plugin.ts index a014535fa10cf..906caf72a450a 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/plugin.ts +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/public/plugin.ts @@ -16,7 +16,6 @@ import { import { OBSERVABILITY_LOGS_EXPLORER_APP_ID } from '@kbn/deeplinks-observability'; import { AllDatasetsLocatorDefinition, - DatasetQualityLocatorDefinition, ObservabilityLogsExplorerLocators, SingleDatasetLocatorDefinition, } from '../common/locators'; @@ -101,11 +100,6 @@ export class ObservabilityLogsExplorerPlugin useHash, }) ); - const datasetQualityLocator = share.url.locators.create( - new DatasetQualityLocatorDefinition({ - useHash, - }) - ); const dataViewLocator = share.url.locators.create( new DataViewLocatorDefinition({ @@ -120,7 +114,6 @@ export class ObservabilityLogsExplorerPlugin this.locators = { allDatasetsLocator, - datasetQualityLocator, dataViewLocator, singleDatasetLocator, }; diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/routes/main/dataset_quality_route.tsx b/x-pack/plugins/observability_solution/observability_logs_explorer/public/routes/main/dataset_quality_route.tsx deleted file mode 100644 index 325da7a1ceb08..0000000000000 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/routes/main/dataset_quality_route.tsx +++ /dev/null @@ -1,108 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { EuiEmptyPrompt, EuiLoadingLogo } from '@elastic/eui'; -import { CoreStart } from '@kbn/core/public'; -import { DatasetQualityPluginStart } from '@kbn/dataset-quality-plugin/public'; -import { DatasetQualityController } from '@kbn/dataset-quality-plugin/public/controller'; -import { OBSERVABILITY_LOGS_EXPLORER_APP_ID } from '@kbn/deeplinks-observability'; -import { FormattedMessage } from '@kbn/i18n-react'; -import { useLinkProps } from '@kbn/observability-shared-plugin/public'; -import { useActor } from '@xstate/react'; -import React from 'react'; -import { ObservabilityLogsExplorerPageTemplate } from '../../components/page_template'; -import { - ObservabilityDatasetQualityPageStateProvider, - useObservabilityDatasetQualityPageStateContext, -} from '../../state_machines/dataset_quality/src/provider'; -import { useBreadcrumbs } from '../../utils/breadcrumbs'; -import { useKbnUrlStateStorageFromRouterContext } from '../../utils/kbn_url_state_context'; -import { useKibanaContextForPlugin } from '../../utils/use_kibana'; - -export interface DatasetQualityRouteProps { - core: CoreStart; -} - -export const DatasetQualityRoute = () => { - const { services } = useKibanaContextForPlugin(); - const { datasetQuality, serverless, chrome, notifications } = services; - const logsExplorerLinkProps = useLinkProps({ app: OBSERVABILITY_LOGS_EXPLORER_APP_ID }); - - useBreadcrumbs( - [ - { - text: 'Datasets', - ...logsExplorerLinkProps, - }, - ], - chrome, - serverless - ); - - const urlStateStorageContainer = useKbnUrlStateStorageFromRouterContext(); - - return ( - - datasetQuality.createDatasetQualityController(initialState) - } - toasts={notifications.toasts} - urlStateStorageContainer={urlStateStorageContainer} - > - - - ); -}; - -const ConnectedContent = React.memo(() => { - const { - services: { datasetQuality }, - } = useKibanaContextForPlugin(); - - const [state] = useActor(useObservabilityDatasetQualityPageStateContext()); - - if (state.matches('initialized')) { - return ( - - ); - } else { - return ; - } -}); - -const InitializingContent = React.memo(() => ( - - } - title={ - - } - /> - -)); - -const InitializedContent = React.memo( - ({ - datasetQuality, - datasetQualityController, - }: { - datasetQuality: DatasetQualityPluginStart; - datasetQualityController: DatasetQualityController; - }) => { - return ( - - - - ); - } -); diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/routes/main/index.tsx b/x-pack/plugins/observability_solution/observability_logs_explorer/public/routes/main/index.tsx index 9d755f302d162..889e340497cf9 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/routes/main/index.tsx +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/public/routes/main/index.tsx @@ -6,4 +6,3 @@ */ export * from './main_route'; -export * from './dataset_quality_route'; diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/controller_service.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/controller_service.ts deleted file mode 100644 index 9847b24fcd03c..0000000000000 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/controller_service.ts +++ /dev/null @@ -1,70 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { CreateDatasetQualityController } from '@kbn/dataset-quality-plugin/public/controller'; -import type { InvokeCreator } from 'xstate'; -import type { ObservabilityDatasetQualityContext, ObservabilityDatasetQualityEvent } from './types'; - -export const createController = - ({ - createDatasetQualityController, - }: { - createDatasetQualityController: CreateDatasetQualityController; - }): InvokeCreator => - (context, event) => - (send) => { - createDatasetQualityController({ - initialState: context.initialDatasetQualityState, - }).then((controller) => { - send({ - type: 'CONTROLLER_CREATED', - controller, - }); - }); - }; - -export const subscribeToDatasetQualityState: InvokeCreator< - ObservabilityDatasetQualityContext, - ObservabilityDatasetQualityEvent -> = (context, _event) => (send) => { - if (!('controller' in context)) { - throw new Error('Failed to subscribe to controller: no controller in context'); - } - - const { controller } = context; - - const subscription = controller.state$.subscribe({ - next: (state) => { - send({ type: 'DATASET_QUALITY_STATE_CHANGED', state }); - }, - }); - - controller.service.start(); - - return () => { - subscription.unsubscribe(); - controller.service.stop(); - }; -}; - -export const openDatasetFlyout = (context: ObservabilityDatasetQualityContext) => { - if (!('controller' in context)) { - throw new Error('Failed to subscribe to controller: no controller in context'); - } - - const { - controller, - initialDatasetQualityState: { flyout }, - } = context; - - if (flyout?.dataset) { - controller.service.send({ - type: 'OPEN_FLYOUT', - dataset: flyout.dataset, - }); - } -}; diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/provider.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/provider.ts deleted file mode 100644 index e900e4851cfc3..0000000000000 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/provider.ts +++ /dev/null @@ -1,30 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { getDevToolsOptions } from '@kbn/xstate-utils'; -import { useInterpret } from '@xstate/react'; -import createContainer from 'constate'; -import { - createObservabilityDatasetQualityStateMachine, - ObservabilityDatasetQualityStateMachineDependencies, -} from './state_machine'; - -export const useObservabilityDatasetQualityPageState = ( - deps: ObservabilityDatasetQualityStateMachineDependencies -) => { - const observabilityDatasetQualityPageStateService = useInterpret( - () => createObservabilityDatasetQualityStateMachine(deps), - { devTools: getDevToolsOptions() } - ); - - return observabilityDatasetQualityPageStateService; -}; - -export const [ - ObservabilityDatasetQualityPageStateProvider, - useObservabilityDatasetQualityPageStateContext, -] = createContainer(useObservabilityDatasetQualityPageState); diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/state_machine.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/state_machine.ts deleted file mode 100644 index 71e97192e07ec..0000000000000 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/state_machine.ts +++ /dev/null @@ -1,146 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { IToasts } from '@kbn/core-notifications-browser'; -import { CreateDatasetQualityController } from '@kbn/dataset-quality-plugin/public/controller'; -import { IKbnUrlStateStorage } from '@kbn/kibana-utils-plugin/public'; -import { actions, createMachine, InterpreterFrom } from 'xstate'; -import { - createController, - openDatasetFlyout, - subscribeToDatasetQualityState, -} from './controller_service'; -import { DEFAULT_CONTEXT } from './defaults'; -import { - ObservabilityDatasetQualityContext, - ObservabilityDatasetQualityEvent, - ObservabilityDatasetQualityTypeState, -} from './types'; -import { initializeFromUrl, updateUrlFromDatasetQualityState } from './url_state_storage_service'; - -export const createPureObservabilityDatasetQualityStateMachine = ( - initialContext: ObservabilityDatasetQualityContext -) => - /** @xstate-layout N4IgpgJg5mDOIC5QHkBGswCcBuBDVAlgDYEAuAngDID2UAogB4AOR1mWAdAK4B2BfpArhIAvSAGIA2gAYAuolBNqsMgWo8FIBogDMOjgFYAbAEZpAdgCcRgwBYAHAcsGANCHK7bHWztsGTRjomevbmRpYAvhFuaBg4+MRkVLSMLGyc-KrCBCL8UABimNQAtgAqBMVg+cSkWADKWNgEAMZg4gCSAHLtpe0AgpTtAFp0ACIA+vkASsgAsuO9s3ST7ZSldFPjdRsAau0AwnQy8kggSiqC6praCAC0ZvrhRua24Tp2jiZuHggATEb2Dj-aQ2PQmcEGSFRGLoRoJEgUGj0ZisdiYDiZQTZXI8ApFYoAVUwRA63V6A2GY0mM3mBKmlGOmnOqiupxutx0Rg49ksv2kBl+9hMQp0oV+30QBnsXgsAX8lhevx0lki0RAsThhARyWRaTRHGa7Fwglx+3UpCKRCIWHE+2QnVKM0olA2432UzofXWo0Zp2Zlw0bMQt0FHCMAN85jC9k5tl+cYlCFCJg4QRMxnM0lsZkcRmh6th8S1SSRqVRGQEQlEkG4PAA1jxqAB3HillHpTB1UjGtqUZAAcXGdAAGgAFPsezZ1Upe5b7AASfU6-bGvsUyhZgdANyVBg4JmzRl+UtFFks9nsiYh0n3tn59lM-2FNnzGqLiURKXb+sxVZyNbwEgIDbPV6m7WpxD7QcR3HZBJy2Gd1jdRdl1XOQmQ3ANrklUxDFCSxDwVX4TAIq9BXMIFnnTc9gXseMojVRsIDgTQ3zwYtP11ctMAwi41C3LRg3TFMnheN4Pn8RN7h0CjpDk6QDyFcxiOkX5VRhOJ2I-HUyw7Wtf2xSBeM3bCEAot4LyFHl42cEEpNsSxDHkkwlTMKwH2cV9Cy07UQO4jFK2xPJChKcpKmqIhak7RoWjAYysKDO57Bvayswc0EDxeMiuVscwdEFAUBRci9fi8zT4RLL9QPRAzRGC-EiSIeL+NMjkuXeNT3PDF5fFcdxEDjFNlNBSxwQvXKdDKzVtL8vTDTAY08jNHgLWoK0sGa1lt2DTkOGsJUHNGuSSJ8RMXhTEw8t8S61LkpwpvfXyqv82r-wgTaBPZOjvGSz49F5RxzEvfqEDMdMwzvBwAnMAwoxIh6fMqri9NesQIFrBtm1bZ6Oy7HsPta3wfukP7lQKoGr2fDhpEsTllNCAwdAUya1TYirON0n9AurdHAIIYCcbRPHagJxKjBp-cDCzA9LDuqxLEph9qdp55yMZhSDAYiIgA */ - createMachine< - ObservabilityDatasetQualityContext, - ObservabilityDatasetQualityEvent, - ObservabilityDatasetQualityTypeState - >( - { - context: initialContext, - predictableActionArguments: true, - id: 'ObservabilityDatasetQuality', - initial: 'initializingFromUrl', - states: { - initializingFromUrl: { - invoke: { - src: 'initializeFromUrl', - }, - on: { - INITIALIZED_FROM_URL: { - target: 'creatingController', - actions: ['storeInitialUrlState'], - }, - }, - }, - creatingController: { - invoke: { - src: 'createController', - }, - on: { - CONTROLLER_CREATED: { - target: 'initialized', - actions: ['storeController', 'openDatasetFlyout'], - }, - }, - }, - initialized: { - invoke: { - src: 'subscribeToDatasetQualityState', - }, - states: { - unknownDatasetQualityState: { - on: { - DATASET_QUALITY_STATE_CHANGED: { - target: 'validDatasetQualityState', - actions: ['storeDatasetQualityState', 'updateUrlFromDatasetQualityState'], - }, - }, - }, - validDatasetQualityState: { - on: { - DATASET_QUALITY_STATE_CHANGED: { - actions: ['storeDatasetQualityState', 'updateUrlFromDatasetQualityState'], - target: 'validDatasetQualityState', - internal: true, - }, - }, - }, - }, - initial: 'unknownDatasetQualityState', - }, - }, - }, - { - actions: { - storeController: actions.assign((_context, event) => { - return 'controller' in event && event.type === 'CONTROLLER_CREATED' - ? { controller: event.controller } - : {}; - }), - storeInitialUrlState: actions.assign((context, event) => { - return 'stateFromUrl' in event && event.type === 'INITIALIZED_FROM_URL' - ? { - initialDatasetQualityState: { - ...('initialDatasetQualityState' in context - ? context.initialDatasetQualityState - : {}), - ...event.stateFromUrl, - }, - } - : {}; - }), - storeDatasetQualityState: actions.assign((_context, event) => { - return 'state' in event && event.type === 'DATASET_QUALITY_STATE_CHANGED' - ? { datasetQualityState: event.state } - : {}; - }), - }, - } - ); - -export interface ObservabilityDatasetQualityStateMachineDependencies { - createDatasetQualityController: CreateDatasetQualityController; - initialContext?: ObservabilityDatasetQualityContext; - toasts: IToasts; - urlStateStorageContainer: IKbnUrlStateStorage; -} - -export const createObservabilityDatasetQualityStateMachine = ({ - initialContext = DEFAULT_CONTEXT, - toasts, - urlStateStorageContainer, - createDatasetQualityController, -}: ObservabilityDatasetQualityStateMachineDependencies) => - createPureObservabilityDatasetQualityStateMachine(initialContext).withConfig({ - actions: { - updateUrlFromDatasetQualityState: updateUrlFromDatasetQualityState({ - urlStateStorageContainer, - }), - openDatasetFlyout, - }, - services: { - createController: createController({ createDatasetQualityController }), - initializeFromUrl: initializeFromUrl({ urlStateStorageContainer, toastsService: toasts }), - subscribeToDatasetQualityState, - }, - }); - -export type ObservabilityDatasetQualityService = InterpreterFrom< - typeof createObservabilityDatasetQualityStateMachine ->; diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/types.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/types.ts deleted file mode 100644 index 4fa864b35951e..0000000000000 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/types.ts +++ /dev/null @@ -1,54 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { - DatasetQualityController, - DatasetQualityPublicState, - DatasetQualityPublicStateUpdate, -} from '@kbn/dataset-quality-plugin/public/controller'; - -export type ObservabilityDatasetQualityContext = ObservabilityDatasetQualityTypeState['context']; - -export interface CommonObservabilityDatasetQualityContext { - initialDatasetQualityState: DatasetQualityPublicStateUpdate; -} - -export interface WithDatasetQualityState { - datasetQualityState: DatasetQualityPublicState; -} - -export interface WithController { - controller: DatasetQualityController; -} - -export type ObservabilityDatasetQualityEvent = - | { - type: 'INITIALIZED_FROM_URL'; - stateFromUrl?: DatasetQualityPublicStateUpdate; - } - | { - type: 'CONTROLLER_CREATED'; - controller: DatasetQualityController; - } - | { - type: 'DATASET_QUALITY_STATE_CHANGED'; - state: DatasetQualityPublicState; - }; - -export type ObservabilityDatasetQualityTypeState = - | { - value: 'initializingFromUrl' | 'creatingController'; - context: CommonObservabilityDatasetQualityContext; - } - | { - value: 'initialized' | { initialized: 'unknownDatasetQualityState' }; - context: CommonObservabilityDatasetQualityContext & WithController; - } - | { - value: { initialized: 'validDatasetQualityState' }; - context: CommonObservabilityDatasetQualityContext & WithDatasetQualityState & WithController; - }; diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/url_state_storage_service.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/url_state_storage_service.ts deleted file mode 100644 index 43cbd834729fc..0000000000000 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/state_machines/dataset_quality/src/url_state_storage_service.ts +++ /dev/null @@ -1,75 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { IToasts } from '@kbn/core-notifications-browser'; -import { createPlainError, formatErrors } from '@kbn/io-ts-utils'; -import { IKbnUrlStateStorage, withNotifyOnErrors } from '@kbn/kibana-utils-plugin/public'; -import * as Either from 'fp-ts/lib/Either'; -import * as rt from 'io-ts'; -import { InvokeCreator } from 'xstate'; -import { OBSERVABILITY_DATASET_QUALITY_URL_STATE_KEY } from '../../../../common'; -import type { ObservabilityDatasetQualityContext, ObservabilityDatasetQualityEvent } from './types'; -import * as urlSchemaV1 from './url_schema_v1'; - -interface ObservabilityDatasetQualityUrlStateDependencies { - toastsService: IToasts; - urlStateStorageContainer: IKbnUrlStateStorage; -} - -export const updateUrlFromDatasetQualityState = - ({ urlStateStorageContainer }: { urlStateStorageContainer: IKbnUrlStateStorage }) => - (context: ObservabilityDatasetQualityContext, event: ObservabilityDatasetQualityEvent) => { - if (!('datasetQualityState' in context)) { - return; - } - - const encodedUrlStateValues = urlSchemaV1.stateFromUntrustedUrlRT.encode( - context.datasetQualityState - ); - - urlStateStorageContainer.set( - OBSERVABILITY_DATASET_QUALITY_URL_STATE_KEY, - encodedUrlStateValues, - { - replace: true, - } - ); - }; - -export const initializeFromUrl = - ({ - toastsService, - urlStateStorageContainer, - }: ObservabilityDatasetQualityUrlStateDependencies): InvokeCreator< - ObservabilityDatasetQualityContext, - ObservabilityDatasetQualityEvent - > => - (_context, _event) => - (send) => { - const urlStateValues = - urlStateStorageContainer.get(OBSERVABILITY_DATASET_QUALITY_URL_STATE_KEY) ?? - undefined; - - const stateValuesE = rt - .union([rt.undefined, urlSchemaV1.stateFromUntrustedUrlRT]) - .decode(urlStateValues); - - if (Either.isLeft(stateValuesE)) { - withNotifyOnErrors(toastsService).onGetError( - createPlainError(formatErrors(stateValuesE.left)) - ); - send({ - type: 'INITIALIZED_FROM_URL', - stateFromUrl: undefined, - }); - } else { - send({ - type: 'INITIALIZED_FROM_URL', - stateFromUrl: stateValuesE.right, - }); - } - }; diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/public/types.ts b/x-pack/plugins/observability_solution/observability_logs_explorer/public/types.ts index b62863cbb4783..d66a26a6b3c35 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/public/types.ts +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/public/types.ts @@ -13,7 +13,6 @@ import { ServerlessPluginStart } from '@kbn/serverless/public'; import { SharePluginSetup, SharePluginStart } from '@kbn/share-plugin/public'; import { AppMountParameters, ScopedHistory } from '@kbn/core/public'; import { LogsSharedClientStartExports } from '@kbn/logs-shared-plugin/public'; -import { DatasetQualityPluginStart } from '@kbn/dataset-quality-plugin/public'; import { ObservabilityAIAssistantPublicStart } from '@kbn/observability-ai-assistant-plugin/public'; import { TriggersAndActionsUIPublicPluginStart } from '@kbn/triggers-actions-ui-plugin/public'; import { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/public'; @@ -54,7 +53,6 @@ export interface ObservabilityLogsExplorerStartDeps { dataViewEditor?: DataViewEditorStart; lens?: LensPublicStart; share: SharePluginStart; - datasetQuality: DatasetQualityPluginStart; } export type ObservabilityLogsExplorerHistory = diff --git a/x-pack/plugins/observability_solution/observability_logs_explorer/tsconfig.json b/x-pack/plugins/observability_solution/observability_logs_explorer/tsconfig.json index c41cf932e9ece..f88b9de65d0c0 100644 --- a/x-pack/plugins/observability_solution/observability_logs_explorer/tsconfig.json +++ b/x-pack/plugins/observability_solution/observability_logs_explorer/tsconfig.json @@ -17,7 +17,6 @@ "@kbn/core-mount-utils-browser-internal", "@kbn/core-notifications-browser", "@kbn/data-plugin", - "@kbn/dataset-quality-plugin", "@kbn/deeplinks-observability", "@kbn/discover-plugin", "@kbn/i18n", diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 5493da4a52b6f..45f91ad82c4ac 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -44884,7 +44884,6 @@ "xpack.observabilityLogsExplorer.appTitle": "Explorateur de logs", "xpack.observabilityLogsExplorer.betaBadgeDescription": "Il s'agit du stade bêta de l'application, qui est donc susceptible d'évoluer.", "xpack.observabilityLogsExplorer.betaBadgeTitle": "Bêta", - "xpack.observabilityLogsExplorer.datasetQuality.InitializingTitle": "Initialisation de la qualité de l'ensemble de données", "xpack.observabilityLogsExplorer.discoverLinkTitle": "Ouvrir dans Discover", "xpack.observabilityLogsExplorer.feedbackLinkTitle": "Donner un retour", "xpack.observabilityLogsExplorer.feedbackToast.buttonText": "Répondre à une enquête rapide", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index e1691ae0ab930..8074fc8815f89 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -44854,7 +44854,6 @@ "xpack.observabilityLogsExplorer.appTitle": "ログエクスプローラー", "xpack.observabilityLogsExplorer.betaBadgeDescription": "このアプリケーションはベータ版であるため、変更される場合があります。", "xpack.observabilityLogsExplorer.betaBadgeTitle": "ベータ", - "xpack.observabilityLogsExplorer.datasetQuality.InitializingTitle": "データセット品質を初期化しています", "xpack.observabilityLogsExplorer.discoverLinkTitle": "Discoverで開く", "xpack.observabilityLogsExplorer.feedbackLinkTitle": "フィードバックを作成する", "xpack.observabilityLogsExplorer.feedbackToast.buttonText": "簡単なアンケートに答える", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 70c4740f38375..0d52e86e5b9a3 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -44903,7 +44903,6 @@ "xpack.observabilityLogsExplorer.appTitle": "日志浏览器", "xpack.observabilityLogsExplorer.betaBadgeDescription": "此应用程序为公测版,因此可能会进行更改。", "xpack.observabilityLogsExplorer.betaBadgeTitle": "公测版", - "xpack.observabilityLogsExplorer.datasetQuality.InitializingTitle": "正在初始化数据集质量", "xpack.observabilityLogsExplorer.discoverLinkTitle": "在 Discover 中打开", "xpack.observabilityLogsExplorer.feedbackLinkTitle": "反馈", "xpack.observabilityLogsExplorer.feedbackToast.buttonText": "参加快速调查", diff --git a/x-pack/test/functional/page_objects/dataset_quality.ts b/x-pack/test/functional/page_objects/dataset_quality.ts index ba7a4241bdf8a..3a7911696b1b9 100644 --- a/x-pack/test/functional/page_objects/dataset_quality.ts +++ b/x-pack/test/functional/page_objects/dataset_quality.ts @@ -11,9 +11,9 @@ import expect from '@kbn/expect'; import { TimeUnitId } from '@elastic/eui'; import { WebElementWrapper } from '@kbn/ftr-common-functional-ui-services'; import { - OBSERVABILITY_DATASET_QUALITY_URL_STATE_KEY, + DATA_QUALITY_URL_STATE_KEY, datasetQualityUrlSchemaV1, -} from '@kbn/observability-logs-explorer-plugin/common'; +} from '@kbn/data-quality-plugin/common'; import { DEFAULT_DEGRADED_FIELD_SORT_DIRECTION, DEFAULT_DEGRADED_FIELD_SORT_FIELD, @@ -114,7 +114,7 @@ export function DatasetQualityPageObject({ getPageObjects, getService }: FtrProv pageState?: datasetQualityUrlSchemaV1.UrlSchema; } = {}) { const queryStringParams = querystring.stringify({ - [OBSERVABILITY_DATASET_QUALITY_URL_STATE_KEY]: rison.encode( + [DATA_QUALITY_URL_STATE_KEY]: rison.encode( datasetQualityUrlSchemaV1.urlSchemaRT.encode({ ...defaultPageState, ...pageState, @@ -123,8 +123,8 @@ export function DatasetQualityPageObject({ getPageObjects, getService }: FtrProv }); return PageObjects.common.navigateToUrlWithBrowserHistory( - 'observabilityLogsExplorer', - '/dataset-quality', + 'management', + '/data/data_quality', queryStringParams, { // the check sometimes is too slow for the page so it misses the point diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index d307c65c96742..10d864d304006 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -175,6 +175,7 @@ "@kbn/analytics-ftr-helpers-plugin", "@kbn/alerting-comparators", "@kbn/alerting-state-types", - "@kbn/reporting-server" + "@kbn/reporting-server", + "@kbn/data-quality-plugin" ] } diff --git a/yarn.lock b/yarn.lock index 3366cf8c58830..3272c5b492a28 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4371,6 +4371,10 @@ version "0.0.0" uid "" +"@kbn/data-quality-plugin@link:x-pack/plugins/data_quality": + version "0.0.0" + uid "" + "@kbn/data-search-plugin@link:test/plugin_functional/plugins/data_search": version "0.0.0" uid ""