Skip to content

Commit

Permalink
fix: disable sharing action when upload is not possible
Browse files Browse the repository at this point in the history
Closes #477
  • Loading branch information
lidel committed May 30, 2018
1 parent b0d5d06 commit 8f2a719
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion add-on/src/popup/browser-action/operations.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ module.exports = function operations ({
ipfsNodeType,
isIpfsOnline,
redirectEnabled,
uploadEnabled,
onQuickUpload,
onOpenWebUi,
onOpenPrefs,
onToggleRedirect
}) {
return html`
<div class="fade-in pv1">
${isIpfsOnline ? (
${isIpfsOnline && uploadEnabled ? (
navItem({
text: browser.i18n.getMessage('panel_quickUpload'),
bold: true,
Expand Down
5 changes: 4 additions & 1 deletion add-on/src/popup/browser-action/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ module.exports = (state, emitter) => {
gatewayAddress: null,
swarmPeers: null,
gatewayVersion: null,
redirectEnabled: false
redirectEnabled: false,
uploadEnabled: false
})

let port
Expand Down Expand Up @@ -201,6 +202,8 @@ module.exports = (state, emitter) => {
state.ipfsNodeType = status.ipfsNodeType
state.ipfsApiUrl = options.ipfsApiUrl
state.redirectEnabled = options.useCustomGateway
// Upload requires access to the background page (https://github.com/ipfs-shipyard/ipfs-companion/issues/477)
state.uploadEnabled = !!(await browser.runtime.getBackgroundPage())
state.swarmPeers = status.peerCount === -1 ? 0 : status.peerCount
state.isIpfsOnline = status.peerCount > -1
state.gatewayVersion = status.gatewayVersion ? status.gatewayVersion : null
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5554,7 +5554,7 @@ level-js@^2.2.4:
typedarray-to-buffer "~1.0.0"
xtend "~2.1.2"

"level-js@github:timkuijsten/level.js#idbunwrapper":
level-js@timkuijsten/level.js#idbunwrapper:
version "2.2.3"
resolved "https://codeload.github.com/timkuijsten/level.js/tar.gz/18e03adab34c49523be7d3d58fafb0c632f61303"
dependencies:
Expand Down

0 comments on commit 8f2a719

Please sign in to comment.