diff --git a/src/legacy/core_plugins/data/public/expressions/expression_renderer.tsx b/src/legacy/core_plugins/data/public/expressions/expression_renderer.tsx
index c1899aa9df9a2..c87ab2a7311b6 100644
--- a/src/legacy/core_plugins/data/public/expressions/expression_renderer.tsx
+++ b/src/legacy/core_plugins/data/public/expressions/expression_renderer.tsx
@@ -58,7 +58,7 @@ export const createRenderer = (run: ExpressionRunner): ExpressionRenderer => ({
}
});
}
- }, [expression, mountpoint.current]);
+ }, [expression, mountpoint.current, options.context, options.getInitialContext]);
return (
{
description: 'Explore and visualize data.',
main: `plugins/${PLUGIN_ID}/index`,
},
+ embeddableFactories: ['plugins/lens/register_embeddable'],
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
mappings,
visTypes: ['plugins/lens/register_vis_type_alias'],
@@ -35,7 +36,7 @@ export const lens: LegacyPluginInitializer = kibana => {
isImportableAndExportable: true,
getTitle: (obj: { attributes: { title: string } }) => obj.attributes.title,
getInAppUrl: (obj: { id: string }) => ({
- path: `/app/lens#/edit/${encodeURIComponent(obj.id)}`,
+ path: getEditPath(obj.id),
uiCapabilitiesPath: 'lens.show',
}),
},
@@ -63,7 +64,7 @@ export const lens: LegacyPluginInitializer = kibana => {
all: [],
read: [],
},
- ui: ['show'],
+ ui: ['save', 'show'],
},
read: {
api: [PLUGIN_ID],
diff --git a/x-pack/legacy/plugins/lens/mappings.json b/x-pack/legacy/plugins/lens/mappings.json
index f7bf55fd76a67..9136447531be8 100644
--- a/x-pack/legacy/plugins/lens/mappings.json
+++ b/x-pack/legacy/plugins/lens/mappings.json
@@ -12,6 +12,9 @@
},
"state": {
"type": "text"
+ },
+ "expression": {
+ "type": "text"
}
}
}
diff --git a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/editor_frame.test.tsx b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/editor_frame.test.tsx
index 8dbf80d9afc74..e95e6c982a50c 100644
--- a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/editor_frame.test.tsx
+++ b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/editor_frame.test.tsx
@@ -130,12 +130,16 @@ describe('editor_frame', () => {
activeDatasourceId: 'testDatasource',
visualizationType: 'testVis',
title: '',
+ expression: '',
state: {
datasourceStates: {
testDatasource: datasource1State,
testDatasource2: datasource2State,
},
visualization: {},
+ datasourceMetaData: {
+ filterableIndexPatterns: [],
+ },
},
}}
/>
@@ -341,38 +345,52 @@ describe('editor_frame', () => {
instance.update();
expect(instance.find(expressionRendererMock).prop('expression')).toMatchInlineSnapshot(`
- Object {
- "chain": Array [
- Object {
- "arguments": Object {
- "layerIds": Array [
- "first",
- ],
- "tables": Array [
- Object {
- "chain": Array [
- Object {
- "arguments": Object {},
- "function": "datasource",
- "type": "function",
- },
- ],
- "type": "expression",
- },
- ],
+ Object {
+ "chain": Array [
+ Object {
+ "arguments": Object {},
+ "function": "kibana",
+ "type": "function",
+ },
+ Object {
+ "arguments": Object {
+ "filters": Array [],
+ "query": Array [],
+ "timeRange": Array [],
+ },
+ "function": "kibana_context",
+ "type": "function",
+ },
+ Object {
+ "arguments": Object {
+ "layerIds": Array [
+ "first",
+ ],
+ "tables": Array [
+ Object {
+ "chain": Array [
+ Object {
+ "arguments": Object {},
+ "function": "datasource",
+ "type": "function",
},
- "function": "lens_merge_tables",
- "type": "function",
- },
- Object {
- "arguments": Object {},
- "function": "vis",
- "type": "function",
- },
- ],
- "type": "expression",
- }
- `);
+ ],
+ "type": "expression",
+ },
+ ],
+ },
+ "function": "lens_merge_tables",
+ "type": "function",
+ },
+ Object {
+ "arguments": Object {},
+ "function": "vis",
+ "type": "function",
+ },
+ ],
+ "type": "expression",
+ }
+ `);
});
it('should render individual expression for each given layer', async () => {
@@ -398,12 +416,16 @@ describe('editor_frame', () => {
activeDatasourceId: 'testDatasource',
visualizationType: 'testVis',
title: '',
+ expression: '',
state: {
datasourceStates: {
testDatasource: {},
testDatasource2: {},
},
visualization: {},
+ datasourceMetaData: {
+ filterableIndexPatterns: [],
+ },
},
}}
/>
@@ -416,6 +438,20 @@ describe('editor_frame', () => {
expect(instance.find(expressionRendererMock).prop('expression')).toMatchInlineSnapshot(`
Object {
"chain": Array [
+ Object {
+ "arguments": Object {},
+ "function": "kibana",
+ "type": "function",
+ },
+ Object {
+ "arguments": Object {
+ "filters": Array [],
+ "query": Array [],
+ "timeRange": Array [],
+ },
+ "function": "kibana_context",
+ "type": "function",
+ },
Object {
"arguments": Object {
"layerIds": Array [
@@ -608,12 +644,16 @@ describe('editor_frame', () => {
activeDatasourceId: 'testDatasource',
visualizationType: 'testVis',
title: '',
+ expression: '',
state: {
datasourceStates: {
testDatasource: {},
testDatasource2: {},
},
visualization: {},
+ datasourceMetaData: {
+ filterableIndexPatterns: [],
+ },
},
}}
/>
@@ -656,12 +696,16 @@ describe('editor_frame', () => {
activeDatasourceId: 'testDatasource',
visualizationType: 'testVis',
title: '',
+ expression: '',
state: {
datasourceStates: {
testDatasource: datasource1State,
testDatasource2: datasource2State,
},
visualization: {},
+ datasourceMetaData: {
+ filterableIndexPatterns: [],
+ },
},
}}
/>
diff --git a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/editor_frame.tsx b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/editor_frame.tsx
index cdc0f9c19e21e..12ba3ff6e3192 100644
--- a/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/editor_frame.tsx
+++ b/x-pack/legacy/plugins/lens/public/editor_frame_plugin/editor_frame/editor_frame.tsx
@@ -162,7 +162,7 @@ export function EditorFrame(props: EditorFrameProps) {