Fix: correctly access types from "to" function (#32691) (#33068)

* fix: correctly access types

they are not exposed on the handlers object, they must be imported from @kbn/interpreter

* chore: move to function to browser

types can be accessed in the browser now, and a common function makes no sense right now. also https://github.com/elastic/kibana/issues/33039 prevents having the same function in both places anyway
This commit is contained in:
Joe Fleming 2019-03-12 17:04:59 -06:00 committed by GitHub
parent c97eff3bae
commit 2aa8f62401
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 7 additions and 19 deletions

View file

@ -1,9 +0,0 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { to } from './to';
export const commonFunctions = [to];

View file

@ -5,14 +5,13 @@
*/
import { routes } from './server/routes';
import { commonFunctions } from './common/functions';
import { registerCanvasUsageCollector } from './server/usage';
import { functions } from './canvas_plugin_src/functions/server';
import { loadSampleData } from './server/sample_data';
export default async function(server /*options*/) {
const { serverFunctions } = server.plugins.interpreter.register({
serverFunctions: commonFunctions.concat(functions),
serverFunctions: functions,
});
server.injectUiAppVars('canvas', async () => {

View file

@ -26,7 +26,6 @@ import { tagSpecs } from '../../../canvas_plugin_src/uis/tags';
import { functions as browserFunctions } from '../../../canvas_plugin_src/functions/browser';
import { functions as commonPluginFunctions } from '../../../canvas_plugin_src/functions/common';
import { templateSpecs } from '../../../canvas_plugin_src/templates';
import { commonFunctions } from '../../../common/functions';
import { clientFunctions } from '../../functions';
import {
@ -69,10 +68,7 @@ register(registries, {
viewUIs: viewSpecs,
datasourceUIs: datasourceSpecs,
argumentUIs: argSpecs,
browserFunctions: browserFunctions
.concat(commonFunctions)
.concat(clientFunctions)
.concat(commonPluginFunctions),
browserFunctions: browserFunctions.concat(clientFunctions).concat(commonPluginFunctions),
templates: templateSpecs,
tagUIs: tagSpecs,
});

View file

@ -7,5 +7,6 @@
import { asset } from './asset';
import { filters } from './filters';
import { timelion } from './timelion';
import { to } from './to';
export const clientFunctions = [asset, filters, timelion];
export const clientFunctions = [asset, filters, timelion, to];

View file

@ -5,6 +5,7 @@
*/
import { castProvider } from '@kbn/interpreter/common';
import { registries } from '@kbn/interpreter/public';
export const to = () => ({
name: 'to',
@ -19,11 +20,11 @@ export const to = () => ({
multi: true,
},
},
fn: (context, args, { types }) => {
fn: (context, args) => {
if (!args.type) {
throw new Error('Must specify a casting type');
}
return castProvider(types)(context, args.type);
return castProvider(registries.types.toJS())(context, args.type);
},
});