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

Per-site Redirect Opt-out #687

Merged
merged 11 commits into from
Mar 5, 2019
Prev Previous commit
style(browserAction): move Active Tab section to the top
+ unify labels related to redirects
  • Loading branch information
lidel committed Mar 4, 2019
commit f17ae7cba1fb285a6ad34f07648871fbc341f5a2
2 changes: 1 addition & 1 deletion add-on/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"description": "A menu item in Browser Action pop-up (panel_openWebui)"
},
"panel_redirectToggle": {
"message": "Gateway Redirect",
"message": "Redirect to Gateway",
"description": "A menu item in Browser Action pop-up (panel_redirectToggle)"
},
"panel_redirectToggleTooltip": {
Expand Down
6 changes: 4 additions & 2 deletions add-on/src/popup/browser-action/context-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,12 @@ function activeTabActions (state) {
const showActiveTabSection = (state.isRedirectContext) || state.isIpfsContext
if (!showActiveTabSection) return
return html`
<div class="no-select w-100 outline-0--focus tl">
${navHeader('panel_activeTabSectionHeader')}
<div>
${navHeader('panel_activeTabSectionHeader')}
<div class="fade-in pv1 bb b--black-10">
${contextActions(state)}
</div>
</div>
`
}
module.exports.activeTabActions = activeTabActions
24 changes: 0 additions & 24 deletions add-on/src/popup/browser-action/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,15 @@
const browser = require('webextension-polyfill')
const html = require('choo/html')
const navItem = require('./nav-item')
const navHeader = require('./nav-header')

module.exports = function operations ({
active,
redirect,
ipfsNodeType,
isIpfsOnline,
isApiAvailable,
onQuickUpload,
onOpenWebUi,
onToggleGlobalRedirect
}) {
const activeQuickUpload = active && isIpfsOnline && isApiAvailable
const activeWebUI = active && isIpfsOnline && ipfsNodeType === 'external'
const activeRedirectSwitch = active && ipfsNodeType === 'external'

return html`
<div>
<div class="fade-in pv1 bb b--black-10">
${navItem({
text: browser.i18n.getMessage('panel_redirectToggle'),
Expand All @@ -31,20 +22,5 @@ module.exports = function operations ({
onClick: onToggleGlobalRedirect
})}
</div>
${navHeader('panel_toolsSectionHeader')}
<div class="fade-in pv1 bb b--black-10">
${navItem({
text: browser.i18n.getMessage('panel_quickUpload'),
style: 'b',
disabled: !activeQuickUpload,
onClick: onQuickUpload
})}
${navItem({
text: browser.i18n.getMessage('panel_openWebui'),
disabled: !activeWebUI,
onClick: onOpenWebUi
})}
</div>
</div>
`
}
2 changes: 2 additions & 0 deletions add-on/src/popup/browser-action/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const html = require('choo/html')
const header = require('./header')
const { activeTabActions } = require('./context-actions')
const operations = require('./operations')
const tools = require('./tools')

// Render the browser action page:
// Passed current app `state` from the store and `emit`, a function to create
Expand All @@ -31,6 +32,7 @@ module.exports = function browserActionPage (state, emit) {
${header(headerProps)}
${operations(opsProps)}
${activeTabActions(activeTabActionsProps)}
${tools(opsProps)}
</div>
`
}
38 changes: 38 additions & 0 deletions add-on/src/popup/browser-action/tools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict'
/* eslint-env browser, webextensions */

const browser = require('webextension-polyfill')
const html = require('choo/html')
const navItem = require('./nav-item')
const navHeader = require('./nav-header')

module.exports = function tools ({
active,
ipfsNodeType,
isIpfsOnline,
isApiAvailable,
onQuickUpload,
onOpenWebUi
}) {
const activeQuickUpload = active && isIpfsOnline && isApiAvailable
const activeWebUI = active && isIpfsOnline && ipfsNodeType === 'external'

return html`
<div>
${navHeader('panel_toolsSectionHeader')}
<div class="fade-in pv1 bb b--black-10">
${navItem({
text: browser.i18n.getMessage('panel_quickUpload'),
style: 'b',
disabled: !activeQuickUpload,
onClick: onQuickUpload
})}
${navItem({
text: browser.i18n.getMessage('panel_openWebui'),
disabled: !activeWebUI,
onClick: onOpenWebUi
})}
</div>
</div>
`
}