Skip to content

Commit

Permalink
[7.x] [Visualize] Fix export table for table export links (elastic#71249
Browse files Browse the repository at this point in the history
) (elastic#71629)

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
dej611 and elasticmachine authored Jul 14, 2020
1 parent 9925cfe commit 6a67ed9
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/plugins/vis_type_table/public/agg_table/agg_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function KbnAggTable(config, RecursionHelper) {
return;
}

self.csv.filename = (exportTitle || table.title || 'table') + '.csv';
self.csv.filename = (exportTitle || table.title || 'unsaved') + '.csv';
$scope.rows = table.rows;
$scope.formattedColumns = [];

Expand Down
1 change: 1 addition & 0 deletions src/plugins/vis_type_table/public/table_vis_fn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe('interpreter/functions#table', () => {
columns: [{ id: 'col-0-1', name: 'Count' }],
};
const visConfig = {
title: 'My Chart title',
perPage: 10,
showPartialRows: false,
showMetricsAtAllLevels: false,
Expand Down
12 changes: 11 additions & 1 deletion src/plugins/vis_type_table/public/vis_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,18 @@ export function getTableVisualizationControllerClass(
if (!this.$scope) {
return;
}

// How things get into this $scope?
// To inject variables into this $scope there's the following pipeline of stuff to check:
// - visualize_embeddable => that's what the editor creates to wrap this Angular component
// - build_pipeline => it serialize all the params into an Angular template compiled on the fly
// - table_vis_fn => unserialize the params and prepare them for the final React/Angular bridge
// - visualization_renderer => creates the wrapper component for this controller and passes the params
//
// In case some prop is missing check into the top of the chain if they are available and check
// the list above that it is passing through
this.$scope.vis = this.vis;
this.$scope.visState = { params: visParams };
this.$scope.visState = { params: visParams, title: visParams.title };
this.$scope.esResponse = esResponse;

this.$scope.visParams = visParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const visualization = () => ({
const visType = config.visType || visConfig.type;

const vis = new ExprVis({
title: config.title,
type: visType as string,
params: visConfig as VisParams,
});
Expand Down
4 changes: 2 additions & 2 deletions src/plugins/visualizations/public/legacy/build_pipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ export const buildPipeline = async (
const { indexPattern, searchSource } = vis.data;
const query = searchSource!.getField('query');
const filters = searchSource!.getField('filter');
const { uiState } = vis;
const { uiState, title } = vis;

// context
let pipeline = `kibana | kibana_context `;
Expand Down Expand Up @@ -519,7 +519,7 @@ export const buildPipeline = async (
timefilter: params.timefilter,
});
if (buildPipelineVisFunction[vis.type.name]) {
pipeline += buildPipelineVisFunction[vis.type.name](vis.params, schemas, uiState);
pipeline += buildPipelineVisFunction[vis.type.name]({ title, ...vis.params }, schemas, uiState);
} else if (vislibCharts.includes(vis.type.name)) {
const visConfig = { ...vis.params };
visConfig.dimensions = await buildVislibDimensions(vis, params);
Expand Down

0 comments on commit 6a67ed9

Please sign in to comment.