Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Kibana context types clean up #170868

Merged
merged 8 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,22 @@ export const ChangePointDetectionPage: FC = () => {
appDependencies={{
...pick(services, [
'application',
'cases',
'charts',
'data',
'embeddable',
'executionContext',
'charts',
'fieldFormats',
'http',
'i18n',
'lens',
'notifications',
'presentationUtil',
'share',
'storage',
'theme',
'uiSettings',
'unifiedSearch',
'theme',
'lens',
'presentationUtil',
'embeddable',
'cases',
'i18n',
'usageCollection',
]),
fieldStats: { useFieldStatsTrigger, FieldStatsFlyoutProvider },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,19 @@ export const LogCategorizationPage: FC = () => {
showFrozenDataTierChoice={showNodeInfo}
appDependencies={pick(services, [
'application',
'charts',
'data',
'executionContext',
'charts',
'fieldFormats',
'http',
'i18n',
'lens',
'notifications',
'share',
'storage',
'theme',
'uiSettings',
'unifiedSearch',
'theme',
'lens',
'i18n',
])}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,19 @@ export const LogRateAnalysisPage: FC = () => {
showFrozenDataTierChoice={showNodeInfo}
appDependencies={pick(services, [
'application',
'charts',
'data',
'executionContext',
'charts',
'fieldFormats',
'http',
'i18n',
'lens',
'notifications',
'share',
'storage',
'theme',
'uiSettings',
'unifiedSearch',
'theme',
'lens',
'i18n',
])}
/>
)}
Expand Down
38 changes: 20 additions & 18 deletions x-pack/plugins/ml/public/application/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ import { mlApiServicesProvider } from './services/ml_api_service';
import { HttpService } from './services/http_service';
import type { PageDependencies } from './routing/router';
import { EnabledFeaturesContextProvider } from './contexts/ml';
import type { StartServices } from './contexts/kibana';

export type MlDependencies = Omit<
MlSetupDependencies,
'share' | 'fieldFormats' | 'maps' | 'cases' | 'licensing'
'share' | 'fieldFormats' | 'maps' | 'cases' | 'licensing' | 'uiActions'
> &
MlStartDependencies;

Expand Down Expand Up @@ -78,31 +79,32 @@ const App: FC<AppProps> = ({ coreStart, deps, appMountParams, isServerless, mlFe
setBreadcrumbs: coreStart.chrome!.setBreadcrumbs,
};

const services = useMemo(() => {
const services: StartServices = useMemo(() => {
return {
kibanaVersion: deps.kibanaVersion,
share: deps.share,
cases: deps.cases,
charts: deps.charts,
contentManagement: deps.contentManagement,
dashboard: deps.dashboard,
data: deps.data,
dataViewEditor: deps.dataViewEditor,
security: deps.security,
licenseManagement: deps.licenseManagement,
storage: localStorage,
embeddable: deps.embeddable,
maps: deps.maps,
triggersActionsUi: deps.triggersActionsUi,
dataViews: deps.data.dataViews,
dataVisualizer: deps.dataVisualizer,
usageCollection: deps.usageCollection,
embeddable: deps.embeddable,
fieldFormats: deps.fieldFormats,
dashboard: deps.dashboard,
charts: deps.charts,
cases: deps.cases,
unifiedSearch: deps.unifiedSearch,
licensing: deps.licensing,
kibanaVersion: deps.kibanaVersion,
lens: deps.lens,
licenseManagement: deps.licenseManagement,
maps: deps.maps,
presentationUtil: deps.presentationUtil,
savedObjectsManagement: deps.savedObjectsManagement,
savedSearch: deps.savedSearch,
contentManagement: deps.contentManagement,
presentationUtil: deps.presentationUtil,
security: deps.security,
share: deps.share,
storage: localStorage,
triggersActionsUi: deps.triggersActionsUi,
uiActions: deps.uiActions,
unifiedSearch: deps.unifiedSearch,
usageCollection: deps.usageCollection,
...coreStart,
mlServices: getMlGlobalServices(coreStart.http, deps.usageCollection),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ import type { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import type { CoreStart } from '@kbn/core/public';
import type { UsageCollectionSetup } from '@kbn/usage-collection-plugin/public';
import { useKibana, KibanaReactContextValue } from '@kbn/kibana-react-plugin/public';
import type { SecurityPluginSetup } from '@kbn/security-plugin/public';
import type { SecurityPluginStart } from '@kbn/security-plugin/public';
import type { LicenseManagementUIPluginSetup } from '@kbn/license-management-plugin/public';
import type { SharePluginStart } from '@kbn/share-plugin/public';
import type { IStorageWrapper } from '@kbn/kibana-utils-plugin/public';
import type { EmbeddableStart } from '@kbn/embeddable-plugin/public';
import type { MapsStartApi } from '@kbn/maps-plugin/public';
import type { DataVisualizerPluginStart } from '@kbn/data-visualizer-plugin/public';
import type { TriggersAndActionsUIPublicPluginStart } from '@kbn/triggers-actions-ui-plugin/public';
import type { FieldFormatsRegistry } from '@kbn/field-formats-plugin/common';
import type { DashboardStart } from '@kbn/dashboard-plugin/public';
import type { SpacesPluginStart } from '@kbn/spaces-plugin/public';
import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
Expand All @@ -30,33 +29,34 @@ import type { ContentManagementPublicStart } from '@kbn/content-management-plugi
import type { SavedSearchPublicPluginStart } from '@kbn/saved-search-plugin/public';
import type { PresentationUtilPluginStart } from '@kbn/presentation-util-plugin/public';
import type { DataViewEditorStart } from '@kbn/data-view-editor-plugin/public';
import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
import type { UiActionsStart } from '@kbn/ui-actions-plugin/public';
import type { MlServicesContext } from '../../app';

interface StartPlugins {
cases?: CasesUiStart;
charts: ChartsPluginStart;
contentManagement: ContentManagementPublicStart;
dashboard: DashboardStart;
data: DataPublicPluginStart;
dataViewEditor: DataViewEditorStart;
dataViews: DataViewsPublicPluginStart;
security?: SecurityPluginSetup;
licenseManagement?: LicenseManagementUIPluginSetup;
share: SharePluginStart;
embeddable: EmbeddableStart;
maps?: MapsStartApi;
triggersActionsUi?: TriggersAndActionsUIPublicPluginStart;
dataVisualizer?: DataVisualizerPluginStart;
usageCollection?: UsageCollectionSetup;
fieldFormats: FieldFormatsRegistry;
dashboard: DashboardStart;
spacesApi?: SpacesPluginStart;
charts: ChartsPluginStart;
cases?: CasesUiStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
core: CoreStart;
appName: string;
embeddable: EmbeddableStart;
fieldFormats: FieldFormatsStart;
lens: LensPublicStart;
licenseManagement?: LicenseManagementUIPluginSetup;
maps?: MapsStartApi;
presentationUtil: PresentationUtilPluginStart;
savedObjectsManagement: SavedObjectsManagementPluginStart;
savedSearch: SavedSearchPublicPluginStart;
contentManagement: ContentManagementPublicStart;
presentationUtil: PresentationUtilPluginStart;
security?: SecurityPluginStart;
share: SharePluginStart;
spacesApi?: SpacesPluginStart;
triggersActionsUi?: TriggersAndActionsUIPublicPluginStart;
uiActions: UiActionsStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
usageCollection?: UsageCollectionSetup;
}
export type StartServices = CoreStart &
StartPlugins & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { QueryStringInput } from '@kbn/unified-search-plugin/public';
import { QueryErrorMessage } from '@kbn/ml-error-utils';

import { SEARCH_QUERY_LANGUAGE, SearchQueryLanguage } from '@kbn/ml-query-utils';
import { PLUGIN_ID } from '../../../../../../../common/constants/app';
import { Dictionary } from '../../../../../../../common/types/common';
import { removeFilterFromQueryString } from '../../../../../explorer/explorer_utils';
import { useMlKibana } from '../../../../../contexts/kibana';
Expand Down Expand Up @@ -53,17 +54,8 @@ export const ExplorationQueryBar: FC<ExplorationQueryBarProps> = ({
);

const { services } = useMlKibana();
const {
unifiedSearch,
data,
storage,
appName,
notifications,
http,
docLinks,
uiSettings,
dataViews,
} = services;
const { unifiedSearch, data, storage, notifications, http, docLinks, uiSettings, dataViews } =
services;

const searchChangeHandler = (q: Query) => setSearchInput(q);

Expand Down Expand Up @@ -206,7 +198,7 @@ export const ExplorationQueryBar: FC<ExplorationQueryBarProps> = ({
disableAutoFocus={true}
dataTestSubj="mlDFAnalyticsQueryInput"
languageSwitcherPopoverAnchorPosition="rightDown"
appName={appName}
appName={PLUGIN_ID}
deps={{
unifiedSearch,
notifications,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import type { DataView } from '@kbn/data-views-plugin/common';
import type { QueryErrorMessage } from '@kbn/ml-error-utils';
import type { InfluencersFilterQuery } from '@kbn/ml-anomaly-utils';
import { SEARCH_QUERY_LANGUAGE } from '@kbn/ml-query-utils';
import { PLUGIN_ID } from '../../../../../common/constants/app';
import { useAnomalyExplorerContext } from '../../anomaly_explorer_context';
import { useMlKibana } from '../../../contexts/kibana';

Expand Down Expand Up @@ -113,7 +114,6 @@ export const ExplorerQueryBar: FC<ExplorerQueryBarProps> = ({
unifiedSearch,
data,
storage,
appName,
notifications,
http,
docLinks,
Expand Down Expand Up @@ -176,7 +176,7 @@ export const ExplorerQueryBar: FC<ExplorerQueryBarProps> = ({
disableAutoFocus
dataTestSubj="explorerQueryInput"
languageSwitcherPopoverAnchorPosition="rightDown"
appName={appName}
appName={PLUGIN_ID}
deps={{
unifiedSearch,
notifications,
Expand Down
86 changes: 43 additions & 43 deletions x-pack/plugins/ml/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,45 +70,45 @@ import type { MlCapabilities } from './shared';
import { ElasticModels } from './application/services/elastic_models_service';

export interface MlStartDependencies {
dataViewEditor: DataViewEditorStart;
cases?: CasesUiStart;
charts: ChartsPluginStart;
contentManagement: ContentManagementPublicStart;
dashboard: DashboardStart;
data: DataPublicPluginStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
licensing: LicensingPluginStart;
share: SharePluginStart;
uiActions: UiActionsStart;
spaces?: SpacesPluginStart;
embeddable: EmbeddableStart;
maps?: MapsStartApi;
triggersActionsUi?: TriggersAndActionsUIPublicPluginStart;
dataViewEditor: DataViewEditorStart;
dataVisualizer: DataVisualizerPluginStart;
embeddable: EmbeddableStart;
fieldFormats: FieldFormatsStart;
dashboard: DashboardStart;
charts: ChartsPluginStart;
lens?: LensPublicStart;
cases?: CasesUiStart;
security: SecurityPluginStart;
lens: LensPublicStart;
licensing: LicensingPluginStart;
maps?: MapsStartApi;
presentationUtil: PresentationUtilPluginStart;
savedObjectsManagement: SavedObjectsManagementPluginStart;
savedSearch: SavedSearchPublicPluginStart;
contentManagement: ContentManagementPublicStart;
presentationUtil: PresentationUtilPluginStart;
security: SecurityPluginStart;
share: SharePluginStart;
spaces?: SpacesPluginStart;
triggersActionsUi?: TriggersAndActionsUIPublicPluginStart;
uiActions: UiActionsStart;
unifiedSearch: UnifiedSearchPublicPluginStart;
}

export interface MlSetupDependencies {
maps?: MapsSetupApi;
licensing: LicensingPluginSetup;
management?: ManagementSetup;
licenseManagement?: LicenseManagementUIPluginSetup;
home?: HomePublicPluginSetup;
alerting?: AlertingSetup;
cases?: CasesUiSetup;
dashboard: DashboardSetup;
embeddable: EmbeddableSetup;
uiActions: UiActionsSetup;
fieldFormats: FieldFormatsSetup;
home?: HomePublicPluginSetup;
kibanaVersion: string;
licenseManagement?: LicenseManagementUIPluginSetup;
licensing: LicensingPluginSetup;
management?: ManagementSetup;
maps?: MapsSetupApi;
share: SharePluginSetup;
triggersActionsUi?: TriggersAndActionsUIPublicPluginSetup;
alerting?: AlertingSetup;
uiActions: UiActionsSetup;
usageCollection?: UsageCollectionSetup;
fieldFormats: FieldFormatsSetup;
dashboard: DashboardSetup;
cases?: CasesUiSetup;
}

export type MlCoreSetup = CoreSetup<MlStartDependencies, MlPluginStart>;
Expand Down Expand Up @@ -154,31 +154,31 @@ export class MlPlugin implements Plugin<MlPluginSetup, MlPluginStart> {
return renderApp(
coreStart,
{
cases: pluginsStart.cases,
charts: pluginsStart.charts,
contentManagement: pluginsStart.contentManagement,
dashboard: pluginsStart.dashboard,
data: pluginsStart.data,
dataViewEditor: pluginsStart.dataViewEditor,
unifiedSearch: pluginsStart.unifiedSearch,
dashboard: pluginsStart.dashboard,
share: pluginsStart.share,
security: pluginsStart.security,
licensing: pluginsStart.licensing,
management: pluginsSetup.management,
licenseManagement: pluginsSetup.licenseManagement,
home: pluginsSetup.home,
embeddable: { ...pluginsSetup.embeddable, ...pluginsStart.embeddable },
maps: pluginsStart.maps,
uiActions: pluginsStart.uiActions,
kibanaVersion: this.initializerContext.env.packageInfo.version,
triggersActionsUi: pluginsStart.triggersActionsUi,
dataVisualizer: pluginsStart.dataVisualizer,
usageCollection: pluginsSetup.usageCollection,
embeddable: { ...pluginsSetup.embeddable, ...pluginsStart.embeddable },
fieldFormats: pluginsStart.fieldFormats,
home: pluginsSetup.home,
kibanaVersion: this.initializerContext.env.packageInfo.version,
lens: pluginsStart.lens,
cases: pluginsStart.cases,
licenseManagement: pluginsSetup.licenseManagement,
licensing: pluginsStart.licensing,
management: pluginsSetup.management,
maps: pluginsStart.maps,
presentationUtil: pluginsStart.presentationUtil,
savedObjectsManagement: pluginsStart.savedObjectsManagement,
savedSearch: pluginsStart.savedSearch,
contentManagement: pluginsStart.contentManagement,
presentationUtil: pluginsStart.presentationUtil,
security: pluginsStart.security,
share: pluginsStart.share,
triggersActionsUi: pluginsStart.triggersActionsUi,
uiActions: pluginsStart.uiActions,
unifiedSearch: pluginsStart.unifiedSearch,
usageCollection: pluginsSetup.usageCollection,
},
params,
this.isServerless,
Expand Down
Loading