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

feat: remote pinning settings page #1713

Merged
merged 26 commits into from
Mar 26, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
38ddccd
chore: WIP in settinsg page
rafaelramalho19 Jan 20, 2021
db87d03
feat: add remote pinning services to the settings page
rafaelramalho19 Jan 21, 2021
1ba9b0a
chore: memoise pinning service color
rafaelramalho19 Jan 21, 2021
6564ce1
chore: set the same colors for pinning services manager items
rafaelramalho19 Jan 22, 2021
1204ffb
chore: update src/components/pinning-manager/PinningManager.js
rafaelramalho19 Jan 25, 2021
3fa9f73
chore: remove console.log
rafaelramalho19 Jan 25, 2021
bdb68f0
chore: make pinning work in go-ipfs 0.7 & add docs link
rafaelramalho19 Jan 25, 2021
2fb1335
chore: move pinning constants to another file
rafaelramalho19 Jan 26, 2021
14f9a01
feat: detect if remote services are available in the settings page
rafaelramalho19 Jan 26, 2021
a2eb066
chore: switch to production Pinata
lidel Mar 4, 2021
85f4d55
feat: remote pins on files page (#1721)
rafaelramalho19 Mar 15, 2021
b875a6d
chore: disable js-ipfs tests for the time being
rafaelramalho19 Mar 15, 2021
6e7e746
feat: add autoUpload toggle to the pinning manager
rafaelramalho19 Mar 17, 2021
1a38fd4
chore: change autoupload labels
rafaelramalho19 Mar 17, 2021
a19a5ef
refactor: simplify size calculations
lidel Mar 23, 2021
5d6a1b4
fix: pin.remote.ls status check
lidel Mar 23, 2021
8c4c701
fix: meaningful labels and variable names
lidel Mar 25, 2021
7798160
fix: auto upload labels
lidel Mar 25, 2021
1ef2b6d
fix: disable pinning to offline services
lidel Mar 25, 2021
c097a9c
fix: pinning service templates
lidel Mar 25, 2021
579cc36
style: auto upload modal title
lidel Mar 25, 2021
135b6a1
style: auto upload modal description
lidel Mar 25, 2021
ec04d9a
style: auto upload menu item
lidel Mar 25, 2021
a6dfa6c
fix: no online check for local pinning
lidel Mar 25, 2021
dae0e96
style: separate title for remote pin glyph
lidel Mar 25, 2021
eb4be88
chore: cleanup
lidel Mar 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ jobs:
command: npm run build
- run:
command: E2E_IPFSD_TYPE=go npm run test:e2e
- run:
command: E2E_IPFSD_TYPE=js npm run test:e2e
# - run: - TODO: uncomment after pinning services are coded in js-ipfs
# command: E2E_IPFSD_TYPE=js npm run test:e2e
- run:
command: npm run bundlesize
- persist_to_workspace:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ yarn-error.log*
.vscode
.idea
.eslintcache
tsconfig.tsbuildinfo
45,063 changes: 22,975 additions & 22,088 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"start": "run-script-os",
"start:win32": "@powershell -Command $env:REACT_APP_GIT_REV=(git rev-parse --short HEAD); react-scripts start",
"start:darwin:linux": "cross-env REACT_APP_GIT_REV=`git rev-parse --short HEAD` react-scripts start",
"lint": "eslint src/ test/",
"lint": "eslint src/ test/ && tsc --noEmit",
"prebuild": "lol public/locales > src/lib/languages.json",
"build": "run-script-os",
"build:win32": "@powershell -Command $env:REACT_APP_GIT_REV=(git rev-parse --short HEAD); react-scripts build",
Expand Down
26 changes: 19 additions & 7 deletions public/locales/en/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@
"save": "Save",
"saving": "Saving…",
"reset": "Reset",
"learnMoreLink": "Learn more.",
"pinningServices": {
"title": "Pinning Services",
"description": "Support for third-party remote pinning services will be implemented in a future release, and you'll be able to add and configure them here. In the meantime, use local pinning when you want to ensure an item on your node is never garbage-collected, even if you remove it from Files."
"description": "Use local pinning when you want to ensure an item on your node is never garbage-collected, even if you remove it from Files. You can also link your accounts with other remote pinning services to automatically or selectively persist files with those providers, enabling you to keep backup copies of your files and/or make them available to others when your local node is offline.",
"noPinRemoteDescription": "Support for third-party remote pinning services is missing. Update your IPFS node to go-ipfs 0.8.0 or later, and you'll be able to add and configure them here.",
"addAutoUpload": "Enable Auto Upload",
lidel marked this conversation as resolved.
Show resolved Hide resolved
"removeAutoUpload": "Disable Auto Upload"
},
"language": "Language",
"analytics": "Analytics",
Expand Down Expand Up @@ -37,17 +41,26 @@
"secretApiKey": "Secret API key",
"autoUpload": "Auto upload"
},
"autoUploadModal": {
"title": "Change Upload Policy for \"{name}\"",
lidel marked this conversation as resolved.
Show resolved Hide resolved
"description": "When enabled, Auto Upload will periodically pin the root of your \"Files\", ensuring everything is pinned remotely and available to other peers even when your local IPFS node goes offline. If you disable it, you can still pin each file manually using the \"Set pinning\" operation on the \"Files\" screen."
lidel marked this conversation as resolved.
Show resolved Hide resolved
},
"errors": {
"nickname": "Nickname is required",
"apiError": "API error",
"apiEndpoint": "Must be a valid URL",
"secretApiKey": "Secret key is required"
"secretApiKey": "Secret key is required",
"failedToFetch": "Failed to fetch",
"failedToFetchTitle": "Unable to fetch pin count from this remote service. Make sure it is online and that you entered correct credentials. If this is a newly added service, try removing and adding it again."
},
"actions": {
"addService": "Add Service",
"edit": "Change",
"close": "Close",
"save": "Save",
"cancel": "Cancel"
"cancel": "Cancel",
"enable": "Enable",
"disable": "Disable"
},
"edit": "Edit",
"visitService": "Visit service",
Expand All @@ -57,10 +70,9 @@
"size": "Size",
"pins": "Pins",
"autoUpload": "Auto Upload",
"autoUploadKeys": {
"ALL_FILES": "All files",
"DISABLED": "Disabled",
"PINS_ONLY": "Pins only"
"autoUploadPolicy": {
"true": "All files",
"false": "Off"
},
"fetchingSettings": "Fetching settings...",
"configApiNotAvailable": "The IPFS config API is not available. Please disable the \"IPFS Companion\" Web Extension and try again.",
Expand Down
28 changes: 18 additions & 10 deletions src/bundles/files/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ const fileFromStats = ({ cumulativeSize, type, size, cid, name, path, pinned, is
isParent: isParent
})

/**
* @param {IPFSService} ipfs
* @param {string|CID} cidOrPath
* @returns {Promise<number>}
*/
const cumulativeSize = async (ipfs, cidOrPath) => {
const { cumulativeSize } = await stat(ipfs, cidOrPath)
return cumulativeSize || 0
}

/**
* @param {string} path
* @returns {string}
Expand All @@ -68,6 +78,7 @@ export const realMfsPath = (path) => {
* @property {string} path
* @property {'file'|'directory'|'unknown'} type
* @property {CID} cid
* @property {number} cumulativeSize
* @property {number} size
*
* @param {IPFSService} ipfs
Expand All @@ -81,6 +92,7 @@ const stat = async (ipfs, cidOrPath) => {
: `/ipfs/${hashOrPath}`

try {
// TODO: memoize/cache result per CID
const stats = await ipfs.files.stat(path)
return { path, ...stats }
} catch (e) {
Expand All @@ -93,6 +105,7 @@ const stat = async (ipfs, cidOrPath) => {
path: hashOrPath,
cid: new CID(cid),
type: 'unknown',
cumulativeSize: 0,
size: 0
}
}
Expand Down Expand Up @@ -512,13 +525,10 @@ const actions = () => ({
* updated.
*/
doPinsSizeGet: () => perform(ACTIONS.PINS_SIZE_GET, async (ipfs) => {
const allPinsCids = await ipfs.pin.ls({ type: 'recursive' })

let pinsSize = 0
const pinsSize = -1 // TODO: right now calculating size of all pins is too expensive (requires ipfs.files.stat per CID)
let numberOfPins = 0

for await (const { cid } of allPinsCids) {
pinsSize += (await ipfs.files.stat(`/ipfs/${cid.toString()}`)).cumulativeSize
for await (const _ of ipfs.pin.ls({ type: 'recursive' })) { // eslint-disable-line no-unused-vars
numberOfPins++
}

Expand All @@ -530,8 +540,7 @@ const actions = () => ({
* updated.
*/
doFilesSizeGet: () => perform(ACTIONS.SIZE_GET, async (ipfs) => {
const stat = await ipfs.files.stat('/')
return { size: stat.cumulativeSize }
return cumulativeSize(ipfs, '/')
}),

/**
Expand All @@ -544,8 +553,7 @@ const actions = () => ({
*/
async (store) => {
const ipfs = store.getIpfs()
const stat = await ipfs.files.stat(`/ipfs/${cid}`)
return stat.cumulativeSize
return cumulativeSize(ipfs, cid)
}
})

Expand Down Expand Up @@ -615,7 +623,7 @@ const dirStats = async (ipfs, cid, { path, isRoot, sorting }) => {
}

parent = fileFromStats({
...await ipfs.files.stat(parentInfo.realPath),
...await stat(ipfs, parentInfo.realPath),
path: parentInfo.path,
name: '..',
isParent: true
Expand Down
4 changes: 3 additions & 1 deletion src/bundles/peer-bandwidth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createSelector } from 'redux-bundler'
import last from 'it-last'

// Depends on ipfsBundle, peersBundle, routesBundle
export default function (opts) {
const bundle = function (opts) {
opts = opts || {}
// Max number of peers to update at once
opts.peerUpdateConcurrency = opts.peerUpdateConcurrency || 5
Expand Down Expand Up @@ -180,3 +180,5 @@ export default function (opts) {
)
}
}

export default bundle
Loading