Skip to content

Commit

Permalink
Revert "[Discover] Rename everything"
Browse files Browse the repository at this point in the history
This reverts commit 86b3ff6.
  • Loading branch information
jughosta committed Sep 25, 2024
1 parent 86b3ff6 commit 4342088
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 59 deletions.
4 changes: 2 additions & 2 deletions api_docs/kbn_core_analytics_browser.devdocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1782,7 +1782,7 @@
},
{
"plugin": "discover",
"path": "src/plugins/discover/public/services/discover_ebt_manager.test.ts"
"path": "src/plugins/discover/public/services/discover_ebt_context_manager.test.ts"
},
{
"plugin": "@kbn/core-application-browser-internal",
Expand Down Expand Up @@ -3018,4 +3018,4 @@
"misc": [],
"objects": []
}
}
}
4 changes: 2 additions & 2 deletions api_docs/kbn_core_analytics_server.devdocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1790,7 +1790,7 @@
},
{
"plugin": "discover",
"path": "src/plugins/discover/public/services/discover_ebt_manager.test.ts"
"path": "src/plugins/discover/public/services/discover_ebt_context_manager.test.ts"
},
{
"plugin": "@kbn/core-application-browser-internal",
Expand Down Expand Up @@ -3017,4 +3017,4 @@
"misc": [],
"objects": []
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ function DiscoverDocumentsComponent({
const services = useDiscoverServices();
const documents$ = stateContainer.dataState.data$.documents$;
const savedSearch = useSavedSearchInitial();
const { dataViews, capabilities, uiSettings, uiActions, ebtManager, fieldsMetadata } = services;
const { dataViews, capabilities, uiSettings, uiActions, ebtContextManager, fieldsMetadata } =
services;
const [
dataSource,
query,
Expand Down Expand Up @@ -200,17 +201,17 @@ function DiscoverDocumentsComponent({
const onAddColumnWithTracking = useCallback(
(columnName: string) => {
onAddColumn(columnName);
void ebtManager.trackDataTableSelection({ fieldName: columnName, fieldsMetadata });
void ebtContextManager.trackDataTableSelection({ fieldName: columnName, fieldsMetadata });
},
[onAddColumn, ebtManager, fieldsMetadata]
[onAddColumn, ebtContextManager, fieldsMetadata]
);

const onRemoveColumnWithTracking = useCallback(
(columnName: string) => {
onRemoveColumn(columnName);
void ebtManager.trackDataTableRemoval({ fieldName: columnName, fieldsMetadata });
void ebtContextManager.trackDataTableRemoval({ fieldName: columnName, fieldsMetadata });
},
[onRemoveColumn, ebtManager, fieldsMetadata]
[onRemoveColumn, ebtContextManager, fieldsMetadata]
);

const setExpandedDoc = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function DiscoverLayout({ stateContainer }: DiscoverLayoutProps) {
spaces,
observabilityAIAssistant,
dataVisualizer: dataVisualizerService,
ebtManager,
ebtContextManager,
fieldsMetadata,
} = useDiscoverServices();
const pageBackgroundColor = useEuiBackgroundColor('plain');
Expand Down Expand Up @@ -159,17 +159,17 @@ export function DiscoverLayout({ stateContainer }: DiscoverLayoutProps) {
const onAddColumnWithTracking = useCallback(
(columnName: string) => {
onAddColumn(columnName);
void ebtManager.trackDataTableSelection({ fieldName: columnName, fieldsMetadata });
void ebtContextManager.trackDataTableSelection({ fieldName: columnName, fieldsMetadata });
},
[onAddColumn, ebtManager, fieldsMetadata]
[onAddColumn, ebtContextManager, fieldsMetadata]
);

const onRemoveColumnWithTracking = useCallback(
(columnName: string) => {
onRemoveColumn(columnName);
void ebtManager.trackDataTableRemoval({ fieldName: columnName, fieldsMetadata });
void ebtContextManager.trackDataTableRemoval({ fieldName: columnName, fieldsMetadata });
},
[onRemoveColumn, ebtManager, fieldsMetadata]
[onRemoveColumn, ebtContextManager, fieldsMetadata]
);

// The assistant is getting the state from the url correctly
Expand All @@ -193,14 +193,22 @@ export function DiscoverLayout({ stateContainer }: DiscoverLayoutProps) {
if (trackUiMetric) {
trackUiMetric(METRIC_TYPE.CLICK, 'filter_added');
}
void ebtManager.trackFilterAddition({
void ebtContextManager.trackFilterAddition({
fieldName: fieldName === '_exists_' ? String(values) : fieldName,
filterOperation: fieldName === '_exists_' ? '_exists_' : operation,
fieldsMetadata,
});
return filterManager.addFilters(newFilters);
},
[filterManager, dataView, dataViews, trackUiMetric, capabilities, ebtManager, fieldsMetadata]
[
filterManager,
dataView,
dataViews,
trackUiMetric,
capabilities,
ebtContextManager,
fieldsMetadata,
]
);

const getOperator = (fieldName: string, values: unknown, operation: '+' | '-') => {
Expand Down Expand Up @@ -245,13 +253,13 @@ export function DiscoverLayout({ stateContainer }: DiscoverLayoutProps) {
if (trackUiMetric) {
trackUiMetric(METRIC_TYPE.CLICK, 'esql_filter_added');
}
void ebtManager.trackFilterAddition({
void ebtContextManager.trackFilterAddition({
fieldName: fieldName === '_exists_' ? String(values) : fieldName,
filterOperation: fieldName === '_exists_' ? '_exists_' : operation,
fieldsMetadata,
});
},
[data.query.queryString, query, trackUiMetric, ebtManager, fieldsMetadata]
[data.query.queryString, query, trackUiMetric, ebtContextManager, fieldsMetadata]
);

const onFilter = isEsqlMode ? onPopulateWhereClause : onAddFilter;
Expand Down
10 changes: 5 additions & 5 deletions src/plugins/discover/public/build_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ import type { DiscoverContextAppLocator } from './application/context/services/l
import type { DiscoverSingleDocLocator } from './application/doc/locator';
import type { DiscoverAppLocator } from '../common';
import type { ProfilesManager } from './context_awareness';
import type { DiscoverEBTManager } from './services/discover_ebt_manager';
import type { DiscoverEBTContextManager } from './services/discover_ebt_context_manager';

/**
* Location state of internal Discover history instance
Expand Down Expand Up @@ -131,7 +131,7 @@ export interface DiscoverServices {
noDataPage?: NoDataPagePluginStart;
observabilityAIAssistant?: ObservabilityAIAssistantPublicStart;
profilesManager: ProfilesManager;
ebtManager: DiscoverEBTManager;
ebtContextManager: DiscoverEBTContextManager;
fieldsMetadata?: FieldsMetadataPublicStart;
}

Expand All @@ -147,7 +147,7 @@ export const buildServices = memoize(
scopedHistory,
urlTracker,
profilesManager,
ebtManager,
ebtContextManager,
setHeaderActionMenu = noop,
}: {
core: CoreStart;
Expand All @@ -160,7 +160,7 @@ export const buildServices = memoize(
scopedHistory?: ScopedHistory;
urlTracker: UrlTracker;
profilesManager: ProfilesManager;
ebtManager: DiscoverEBTManager;
ebtContextManager: DiscoverEBTContextManager;
setHeaderActionMenu?: AppMountParameters['setHeaderActionMenu'];
}): DiscoverServices => {
const { usageCollection } = plugins;
Expand Down Expand Up @@ -221,7 +221,7 @@ export const buildServices = memoize(
noDataPage: plugins.noDataPage,
observabilityAIAssistant: plugins.observabilityAIAssistant,
profilesManager,
ebtManager,
ebtContextManager,
fieldsMetadata: plugins.fieldsMetadata,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
SolutionType,
} from '../profiles';
import { ProfilesManager } from '../profiles_manager';
import { DiscoverEBTManager } from '../../services/discover_ebt_manager';
import { DiscoverEBTContextManager } from '../../services/discover_ebt_context_manager';
import { createLogsContextServiceMock } from '@kbn/discover-utils/src/__mocks__';

export const createContextAwarenessMocks = ({
Expand Down Expand Up @@ -151,12 +151,12 @@ export const createContextAwarenessMocks = ({
documentProfileServiceMock.registerProvider(documentProfileProviderMock);
}

const ebtManagerMock = new DiscoverEBTManager();
const ebtContextManagerMock = new DiscoverEBTContextManager();
const profilesManagerMock = new ProfilesManager(
rootProfileServiceMock,
dataSourceProfileServiceMock,
documentProfileServiceMock,
ebtManagerMock
ebtContextManagerMock
);

const profileProviderServices = createProfileProviderServicesMock();
Expand All @@ -172,7 +172,7 @@ export const createContextAwarenessMocks = ({
contextRecordMock2,
profilesManagerMock,
profileProviderServices,
ebtManagerMock,
ebtContextManagerMock,
};
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('ProfilesManager', () => {
beforeEach(() => {
jest.clearAllMocks();
mocks = createContextAwarenessMocks();
jest.spyOn(mocks.ebtManagerMock, 'updateProfilesContextWith');
jest.spyOn(mocks.ebtContextManagerMock, 'updateProfilesContextWith');
});

it('should return default profiles', () => {
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('ProfilesManager', () => {
mocks.documentProfileProviderMock.profile,
]);

expect(mocks.ebtManagerMock.updateProfilesContextWith).toHaveBeenCalledWith([
expect(mocks.ebtContextManagerMock.updateProfilesContextWith).toHaveBeenCalledWith([
'root-profile',
'data-source-profile',
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type {
DocumentContext,
} from './profiles';
import type { ContextWithProfileId } from './profile_service';
import { DiscoverEBTManager } from '../services/discover_ebt_manager';
import { DiscoverEBTContextManager } from '../services/discover_ebt_context_manager';

interface SerializedRootProfileParams {
solutionNavId: RootProfileProviderParams['solutionNavId'];
Expand Down Expand Up @@ -53,7 +53,7 @@ export interface GetProfilesOptions {
export class ProfilesManager {
private readonly rootContext$: BehaviorSubject<ContextWithProfileId<RootContext>>;
private readonly dataSourceContext$: BehaviorSubject<ContextWithProfileId<DataSourceContext>>;
private readonly ebtManager: DiscoverEBTManager;
private readonly ebtContextManager: DiscoverEBTContextManager;

private prevRootProfileParams?: SerializedRootProfileParams;
private prevDataSourceProfileParams?: SerializedDataSourceProfileParams;
Expand All @@ -64,11 +64,11 @@ export class ProfilesManager {
private readonly rootProfileService: RootProfileService,
private readonly dataSourceProfileService: DataSourceProfileService,
private readonly documentProfileService: DocumentProfileService,
ebtManager: DiscoverEBTManager
ebtContextManager: DiscoverEBTContextManager
) {
this.rootContext$ = new BehaviorSubject(rootProfileService.defaultContext);
this.dataSourceContext$ = new BehaviorSubject(dataSourceProfileService.defaultContext);
this.ebtManager = ebtManager;
this.ebtContextManager = ebtContextManager;
}

/**
Expand Down Expand Up @@ -206,7 +206,7 @@ export class ProfilesManager {
private trackActiveProfiles(rootContextProfileId: string, dataSourceContextProfileId: string) {
const dscProfiles = [rootContextProfileId, dataSourceContextProfileId];

this.ebtManager.updateProfilesContextWith(dscProfiles);
this.ebtContextManager.updateProfilesContextWith(dscProfiles);
}
}

Expand Down
Loading

0 comments on commit 4342088

Please sign in to comment.