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

add an option for url types so that it can be opened in current tab (master branch) #13209

Merged
merged 5 commits into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/core_plugins/kibana/common/field_formats/types/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ UrlFormat.prototype._convert = {
linkLabel = label;
}

return `<a href="${url}" target="_blank">${linkLabel}</a>`;
const linkTarget = this.param('openLinkInCurrentTab') ? '_self' : '_blank';

return `<a href="${url}" target="${linkTarget}" rel="noopener">${linkLabel}</a>`;
}
}
};
10 changes: 9 additions & 1 deletion src/core_plugins/kibana/public/field_formats/__tests__/_url.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('Url Format', function () {
Url = fieldFormats.getType('url');
});

it('ouputs a simple <a> tab by default', function () {
it('outputs a simple <a> tab by default', function () {
const url = new Url();

const $a = unwrap($(url.convert('http://elastic.co', 'html')));
Expand All @@ -34,6 +34,14 @@ describe('Url Format', function () {
expect($a.children().size()).to.be(0);
});

it('outputs a <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 <image> if type === "img"', function () {
const url = new Url({ type: 'img' });

Expand Down
14 changes: 14 additions & 0 deletions src/ui/public/field_format_editor/editors/url/url.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@
</select>
</div>

<div ng-if="editor.formatParams.type == 'a'">
<label class="kuiCheckBoxLabel">
<input
class="kuiCheckBox"
type="checkbox"
ng-model="editor.formatParams.openLinkInCurrentTab"
></input>

<span class="kuiCheckBoxLabel__text">
Open link in current tab
</span>
</label>
</div>

<div class="form-group">
<span class="pull-right text-info hintbox-label" ng-click="editor.showUrlTmplHelp = !editor.showUrlTmplHelp">
<i class="fa fa-info"></i> Url Template Help
Expand Down