From f655d7af1fb3510e6922de0fc87f63a0be9706ed Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Sat, 13 Jun 2020 00:37:37 +0200 Subject: [PATCH] feat: option to opt-in for bleeding edge ipfs-webui (#893) Co-authored-by: Jessica Schilling --- add-on/_locales/en/messages.json | 8 ++++++++ add-on/src/lib/ipfs-companion.js | 1 + add-on/src/lib/options.js | 1 + add-on/src/lib/state.js | 3 +++ add-on/src/options/forms/experiments-form.js | 11 +++++++++++ add-on/src/options/page.js | 1 + 6 files changed, 25 insertions(+) diff --git a/add-on/_locales/en/messages.json b/add-on/_locales/en/messages.json index b9b2c3d77..fdcf4e824 100644 --- a/add-on/_locales/en/messages.json +++ b/add-on/_locales/en/messages.json @@ -379,6 +379,14 @@ "message": "Be warned: these features are new or work-in-progress. YMMV.", "description": "Warning about Experiments section on the Preferences screen (option_experiments_warning)" }, + "option_useLatestWebUI_title": { + "message": "Use Latest WebUI", + "description": "An option title on the Preferences screen (option_useLatestWebUI_title)" + }, + "option_useLatestWebUI_description": { + "message": "Loads bleeding-edge Web UI from DNSLink at webui.ipfs.io, instead of the hardcoded release CID shipped with IPFS daemon. Enable only if you trust your DNS resolver and know how to set up the required CORS headers.", + "description": "An option description on the Preferences screen (option_useLatestWebUI_description)" + }, "option_displayNotifications_title": { "message": "Enable Notifications", "description": "An option title on the Preferences screen (option_displayNotifications_title)" diff --git a/add-on/src/lib/ipfs-companion.js b/add-on/src/lib/ipfs-companion.js index 92ddbd78a..dd66301e1 100644 --- a/add-on/src/lib/ipfs-companion.js +++ b/add-on/src/lib/ipfs-companion.js @@ -686,6 +686,7 @@ module.exports = async function init () { case 'detectIpfsPathHeader': case 'preloadAtPublicGateway': case 'openViaWebUI': + case 'useLatestWebUI': case 'noIntegrationsHostnames': case 'dnslinkRedirect': state[key] = change.newValue diff --git a/add-on/src/lib/options.js b/add-on/src/lib/options.js index 606c3a9e8..9eb199de6 100644 --- a/add-on/src/lib/options.js +++ b/add-on/src/lib/options.js @@ -31,6 +31,7 @@ exports.optionDefaults = Object.freeze({ ipfsProxy: true, // window.ipfs logNamespaces: 'jsipfs*,ipfs*,libp2p:mdns*,libp2p-delegated*,-*:ipns*,-ipfs:preload*,-ipfs-http-client:request*,-ipfs:http-api*', importDir: '/ipfs-companion-imports/%Y-%M-%D_%h%m%s/', + useLatestWebUI: false, openViaWebUI: true }) diff --git a/add-on/src/lib/state.js b/add-on/src/lib/state.js index 535e3bfd1..75024895a 100644 --- a/add-on/src/lib/state.js +++ b/add-on/src/lib/state.js @@ -45,6 +45,9 @@ function initState (options, overrides) { }) Object.defineProperty(state, 'webuiRootUrl', { get: function () { + // Did user opt-in for rolling release published on DNSLink? + if (state.useLatestWebUI) return `${state.gwURLString}ipns/webui.ipfs.io/` + // Below is needed to make webui work for embedded js-ipfs // TODO: revisit if below is still needed after upgrading to js-ipfs >= 44 const webuiUrl = state.ipfsNodeType === 'embedded:chromesockets' diff --git a/add-on/src/options/forms/experiments-form.js b/add-on/src/options/forms/experiments-form.js index d7125e9a3..0935fe0fb 100644 --- a/add-on/src/options/forms/experiments-form.js +++ b/add-on/src/options/forms/experiments-form.js @@ -6,6 +6,7 @@ const html = require('choo/html') const switchToggle = require('../../pages/components/switch-toggle') function experimentsForm ({ + useLatestWebUI, displayNotifications, catchUnhandledProtocols, linkify, @@ -17,6 +18,7 @@ function experimentsForm ({ onOptionsReset }) { const onDisplayNotificationsChange = onOptionChange('displayNotifications') + const onUseLatestWebUIChange = onOptionChange('useLatestWebUI') const onCatchUnhandledProtocolsChange = onOptionChange('catchUnhandledProtocols') const onLinkifyChange = onOptionChange('linkify') const onrecoverFailedHttpRequestsChange = onOptionChange('recoverFailedHttpRequests') @@ -28,6 +30,15 @@ function experimentsForm ({

${browser.i18n.getMessage('option_header_experiments')}

${browser.i18n.getMessage('option_experiments_warning')}
+
+ +
${switchToggle({ id: 'useLatestWebUI', checked: useLatestWebUI, onchange: onUseLatestWebUIChange })}
+