Skip to content

Commit

Permalink
Fix: correctly access types from "to" function (#32691) (#33067)
Browse files Browse the repository at this point in the history
* 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 #33039 prevents having the same function in both places anyway
  • Loading branch information
w33ble authored Mar 12, 2019
1 parent 803d563 commit 9176f96
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 19 deletions.
9 changes: 0 additions & 9 deletions x-pack/plugins/canvas/common/functions/index.js

This file was deleted.

3 changes: 1 addition & 2 deletions x-pack/plugins/canvas/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
6 changes: 1 addition & 5 deletions x-pack/plugins/canvas/public/components/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,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 {
Expand Down Expand Up @@ -67,10 +66,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,
});
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/canvas/public/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { castProvider } from '@kbn/interpreter/common';
import { registries } from '@kbn/interpreter/public';

export const to = () => ({
name: 'to',
Expand All @@ -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);
},
});

0 comments on commit 9176f96

Please sign in to comment.