mirror of
https://github.com/balena-io/etcher.git
synced 2025-04-25 07:47:18 +00:00
feat(GUI): allow disabling links and hiding help link (#2290)
We allow users to pass an env var `ETCHER_DISABLE_EXTERNAL_LINKS` to disable external links and hide links rendered useless by the change such as the help icon. Closes: https://github.com/resin-io/etcher/issues/2246 Closes: https://github.com/resin-io/etcher/issues/2247 Change-Type: patch Changelog-Entry: Allow disabling links and hiding help link with an env var.
This commit is contained in:
parent
e40d5a0a5d
commit
d7211b130b
@ -312,6 +312,20 @@ app.controller('HeaderController', function (OSOpenExternalService) {
|
|||||||
const supportUrl = selectionState.getImageSupportUrl() || DEFAULT_SUPPORT_URL
|
const supportUrl = selectionState.getImageSupportUrl() || DEFAULT_SUPPORT_URL
|
||||||
OSOpenExternalService.open(supportUrl)
|
OSOpenExternalService.open(supportUrl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @summary Whether to show the help link
|
||||||
|
* @function
|
||||||
|
* @public
|
||||||
|
*
|
||||||
|
* @returns {Boolean}
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* HeaderController.shouldShowHelp()
|
||||||
|
*/
|
||||||
|
this.shouldShowHelp = () => {
|
||||||
|
return Boolean(process.env.ETCHER_DISABLE_EXTERNAL_LINKS)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.controller('StateController', function ($rootScope, $scope) {
|
app.controller('StateController', function ($rootScope, $scope) {
|
||||||
|
@ -212,7 +212,10 @@ class SafeWebview extends react.PureComponent {
|
|||||||
|
|
||||||
if (_.every([
|
if (_.every([
|
||||||
url.protocol === 'http:' || url.protocol === 'https:',
|
url.protocol === 'http:' || url.protocol === 'https:',
|
||||||
event.disposition === 'foreground-tab'
|
event.disposition === 'foreground-tab',
|
||||||
|
|
||||||
|
// Don't open links if they're disabled by the env var
|
||||||
|
!process.env.ETCHER_DISABLE_EXTERNAL_LINKS
|
||||||
])) {
|
])) {
|
||||||
electron.shell.openExternal(url.href)
|
electron.shell.openExternal(url.href)
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<header class="section-header" ng-controller="HeaderController as header">
|
<header class="section-header" ng-controller="HeaderController as header">
|
||||||
<button class="button button-link"
|
<button class="button button-link"
|
||||||
|
ng-if="header.shouldShowHelp()"
|
||||||
ng-click="header.openHelpPage()"
|
ng-click="header.openHelpPage()"
|
||||||
tabindex="4">
|
tabindex="4">
|
||||||
<span class="glyphicon glyphicon-question-sign"></span>
|
<span class="glyphicon glyphicon-question-sign"></span>
|
||||||
|
@ -31,6 +31,11 @@ module.exports = function () {
|
|||||||
* OSOpenExternalService.open('https://www.google.com');
|
* OSOpenExternalService.open('https://www.google.com');
|
||||||
*/
|
*/
|
||||||
this.open = (url) => {
|
this.open = (url) => {
|
||||||
|
// Don't open links if they're disabled by the env var
|
||||||
|
if (process.env.ETCHER_DISABLE_EXTERNAL_LINKS) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
analytics.logEvent('Open external link', {
|
analytics.logEvent('Open external link', {
|
||||||
url
|
url
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user