mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
[Data] Move the rest of the datatable
utility functions to the related service (#134562)
* Move date histogram column meta utility function to the datatable utilities service * Move number histogram interval utility function to the datatable utilities service * Move precision error check to the datatable utility service
This commit is contained in:
parent
161e9df8c3
commit
f13d321c9f
53 changed files with 453 additions and 293 deletions
|
@ -14,7 +14,7 @@ import {
|
|||
getTimeScale,
|
||||
getDatatable,
|
||||
} from '../../common/expressions';
|
||||
import { getFormatFactory, getTimeZoneFactory } from './utils';
|
||||
import { getDatatableUtilitiesFactory, getFormatFactory, getTimeZoneFactory } from './utils';
|
||||
|
||||
import type { PluginStartContract } from '../plugin';
|
||||
|
||||
|
@ -27,6 +27,6 @@ export const setupExpressions = (
|
|||
formatColumn,
|
||||
renameColumns,
|
||||
getDatatable(getFormatFactory(core)),
|
||||
getTimeScale(getTimeZoneFactory(core)),
|
||||
getTimeScale(getDatatableUtilitiesFactory(core), getTimeZoneFactory(core)),
|
||||
].forEach((expressionFn) => expressions.registerFunction(expressionFn));
|
||||
};
|
||||
|
|
|
@ -43,3 +43,20 @@ export const getTimeZoneFactory =
|
|||
/** if `Browser`, hardcode it to 'UTC' so the export has data that makes sense **/
|
||||
return timezone === 'Browser' ? 'UTC' : timezone;
|
||||
};
|
||||
|
||||
/** @internal **/
|
||||
export const getDatatableUtilitiesFactory =
|
||||
(core: CoreSetup<PluginStartContract>) => async (context: ExecutionContext) => {
|
||||
const kibanaRequest = context.getKibanaRequest?.();
|
||||
|
||||
if (!kibanaRequest) {
|
||||
throw new Error('expression function cannot be executed without a KibanaRequest');
|
||||
}
|
||||
|
||||
const [{ elasticsearch, savedObjects }, { data }] = await core.getStartServices();
|
||||
const elasticsearchClient = elasticsearch.client.asScoped(kibanaRequest).asCurrentUser;
|
||||
const savedObjectsClient = savedObjects.getScopedClient(kibanaRequest);
|
||||
const { datatableUtilities } = data;
|
||||
|
||||
return datatableUtilities.asScopedToClient(savedObjectsClient, elasticsearchClient);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue