Skip to content

Commit

Permalink
fixing custom vis types buildPipeline (#39874) (#40136)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppisljar authored Jul 2, 2019
1 parent 137252b commit 4443308
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,21 @@ export const visualization = () => ({
if (context.columns) {
// assign schemas to aggConfigs
context.columns.forEach(column => {
column.aggConfig.aggConfigs.schemas = visType.schemas.all;
if (column.aggConfig) {
column.aggConfig.aggConfigs.schemas = visType.schemas.all;
}
});

Object.keys(schemas).forEach(key => {
schemas[key].forEach(i => {
context.columns[i].aggConfig.schema = key;
if (context.columns[i] && context.columns[i].aggConfig) {
context.columns[i].aggConfig.schema = key;
}
});
});
}

context = await responseHandler(context);
context = await responseHandler(context, visConfigParams.dimensions);
}

return {
Expand Down

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

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { prepareJson, prepareString, buildPipelineVisFunction } from './build_pipeline';
import { prepareJson, prepareString, buildPipelineVisFunction, buildPipeline } from './build_pipeline';

jest.mock('ui/agg_types/buckets/date_histogram', () => ({}));

Expand Down Expand Up @@ -224,4 +224,25 @@ describe('visualize loader pipeline helpers: build pipeline', () => {
expect(actual).toMatchSnapshot();
});
});

describe('buildPipeline', () => {
it('calls toExpression on vis_type if it exists', async () => {
const vis = {
getCurrentState: () => {},
getUiState: () => null,
isHierarchical: () => false,
aggs: {
getResponseAggs: () => [],
},
type: {
toExpression: () => 'testing custom expressions',
}
};
const searchSource = {
getField: () => null,
};
const expression = await buildPipeline(vis, { searchSource });
expect(expression).toMatchSnapshot();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,13 @@ export const buildPipeline = async (
visConfig.dimensions = await buildVislibDimensions(vis, params);

pipeline += `vislib ${prepareJson('visConfig', visState.params)}`;
} else if (vis.type.toExpression) {
pipeline += await vis.type.toExpression(vis, params);
} else {
const visConfig = visState.params;
visConfig.dimensions = schemas;
pipeline += `visualization type='${vis.type.name}'
${prepareJson('visConfig', visState.params)}
${prepareJson('visConfig', visConfig)}
metricsAtAllLevels=${vis.isHierarchical()}
partialRows=${vis.type.requiresPartialRows || vis.params.showPartialRows || false} `;
if (indexPattern) {
Expand Down

0 comments on commit 4443308

Please sign in to comment.