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

Storage buckets overview #1140

Merged
merged 69 commits into from
Jun 18, 2021
Merged
Changes from 1 commit
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
0bed9ca
fix broken things
FSM1 May 18, 2021
0a327c1
rewire for new apis
FSM1 May 19, 2021
cce9198
lingui extract
actions-user May 19, 2021
6bbb233
clean up linting errors
FSM1 May 20, 2021
6bda362
Align paths and test
FSM1 May 20, 2021
d8e2997
Merge remote-tracking branch 'origin/dev' into mnt/update-api-client-…
FSM1 May 20, 2021
5b2d466
post merge fixes
FSM1 May 20, 2021
331deef
Apply suggestions from code review
FSM1 May 20, 2021
d96583b
Update packages/files-ui/src/Utils/pathUtils.ts
FSM1 May 20, 2021
c66e332
Merge remote-tracking branch 'origin/dev' into mnt/update-api-client-…
FSM1 May 21, 2021
7cb0cb0
update context and hook names
FSM1 May 21, 2021
fbb22c1
fix search
FSM1 May 21, 2021
09bfff7
fix bin folder navigation
FSM1 May 21, 2021
6d6eebc
fix grid item navigation
FSM1 May 21, 2021
702e554
init
Tbaut May 21, 2021
2e0e6ad
add permission to buckets
Tbaut May 28, 2021
d687229
Nav and filtering
Tbaut May 31, 2021
d1f28d6
merge dev and fix conflicts
Tbaut Jun 1, 2021
678613f
lingui extract
actions-user Jun 1, 2021
a62c580
with some todos
Tbaut Jun 1, 2021
c0dbea3
Merge branch 'feat/tbaut-shared-overview-1041' of github.com:ChainSaf…
Tbaut Jun 1, 2021
e855e8e
merge dev
Tbaut Jun 10, 2021
d5417d5
lint
Tbaut Jun 10, 2021
4c3378c
Merge branch 'dev' into feat/tbaut-shared-overview-1041
Tbaut Jun 11, 2021
c976022
basics
Tbaut Jun 11, 2021
c38c7c7
lingui extract
actions-user Jun 11, 2021
edd8d71
User circles
Tbaut Jun 14, 2021
c55af18
Merge branch 'feat/tbaut-shared-overview-1041' of github.com:ChainSaf…
Tbaut Jun 14, 2021
9ebd6b7
Merge branch 'dev' into feat/tbaut-shared-overview-1041
Tbaut Jun 15, 2021
6095398
add storage bucket list and bucket details
FSM1 Jun 15, 2021
adae31a
clean up file browser modals
FSM1 Jun 15, 2021
8b2973f
Merge branch 'dev' into feat/storage-buckets-overview-1104
FSM1 Jun 15, 2021
3eb13fb
fix linting
FSM1 Jun 15, 2021
df484b2
fix CRLF
FSM1 Jun 15, 2021
a9a108b
Merge branch 'dev' into feat/storage-buckets-overview-1104
FSM1 Jun 15, 2021
0105a5b
wire up file upload
FSM1 Jun 15, 2021
be5e3cf
clean up styling
FSM1 Jun 16, 2021
a77c9ee
refresh buckets on delete
FSM1 Jun 16, 2021
b574274
remove some styling
FSM1 Jun 16, 2021
e1841f3
remove bulk ops
FSM1 Jun 16, 2021
89c3972
Merge branch 'dev' of github.com:ChainSafe/files-ui into feat/tbaut-s…
Tbaut Jun 16, 2021
13c5ccf
user icons with tooltip
Tbaut Jun 16, 2021
d9e7e6d
Merge branch 'feat/tbaut-shared-overview-1041' of github.com:ChainSaf…
Tbaut Jun 16, 2021
bdf5fdc
Merge branch 'dev' into feat/storage-buckets-overview-1104
FSM1 Jun 16, 2021
6c8a65a
Merge branch 'feat/tbaut-shared-overview-1041' of github.com:ChainSaf…
Tbaut Jun 17, 2021
3b0c058
loader
Tbaut Jun 17, 2021
e16b80b
lingui extract
actions-user Jun 17, 2021
cd41eb4
Merge branch 'dev' into feat/storage-buckets-overview-1104
tanmoyAtb Jun 17, 2021
9666ba4
nav color
Tbaut Jun 17, 2021
bbdb632
Merge branch 'feat/storage-buckets-overview-1104' of github.com:Chain…
Tbaut Jun 17, 2021
4aa4b0e
Revert "nav color"
Tbaut Jun 17, 2021
9bf40f0
Revert "loader"
Tbaut Jun 17, 2021
9816d38
lingui extract
actions-user Jun 17, 2021
49fa8e7
Merge branch 'dev' into feat/storage-buckets-overview-1104
FSM1 Jun 17, 2021
48c231c
Merge branch 'dev' into feat/storage-buckets-overview-1104
tanmoyAtb Jun 18, 2021
5f9bd2d
Revert "Merge branch 'feat/tbaut-shared-overview-1041' of github.com:…
Tbaut Jun 18, 2021
f98a3a5
Apply suggestions from code review
FSM1 Jun 18, 2021
82ba2c5
implement feedback
FSM1 Jun 18, 2021
0c0e743
more cleaning up
FSM1 Jun 18, 2021
62ff04a
clean up unused imports
FSM1 Jun 18, 2021
f60926c
show the failed pins
Tbaut Jun 18, 2021
3ff88e2
add pinning bucket to size calc
FSM1 Jun 18, 2021
6b3d1cb
Merge branch 'feat/storage-buckets-overview-1104' of github.com:Chain…
Tbaut Jun 18, 2021
277f6dc
Hide facebook login
FSM1 Jun 18, 2021
7ad2cb9
Merge branch 'feat/storage-buckets-overview-1104' of https://github.c…
FSM1 Jun 18, 2021
131b9ec
remove title
FSM1 Jun 18, 2021
3cf4c44
fix broken import and remove unused icon
FSM1 Jun 18, 2021
a5a82f0
fix app name
FSM1 Jun 18, 2021
aae17d1
rename to Storage
FSM1 Jun 18, 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
Next Next commit
fix broken things
FSM1 committed May 18, 2021
commit 0bed9cab93c329766771060c25fdf0377e01d80f
2 changes: 1 addition & 1 deletion packages/common-contexts/package.json
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
},
"dependencies": {
"@chainsafe/browser-storage-hooks": "^1.0.1",
"@chainsafe/files-api-client": "1.9.0",
"@chainsafe/files-api-client": "1.11.1",
"axios": "^0.21.1",
"uuid": "^8.3.1"
},
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useCallback, useEffect, useMemo, useState } from "react"
import { BucketType, FileSystemItem, useDrive } from "../../../Contexts/DriveContext"
import { FileSystemItem, useDrive } from "../../../Contexts/DriveContext"
import { IBulkOperations, IFilesBrowserModuleProps } from "./types"
import FilesTableView from "./views/FilesTable.view"
import DragAndDrop from "../../../Contexts/DnDContext"
@@ -13,14 +13,15 @@ import { ROUTE_LINKS } from "../../FilesRoutes"
import { FileBrowserContext } from "../../../Contexts/FileBrowserContext"

