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

Transfer multiple files and folders #1606

Merged
merged 27 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b33eb6b
initial restructure
tanmoyAtb Oct 1, 2021
94650a0
folder transfers
tanmoyAtb Oct 1, 2021
546f177
sharing working as expected
tanmoyAtb Oct 1, 2021
6303ade
sharing is ready
tanmoyAtb Oct 1, 2021
c853bff
toasts and error handling
tanmoyAtb Oct 1, 2021
45d1b33
error messages
tanmoyAtb Oct 1, 2021
351dfc6
transfer progress ready
tanmoyAtb Oct 2, 2021
c91c275
lingui extract
actions-user Oct 3, 2021
91c9117
Merge branch 'dev' of github.com:ChainSafe/ui-monorepo into feat/mult…
tanmoyAtb Oct 4, 2021
c234ee0
Merge branch 'feat/multiple-file-share-1509' of github.com:ChainSafe/…
tanmoyAtb Oct 4, 2021
61e057c
Merge branch 'dev' into feat/multiple-file-share-1509
FSM1 Oct 5, 2021
8d1ea84
Update packages/files-ui/src/Contexts/FilesContext.tsx
tanmoyAtb Oct 5, 2021
e75d0b0
Merge branch 'dev' into feat/multiple-file-share-1509
Tbaut Oct 6, 2021
ec95671
Merge branch 'dev' into feat/multiple-file-share-1509
FSM1 Oct 6, 2021
fffae0e
Merge branch 'dev' of github.com:ChainSafe/ui-monorepo into feat/mult…
tanmoyAtb Oct 6, 2021
bcc2c1f
Merge branch 'feat/multiple-file-share-1509' of github.com:ChainSafe/…
tanmoyAtb Oct 6, 2021
911fb54
using reduce and handling each file share error
tanmoyAtb Oct 6, 2021
32ce649
updated terms
tanmoyAtb Oct 6, 2021
5e224ef
lingui extract
actions-user Oct 6, 2021
9c607a2
Merge branch 'dev' into feat/multiple-file-share-1509
FSM1 Oct 7, 2021
dbcaace
added no files check
tanmoyAtb Oct 7, 2021
e416a43
lingui extract
actions-user Oct 7, 2021
eb1e32e
share messages
tanmoyAtb Oct 7, 2021
defd78c
Merge branch 'feat/multiple-file-share-1509' of github.com:ChainSafe/…
tanmoyAtb Oct 7, 2021
3bc1606
lingui extract
actions-user Oct 7, 2021
cead339
lint
tanmoyAtb Oct 7, 2021
b3378c4
Merge branch 'feat/multiple-file-share-1509' of github.com:ChainSafe/…
tanmoyAtb Oct 7, 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
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ const CSFFileBrowser: React.FC<IFileBrowserModuleProps> = () => {
}, [currentPath, pathContents, redirect])

const bulkOperations: IBulkOperations = useMemo(() => ({
[CONTENT_TYPES.Directory]: ["download", "move", "delete"],
[CONTENT_TYPES.File]: ["download", "delete", "move"]
[CONTENT_TYPES.Directory]: ["download", "move", "delete", "share"],
[CONTENT_TYPES.File]: ["download", "delete", "move", "share"]
}), [])

