Skip to content

Commit

Permalink
Apply url params in vis_type_table
Browse files Browse the repository at this point in the history
  • Loading branch information
Avinar-24 committed Dec 19, 2019
1 parent ba7589d commit c2a0bd2
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ interface Column {
title: string;
formatter?: {
convert?: (val: string) => string;
[key: string]: any;
};
sortable?: boolean;
}
Expand Down Expand Up @@ -94,15 +95,19 @@ describe('Table Vis - Paginated table', () => {

if (isNumber(colCount)) {
times(colCount, i => {
columns.push({ id: `${i}`, title: `column${i}`, formatter: { convert: identity } });
columns.push({
id: `${i}`,
title: `column${i}`,
formatter: { convert: identity, getConverterFor: () => identity },
});
});
} else {
columns = colCount.map(
(col, i) =>
({
id: `${i}`,
title: col.title,
formatter: col.formatter || { convert: identity },
formatter: col.formatter || { convert: identity, getConverterFor: () => identity },
} as Column)
);
}
Expand Down Expand Up @@ -678,6 +683,9 @@ describe('Table Vis - Paginated table', () => {
convert: val => {
return val === 'zzz' ? '<h1>hello</h1>' : val;
},
getConverterFor: () => (val: any) => {
return val === 'zzz' ? '<h1>hello</h1>' : val;
},
},
},
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ import $ from 'jquery';
import _ from 'lodash';
import tableCellFilterHtml from './table_cell_filter.html';

function getFormattedValue(formatter, value) {
const parsedUrl = {
origin: window.location.origin,
pathname: window.location.pathname,
};

return formatter.getConverterFor('html')(value, false, false, parsedUrl);
}

export function KbnRows($compile) {
return {
restrict: 'A',
Expand Down Expand Up @@ -72,7 +81,7 @@ export function KbnRows($compile) {

// An AggConfigResult can "enrich" cell contents by applying a field formatter,
// which we want to do if possible.
contents = contentsIsDefined ? column.formatter.convert(contents, 'html') : '';
contents = contentsIsDefined ? getFormattedValue(column.formatter, contents) : '';

if (_.isObject(contents)) {
if (contents.attr) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export const getFormat: FormatFactory = mapping => {
basePath: npStart.core.http.basePath,
};
// @ts-ignore
return format.convert(val, undefined, undefined, parsedUrl);
return format.getConverterFor(type)(val, false, false, parsedUrl);
};
},
convert: (val: string, type: string) => {
Expand All @@ -163,7 +163,7 @@ export const getFormat: FormatFactory = mapping => {
basePath: npStart.core.http.basePath,
};
// @ts-ignore
return format.convert(val, type, undefined, parsedUrl);
return format.getConverterFor(type)(val, false, false, parsedUrl);
},
} as FieldFormat;
} else {
Expand Down

0 comments on commit c2a0bd2

Please sign in to comment.