Skip to content

Commit

Permalink
[8.x] [ML] AIOps: Cleanup context/embeddingOrigin (#194442) (#195284)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.x`:
- [[ML] AIOps: Cleanup context/embeddingOrigin
(#194442)](#194442)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Walter
Rafelsberger","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-07T15:32:18Z","message":"[ML]
AIOps: Cleanup context/embeddingOrigin (#194442)\n\n##
Summary\r\n\r\nPart of #187772.\r\n\r\nWe had a mix of passing around
`embeddingOrigin` via props and context.\r\nThis PR cleans this up,
`embeddingOrigin` is now be required to be\r\npassed in on the outer
most component and will then be used internally\r\nvia context
only.\r\n\r\nThe PR also renames references to `AppDependencies`
to\r\n`AiopsAppContextValue`. Originally, this context was used only to
pass\r\nin dependencies to be used via `useKibana`. Over time this
changed a bit\r\nand we started passing in other non-changing values,
the naming change\r\nnow reflects that more properly and brings the name
in line with the\r\nother context related vars like
`AiopsAppContext.Provider` and\r\n`useAiopsAppContext`.\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] This was checked for breaking
API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"ae36dd5bf2713cafc2e5eaa73629612686842c1a","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":[":ml","release_note:skip","v9.0.0","Feature:ML/AIOps","ci:project-deploy-observability","Team:obs-ux-management","v8.16.0","backport:version"],"title":"[ML]
AIOps: Cleanup
context/embeddingOrigin","number":194442,"url":"https://github.com/elastic/kibana/pull/194442","mergeCommit":{"message":"[ML]
AIOps: Cleanup context/embeddingOrigin (#194442)\n\n##
Summary\r\n\r\nPart of #187772.\r\n\r\nWe had a mix of passing around
`embeddingOrigin` via props and context.\r\nThis PR cleans this up,
`embeddingOrigin` is now be required to be\r\npassed in on the outer
most component and will then be used internally\r\nvia context
only.\r\n\r\nThe PR also renames references to `AppDependencies`
to\r\n`AiopsAppContextValue`. Originally, this context was used only to
pass\r\nin dependencies to be used via `useKibana`. Over time this
changed a bit\r\nand we started passing in other non-changing values,
the naming change\r\nnow reflects that more properly and brings the name
in line with the\r\nother context related vars like
`AiopsAppContext.Provider` and\r\n`useAiopsAppContext`.\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] This was checked for breaking
API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"ae36dd5bf2713cafc2e5eaa73629612686842c1a"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/194442","number":194442,"mergeCommit":{"message":"[ML]
AIOps: Cleanup context/embeddingOrigin (#194442)\n\n##
Summary\r\n\r\nPart of #187772.\r\n\r\nWe had a mix of passing around
`embeddingOrigin` via props and context.\r\nThis PR cleans this up,
`embeddingOrigin` is now be required to be\r\npassed in on the outer
most component and will then be used internally\r\nvia context
only.\r\n\r\nThe PR also renames references to `AppDependencies`
to\r\n`AiopsAppContextValue`. Originally, this context was used only to
pass\r\nin dependencies to be used via `useKibana`. Over time this
changed a bit\r\nand we started passing in other non-changing values,
the naming change\r\nnow reflects that more properly and brings the name
in line with the\r\nother context related vars like
`AiopsAppContext.Provider` and\r\n`useAiopsAppContext`.\r\n\r\n\r\n###
Checklist\r\n\r\n- [ ] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [ ] [Flaky
Test\r\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\r\nused on any tests changed\r\n- [x] This was checked for breaking
API changes and was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"ae36dd5bf2713cafc2e5eaa73629612686842c1a"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Walter Rafelsberger <[email protected]>
  • Loading branch information
kibanamachine and walterra authored Oct 7, 2024
1 parent 821ddaa commit 07c493c
Show file tree
Hide file tree
Showing 34 changed files with 243 additions and 264 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { METRIC_TYPE, UiCounterMetricType } from '@kbn/analytics';
import { type EmbeddablePatternAnalysisInput } from '@kbn/aiops-log-pattern-analysis/embeddable';
import { pick } from 'lodash';
import type { LogCategorizationEmbeddableProps } from '@kbn/aiops-plugin/public/components/log_categorization/log_categorization_for_embeddable/log_categorization_for_discover';
import type { AiopsAppContextValue } from '@kbn/aiops-plugin/public/hooks/use_aiops_app_context';
import { useDiscoverServices } from '../../../../hooks/use_discover_services';
import type { DiscoverStateContainer } from '../../state_management/discover_state';
import { PATTERN_ANALYSIS_LOADED } from './constants';
Expand Down Expand Up @@ -63,8 +64,11 @@ export const PatternAnalysisTable = (props: PatternAnalysisTableProps) => {
return (
<aiopsService.PatternAnalysisComponent
props={patternAnalysisComponentProps}
deps={services}
embeddingOrigin="discover"
appContextValue={
// TODO We shouldn't cast to `unknown` here, goal is to use feature specific contexts.
// See https://github.com/elastic/kibana/pull/194442
{ embeddingOrigin: 'discover', ...services } as unknown as AiopsAppContextValue
}
/>
);
};
16 changes: 11 additions & 5 deletions x-pack/packages/ml/aiops_common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ export const AIOPS_API_ENDPOINT = {
CATEGORIZATION_FIELD_VALIDATION: '/internal/aiops/categorization_field_validation',
} as const;

export const AIOPS_TELEMETRY_ID = {
AIOPS_DEFAULT_SOURCE: 'ml_aiops_labs',
AIOPS_ANALYSIS_RUN_ORIGIN: 'aiops-analysis-run-origin',
} as const;
/**
* Used for telemetry purposes to track the origin of the analysis run.
*/
export const AIOPS_ANALYSIS_RUN_ORIGIN = 'aiops-analysis-run-origin';

export const EMBEDDABLE_ORIGIN = 'embeddable';
export const AIOPS_EMBEDDABLE_ORIGIN = {
CASES: 'cases',
DASHBOARD: 'dashboard',
DEFAULT: 'embeddable',
DISCOVER: 'discover',
ML_AIOPS_LABS: 'ml_aiops_labs',
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import {
mlTimefilterRefresh$,
} from '@kbn/ml-date-picker';
import { UI_SETTINGS } from '@kbn/data-plugin/common';
import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants';
import { AIOPS_EMBEDDABLE_ORIGIN } from '@kbn/aiops-common/constants';

import { DataSourceContext } from '../../hooks/use_data_source';
import type { AiopsAppDependencies } from '../../hooks/use_aiops_app_context';
import type { AiopsAppContextValue } from '../../hooks/use_aiops_app_context';
import { AiopsAppContext } from '../../hooks/use_aiops_app_context';
import { AIOPS_STORAGE_KEYS } from '../../types/storage';

Expand All @@ -52,20 +52,20 @@ export interface ChangePointDetectionAppStateProps {
dataView: DataView;
/** The saved search to analyze. */
savedSearch: SavedSearch | null;
/** App dependencies */
appDependencies: AiopsAppDependencies;
/** App context value */
appContextValue: AiopsAppContextValue;
/** Optional flag to indicate whether kibana is running in serverless */
showFrozenDataTierChoice?: boolean;
}

export const ChangePointDetectionAppState: FC<ChangePointDetectionAppStateProps> = ({
dataView,
savedSearch,
appDependencies,
appContextValue,
showFrozenDataTierChoice = true,
}) => {
const datePickerDeps: DatePickerDependencies = {
...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
...pick(appContextValue, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
uiSettingsKeys: UI_SETTINGS,
showFrozenDataTierChoice,
};
Expand All @@ -80,19 +80,19 @@ export const ChangePointDetectionAppState: FC<ChangePointDetectionAppStateProps>
return <>{warning}</>;
}

appDependencies.embeddingOrigin = AIOPS_TELEMETRY_ID.AIOPS_DEFAULT_SOURCE;
appContextValue.embeddingOrigin = AIOPS_EMBEDDABLE_ORIGIN.ML_AIOPS_LABS;

const PresentationContextProvider =
appDependencies.presentationUtil?.ContextProvider ?? React.Fragment;
appContextValue.presentationUtil?.ContextProvider ?? React.Fragment;

const CasesContext = appDependencies.cases?.ui.getCasesContext() ?? React.Fragment;
const casesPermissions = appDependencies.cases?.helpers.canUseCases();
const CasesContext = appContextValue.cases?.ui.getCasesContext() ?? React.Fragment;
const casesPermissions = appContextValue.cases?.helpers.canUseCases();

return (
<PresentationContextProvider>
<KibanaThemeProvider theme={appDependencies.theme}>
<KibanaThemeProvider theme={appContextValue.theme}>
<CasesContext owner={[]} permissions={casesPermissions!}>
<AiopsAppContext.Provider value={appDependencies}>
<AiopsAppContext.Provider value={appContextValue}>
<UrlStateProvider>
<DataSourceContext.Provider value={{ dataView, savedSearch }}>
<StorageContextProvider storage={localStorage} storageKeys={AIOPS_STORAGE_KEYS}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ import { UrlStateProvider } from '@kbn/ml-url-state';
import { Storage } from '@kbn/kibana-utils-plugin/public';
import { DatePickerContextProvider, type DatePickerDependencies } from '@kbn/ml-date-picker';
import { UI_SETTINGS } from '@kbn/data-plugin/common';
import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants';

import { DataSourceContext } from '../../hooks/use_data_source';
import type { AiopsAppDependencies } from '../../hooks/use_aiops_app_context';
import type { AiopsAppContextValue } from '../../hooks/use_aiops_app_context';
import { AIOPS_STORAGE_KEYS } from '../../types/storage';
import { AiopsAppContext } from '../../hooks/use_aiops_app_context';

Expand All @@ -35,16 +34,16 @@ export interface LogCategorizationAppStateProps {
dataView: DataView;
/** The saved search to analyze. */
savedSearch: SavedSearch | null;
/** App dependencies */
appDependencies: AiopsAppDependencies;
/** App context value */
appContextValue: AiopsAppContextValue;
/** Optional flag to indicate whether kibana is running in serverless */
showFrozenDataTierChoice?: boolean;
}

export const LogCategorizationAppState: FC<LogCategorizationAppStateProps> = ({
dataView,
savedSearch,
appDependencies,
appContextValue,
showFrozenDataTierChoice = true,
}) => {
if (!dataView) return null;
Expand All @@ -56,18 +55,18 @@ export const LogCategorizationAppState: FC<LogCategorizationAppStateProps> = ({
}

const datePickerDeps: DatePickerDependencies = {
...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
...pick(appContextValue, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
uiSettingsKeys: UI_SETTINGS,
showFrozenDataTierChoice,
};

return (
<AiopsAppContext.Provider value={appDependencies}>
<AiopsAppContext.Provider value={appContextValue}>
<UrlStateProvider>
<DataSourceContext.Provider value={{ dataView, savedSearch }}>
<StorageContextProvider storage={localStorage} storageKeys={AIOPS_STORAGE_KEYS}>
<DatePickerContextProvider {...datePickerDeps}>
<LogCategorizationPage embeddingOrigin={AIOPS_TELEMETRY_ID.AIOPS_DEFAULT_SOURCE} />
<LogCategorizationPage />
</DatePickerContextProvider>
</StorageContextProvider>
</DataSourceContext.Provider>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import type { FieldValidationResults } from '@kbn/ml-category-validator';
import type { Category } from '@kbn/aiops-log-pattern-analysis/types';

import type { CategorizationAdditionalFilter } from '@kbn/aiops-log-pattern-analysis/create_category_request';
import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants';
import { AIOPS_ANALYSIS_RUN_ORIGIN } from '@kbn/aiops-common/constants';
import type { EmbeddablePatternAnalysisInput } from '@kbn/aiops-log-pattern-analysis/embeddable';
import { css } from '@emotion/react';
import { useTableState } from '@kbn/ml-in-memory-table/hooks/use_table_state';
Expand Down Expand Up @@ -270,7 +270,7 @@ export const LogCategorizationDiscover: FC<LogCategorizationEmbeddableProps> = (
searchQuery,
runtimeMappings,
{
[AIOPS_TELEMETRY_ID.AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin,
[AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin,
}
),
runCategorizeRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,67 +7,40 @@

import type { FC } from 'react';
import React, { Suspense } from 'react';
import type { ThemeServiceStart } from '@kbn/core-theme-browser';
import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { IUiSettingsClient } from '@kbn/core/public';
import type { CoreStart } from '@kbn/core/public';
import type { LensPublicStart } from '@kbn/lens-plugin/public';
import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
import type { UiActionsStart } from '@kbn/ui-actions-plugin/public';
import { pick } from 'lodash';

import { DatePickerContextProvider } from '@kbn/ml-date-picker';
import { StorageContextProvider } from '@kbn/ml-local-storage';

import { pick } from 'lodash';
import { UI_SETTINGS } from '@kbn/data-plugin/public';
import { Storage } from '@kbn/kibana-utils-plugin/public';

import { AIOPS_STORAGE_KEYS } from '../../../types/storage';
import type { AiopsAppDependencies } from '../../../hooks/use_aiops_app_context';
import { AiopsAppContext } from '../../../hooks/use_aiops_app_context';
import { AiopsAppContext, type AiopsAppContextValue } from '../../../hooks/use_aiops_app_context';

import type { LogCategorizationEmbeddableProps } from './log_categorization_for_discover';
import { LogCategorizationDiscover } from './log_categorization_for_discover';

export interface EmbeddableLogCategorizationDeps {
theme: ThemeServiceStart;
data: DataPublicPluginStart;
uiSettings: IUiSettingsClient;
http: CoreStart['http'];
notifications: CoreStart['notifications'];
i18n: CoreStart['i18n'];
lens: LensPublicStart;
fieldFormats: FieldFormatsStart;
application: CoreStart['application'];
charts: ChartsPluginStart;
uiActions: UiActionsStart;
}

export interface LogCategorizationEmbeddableWrapperProps {
deps: EmbeddableLogCategorizationDeps;
appContextValue: AiopsAppContextValue;
props: LogCategorizationEmbeddableProps;
embeddingOrigin?: string;
}

const localStorage = new Storage(window.localStorage);

export const LogCategorizationDiscoverWrapper: FC<LogCategorizationEmbeddableWrapperProps> = ({
deps,
appContextValue,
props,
embeddingOrigin,
}) => {
const I18nContext = deps.i18n.Context;
const aiopsAppContextValue = {
embeddingOrigin,
...deps,
} as unknown as AiopsAppDependencies;
const I18nContext = appContextValue.i18n.Context;

const datePickerDeps = {
...pick(deps, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
...pick(appContextValue, ['data', 'http', 'notifications', 'theme', 'uiSettings', 'i18n']),
uiSettingsKeys: UI_SETTINGS,
};

return (
<I18nContext>
<AiopsAppContext.Provider value={aiopsAppContextValue}>
<AiopsAppContext.Provider value={appContextValue}>
<DatePickerContextProvider {...datePickerDeps}>
<StorageContextProvider storage={localStorage} storageKeys={AIOPS_STORAGE_KEYS}>
<Suspense fallback={null}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { Category } from '@kbn/aiops-log-pattern-analysis/types';
import type { CategorizationAdditionalFilter } from '@kbn/aiops-log-pattern-analysis/create_category_request';
import type { EmbeddablePatternAnalysisInput } from '@kbn/aiops-log-pattern-analysis/embeddable';
import { useTableState } from '@kbn/ml-in-memory-table/hooks/use_table_state';
import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants';
import { AIOPS_ANALYSIS_RUN_ORIGIN } from '@kbn/aiops-common/constants';
import datemath from '@elastic/datemath';
import useMountedState from 'react-use/lib/useMountedState';
import { useFilterQueryUpdates } from '../../../hooks/use_filters_query';
Expand Down Expand Up @@ -224,7 +224,7 @@ export const LogCategorizationEmbeddable: FC<LogCategorizationEmbeddableProps> =
searchQuery,
runtimeMappings,
{
[AIOPS_TELEMETRY_ID.AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin,
[AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin,
}
),
runCategorizeRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { usePageUrlState } from '@kbn/ml-url-state';
import type { FieldValidationResults } from '@kbn/ml-category-validator';
import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants';
import { AIOPS_ANALYSIS_RUN_ORIGIN } from '@kbn/aiops-common/constants';
import type { CategorizationAdditionalFilter } from '@kbn/aiops-log-pattern-analysis/create_category_request';
import type { Category } from '@kbn/aiops-log-pattern-analysis/types';

Expand Down Expand Up @@ -64,8 +64,6 @@ export interface LogCategorizationPageProps {
savedSearch: SavedSearch | null;
selectedField: DataViewField;
onClose: () => void;
/** Identifier to indicate the plugin utilizing the component */
embeddingOrigin: string;
additionalFilter?: CategorizationAdditionalFilter;
}

Expand All @@ -76,7 +74,6 @@ export const LogCategorizationFlyout: FC<LogCategorizationPageProps> = ({
savedSearch,
selectedField,
onClose,
embeddingOrigin,
additionalFilter,
}) => {
const {
Expand All @@ -85,6 +82,7 @@ export const LogCategorizationFlyout: FC<LogCategorizationPageProps> = ({
query: { getState },
},
uiSettings,
embeddingOrigin,
} = useAiopsAppContext();

const { runValidateFieldRequest, cancelRequest: cancelValidationRequest } =
Expand Down Expand Up @@ -198,7 +196,7 @@ export const LogCategorizationFlyout: FC<LogCategorizationPageProps> = ({
searchQuery,
runtimeMappings,
{
[AIOPS_TELEMETRY_ID.AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin,
[AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin,
}
),
runCategorizeRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { usePageUrlState, useUrlState } from '@kbn/ml-url-state';
import type { FieldValidationResults } from '@kbn/ml-category-validator';
import type { SearchQueryLanguage } from '@kbn/ml-query-utils';
import { AIOPS_TELEMETRY_ID } from '@kbn/aiops-common/constants';
import { AIOPS_ANALYSIS_RUN_ORIGIN } from '@kbn/aiops-common/constants';
import type { Category } from '@kbn/aiops-log-pattern-analysis/types';

import { useTableState } from '@kbn/ml-in-memory-table/hooks/use_table_state';

import { useDataSource } from '../../hooks/use_data_source';
import { useData } from '../../hooks/use_data';
import { useSearch } from '../../hooks/use_search';
Expand Down Expand Up @@ -59,14 +59,10 @@ import { useActions } from './category_table/use_actions';
const BAR_TARGET = 20;
const DEFAULT_SELECTED_FIELD = 'message';

interface LogCategorizationPageProps {
/** Identifier to indicate the plugin utilizing the component */
embeddingOrigin: string;
}

export const LogCategorizationPage: FC<LogCategorizationPageProps> = ({ embeddingOrigin }) => {
export const LogCategorizationPage: FC = () => {
const {
notifications: { toasts },
embeddingOrigin,
} = useAiopsAppContext();
const { dataView, savedSearch } = useDataSource();

Expand Down Expand Up @@ -229,7 +225,7 @@ export const LogCategorizationPage: FC<LogCategorizationPageProps> = ({ embeddin
searchQuery,
runtimeMappings,
{
[AIOPS_TELEMETRY_ID.AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin,
[AIOPS_ANALYSIS_RUN_ORIGIN]: embeddingOrigin,
}
),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { StorageContextProvider } from '@kbn/ml-local-storage';
import type { CategorizationAdditionalFilter } from '@kbn/aiops-log-pattern-analysis/create_category_request';
import type { AiopsPluginStartDeps } from '../../types';
import { LogCategorizationFlyout } from './log_categorization_for_flyout';
import { AiopsAppContext, type AiopsAppDependencies } from '../../hooks/use_aiops_app_context';
import { AiopsAppContext, type AiopsAppContextValue } from '../../hooks/use_aiops_app_context';
import { AIOPS_STORAGE_KEYS } from '../../types/storage';

const localStorage = new Storage(window.localStorage);
Expand All @@ -43,13 +43,14 @@ export async function showCategorizeFlyout(
resolve();
};

const appDependencies: AiopsAppDependencies = {
const appContextValue: AiopsAppContextValue = {
embeddingOrigin: originatingApp,
...coreStart,
...plugins,
};
const startServices = pick(coreStart, 'analytics', 'i18n', 'theme');
const datePickerDeps: DatePickerDependencies = {
...pick(appDependencies, ['data', 'http', 'notifications', 'theme', 'uiSettings']),
...pick(appContextValue, ['data', 'http', 'notifications', 'theme', 'uiSettings']),
i18n,
uiSettingsKeys: UI_SETTINGS,
};
Expand All @@ -61,15 +62,14 @@ export async function showCategorizeFlyout(
...coreStart,
}}
>
<AiopsAppContext.Provider value={appDependencies}>
<AiopsAppContext.Provider value={appContextValue}>
<DatePickerContextProvider {...datePickerDeps}>
<StorageContextProvider storage={localStorage} storageKeys={AIOPS_STORAGE_KEYS}>
<LogCategorizationFlyout
dataView={dataView}
savedSearch={null}
selectedField={field}
onClose={onFlyoutClose}
embeddingOrigin={originatingApp}
additionalFilter={additionalFilter}
/>
</StorageContextProvider>
Expand Down
Loading

0 comments on commit 07c493c

Please sign in to comment.