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:
Benedict Aas 2018-05-02 17:29:08 +01:00 committed by GitHub
parent e40d5a0a5d
commit d7211b130b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 1 deletions

View File

@ -312,6 +312,20 @@ app.controller('HeaderController', function (OSOpenExternalService) {
const supportUrl = selectionState.getImageSupportUrl() || DEFAULT_SUPPORT_URL
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) {

View File

@ -212,7 +212,10 @@ class SafeWebview extends react.PureComponent {
if (_.every([
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)
}

View File

@ -12,6 +12,7 @@
<body>
<header class="section-header" ng-controller="HeaderController as header">
<button class="button button-link"
ng-if="header.shouldShowHelp()"
ng-click="header.openHelpPage()"
tabindex="4">
<span class="glyphicon glyphicon-question-sign"></span>

View File

@ -31,6 +31,11 @@ module.exports = function () {
* OSOpenExternalService.open('https://www.google.com');
*/
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', {
url
})