Skip to content

Commit

Permalink
[Canvas] Convert Autocomplete to Typescript (elastic#42502)
Browse files Browse the repository at this point in the history
* Move the files around

* Convert Auto Complete to TS. Convert Collectors to ExpressionAST type

* Remove TS-Lint ignores

* Add comment for getFnArgPosition method
  • Loading branch information
Corey Robertson authored and crob611 committed Aug 14, 2019
1 parent 04489a3 commit 21442e5
Show file tree
Hide file tree
Showing 12 changed files with 647 additions and 484 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

// @ts-ignore Untyped Library
import { Fn } from '@kbn/interpreter/common';
import { functions as browserFns } from '../../canvas_plugin_src/functions/browser';
import { functions as commonFns } from '../../canvas_plugin_src/functions/common';
Expand Down
119 changes: 0 additions & 119 deletions x-pack/legacy/plugins/canvas/__tests__/fixtures/workpads.js

This file was deleted.

184 changes: 184 additions & 0 deletions x-pack/legacy/plugins/canvas/__tests__/fixtures/workpads.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/*
* 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 { CanvasWorkpad, CanvasElement, CanvasPage } from '../../types';

const BaseWorkpad: CanvasWorkpad = {
name: 'base workpad',
id: 'base-workpad',
width: 0,
height: 0,
css: '',
page: 1,
pages: [],
colors: [],
isWriteable: true,
};

const BasePage: CanvasPage = {
id: 'base-page',
style: { background: 'white' },
transition: {},
elements: [],
groups: [],
};
const BaseElement: CanvasElement = {
position: {
top: 0,
left: 0,
width: 0,
height: 0,
angle: 0,
parent: null,
},
id: 'base-id',
type: 'element',
expression: 'render',
filter: '',
};

export const workpads: CanvasWorkpad[] = [
{
...BaseWorkpad,
pages: [
{
...BasePage,
elements: [
{
...BaseElement,
expression: `
demodata |
ply by=age fn={rowCount | as count} |
staticColumn total value={math 'sum(count)'} |
mapColumn percentage fn={math 'count/total * 100'} |
sort age |
pointseries x=age y=percentage |
plot defaultStyle={seriesStyle points=0 lines=5}`,
},
],
},
],
},
{
...BaseWorkpad,
pages: [
{
...BasePage,
elements: [
{ ...BaseElement, expression: 'filters | demodata | markdown "hello" | render' },
],
},
],
},
{
...BaseWorkpad,
pages: [
{
...BasePage,
elements: [
{ ...BaseElement, expression: 'demodata | pointseries | getCell | repeatImage | render' },
{ ...BaseElement, expression: 'demodata | pointseries | getCell | repeatImage | render' },
{ ...BaseElement, expression: 'demodata | pointseries | getCell | repeatImage | render' },
{ ...BaseElement, expression: 'filters | demodata | markdown "hello" | render' },
{ ...BaseElement, expression: 'filters | demodata | pointseries | pie | render' },
],
},
{
...BasePage,
elements: [{ ...BaseElement, expression: 'filters | demodata | table | render' }],
},
{ ...BasePage, elements: [{ ...BaseElement, expression: 'image | render' }] },
{ ...BasePage, elements: [{ ...BaseElement, expression: 'image | render' }] },
],
},
{
...BaseWorkpad,
pages: [
{
...BasePage,
elements: [
{ ...BaseElement, expression: 'filters | demodata | markdown "hello" | render' },
{ ...BaseElement, expression: 'filters | demodata | markdown "hello" | render' },
{ ...BaseElement, expression: 'image | render' },
],
},
{
...BasePage,
elements: [
{ ...BaseElement, expression: 'demodata | pointseries | getCell | repeatImage | render' },
{ ...BaseElement, expression: 'filters | demodata | markdown "hello" | render' },
{ ...BaseElement, expression: 'filters | demodata | pointseries | pie | render' },
{ ...BaseElement, expression: 'image | render' },
],
},
{
...BasePage,
elements: [
{ ...BaseElement, expression: 'filters | demodata | pointseries | pie | render' },
{
...BaseElement,
expression:
'filters | demodata | pointseries | plot defaultStyle={seriesStyle points=0 lines=5} | render',
},
],
},
],
},
{
...BaseWorkpad,
pages: [
{
...BasePage,
elements: [
{ ...BaseElement, expression: 'demodata | render as=debug' },
{ ...BaseElement, expression: 'filters | demodata | pointseries | plot | render' },
{ ...BaseElement, expression: 'filters | demodata | table | render' },
{ ...BaseElement, expression: 'filters | demodata | table | render' },
],
},
{
...BasePage,
elements: [
{ ...BaseElement, expression: 'demodata | pointseries | getCell | repeatImage | render' },
{ ...BaseElement, expression: 'filters | demodata | pointseries | pie | render' },
{ ...BaseElement, expression: 'image | render' },
],
},
{
...BasePage,
elements: [
{ ...BaseElement, expression: 'demodata | pointseries | getCell | repeatImage | render' },
{ ...BaseElement, expression: 'demodata | render as=debug' },
{ ...BaseElement, expression: 'shape "square" | render' },
],
},
],
},
{
...BaseWorkpad,
pages: [
{
...BasePage,
elements: [
{ ...BaseElement, expression: 'demodata | pointseries | getCell | repeatImage | render' },
{ ...BaseElement, expression: 'filters | demodata | markdown "hello" | render' },
],
},
{ ...BasePage, elements: [{ ...BaseElement, expression: 'image | render' }] },
{ ...BasePage, elements: [{ ...BaseElement, expression: 'image | render' }] },
{
...BasePage,
elements: [{ ...BaseElement, expression: 'filters | demodata | table | render' }],
},
],
},
];

export const elements: CanvasElement[] = [
{ ...BaseElement, expression: 'demodata | pointseries | getCell | repeatImage | render' },
{ ...BaseElement, expression: 'filters | demodata | markdown "hello" | render' },
{ ...BaseElement, expression: 'filters | demodata | pointseries | pie | render' },
{ ...BaseElement, expression: 'image | render' },
];
Loading

0 comments on commit 21442e5

Please sign in to comment.