Skip to content

Commit f655d7a

Browse files
feat: option to opt-in for bleeding edge ipfs-webui (#893)
Co-authored-by: Jessica Schilling <[email protected]>
1 parent a462439 commit f655d7a

File tree

6 files changed

+25
-0
lines changed

6 files changed

+25
-0
lines changed

add-on/_locales/en/messages.json

+8
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,14 @@
379379
"message": "Be warned: these features are new or work-in-progress. YMMV.",
380380
"description": "Warning about Experiments section on the Preferences screen (option_experiments_warning)"
381381
},
382+
"option_useLatestWebUI_title": {
383+
"message": "Use Latest WebUI",
384+
"description": "An option title on the Preferences screen (option_useLatestWebUI_title)"
385+
},
386+
"option_useLatestWebUI_description": {
387+
"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.",
388+
"description": "An option description on the Preferences screen (option_useLatestWebUI_description)"
389+
},
382390
"option_displayNotifications_title": {
383391
"message": "Enable Notifications",
384392
"description": "An option title on the Preferences screen (option_displayNotifications_title)"

add-on/src/lib/ipfs-companion.js

+1
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,7 @@ module.exports = async function init () {
686686
case 'detectIpfsPathHeader':
687687
case 'preloadAtPublicGateway':
688688
case 'openViaWebUI':
689+
case 'useLatestWebUI':
689690
case 'noIntegrationsHostnames':
690691
case 'dnslinkRedirect':
691692
state[key] = change.newValue

add-on/src/lib/options.js

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ exports.optionDefaults = Object.freeze({
3131
ipfsProxy: true, // window.ipfs
3232
logNamespaces: 'jsipfs*,ipfs*,libp2p:mdns*,libp2p-delegated*,-*:ipns*,-ipfs:preload*,-ipfs-http-client:request*,-ipfs:http-api*',
3333
importDir: '/ipfs-companion-imports/%Y-%M-%D_%h%m%s/',
34+
useLatestWebUI: false,
3435
openViaWebUI: true
3536
})
3637

add-on/src/lib/state.js

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ function initState (options, overrides) {
4545
})
4646
Object.defineProperty(state, 'webuiRootUrl', {
4747
get: function () {
48+
// Did user opt-in for rolling release published on DNSLink?
49+
if (state.useLatestWebUI) return `${state.gwURLString}ipns/webui.ipfs.io/`
50+
4851
// Below is needed to make webui work for embedded js-ipfs
4952
// TODO: revisit if below is still needed after upgrading to js-ipfs >= 44
5053
const webuiUrl = state.ipfsNodeType === 'embedded:chromesockets'

add-on/src/options/forms/experiments-form.js

+11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const html = require('choo/html')
66
const switchToggle = require('../../pages/components/switch-toggle')
77

88
function experimentsForm ({
9+
useLatestWebUI,
910
displayNotifications,
1011
catchUnhandledProtocols,
1112
linkify,
@@ -17,6 +18,7 @@ function experimentsForm ({
1718
onOptionsReset
1819
}) {
1920
const onDisplayNotificationsChange = onOptionChange('displayNotifications')
21+
const onUseLatestWebUIChange = onOptionChange('useLatestWebUI')
2022
const onCatchUnhandledProtocolsChange = onOptionChange('catchUnhandledProtocols')
2123
const onLinkifyChange = onOptionChange('linkify')
2224
const onrecoverFailedHttpRequestsChange = onOptionChange('recoverFailedHttpRequests')
@@ -28,6 +30,15 @@ function experimentsForm ({
2830
<fieldset class="mb3 pa1 pa4-ns pa3 bg-snow-muted charcoal">
2931
<h2 class="ttu tracked f6 fw4 teal mt0-ns mb3-ns mb1 mt2 ">${browser.i18n.getMessage('option_header_experiments')}</h2>
3032
<div class="mb2">${browser.i18n.getMessage('option_experiments_warning')}</div>
33+
<div class="flex-row-ns pb0-ns">
34+
<label for="useLatestWebUI">
35+
<dl>
36+
<dt>${browser.i18n.getMessage('option_useLatestWebUI_title')}</dt>
37+
<dd>${browser.i18n.getMessage('option_useLatestWebUI_description')}</dd>
38+
</dl>
39+
</label>
40+
<div class="self-center-ns">${switchToggle({ id: 'useLatestWebUI', checked: useLatestWebUI, onchange: onUseLatestWebUIChange })}</div>
41+
</div>
3142
<div class="flex-row-ns pb0-ns">
3243
<label for="displayNotifications">
3344
<dl>

add-on/src/options/page.js

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ module.exports = function optionsPage (state, emit) {
8686
onOptionChange
8787
})}
8888
${experimentsForm({
89+
useLatestWebUI: state.options.useLatestWebUI,
8990
displayNotifications: state.options.displayNotifications,
9091
catchUnhandledProtocols: state.options.catchUnhandledProtocols,
9192
linkify: state.options.linkify,

0 commit comments

Comments
 (0)