kibana/x-pack/plugins/canvas/types/elements.ts

83 lines
1.6 KiB
TypeScript
Raw Normal View History

[Canvas]Feat: Custom Elements (#34140) * Added custom element routes Added context menu to sidebar header Added custom element modal Added tabs to element_types Added handlers for retrieving custom elements sidebar header tweaks Added edit and delete element controls Added a selector for transient.selectedToplevelNodes Refactored element event handlers Added additional sidebar views Fixed adding custom element to workpad Converted element_controls to tsx Disabled group/ungroup buttons sidebar Disabled layer controls in multi_element_settings Cleaned up props for element_types Added story for element_controls Added stories for global_config, group_settings, and multi_element_config TSified element_handler_creators fixed ts errors more tsifying Added decorator to element_controls Updated stories for custom_element_modal Disabled global_config, group_settings, and multi_element_settings stories TSified sidebar disable layer controls in group_settings Removed save element shortcut added public/private keywords Converted sidebar_header to ts and added stories Refactored sidebar_header fix file extension design cleanup fix image in edit modal Fixed ts errors Update x-pack/plugins/canvas/server/routes/custom_elements.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Update x-pack/plugins/canvas/server/routes/workpad.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Reordered args for insertNodes and removeNodes to match corresponding redux actions Extracted PositionedElement interface Fixed TS issues Adjust title and desc lengths Added comments to props interface Refactored onClick handlers more ts Added types for ast Switched common/lib/constants back to JS Added comments Updated more comments Removed unused import Added snapshots Typed custom_element_service Fixed ts errors * Added comments to @ts-ignore's * Removed custom_element_modal stories * Added a few more comments * Update security tests with new canvas-element saved object * Updated privileges test * Updated ui_capabilities security_only saved_objects_management test * Added state interface for CustomElementTypes * Added state interfaces * fixed comment * Removed unnecessary exports
2019-05-02 23:38:46 +02:00
/*
* 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.
*/
Expressions refactor (#54342) * feat: 🎸 add UiComponent interface * feat: 🎸 add adapter for react => ui components and back * refactor: 💡 move registries to shared /common folder * feat: 🎸 create expressions service state contaienr * chore: 🤖 export some symbols * feat: 🎸 add Executor class * test: 💍 add simple integration test * feat: 🎸 move registries into executor * feat: 🎸 add initial implementation of Execution * feat: 🎸 move Executor's state container into a signle file * refactor: 💡 move createError() to /common folder * feat: 🎸 use Executor in plugin definition * refactor: 💡 rename handlers to FunctionHandlers * feat: 🎸 improve function typings * feat: 🎸 move types and func in sep folder, improve Execution * refactor: 💡 cleanup expression_types folder * refactor: 💡 improve typing names of expression types * refactor: 💡 remove lodash from ExpressionType and improve types * test: 💍 add ExpressionType tests * refactor: 💡 remove function wrappers around types * refactor: 💡 move functions to /common * test: 💍 improve expression function tests * feat: 🎸 create /parser folder * refactor: 💡 move function types into /expression_functions dir * refactor: 💡 improve parser setup * refactor: 💡 fix export structure and move args into expr_func * test: 💍 add ExpressionFunctionParameter tests * fix: 🐛 fix executor types and imports * refactor: 💡 move getByAlias to plugin, fix Execution types * feat: 🎸 add function for argument parsing * test: 💍 add Executor type tests * test: 💍 add executor function and context tests * test: 💍 check that Executor returns Execution * test: 💍 add basic tests for Execution * test: 💍 add basic test for execution of a chain of functions * test: 💍 add "mult" function tot tests * feat: 🎸 create separate expression_renderer folder * feat: 🎸 use new executor in public plugin * feat: 🎸 remove renderers from executor, add result to execution * fix: 🐛 fix Kibana TypeScript errors * test: 💍 add file to write integration tests for expr plugin * refactor: 💡 move state_containers to /common * refactor: 💡 move /parser to /ast and inline format() function * refactor: 💡 remove remaining @kbn/interpreter imports * feat: 🎸 better handling and typing for Executor context * feat: 🎸 use Executor.run function in plugin * fix: 🐛 fix TypeScript type errors * test: 💍 move integration tests into one file * feat: 🎸 create ExpressionsService * chore: 🤖 clean up legacy code * feat: 🎸 use ExpressionsService in /public * refactor: 💡 move inspector adapters to /common * feat: 🎸 improve execution * feat: 🎸 add state to execution state and don't clone AST * test: 💍 add tests for Execution object * test: 💍 improve expression test helpers * test: 💍 add Execution tests * refactor: 💡 improve required argument checking * fix: 🐛 fix Kibana TypeScript errors * test: 💍 add ExpressionsService unit tests * fix: 🐛 fix Expression plugin TypeScript types * refactor: 💡 prefix React component with React* * fix: 🐛 fix X-Pack TypeScript errors * fix: 🐛 fix test TypeScript errors * fix: 🐛 fix issues preventing loading * feat: 🎸 remove getInitialContext() handler * fix: 🐛 fix TypeScript errors * chore: 🤖 remove uicomponent interface * chore: 🤖 remove missing import * fix: 🐛 correctly handle .query in "kibana" expression function * refactor: 💡 call first arg in expression functions "input" * fix: 🐛 do not free Execution state container * test: 💍 fix tests after refactor * test: 💍 fix more tests after refactor * fix: 🐛 remove redundant export * test: 💍 update intepreter_functional test shapshots * fix: 🐛 relax "kibana" function throwing on missin gsearch ctx * refactor: 💡 don't use ExpressionAST interface in Canvas * docs: ✏️ improve ExpressionRenderer JSDocs * refactor: 💡 rename context.types to inputTypes in internal fn * refactor: 💡 replace context.types by unknown in ExprFuncDef * refactor: 💡 improve expression function definitions in OSS * fix: 🐛 correctly set name on metric_vis_fn * refactor: 💡 improve Lens definitions of expression functions * refactor: 💡 improve Canvas expression function definitions * test: 💍 add createMockExecutionContext() helper * refactor: 💡 add some type to events$ observable in expr handler * feat: 🎸 add types to observables in data handler * refactor: 💡 use inputTypes in canvas * fix: 🐛 fix interpreter grammer generation script * feat: 🎸 allow array in getByAlias * test: 💍 simplify test function specs * test: 💍 fix autocomplete tests * fix: 🐛 use correct expression types and NP getFunctions() API * refactor: 💡 use NP expressions to get renderer * fix: 🐛 use context.types on server-side Canvas function defs * refactor: 💡 use NP API to register Canvas renderers * feat: 🎸 use NP API to get types * style: 💄 minor formatting changes * feat: 🎸 use NP API to get expression functions * fix: 🐛 fix Canvas workpads * test: 💍 add missing mock functions * refactor: 💡 improve Lens func definition argument types * fix: 🐛 fix Lens type error * feat: 🎸 make lens datatable work again * feat: 🎸 bootstrap ExpressionsService on server-side * feat: 🎸 expose more registry related functions in contract * feat: 🎸 add environment: server to server-side expressions * docs: ✏️ add documentation * test: 💍 add missing Jest mocks * fix: 🐛 correct TypeScript type * docs: ✏️ improve documentation * fix: 🐛 make FunctionHelpDict type contain only Canvas functions * fix: 🐛 fix merge conflict * test: 💍 fix expression mocks
2020-02-11 19:47:36 +01:00
import { ExpressionAstExpression } from 'src/plugins/expressions';
import { CanvasElement } from '.';
2019-07-10 17:02:35 +02:00
export interface ElementSpec {
name: string;
icon?: string;
2019-07-10 17:02:35 +02:00
expression: string;
displayName?: string;
type?: string;
2019-07-10 17:02:35 +02:00
help?: string;
filter?: string;
width?: number;
height?: number;
}
[Canvas]Feat: Custom Elements (#34140) * Added custom element routes Added context menu to sidebar header Added custom element modal Added tabs to element_types Added handlers for retrieving custom elements sidebar header tweaks Added edit and delete element controls Added a selector for transient.selectedToplevelNodes Refactored element event handlers Added additional sidebar views Fixed adding custom element to workpad Converted element_controls to tsx Disabled group/ungroup buttons sidebar Disabled layer controls in multi_element_settings Cleaned up props for element_types Added story for element_controls Added stories for global_config, group_settings, and multi_element_config TSified element_handler_creators fixed ts errors more tsifying Added decorator to element_controls Updated stories for custom_element_modal Disabled global_config, group_settings, and multi_element_settings stories TSified sidebar disable layer controls in group_settings Removed save element shortcut added public/private keywords Converted sidebar_header to ts and added stories Refactored sidebar_header fix file extension design cleanup fix image in edit modal Fixed ts errors Update x-pack/plugins/canvas/server/routes/custom_elements.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Update x-pack/plugins/canvas/server/routes/workpad.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Reordered args for insertNodes and removeNodes to match corresponding redux actions Extracted PositionedElement interface Fixed TS issues Adjust title and desc lengths Added comments to props interface Refactored onClick handlers more ts Added types for ast Switched common/lib/constants back to JS Added comments Updated more comments Removed unused import Added snapshots Typed custom_element_service Fixed ts errors * Added comments to @ts-ignore's * Removed custom_element_modal stories * Added a few more comments * Update security tests with new canvas-element saved object * Updated privileges test * Updated ui_capabilities security_only saved_objects_management test * Added state interface for CustomElementTypes * Added state interfaces * fixed comment * Removed unnecessary exports
2019-05-02 23:38:46 +02:00
2019-07-10 17:02:35 +02:00
export type ElementFactory = () => ElementSpec;
export interface CustomElement {
/**
* unique ID for the custom element
*/
id: string;
[Canvas]Feat: Custom Elements (#34140) * Added custom element routes Added context menu to sidebar header Added custom element modal Added tabs to element_types Added handlers for retrieving custom elements sidebar header tweaks Added edit and delete element controls Added a selector for transient.selectedToplevelNodes Refactored element event handlers Added additional sidebar views Fixed adding custom element to workpad Converted element_controls to tsx Disabled group/ungroup buttons sidebar Disabled layer controls in multi_element_settings Cleaned up props for element_types Added story for element_controls Added stories for global_config, group_settings, and multi_element_config TSified element_handler_creators fixed ts errors more tsifying Added decorator to element_controls Updated stories for custom_element_modal Disabled global_config, group_settings, and multi_element_settings stories TSified sidebar disable layer controls in group_settings Removed save element shortcut added public/private keywords Converted sidebar_header to ts and added stories Refactored sidebar_header fix file extension design cleanup fix image in edit modal Fixed ts errors Update x-pack/plugins/canvas/server/routes/custom_elements.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Update x-pack/plugins/canvas/server/routes/workpad.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Reordered args for insertNodes and removeNodes to match corresponding redux actions Extracted PositionedElement interface Fixed TS issues Adjust title and desc lengths Added comments to props interface Refactored onClick handlers more ts Added types for ast Switched common/lib/constants back to JS Added comments Updated more comments Removed unused import Added snapshots Typed custom_element_service Fixed ts errors * Added comments to @ts-ignore's * Removed custom_element_modal stories * Added a few more comments * Update security tests with new canvas-element saved object * Updated privileges test * Updated ui_capabilities security_only saved_objects_management test * Added state interface for CustomElementTypes * Added state interfaces * fixed comment * Removed unnecessary exports
2019-05-02 23:38:46 +02:00
/**
2019-07-10 17:02:35 +02:00
* name of the custom element
[Canvas]Feat: Custom Elements (#34140) * Added custom element routes Added context menu to sidebar header Added custom element modal Added tabs to element_types Added handlers for retrieving custom elements sidebar header tweaks Added edit and delete element controls Added a selector for transient.selectedToplevelNodes Refactored element event handlers Added additional sidebar views Fixed adding custom element to workpad Converted element_controls to tsx Disabled group/ungroup buttons sidebar Disabled layer controls in multi_element_settings Cleaned up props for element_types Added story for element_controls Added stories for global_config, group_settings, and multi_element_config TSified element_handler_creators fixed ts errors more tsifying Added decorator to element_controls Updated stories for custom_element_modal Disabled global_config, group_settings, and multi_element_settings stories TSified sidebar disable layer controls in group_settings Removed save element shortcut added public/private keywords Converted sidebar_header to ts and added stories Refactored sidebar_header fix file extension design cleanup fix image in edit modal Fixed ts errors Update x-pack/plugins/canvas/server/routes/custom_elements.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Update x-pack/plugins/canvas/server/routes/workpad.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Reordered args for insertNodes and removeNodes to match corresponding redux actions Extracted PositionedElement interface Fixed TS issues Adjust title and desc lengths Added comments to props interface Refactored onClick handlers more ts Added types for ast Switched common/lib/constants back to JS Added comments Updated more comments Removed unused import Added snapshots Typed custom_element_service Fixed ts errors * Added comments to @ts-ignore's * Removed custom_element_modal stories * Added a few more comments * Update security tests with new canvas-element saved object * Updated privileges test * Updated ui_capabilities security_only saved_objects_management test * Added state interface for CustomElementTypes * Added state interfaces * fixed comment * Removed unnecessary exports
2019-05-02 23:38:46 +02:00
*/
2019-07-10 17:02:35 +02:00
name: string;
[Canvas]Feat: Custom Elements (#34140) * Added custom element routes Added context menu to sidebar header Added custom element modal Added tabs to element_types Added handlers for retrieving custom elements sidebar header tweaks Added edit and delete element controls Added a selector for transient.selectedToplevelNodes Refactored element event handlers Added additional sidebar views Fixed adding custom element to workpad Converted element_controls to tsx Disabled group/ungroup buttons sidebar Disabled layer controls in multi_element_settings Cleaned up props for element_types Added story for element_controls Added stories for global_config, group_settings, and multi_element_config TSified element_handler_creators fixed ts errors more tsifying Added decorator to element_controls Updated stories for custom_element_modal Disabled global_config, group_settings, and multi_element_settings stories TSified sidebar disable layer controls in group_settings Removed save element shortcut added public/private keywords Converted sidebar_header to ts and added stories Refactored sidebar_header fix file extension design cleanup fix image in edit modal Fixed ts errors Update x-pack/plugins/canvas/server/routes/custom_elements.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Update x-pack/plugins/canvas/server/routes/workpad.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Reordered args for insertNodes and removeNodes to match corresponding redux actions Extracted PositionedElement interface Fixed TS issues Adjust title and desc lengths Added comments to props interface Refactored onClick handlers more ts Added types for ast Switched common/lib/constants back to JS Added comments Updated more comments Removed unused import Added snapshots Typed custom_element_service Fixed ts errors * Added comments to @ts-ignore's * Removed custom_element_modal stories * Added a few more comments * Update security tests with new canvas-element saved object * Updated privileges test * Updated ui_capabilities security_only saved_objects_management test * Added state interface for CustomElementTypes * Added state interfaces * fixed comment * Removed unnecessary exports
2019-05-02 23:38:46 +02:00
/**
2019-07-10 17:02:35 +02:00
* name to be displayed from element picker
[Canvas]Feat: Custom Elements (#34140) * Added custom element routes Added context menu to sidebar header Added custom element modal Added tabs to element_types Added handlers for retrieving custom elements sidebar header tweaks Added edit and delete element controls Added a selector for transient.selectedToplevelNodes Refactored element event handlers Added additional sidebar views Fixed adding custom element to workpad Converted element_controls to tsx Disabled group/ungroup buttons sidebar Disabled layer controls in multi_element_settings Cleaned up props for element_types Added story for element_controls Added stories for global_config, group_settings, and multi_element_config TSified element_handler_creators fixed ts errors more tsifying Added decorator to element_controls Updated stories for custom_element_modal Disabled global_config, group_settings, and multi_element_settings stories TSified sidebar disable layer controls in group_settings Removed save element shortcut added public/private keywords Converted sidebar_header to ts and added stories Refactored sidebar_header fix file extension design cleanup fix image in edit modal Fixed ts errors Update x-pack/plugins/canvas/server/routes/custom_elements.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Update x-pack/plugins/canvas/server/routes/workpad.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Reordered args for insertNodes and removeNodes to match corresponding redux actions Extracted PositionedElement interface Fixed TS issues Adjust title and desc lengths Added comments to props interface Refactored onClick handlers more ts Added types for ast Switched common/lib/constants back to JS Added comments Updated more comments Removed unused import Added snapshots Typed custom_element_service Fixed ts errors * Added comments to @ts-ignore's * Removed custom_element_modal stories * Added a few more comments * Update security tests with new canvas-element saved object * Updated privileges test * Updated ui_capabilities security_only saved_objects_management test * Added state interface for CustomElementTypes * Added state interfaces * fixed comment * Removed unnecessary exports
2019-05-02 23:38:46 +02:00
*/
2019-07-10 17:02:35 +02:00
displayName: string;
[Canvas]Feat: Custom Elements (#34140) * Added custom element routes Added context menu to sidebar header Added custom element modal Added tabs to element_types Added handlers for retrieving custom elements sidebar header tweaks Added edit and delete element controls Added a selector for transient.selectedToplevelNodes Refactored element event handlers Added additional sidebar views Fixed adding custom element to workpad Converted element_controls to tsx Disabled group/ungroup buttons sidebar Disabled layer controls in multi_element_settings Cleaned up props for element_types Added story for element_controls Added stories for global_config, group_settings, and multi_element_config TSified element_handler_creators fixed ts errors more tsifying Added decorator to element_controls Updated stories for custom_element_modal Disabled global_config, group_settings, and multi_element_settings stories TSified sidebar disable layer controls in group_settings Removed save element shortcut added public/private keywords Converted sidebar_header to ts and added stories Refactored sidebar_header fix file extension design cleanup fix image in edit modal Fixed ts errors Update x-pack/plugins/canvas/server/routes/custom_elements.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Update x-pack/plugins/canvas/server/routes/workpad.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Reordered args for insertNodes and removeNodes to match corresponding redux actions Extracted PositionedElement interface Fixed TS issues Adjust title and desc lengths Added comments to props interface Refactored onClick handlers more ts Added types for ast Switched common/lib/constants back to JS Added comments Updated more comments Removed unused import Added snapshots Typed custom_element_service Fixed ts errors * Added comments to @ts-ignore's * Removed custom_element_modal stories * Added a few more comments * Update security tests with new canvas-element saved object * Updated privileges test * Updated ui_capabilities security_only saved_objects_management test * Added state interface for CustomElementTypes * Added state interfaces * fixed comment * Removed unnecessary exports
2019-05-02 23:38:46 +02:00
/**
2019-07-10 17:02:35 +02:00
* description of the custom element
[Canvas]Feat: Custom Elements (#34140) * Added custom element routes Added context menu to sidebar header Added custom element modal Added tabs to element_types Added handlers for retrieving custom elements sidebar header tweaks Added edit and delete element controls Added a selector for transient.selectedToplevelNodes Refactored element event handlers Added additional sidebar views Fixed adding custom element to workpad Converted element_controls to tsx Disabled group/ungroup buttons sidebar Disabled layer controls in multi_element_settings Cleaned up props for element_types Added story for element_controls Added stories for global_config, group_settings, and multi_element_config TSified element_handler_creators fixed ts errors more tsifying Added decorator to element_controls Updated stories for custom_element_modal Disabled global_config, group_settings, and multi_element_settings stories TSified sidebar disable layer controls in group_settings Removed save element shortcut added public/private keywords Converted sidebar_header to ts and added stories Refactored sidebar_header fix file extension design cleanup fix image in edit modal Fixed ts errors Update x-pack/plugins/canvas/server/routes/custom_elements.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Update x-pack/plugins/canvas/server/routes/workpad.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Reordered args for insertNodes and removeNodes to match corresponding redux actions Extracted PositionedElement interface Fixed TS issues Adjust title and desc lengths Added comments to props interface Refactored onClick handlers more ts Added types for ast Switched common/lib/constants back to JS Added comments Updated more comments Removed unused import Added snapshots Typed custom_element_service Fixed ts errors * Added comments to @ts-ignore's * Removed custom_element_modal stories * Added a few more comments * Update security tests with new canvas-element saved object * Updated privileges test * Updated ui_capabilities security_only saved_objects_management test * Added state interface for CustomElementTypes * Added state interfaces * fixed comment * Removed unnecessary exports
2019-05-02 23:38:46 +02:00
*/
2019-07-10 17:02:35 +02:00
help?: string;
/**
* base 64 data URL string of the preview image
*/
image?: string;
/**
* the element object stringified
*/
content: string;
}
export interface ElementPosition {
[Canvas]Feat: Custom Elements (#34140) * Added custom element routes Added context menu to sidebar header Added custom element modal Added tabs to element_types Added handlers for retrieving custom elements sidebar header tweaks Added edit and delete element controls Added a selector for transient.selectedToplevelNodes Refactored element event handlers Added additional sidebar views Fixed adding custom element to workpad Converted element_controls to tsx Disabled group/ungroup buttons sidebar Disabled layer controls in multi_element_settings Cleaned up props for element_types Added story for element_controls Added stories for global_config, group_settings, and multi_element_config TSified element_handler_creators fixed ts errors more tsifying Added decorator to element_controls Updated stories for custom_element_modal Disabled global_config, group_settings, and multi_element_settings stories TSified sidebar disable layer controls in group_settings Removed save element shortcut added public/private keywords Converted sidebar_header to ts and added stories Refactored sidebar_header fix file extension design cleanup fix image in edit modal Fixed ts errors Update x-pack/plugins/canvas/server/routes/custom_elements.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Update x-pack/plugins/canvas/server/routes/workpad.js Co-Authored-By: cqliu1 <catherineqliu@outlook.com> Reordered args for insertNodes and removeNodes to match corresponding redux actions Extracted PositionedElement interface Fixed TS issues Adjust title and desc lengths Added comments to props interface Refactored onClick handlers more ts Added types for ast Switched common/lib/constants back to JS Added comments Updated more comments Removed unused import Added snapshots Typed custom_element_service Fixed ts errors * Added comments to @ts-ignore's * Removed custom_element_modal stories * Added a few more comments * Update security tests with new canvas-element saved object * Updated privileges test * Updated ui_capabilities security_only saved_objects_management test * Added state interface for CustomElementTypes * Added state interfaces * fixed comment * Removed unnecessary exports
2019-05-02 23:38:46 +02:00
/**
* distance from the left edge of the page
*/
left: number;
/**
* distance from the top edge of the page
* */
top: number;
/**
* width of the element
*/
width: number;
/**
* height of the element
*/
height: number;
/**
* angle of rotation
*/
angle: number;
/**
* the id of the parent of this element part of a group
*/
parent: string | null;
}
2020-04-30 23:51:24 +02:00
export type PositionedElement = CanvasElement & {
ast: ExpressionAstExpression;
} & {
position: ElementPosition;
};