Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display channel-appropriate release notes upon Companion version update #913

Merged
merged 9 commits into from
Jul 21, 2020
8 changes: 8 additions & 0 deletions add-on/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,14 @@
"message": "Display OS-level notifications when a link is copied to the clipboard,the API state changes, etc.",
"description": "An option description on the Preferences screen (option_displayNotifications_description)"
},
"option_displayReleaseNotes_title": {
"message": "Show Release Notes",
jessicaschilling marked this conversation as resolved.
Show resolved Hide resolved
"description": "An option title on the Preferences screen (option_displayReleaseNotes_title)"
},
"option_displayReleaseNotes_description": {
"message": "Open Release Notes in a new tab after an update is installed.",
jessicaschilling marked this conversation as resolved.
Show resolved Hide resolved
"description": "An option description on the Preferences screen (option_displayReleaseNotes_description)"
},
jessicaschilling marked this conversation as resolved.
Show resolved Hide resolved
"option_catchUnhandledProtocols_title": {
"message": "Catch Unhandled IPFS Protocols",
"description": "An option title on the Preferences screen (option_catchUnhandledProtocols_title)"
Expand Down
1 change: 1 addition & 0 deletions add-on/src/lib/ipfs-companion.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ module.exports = async function init () {
case 'linkify':
case 'catchUnhandledProtocols':
case 'displayNotifications':
case 'displayReleaseNotes':
case 'automaticMode':
case 'detectIpfsPathHeader':
case 'preloadAtPublicGateway':
Expand Down
15 changes: 13 additions & 2 deletions add-on/src/lib/on-installed.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,33 @@
const browser = require('webextension-polyfill')

exports.welcomePage = '/dist/landing-pages/welcome/index.html'
exports.updatePage = 'https://github.com/ipfs-shipyard/ipfs-companion/releases/tag/v'

exports.onInstalled = async (details) => {
// details.temporary === run via `npm run firefox`
if (details.reason === 'install' || details.temporary) {
await browser.storage.local.set({ showLandingPage: 'onInstallWelcome' })
} else if (details.reason === 'update' || details.temporary) {
await browser.storage.local.set({ showLandingPage: 'onVersionUpdate' })
}
}

exports.showPendingLandingPages = async () => {
const hint = await browser.storage.local.get('showLandingPage')
const hint = await browser.storage.local.get([
'showLandingPage',
'displayReleaseNotes'
])
switch (hint.showLandingPage) {
case 'onInstallWelcome':
await browser.storage.local.remove('showLandingPage')
return browser.tabs.create({
url: exports.welcomePage
})
// case 'onVersionUpdate'
case 'onVersionUpdate':
await browser.storage.local.remove('showLandingPage')
if (!hint.displayReleaseNotes) return
return browser.tabs.create({
url: exports.updatePage + browser.runtime.getManifest().version
})
}
}
1 change: 1 addition & 0 deletions add-on/src/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ exports.optionDefaults = Object.freeze({
preloadAtPublicGateway: true,
catchUnhandledProtocols: true,
displayNotifications: true,
displayReleaseNotes: true,
customGatewayUrl: buildCustomGatewayUrl(),
ipfsApiUrl: buildIpfsApiUrl(),
ipfsApiPollMs: 3000,
Expand Down
11 changes: 11 additions & 0 deletions add-on/src/options/forms/experiments-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const switchToggle = require('../../pages/components/switch-toggle')
function experimentsForm ({
useLatestWebUI,
displayNotifications,
displayReleaseNotes,
catchUnhandledProtocols,
linkify,
recoverFailedHttpRequests,
Expand All @@ -17,6 +18,7 @@ function experimentsForm ({
onOptionChange
}) {
const onDisplayNotificationsChange = onOptionChange('displayNotifications')
const onDisplayReleaseNotesChange = onOptionChange('displayReleaseNotes')
const onUseLatestWebUIChange = onOptionChange('useLatestWebUI')
const onCatchUnhandledProtocolsChange = onOptionChange('catchUnhandledProtocols')
const onLinkifyChange = onOptionChange('linkify')
Expand Down Expand Up @@ -47,6 +49,15 @@ function experimentsForm ({
</label>
<div class="self-center-ns">${switchToggle({ id: 'displayNotifications', checked: displayNotifications, onchange: onDisplayNotificationsChange })}</div>
</div>
<div class="flex-row-ns pb0-ns">
<label for="displayReleaseNotes">
<dl>
<dt>${browser.i18n.getMessage('option_displayReleaseNotes_title')}</dt>
<dd>${browser.i18n.getMessage('option_displayReleaseNotes_description')}</dd>
</dl>
</label>
<div class="self-center-ns">${switchToggle({ id: 'displayReleaseNotes', checked: displayReleaseNotes, onchange: onDisplayReleaseNotesChange })}</div>
</div>
<div class="flex-row-ns pb0-ns">
<label for="catchUnhandledProtocols">
<dl>
Expand Down
1 change: 1 addition & 0 deletions add-on/src/options/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ module.exports = function optionsPage (state, emit) {
${experimentsForm({
useLatestWebUI: state.options.useLatestWebUI,
displayNotifications: state.options.displayNotifications,
displayReleaseNotes: state.options.displayReleaseNotes,
catchUnhandledProtocols: state.options.catchUnhandledProtocols,
linkify: state.options.linkify,
recoverFailedHttpRequests: state.options.recoverFailedHttpRequests,
Expand Down