const itemOperations: IFilesTableBrowserProps["itemOperations"] = useMemo(() => ({
Expand All @@ -180,7 +180,7 @@ const CSFFileBrowser: React.FC<IFileBrowserModuleProps> = () => {
[CONTENT_TYPES.Pdf]: ["preview"],
[CONTENT_TYPES.Text]: ["preview"],
[CONTENT_TYPES.File]: ["download", "info", "rename", "move", "delete", "share"],
[CONTENT_TYPES.Directory]: ["download", "rename", "move", "delete"]
[CONTENT_TYPES.Directory]: ["download", "rename", "move", "delete", "share"]
}), [])

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,11 @@ const useStyles = makeStyles(
)

interface IShareFileProps {
file: FileSystemItem
fileSystemItems: FileSystemItem[]
close: () => void
filePath: string
}

const ShareModal = ({ close, file, filePath }: IShareFileProps) => {
const ShareModal = ({ close, fileSystemItems }: IShareFileProps) => {
const classes = useStyles()
const { handleCreateSharedFolder } = useCreateOrEditSharedFolder()
const [sharedFolderName, setSharedFolderName] = useState("")
Expand All @@ -194,7 +193,7 @@ const ShareModal = ({ close, file, filePath }: IShareFileProps) => {
const [keepOriginalFile, setKeepOriginalFile] = useState(true)
const [destinationBucket, setDestinationBucket] = useState<BucketKeyPermission | undefined>()
const { buckets, transferFileBetweenBuckets } = useFiles()
const { bucket } = useFileBrowser()
const { bucket, currentPath } = useFileBrowser()
const { profile } = useUser()
const [nameError, setNameError] = useState("")
const inSharedBucket = useMemo(() => bucket?.type === "share", [bucket])
Expand Down Expand Up @@ -284,21 +283,21 @@ const ShareModal = ({ close, file, filePath }: IShareFileProps) => {
return
}

transferFileBetweenBuckets(bucket.id, file, filePath, bucketToUpload, keepOriginalFile)
transferFileBetweenBuckets(bucket, fileSystemItems, currentPath, bucketToUpload, keepOriginalFile)
close()
}, [
bucket,
destinationBucket,
file,
filePath,
handleCreateSharedFolder,
isUsingCurrentBucket,
sharedFolderName,
sharedFolderReaders,
sharedFolderWriters,
keepOriginalFile,
close,
transferFileBetweenBuckets
transferFileBetweenBuckets,
currentPath,
fileSystemItems
])

return (
Expand Down Expand Up @@ -428,7 +427,7 @@ const ShareModal = ({ close, file, filePath }: IShareFileProps) => {
<CheckboxInput
value={keepOriginalFile}
onChange={() => setKeepOriginalFile(!keepOriginalFile)}
label={t`Keep original file`}
label={t`Keep original files`}
/>
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ const SharedFileBrowser = () => {
}, [addToast, uploadFiles, bucket, refreshContents])

const bulkOperations: IBulkOperations = useMemo(() => ({
[CONTENT_TYPES.Directory]: ["download", "move", "delete"],
[CONTENT_TYPES.Directory]: ["download", "move", "delete", "share"],
[CONTENT_TYPES.File]: ["download", "delete", "move", "share"]
}), [])

Expand All @@ -204,7 +204,7 @@ const SharedFileBrowser = () => {
[CONTENT_TYPES.Pdf]: ["preview"],
[CONTENT_TYPES.Text]: ["preview"],
[CONTENT_TYPES.File]: ["download", "info", "rename", "move", "delete", "share"],
[CONTENT_TYPES.Directory]: ["rename", "move", "delete"]
[CONTENT_TYPES.Directory]: ["rename", "move", "delete", "share"]
}
case "writer":
return {
Expand All @@ -214,7 +214,7 @@ const SharedFileBrowser = () => {
[CONTENT_TYPES.Pdf]: ["preview"],
[CONTENT_TYPES.Text]: ["preview"],
[CONTENT_TYPES.File]: ["download", "info", "rename", "move", "delete", "report", "share"],
[CONTENT_TYPES.Directory]: ["rename", "move", "delete"]
[CONTENT_TYPES.Directory]: ["rename", "move", "delete", "share"]
}
// case "reader":
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ interface IFileSystemItemProps {
browserView: BrowserView
reportFile?: (path: string) => void
showFileInfo?: (path: string) => void
share?: (path: string, fileIndex: number) => void
handleShare?: (file: FileSystemItemType) => void
showPreview?: (fileIndex: number) => void
}

Expand All @@ -145,7 +145,7 @@ const FileSystemItem = ({
resetSelectedFiles,
reportFile,
showFileInfo,
share,
handleShare,
showPreview
}: IFileSystemItemProps) => {
const { bucket, downloadFile, currentPath, handleUploadOnDrop, moveItems } = useFileBrowser()
Expand Down Expand Up @@ -247,7 +247,7 @@ const FileSystemItem = ({
</span>
</>
),
onClick: () => share && share(filePath, files?.indexOf(file))
onClick: () => handleShare && handleShare(file)
},
info: {
contents: (
Expand Down Expand Up @@ -316,9 +316,8 @@ const FileSystemItem = ({
currentPath,
downloadFile,
moveFile,
share,
handleShare,
filePath,
files,
showFileInfo,
recoverFile,
onFilePreview,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,12 @@ const FilesList = ({ isShared = false }: Props) => {
setIsDeleteModalOpen(true)
}, [])

const handleOpenShareDialog = useCallback((e: React.MouseEvent) => {
e.preventDefault()
e.stopPropagation()
setIsShareModalOpen(true)
}, [])

const mobileMenuItems = useMemo(() => [
{
contents: (
Expand All @@ -642,13 +648,12 @@ const FilesList = ({ isShared = false }: Props) => {
],
[classes.menuIcon])

const onShare = useCallback((fileInfoPath: string, fileIndex: number) => {
const onShare = useCallback((fileSystemItem: FileSystemItemType) => {
if(hasSeenSharingExplainerModal) {
setClickedShare(true)
}

setFilePath(fileInfoPath)
setFileIndex(fileIndex)
setSelectedItems([fileSystemItem])
setIsShareModalOpen(true)
}, [hasSeenSharingExplainerModal])

Expand Down Expand Up @@ -817,6 +822,15 @@ const FilesList = ({ isShared = false }: Props) => {
<Trans>Delete selected</Trans>
</Button>
)}
{validBulkOps.includes("share") && (
<Button
onClick={handleOpenShareDialog}
variant="outline"
testId="share-selected-file"
>
<Trans>Share selected</Trans>
</Button>
)}
</>
)}
</section>
Expand Down Expand Up @@ -954,7 +968,7 @@ const FilesList = ({ isShared = false }: Props) => {
setFileIndex(fileIndex)
setIsPreviewOpen(true)
}}
share={onShare}
handleShare={onShare}
/>
))}
</TableBody>
Expand Down Expand Up @@ -1007,7 +1021,7 @@ const FilesList = ({ isShared = false }: Props) => {
setFilePath(fileInfoPath)
setIsFileInfoModalOpen(true)
}}
share={onShare}
handleShare={onShare}
showPreview={(fileIndex: number) => {
setFileIndex(fileIndex)
setIsPreviewOpen(true)
Expand Down Expand Up @@ -1093,14 +1107,13 @@ const FilesList = ({ isShared = false }: Props) => {
}}
/>
}
{ !showExplainerBeforeShare && isShareModalOpen && filePath && fileIndex !== undefined &&
{ !showExplainerBeforeShare && isShareModalOpen && selectedItems.length &&
<ShareModal
file={files[fileIndex]}
close={() => {
setIsShareModalOpen(false)
setFilePath(undefined)
}}
filePath={currentPath}
fileSystemItems={selectedItems}
/>
}
<SharingExplainerModal
Expand Down
Loading