Skip to content

Commit

Permalink
Clean up unused kibana services usage in legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Caldwell committed Apr 1, 2020
1 parent 9a3e560 commit 51830aa
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 78 deletions.
62 changes: 0 additions & 62 deletions x-pack/legacy/plugins/maps/public/kibana_services.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,88 +4,26 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { esFilters, search } from '../../../../../src/plugins/data/public';
const { getRequestInspectorStats, getResponseInspectorStats } = search;

export const SPATIAL_FILTER_TYPE = esFilters.FILTERS.SPATIAL_FILTER;
export { SearchSource } from '../../../../../src/plugins/data/public';

let indexPatternService;
export const setIndexPatternService = dataIndexPatterns =>
(indexPatternService = dataIndexPatterns);
export const getIndexPatternService = () => indexPatternService;

let autocompleteService;
export const setAutocompleteService = dataAutoComplete => (autocompleteService = dataAutoComplete);
export const getAutocompleteService = () => autocompleteService;

let licenseId;
export const setLicenseId = latestLicenseId => (licenseId = latestLicenseId);
export const getLicenseId = () => {
return licenseId;
};

let inspector;
export const setInspector = newInspector => (inspector = newInspector);
export const getInspector = () => {
return inspector;
};

let fileUploadPlugin;
export const setFileUpload = fileUpload => (fileUploadPlugin = fileUpload);
export const getFileUploadComponent = () => {
return fileUploadPlugin.JsonUploadAndParse;
};

let getInjectedVar;
export const setInjectedVarFunc = getInjectedVarFunc => (getInjectedVar = getInjectedVarFunc);
export const getInjectedVarFunc = () => getInjectedVar;

let uiSettings;
export const setUiSettings = coreUiSettings => (uiSettings = coreUiSettings);
export const getUiSettings = () => uiSettings;

let indexPatternSelectComponent;
export const setIndexPatternSelect = indexPatternSelect =>
(indexPatternSelectComponent = indexPatternSelect);
export const getIndexPatternSelectComponent = () => indexPatternSelectComponent;

let coreHttp;
export const setHttp = http => (coreHttp = http);
export const getHttp = () => coreHttp;

let dataTimeFilter;
export const setTimeFilter = timeFilter => (dataTimeFilter = timeFilter);
export const getTimeFilter = () => dataTimeFilter;

let toast;
export const setToasts = notificationToast => (toast = notificationToast);
export const getToasts = () => toast;

export async function fetchSearchSourceAndRecordWithInspector({
searchSource,
requestId,
requestName,
requestDesc,
inspectorAdapters,
abortSignal,
}) {
const inspectorRequest = inspectorAdapters.requests.start(requestName, {
id: requestId,
description: requestDesc,
});
let resp;
try {
inspectorRequest.stats(getRequestInspectorStats(searchSource));
searchSource.getSearchRequestBody().then(body => {
inspectorRequest.json(body);
});
resp = await searchSource.fetch({ abortSignal });
inspectorRequest.stats(getResponseInspectorStats(searchSource, resp)).ok({ json: resp });
} catch (error) {
inspectorRequest.error({ error });
throw error;
}

return resp;
}
17 changes: 1 addition & 16 deletions x-pack/legacy/plugins/maps/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,11 @@ import { Start as InspectorStartContract } from 'src/plugins/inspector/public';
import { MapListing } from './components/map_listing';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import {
setLicenseId,
setInspector,
setFileUpload,
setIndexPatternSelect,
setHttp,
setTimeFilter,
setUiSettings,
setInjectedVarFunc,
setToasts,
setIndexPatternService,
setAutocompleteService,
} from './kibana_services';
// @ts-ignore
import {
Expand Down Expand Up @@ -62,26 +56,17 @@ interface MapsPluginStartDependencies {
}

export const bindSetupCoreAndPlugins = (core: CoreSetup, plugins: any) => {
const { licensing } = plugins;
const { injectedMetadata, http } = core;
if (licensing) {
licensing.license$.subscribe(({ uid }: { uid: string }) => setLicenseId(uid));
}
setInjectedVarFunc(injectedMetadata.getInjectedVar);
setHttp(http);
setUiSettings(core.uiSettings);
setInjectedVarFunc(core.injectedMetadata.getInjectedVar);
setToasts(core.notifications.toasts);
};

export const bindStartCoreAndPlugins = (core: CoreStart, plugins: any) => {
const { file_upload, data, inspector } = plugins;
const { data, inspector } = plugins;
setInspector(inspector);
setFileUpload(file_upload);
setIndexPatternSelect(data.ui.IndexPatternSelect);
setTimeFilter(data.query.timefilter.timefilter);
setIndexPatternService(data.indexPatterns);
setAutocompleteService(data.autocomplete);
};

/** @internal */
Expand Down

0 comments on commit 51830aa

Please sign in to comment.