mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[expressions] decrease bundle size (#114229)
This commit is contained in:
parent
109e966a7a
commit
73a0fc0948
39 changed files with 877 additions and 675 deletions
|
@ -19,11 +19,7 @@ import {
|
|||
EuiText,
|
||||
EuiTitle,
|
||||
} from '@elastic/eui';
|
||||
import {
|
||||
ExpressionsStart,
|
||||
ReactExpressionRenderer,
|
||||
ExpressionsInspectorAdapter,
|
||||
} from '../../../src/plugins/expressions/public';
|
||||
import { ExpressionsStart } from '../../../src/plugins/expressions/public';
|
||||
import { ExpressionEditor } from './editor/expression_editor';
|
||||
import { UiActionsStart } from '../../../src/plugins/ui_actions/public';
|
||||
import { NAVIGATE_TRIGGER_ID } from './actions/navigate_trigger';
|
||||
|
@ -42,10 +38,6 @@ export function ActionsExpressionsExample({ expressions, actions }: Props) {
|
|||
updateExpression(value);
|
||||
};
|
||||
|
||||
const inspectorAdapters = {
|
||||
expression: new ExpressionsInspectorAdapter(),
|
||||
};
|
||||
|
||||
const handleEvents = (event: any) => {
|
||||
if (event.name !== 'NAVIGATE') return;
|
||||
// enrich event context with some extra data
|
||||
|
@ -83,10 +75,9 @@ export function ActionsExpressionsExample({ expressions, actions }: Props) {
|
|||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
<EuiPanel paddingSize="none" role="figure">
|
||||
<ReactExpressionRenderer
|
||||
<expressions.ReactExpressionRenderer
|
||||
expression={expression}
|
||||
debug={true}
|
||||
inspectorAdapters={inspectorAdapters}
|
||||
onEvent={handleEvents}
|
||||
renderError={(message: any) => {
|
||||
return <div>{message}</div>;
|
||||
|
|
|
@ -19,11 +19,7 @@ import {
|
|||
EuiText,
|
||||
EuiTitle,
|
||||
} from '@elastic/eui';
|
||||
import {
|
||||
ExpressionsStart,
|
||||
ReactExpressionRenderer,
|
||||
ExpressionsInspectorAdapter,
|
||||
} from '../../../src/plugins/expressions/public';
|
||||
import { ExpressionsStart } from '../../../src/plugins/expressions/public';
|
||||
import { ExpressionEditor } from './editor/expression_editor';
|
||||
import { UiActionsStart } from '../../../src/plugins/ui_actions/public';
|
||||
|
||||
|
@ -45,10 +41,6 @@ export function ActionsExpressionsExample2({ expressions, actions }: Props) {
|
|||
updateExpression(value);
|
||||
};
|
||||
|
||||
const inspectorAdapters = {
|
||||
expression: new ExpressionsInspectorAdapter(),
|
||||
};
|
||||
|
||||
const handleEvents = (event: any) => {
|
||||
updateVariables({ color: event.data.href === 'http://www.google.com' ? 'red' : 'blue' });
|
||||
};
|
||||
|
@ -81,11 +73,10 @@ export function ActionsExpressionsExample2({ expressions, actions }: Props) {
|
|||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
<EuiPanel paddingSize="none" role="figure">
|
||||
<ReactExpressionRenderer
|
||||
<expressions.ReactExpressionRenderer
|
||||
data-test-subj="expressionsVariablesTestRenderer"
|
||||
expression={expression}
|
||||
debug={true}
|
||||
inspectorAdapters={inspectorAdapters}
|
||||
variables={variables}
|
||||
onEvent={handleEvents}
|
||||
renderError={(message: any) => {
|
||||
|
|
|
@ -20,11 +20,7 @@ import {
|
|||
EuiTitle,
|
||||
EuiButton,
|
||||
} from '@elastic/eui';
|
||||
import {
|
||||
ExpressionsStart,
|
||||
ReactExpressionRenderer,
|
||||
ExpressionsInspectorAdapter,
|
||||
} from '../../../src/plugins/expressions/public';
|
||||
import { ExpressionsStart } from '../../../src/plugins/expressions/public';
|
||||
import { ExpressionEditor } from './editor/expression_editor';
|
||||
import { Start as InspectorStart } from '../../../src/plugins/inspector/public';
|
||||
|
||||
|
@ -42,9 +38,7 @@ export function RenderExpressionsExample({ expressions, inspector }: Props) {
|
|||
updateExpression(value);
|
||||
};
|
||||
|
||||
const inspectorAdapters = {
|
||||
expression: new ExpressionsInspectorAdapter(),
|
||||
};
|
||||
const inspectorAdapters = {};
|
||||
|
||||
return (
|
||||
<EuiPageBody>
|
||||
|
@ -83,10 +77,12 @@ export function RenderExpressionsExample({ expressions, inspector }: Props) {
|
|||
</EuiFlexItem>
|
||||
<EuiFlexItem>
|
||||
<EuiPanel data-test-subj="expressionRender" paddingSize="none" role="figure">
|
||||
<ReactExpressionRenderer
|
||||
<expressions.ReactExpressionRenderer
|
||||
expression={expression}
|
||||
debug={true}
|
||||
inspectorAdapters={inspectorAdapters}
|
||||
onData$={(result, panels) => {
|
||||
Object.assign(inspectorAdapters, panels);
|
||||
}}
|
||||
renderError={(message: any) => {
|
||||
return <div>{message}</div>;
|
||||
}}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import React, { useState, useEffect, useMemo } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { pluck } from 'rxjs/operators';
|
||||
import {
|
||||
EuiCodeBlock,
|
||||
|
@ -22,12 +22,9 @@ import {
|
|||
EuiTitle,
|
||||
EuiButton,
|
||||
} from '@elastic/eui';
|
||||
import {
|
||||
ExpressionsStart,
|
||||
ExpressionsInspectorAdapter,
|
||||
} from '../../../src/plugins/expressions/public';
|
||||
import { ExpressionsStart } from '../../../src/plugins/expressions/public';
|
||||
import { ExpressionEditor } from './editor/expression_editor';
|
||||
import { Start as InspectorStart } from '../../../src/plugins/inspector/public';
|
||||
import { Adapters, Start as InspectorStart } from '../../../src/plugins/inspector/public';
|
||||
|
||||
interface Props {
|
||||
expressions: ExpressionsStart;
|
||||
|
@ -37,25 +34,24 @@ interface Props {
|
|||
export function RunExpressionsExample({ expressions, inspector }: Props) {
|
||||
const [expression, updateExpression] = useState('markdownVis "## expressions explorer"');
|
||||
const [result, updateResult] = useState<unknown>({});
|
||||
const [inspectorAdapters, updateInspectorAdapters] = useState<Adapters>({});
|
||||
|
||||
const expressionChanged = (value: string) => {
|
||||
updateExpression(value);
|
||||
};
|
||||
|
||||
const inspectorAdapters = useMemo(
|
||||
() => ({
|
||||
expression: new ExpressionsInspectorAdapter(),
|
||||
}),
|
||||
[]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const execution = expressions.execute(expression, null, {
|
||||
debug: true,
|
||||
inspectorAdapters,
|
||||
});
|
||||
const subscription = execution.getData().pipe(pluck('result')).subscribe(updateResult);
|
||||
|
||||
const subscription = execution
|
||||
.getData()
|
||||
.pipe(pluck('result'))
|
||||
.subscribe((data) => {
|
||||
updateResult(data);
|
||||
updateInspectorAdapters(execution.inspect());
|
||||
});
|
||||
execution.inspect();
|
||||
return () => subscription.unsubscribe();
|
||||
}, [expression, expressions, inspectorAdapters]);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue