Skip to content

Commit

Permalink
Merge dev to epic/link sharing (#1633)
Browse files Browse the repository at this point in the history
* update tests for unsupported preview

* Transfer multiple files and folders (#1606)

* initial restructure

* folder transfers

* sharing working as expected

* sharing is ready

* toasts and error handling

* error messages

* transfer progress ready

* lingui extract

* Update packages/files-ui/src/Contexts/FilesContext.tsx

Co-authored-by: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com>

* using  reduce and handling each file share error

* updated terms

* lingui extract

* added no files check

* lingui extract

* share  messages

* lingui extract

* lint

Co-authored-by: GitHub Actions <actions@github.com>
Co-authored-by: Michael Yankelev <12774278+FSM1@users.noreply.github.com>
Co-authored-by: Thibaut Sardan <33178835+Tbaut@users.noreply.github.com>

* Translations update from Weblate (#1625)

* Translated using Weblate (French)

Currently translated at 100.0% (282 of 282 strings)

Translation: ChainSafe Files/Chainsafe Files user interface
Translate-URL: https://hosted.weblate.org/projects/chainsafe-files/chainsafe-files-user-interface/fr/

* Translated using Weblate (French)

Currently translated at 100.0% (294 of 294 strings)

Translation: ChainSafe Files/Chainsafe Files user interface
Translate-URL: https://hosted.weblate.org/projects/chainsafe-files/chainsafe-files-user-interface/fr/

Co-authored-by: J. Lavoie <j.lavoie@net-c.ca>

* bump cypress to v8.6 (#1628)

* bump cypress to v8.6

* lingui extract

* Update test

Co-authored-by: GitHub Actions <actions@github.com>

* trans

Co-authored-by: Michael Yankelev <myankelev@gmail.com>
Co-authored-by: Tanmoy Basak Anjan <tanmoy3399@gmail.com>
Co-authored-by: GitHub Actions <actions@github.com>
Co-authored-by: Michael Yankelev <12774278+FSM1@users.noreply.github.com>
Co-authored-by: Weblate (bot) <noreply@weblate.org>
Co-authored-by: J. Lavoie <j.lavoie@net-c.ca>
Co-authored-by: Andrew Snaith <asnaith@users.noreply.github.com>
  • Loading branch information
8 people authored Oct 18, 2021
1 parent 64bae53 commit a7debcb
Show file tree
Hide file tree
Showing 16 changed files with 329 additions and 199 deletions.
1 change: 0 additions & 1 deletion packages/files-ui/cypress/tests/file-preview-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ describe("File Preview", () => {
homePage.fileItemName().dblclick()
previewModal.unsupportedFileLabel().should("exist")
previewModal.downloadUnsupportedFileButton().should("be.visible")

// ensure the download request contains the correct file
cy.get("@downloadRequest").its("request.body").should("contain", {
path: "/file.zip"
Expand Down
2 changes: 1 addition & 1 deletion packages/files-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"@types/yup": "^0.29.9",
"@types/zxcvbn": "^4.4.0",
"babel-plugin-macros": "^2.8.0",
"cypress": "^8.5",
"cypress": "^8.6",
"cypress-file-upload": "^5.0.8",
"cypress-pipe": "^2.0.0"
},
Expand Down
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 @@ -427,7 +426,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

0 comments on commit a7debcb

Please sign in to comment.