const BinFileBrowser: React.FC<IFilesBrowserModuleProps> = ({ controls = false }: IFilesBrowserModuleProps) => {
const { removeCSFObjects, moveCSFObject, list } = useDrive()
const { removeCSFObjects, moveCSFObject, list, buckets } = useDrive()
const { addToastMessage } = useToaster()
const [loadingCurrentPath, setLoadingCurrentPath] = useState(false)
const [pathContents, setPathContents] = useState<FileSystemItem[]>([])
const bucketType: BucketType = "trash"
const { pathname } = useLocation()
const [currentPath, setCurrentPath] = useState(extractDrivePath(pathname.split("/").slice(1).join("/")))

const bucket = useMemo(() => buckets.find(b => b.type === "trash"), [buckets])

const refreshContents = useCallback(
(
showLoading?: boolean
@@ -30,7 +31,7 @@ const BinFileBrowser: React.FC<IFilesBrowserModuleProps> = ({ controls = false }
list({
path: currentPath,
source: {
type: bucketType
type: bucket?.type
}
}).then((newContents) => {
showLoading && setLoadingCurrentPath(false)
@@ -54,7 +55,7 @@ const BinFileBrowser: React.FC<IFilesBrowserModuleProps> = ({ controls = false }
showLoading && setLoadingCurrentPath(false)
}
},
[bucketType, list, currentPath]
[bucket, list, currentPath]
)

useEffect(() => {
@@ -77,7 +78,7 @@ const BinFileBrowser: React.FC<IFilesBrowserModuleProps> = ({ controls = false }
const deleteFile = useCallback(async (cid: string) => {
const itemToDelete = pathContents.find((i) => i.cid === cid)

if (!itemToDelete) {
if (!itemToDelete || !bucket) {
console.error("No item found to delete")
return
}
@@ -86,7 +87,7 @@ const BinFileBrowser: React.FC<IFilesBrowserModuleProps> = ({ controls = false }
await removeCSFObjects({
paths: [`${currentPath}${itemToDelete.name}`],
source: {
type: bucketType
type: bucket.type
}
})
refreshContents()
@@ -108,7 +109,7 @@ const BinFileBrowser: React.FC<IFilesBrowserModuleProps> = ({ controls = false }
})
return Promise.reject()
}
}, [addToastMessage, bucketType, currentPath, pathContents, refreshContents, removeCSFObjects])
}, [addToastMessage, bucket, currentPath, pathContents, refreshContents, removeCSFObjects])

const deleteFiles = useCallback(async (cids: string[]) => {
await Promise.all(
@@ -126,9 +127,6 @@ const BinFileBrowser: React.FC<IFilesBrowserModuleProps> = ({ controls = false }
await moveCSFObject({
path: getPathWithFile("/", itemToRestore.name),
new_path: getPathWithFile("/", itemToRestore.name),
source: {
type: "trash"
},
destination: {
type: "csf"
}
@@ -175,6 +173,7 @@ const BinFileBrowser: React.FC<IFilesBrowserModuleProps> = ({ controls = false }

return (
<FileBrowserContext.Provider value={{
bucket: bucket,
crumbs: undefined,
recoverFile,
deleteFiles,
@@ -187,7 +186,6 @@ const BinFileBrowser: React.FC<IFilesBrowserModuleProps> = ({ controls = false }
sourceFiles: pathContents,
heading: t`Bin`,
controls,
bucketType,
itemOperations,
bulkOperations
}}>
Original file line number Diff line number Diff line change
@@ -23,16 +23,19 @@ const CSFFileBrowser: React.FC<IFilesBrowserModuleProps> = () => {
uploadFiles,
moveCSFObject,
uploadsInProgress,
list
list,
buckets
} = useDrive()
const { addToastMessage } = useToaster()
const [loadingCurrentPath, setLoadingCurrentPath] = useState(false)
const [pathContents, setPathContents] = useState<FileSystemItem[]>([])
const bucketType: BucketType = "csf"
const { redirect } = useHistory()

const { pathname } = useLocation()
const [currentPath, setCurrentPath] = useState(extractDrivePath(pathname.split("/").slice(1).join("/")))
const bucket = useMemo(() => {
return buckets.find(b => b.type === "csf")
}, [buckets])
const refreshContents = useCallback(
(
path: string,
@@ -43,7 +46,7 @@ const CSFFileBrowser: React.FC<IFilesBrowserModuleProps> = () => {
list({
path,
source: {
type: bucketType
type: bucket?.type
}
}).then((newContents) => {
showLoading && setLoadingCurrentPath(false)
@@ -68,7 +71,7 @@ const CSFFileBrowser: React.FC<IFilesBrowserModuleProps> = () => {
showLoading && setLoadingCurrentPath(false)
}
},
[bucketType, list]
[bucket, list]
)
const { localStorageGet, localStorageSet } = useLocalStorage()
const { profile } = useUser()
@@ -168,10 +171,10 @@ const CSFFileBrowser: React.FC<IFilesBrowserModuleProps> = () => {

const handleDownload = useCallback(async (cid: string) => {
const target = pathContents.find(item => item.cid === cid)
if (!target) return
if (!target || !bucket) return

await downloadFile(target, currentPath, bucketType)
}, [pathContents, downloadFile, currentPath, bucketType])
await downloadFile(target, currentPath, bucket.type)
}, [pathContents, downloadFile, currentPath, bucket])


// Breadcrumbs/paths
@@ -230,6 +233,7 @@ const CSFFileBrowser: React.FC<IFilesBrowserModuleProps> = () => {

return (
<FileBrowserContext.Provider value={{
bucket: bucket,
bulkOperations,
crumbs,
moduleRootPath: ROUTE_LINKS.Drive(""),
@@ -246,7 +250,6 @@ const CSFFileBrowser: React.FC<IFilesBrowserModuleProps> = () => {
showUploadsInTable: true,
sourceFiles: pathContents,
heading: t`My Files`,
bucketType,
controls: true,
allowDropUpload: true,
itemOperations,
Original file line number Diff line number Diff line change
@@ -129,7 +129,6 @@ const SearchFileBrowser: React.FC<IFilesBrowserModuleProps> = ({ controls = fals
controls,
itemOperations,
isSearch: true,
bucketType,
getPath
}}>
<DragAndDrop>
Original file line number Diff line number Diff line change
@@ -299,9 +299,9 @@ const FilesTableView = () => {
itemOperations,
getPath,
moduleRootPath,
bucketType,
isSearch,
withSurvey
withSurvey,
bucket
} = useFileBrowser()
const classes = useStyles({ themeKey })
const [editing, setEditing] = useState<string | undefined>()
@@ -936,11 +936,11 @@ const FilesTableView = () => {
))}
</section>
)}
{files && previewFileIndex !== undefined && (
{files && previewFileIndex !== undefined && bucket && (
<FilePreviewModal
file={files[previewFileIndex]}
closePreview={clearPreview}
bucketType={bucketType}
bucketType={bucket.type}
nextFile={
previewFileIndex < files.length - 1 ? setNextPreview : undefined
}
20 changes: 16 additions & 4 deletions packages/files-ui/src/Contexts/DriveContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
CSFFilesFullinfoResponse,
CSFFilesFullInfoResponse,
FileContentResponse,
FilesMvRequest,
FilesPathRequest,
@@ -56,6 +56,7 @@ interface GetFileContentParams {


type DriveContext = {
buckets: Bucket[]
uploadFiles: (files: File[], path: string) => Promise<void>
createFolder: (body: FilesPathRequest) => Promise<FileContentResponse>
renameFile: (body: FilesMvRequest) => Promise<void>
@@ -72,7 +73,7 @@ type DriveContext = {
downloadsInProgress: DownloadProgress[]
spaceUsed: number
getFolderTree: () => Promise<DirectoryContentResponse>
getFileInfo: (path: string) => Promise<CSFFilesFullinfoResponse>
getFileInfo: (path: string) => Promise<CSFFilesFullInfoResponse>
secureAccountWithMasterPassword: (candidatePassword: string) => Promise<void>
}

@@ -103,6 +104,16 @@ const DriveProvider = ({ children }: DriveContextProps) => {
const [spaceUsed, setSpaceUsed] = useState(0)
const [encryptionKey, setEncryptionKey] = useState<string | undefined>()

const [buckets, setBuckets] = useState<Bucket[]>([])

useEffect(() => {
const fetchBuckets = async () => {
const result = await imployApiClient.listBuckets()
setBuckets(result)
}
fetchBuckets()
}, [imployApiClient])

// Space used counter
useEffect(() => {
const getSpaceUsage = async () => {
@@ -527,7 +538,8 @@ const DriveProvider = ({ children }: DriveContextProps) => {
listBuckets,
searchFiles,
getFileInfo,
secureAccountWithMasterPassword
secureAccountWithMasterPassword,
buckets
}}
>
{children}
@@ -547,7 +559,7 @@ export { DriveProvider, useDrive }
export type {
FileSystemItem,
DirectoryContentResponse,
CSFFilesFullinfoResponse as FileFullInfo,
CSFFilesFullInfoResponse as FileFullInfo,
BucketType,
SearchEntry
}
4 changes: 2 additions & 2 deletions packages/files-ui/src/Contexts/FileBrowserContext.tsx
Original file line number Diff line number Diff line change
@@ -2,8 +2,9 @@ import { Crumb } from "@chainsafe/common-components"
import React, { useContext } from "react"
import { FileOperation, IBulkOperations, IFilesBrowserModuleProps } from "../Components/Modules/FileBrowsers/types"
import { BucketType, FileSystemItem, UploadProgress } from "./DriveContext"

import { Bucket } from "@chainsafe/files-api-client"
interface FileBrowserContext extends IFilesBrowserModuleProps {
bucket?: Bucket
itemOperations: {[contentType: string]: FileOperation[]}

bulkOperations?: IBulkOperations
@@ -24,7 +25,6 @@ interface FileBrowserContext extends IFilesBrowserModuleProps {

refreshContents?: () => void
currentPath: string
bucketType: BucketType
loadingCurrentPath: boolean
uploadsInProgress?: UploadProgress[]
showUploadsInTable: boolean
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -1664,10 +1664,10 @@
resolved "https://registry.yarnpkg.com/@chainsafe/browser-storage-hooks/-/browser-storage-hooks-1.0.1.tgz#26d32cde1999914db755a631e2643823c54959f7"
integrity sha512-Q4b5gQAZnsRXKeADspd5isqfwwhhXjDk70y++YadufA6EZ3tf340oW0OVszp74KaGEw+CAYFGQR4X7bzpZ3x9Q==

"@chainsafe/files-api-client@1.9.0":
version "1.9.0"
resolved "https://npm.pkg.github.com/download/@chainsafe/files-api-client/1.9.0/4670ba7db48668a6ac1f5ef204bdae517594fcfb5855e4324fe228dfc9da4f29#08dd2c11392619d5cd9f3828876347d07177cd72"
integrity sha512-m5zJkB4zVKZE+8RFThsky1kJmh09niMyAB6xLykyCkUJeF2b4t1Wd5OItoSPTeo09tzUNjQmh+HbOP/jUDA9+Q==
"@chainsafe/files-api-client@1.11.1":
version "1.11.1"
resolved "https://npm.pkg.github.com/download/@chainsafe/files-api-client/1.11.1/e3f6bacbb76a09d44b755dc7a1d9b7e29aa8136a6aa648e784e89c31174abdb2#4879404c2f4d80c18448c11ab15cfff77bd0e7e5"
integrity sha512-6mvyFnqqlOUfMDdf1sSJHQzOA0/wBa4Rnt2TOfD+rV5z82tJYGADxEwCbmbQ3b8G4H01aNhIQxkoaDwFcnMp9w==

"@chainsafe/web3-context@1.1.4":
version "1.1.4"