Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TSVB] Table view - fix the display of table elements if they are in the URL form #105051

Merged
merged 1 commit into from Jul 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -207,6 +207,7 @@ export class TablePanelConfig extends Component<
<EuiFieldText
onChange={this.handleTextChange('drilldown_url')}
value={model.drilldown_url ?? ''}
data-test-subj="drilldownUrl"
/>
</EuiFormRow>

Expand Down
Expand Up @@ -58,7 +58,11 @@ class TableVis extends Component {

renderRow = (row) => {
const { model } = this.props;
let rowDisplay = model.pivot_type === 'date' ? this.dateFormatter.convert(row.key) : row.key;

let rowDisplay = getValueOrEmpty(
model.pivot_type === 'date' ? this.dateFormatter.convert(row.key) : row.key
);

if (model.drilldown_url) {
const url = replaceVars(model.drilldown_url, {}, { key: row.key });
rowDisplay = <a href={sanitizeUrl(url)}>{rowDisplay}</a>;
Expand Down Expand Up @@ -98,7 +102,7 @@ class TableVis extends Component {
});
return (
<tr key={row.key}>
<td>{getValueOrEmpty(rowDisplay)}</td>
<td>{rowDisplay}</td>
{columns}
</tr>
);
Expand Down
17 changes: 16 additions & 1 deletion test/functional/apps/visualize/_tsvb_table.ts
Expand Up @@ -10,12 +10,14 @@ import expect from '@kbn/expect';

import { FtrProviderContext } from '../../ftr_provider_context';

export default function ({ getPageObjects }: FtrProviderContext) {
export default function ({ getPageObjects, getService }: FtrProviderContext) {
const { visualBuilder, visualize, visChart } = getPageObjects([
'visualBuilder',
'visualize',
'visChart',
]);
const findService = getService('find');
const retry = getService('retry');

describe('visual builder', function describeIndexTests() {
before(async () => {
Expand Down Expand Up @@ -43,6 +45,19 @@ export default function ({ getPageObjects }: FtrProviderContext) {
expect(tableData).to.be(EXPECTED);
});

it('should display drilldown urls', async () => {
const baseURL = 'http://elastic.co/foo/';

await visualBuilder.clickPanelOptions('table');
await visualBuilder.setDrilldownUrl(`${baseURL}{{key}}`);

await retry.try(async () => {
const links = await findService.allByCssSelector(`a[href="${baseURL}ios"]`);

expect(links.length).to.be(1);
});
});

it('should display correct values on changing metrics aggregation', async () => {
const EXPECTED = 'OS Cardinality\nwin 8 12\nwin xp 9\nwin 7 8\nios 5\nosx 3';

Expand Down
7 changes: 7 additions & 0 deletions test/functional/page_objects/visual_builder_page.ts
Expand Up @@ -277,6 +277,13 @@ export class VisualBuilderPageObject extends FtrService {
await this.comboBox.setElement(formatterEl, formatter, { clickWithMouse: true });
}

public async setDrilldownUrl(value: string) {
const drilldownEl = await this.testSubjects.find('drilldownUrl');

await drilldownEl.clearValue();
await drilldownEl.type(value);
}

/**
* set duration formatter additional settings
*
Expand Down