From d7211b130be3a33cb7accd745e25c4f5b4c9bca5 Mon Sep 17 00:00:00 2001 From: Benedict Aas Date: Wed, 2 May 2018 17:29:08 +0100 Subject: [PATCH] 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. --- lib/gui/app/app.js | 14 ++++++++++++++ lib/gui/app/components/safe-webview.js | 5 ++++- lib/gui/app/index.html | 1 + .../app/os/open-external/services/open-external.js | 5 +++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/gui/app/app.js b/lib/gui/app/app.js index 13676d24..ebd0b99c 100644 --- a/lib/gui/app/app.js +++ b/lib/gui/app/app.js @@ -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) { diff --git a/lib/gui/app/components/safe-webview.js b/lib/gui/app/components/safe-webview.js index 534a422e..6ee8897e 100644 --- a/lib/gui/app/components/safe-webview.js +++ b/lib/gui/app/components/safe-webview.js @@ -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) } diff --git a/lib/gui/app/index.html b/lib/gui/app/index.html index 3eba3e61..bf71835c 100644 --- a/lib/gui/app/index.html +++ b/lib/gui/app/index.html @@ -12,6 +12,7 @@