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

Allow specifying target in ui-control #1447

Merged
merged 3 commits into from
Nov 11, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/nodes/widgets/ui-control.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ If you want to trigger navigation to an external resource or website, you can do
msg.payload = {
url: 'https://nodered.org'
}
```

You can also specify a `target` property to open the website in a new browser window or tab.

```js
msg.payload = {
url: 'https://nodered.org',
target: '_blank'
}
```

### Show/Hide
Expand Down
5 changes: 5 additions & 0 deletions nodes/widgets/locales/en-US/ui_control.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ <h4>External URL</h4>
<p>It is possible to trigger navigation to an external site, away from your Dashboard by passing in a URL string.</p>
<pre>msg.payload = {
url: 'https://url.goes.here'
}</pre>
<p>You can also specify a target to open the link in a new browser window or tab.</p>
<pre>msg.payload = {
url: 'https://url.goes.here',
target: '_blank'
}</pre>
<h3>Events List</h3>
<p>When any browser client connects or loses connection, changes tab, or expands or collapses a group this node will emit a <code>msg</code> containing:</p>
Expand Down
4 changes: 2 additions & 2 deletions nodes/widgets/ui_control.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@

<script type="text/html" data-template-name="ui-control">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="ui-control.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]ui-control.placeholder.name">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="node-red:common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]node-red:common.label.name">
</div>
<div class="form-row">
<label for="node-input-ui"><i class="fa fa-bookmark"></i> UI</label>
Expand Down
9 changes: 7 additions & 2 deletions ui/src/widgets/ui-control/UIControl.vue
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,13 @@ export default {
}

if ('url' in payload) {
// we are setting the url
window.location.href = payload.url
if ('target' in payload) {
// Open the link in a new browser window or tab
window.open(payload.url, payload.target)
} else {
// Open the link in the same window
window.location.href = payload.url
}
}
})
},
Expand Down
Loading