From 65fb49d2daf9b3aa2bfd631993d710751b3301d7 Mon Sep 17 00:00:00 2001 From: fbaligand Date: Sun, 23 Jul 2017 23:46:58 +0200 Subject: [PATCH] add an option for url types so that it can be opened in current tab --- src/ui/public/stringify/__tests__/_url.js | 10 +++++++++- src/ui/public/stringify/editors/url.html | 8 ++++++++ src/ui/public/stringify/types/url.js | 4 +++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/ui/public/stringify/__tests__/_url.js b/src/ui/public/stringify/__tests__/_url.js index 2444766e5942..3420df52e357 100644 --- a/src/ui/public/stringify/__tests__/_url.js +++ b/src/ui/public/stringify/__tests__/_url.js @@ -23,7 +23,7 @@ describe('Url Format', function () { Url = fieldFormats.getType('url'); }); - it('ouputs a simple tab by default', function () { + it('outputs a simple tab by default', function () { const url = new Url(); const $a = unwrap($(url.convert('http://elastic.co', 'html'))); @@ -34,6 +34,14 @@ describe('Url Format', function () { expect($a.children().size()).to.be(0); }); + it('outputs a link with target=_self if "open link in current tab" is checked', function () { + const url = new Url({ openLinkInCurrentTab: true }); + + const $a = unwrap($(url.convert('http://elastic.co', 'html'))); + expect($a.is('a')).to.be(true); + expect($a.attr('target')).to.be('_self'); + }); + it('outputs an if type === "img"', function () { const url = new Url({ type: 'img' }); diff --git a/src/ui/public/stringify/editors/url.html b/src/ui/public/stringify/editors/url.html index 5143fce2aae1..259143893cbe 100644 --- a/src/ui/public/stringify/editors/url.html +++ b/src/ui/public/stringify/editors/url.html @@ -7,6 +7,13 @@ +
+ +
+
Url Template Help @@ -119,6 +126,7 @@

+ diff --git a/src/ui/public/stringify/types/url.js b/src/ui/public/stringify/types/url.js index 08543b8bfe57..95c6ea2675e3 100644 --- a/src/ui/public/stringify/types/url.js +++ b/src/ui/public/stringify/types/url.js @@ -110,7 +110,9 @@ export function stringifyUrl(Private) { linkLabel = label; } - return `
${linkLabel}`; + let linkTarget = this.param('openLinkInCurrentTab') ? '_self' : '_blank'; + + return `${linkLabel}`; } } };