forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Dataset quality] Move page to stack management > Data (elastic#184122)
Relates to elastic#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 <[email protected]>
- Loading branch information
1 parent
74bf816
commit d39739e
Showing
60 changed files
with
659 additions
and
755 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# dataQuality | ||
Page where users can see the quality of their log datasets. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; 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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
x-pack/plugins/data_quality/common/utils/deep_compact_object.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { isEmpty, isPlainObject, isUndefined } from 'lodash'; | ||
|
||
export const deepCompactObject = <Value extends Record<string, any>>(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))) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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", | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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( | ||
<App params={params} core={core} plugins={plugins} pluginStart={pluginStart} />, | ||
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 ( | ||
<KibanaRenderContextProvider {...core} {...params}> | ||
<KibanaContextProviderForPlugin> | ||
<KbnUrlStateStorageFromRouterProvider> | ||
<Router history={params.history}> | ||
<Routes> | ||
<Route path="/" exact={true} render={() => <DatasetQualityRoute />} /> | ||
</Routes> | ||
</Router> | ||
</KbnUrlStateStorageFromRouterProvider> | ||
</KibanaContextProviderForPlugin> | ||
</KibanaRenderContextProvider> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; 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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AppPluginStartDependencies, DataQualityPluginStart>, | ||
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() {} | ||
} |
78 changes: 78 additions & 0 deletions
78
x-pack/plugins/data_quality/public/routes/dataset_quality/context.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<DatasetQualityController>(); | ||
|
||
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 ( | ||
<DatasetQualityContext.Provider value={{ controller }}> | ||
{children} | ||
</DatasetQualityContext.Provider> | ||
); | ||
} | ||
|
||
export const useDatasetQualityContext = () => { | ||
const context = useContext(DatasetQualityContext); | ||
if (context === undefined) { | ||
throw new Error( | ||
'useDatasetQualityContext must be used within a <DatasetQualityContextProvider />' | ||
); | ||
} | ||
return context; | ||
}; |
Oops, something went wrong.