diff --git a/src/ui/public/stringify/__tests__/_url.js b/src/ui/public/stringify/__tests__/_url.js index 2444766e594223..3420df52e35725 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 5143fce2aae1d9..259143893cbe9d 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 08543b8bfe5706..95c6ea2675e30d 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}`; } } };