mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Embeddables] Fix passing the embeddable title down to the data table visualizations (#137844)
This commit is contained in:
parent
a6483d14a3
commit
4905d60951
4 changed files with 22 additions and 12 deletions
|
@ -10,6 +10,7 @@ import { createTableVisFn } from './table_vis_fn';
|
|||
import { tableVisResponseHandler } from './utils';
|
||||
import { TableVisConfig } from './types';
|
||||
|
||||
import { ExecutionContext } from '@kbn/expressions-plugin/common';
|
||||
import { functionWrapper } from '@kbn/expressions-plugin/common/expression_functions/specs/tests/utils';
|
||||
import { Datatable } from '@kbn/expressions-plugin/common/expression_types/specs';
|
||||
|
||||
|
@ -55,25 +56,29 @@ describe('interpreter/functions#table', () => {
|
|||
],
|
||||
buckets: [],
|
||||
} as unknown as TableVisConfig;
|
||||
const handlers = {
|
||||
variables: {},
|
||||
} as ExecutionContext;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
it('returns an object with the correct structure', async () => {
|
||||
const actual = await fn(context, visConfig, undefined);
|
||||
const actual = await fn(context, visConfig, handlers);
|
||||
expect(actual).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('calls response handler with correct values', async () => {
|
||||
await fn(context, visConfig, undefined);
|
||||
await fn(context, visConfig, handlers);
|
||||
expect(tableVisResponseHandler).toHaveBeenCalledTimes(1);
|
||||
expect(tableVisResponseHandler).toHaveBeenCalledWith(context, visConfig);
|
||||
});
|
||||
|
||||
it('logs correct datatable to inspector', async () => {
|
||||
let loggedTable: Datatable;
|
||||
const handlers = {
|
||||
await fn(context, visConfig, {
|
||||
...handlers,
|
||||
inspectorAdapters: {
|
||||
tables: {
|
||||
logDatatable: (name: string, datatable: Datatable) => {
|
||||
|
@ -82,8 +87,7 @@ describe('interpreter/functions#table', () => {
|
|||
reset: () => {},
|
||||
},
|
||||
},
|
||||
};
|
||||
await fn(context, visConfig, handlers as any);
|
||||
});
|
||||
|
||||
expect(loggedTable!).toMatchSnapshot();
|
||||
});
|
||||
|
|
|
@ -166,13 +166,17 @@ export const createTableVisFn = (): TableExpressionFunctionDefinition => ({
|
|||
const logTable = prepareLogTable(inspectorData, argsTable);
|
||||
handlers.inspectorAdapters.tables.logDatatable('default', logTable);
|
||||
}
|
||||
|
||||
return {
|
||||
type: 'render',
|
||||
as: 'table_vis',
|
||||
value: {
|
||||
visData: convertedData,
|
||||
visType: VIS_TYPE_TABLE,
|
||||
visConfig: args,
|
||||
visConfig: {
|
||||
...args,
|
||||
title: (handlers.variables.embeddableTitle as string) ?? args.title,
|
||||
},
|
||||
},
|
||||
};
|
||||
},
|
||||
|
|
|
@ -115,7 +115,10 @@ export const datatableFn =
|
|||
value: {
|
||||
data: table,
|
||||
untransposedData,
|
||||
args,
|
||||
args: {
|
||||
...args,
|
||||
title: (context.variables.embeddableTitle as string) ?? args.title,
|
||||
},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
|
|
@ -582,11 +582,10 @@ export class Embeddable
|
|||
errors={this.errors}
|
||||
lensInspector={this.lensInspector}
|
||||
searchContext={this.getMergedSearchContext()}
|
||||
variables={
|
||||
input.palette
|
||||
? { theme: { palette: input.palette }, embeddableTitle: this.getTitle() }
|
||||
: { embeddableTitle: this.getTitle() }
|
||||
}
|
||||
variables={{
|
||||
embeddableTitle: this.getTitle(),
|
||||
...(input.palette ? { theme: { palette: input.palette } } : {}),
|
||||
}}
|
||||
searchSessionId={this.externalSearchContext.searchSessionId}
|
||||
handleEvent={this.handleEvent}
|
||||
onData$={this.updateActiveData}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue