-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Indicate that a file is uploading because user has chosen a folder #2605
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
58a5eef
provider-views: indicate a uploaded file is from a folder
chiefGui 5f41acb
Release
chiefGui cd60ac6
Remove unused import
chiefGui e07bbfd
Expose isFromFolder as a type
chiefGui 74d1c6b
Revert "Release"
chiefGui cab9f6f
Add documentation
chiefGui ac8b6d9
provider-views: add relativePath and isSelectedFromFolder
chiefGui ade9663
add gates to relativePath construction
chiefGui 30051dd
Revert "Add documentation"
chiefGui 10c4db1
Merge branch 'master' of https://github.com/transloadit/uppy
chiefGui d84a6b2
Remove redundant gate
chiefGui File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,11 +153,14 @@ module.exports = class ProviderView { | |
this.lastCheckbox = undefined | ||
} | ||
|
||
addFile (file) { | ||
addFile (file, meta) { | ||
const tagFile = { | ||
id: this.providerFileToId(file), | ||
source: this.plugin.id, | ||
data: file, | ||
data: { | ||
...file, | ||
path: file.requestPath | ||
}, | ||
name: file.name || file.id, | ||
type: file.mimeType, | ||
isRemote: true, | ||
|
@@ -171,7 +174,8 @@ module.exports = class ProviderView { | |
fileId: file.id | ||
}, | ||
providerOptions: this.provider.opts | ||
} | ||
}, | ||
...(Boolean(meta) && { meta }) | ||
} | ||
|
||
const fileType = getFileType(tagFile) | ||
|
@@ -321,10 +325,23 @@ module.exports = class ProviderView { | |
} | ||
folders[folderId] = { loading: true, files: [] } | ||
this.plugin.setPluginState({ selectedFolders: { ...folders } }) | ||
return this.listAllFiles(folder.requestPath).then((files) => { | ||
|
||
folder.relativePath = folder.relativePath || '' | ||
const filesRelativePath = `${folder.relativePath}/${folder.name}` | ||
|
||
return this.listAllFiles( | ||
folder.requestPath, | ||
null, | ||
{ previousRelativePath: folder.relativePath, currentFolder: folder } | ||
).then((files) => { | ||
let count = 0 | ||
files.forEach((file) => { | ||
const success = this.addFile(file) | ||
const success = this.addFile(file, { | ||
relativePath: filesRelativePath, | ||
// Indicates that this file was selected through | ||
// folder selection. | ||
isSelectedFromFolder: true | ||
}) | ||
if (success) count++ | ||
}) | ||
const ids = files.map(this.providerFileToId) | ||
|
@@ -430,11 +447,23 @@ module.exports = class ProviderView { | |
} | ||
} | ||
|
||
listAllFiles (path, files = null) { | ||
listAllFiles (path, files = null, meta = undefined) { | ||
files = files || [] | ||
return new Promise((resolve, reject) => { | ||
this.provider.list(path).then((res) => { | ||
let itemsRelativePath | ||
|
||
if (meta) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My idea on having this condition here is that if there's a meta, then there's a |
||
const { previousRelativePath, currentFolder } = meta | ||
|
||
itemsRelativePath = `${previousRelativePath}/${currentFolder.name}` | ||
} | ||
|
||
res.items.forEach((item) => { | ||
if (itemsRelativePath) { | ||
item.relativePath = itemsRelativePath | ||
} | ||
|
||
if (!item.isFolder) { | ||
files.push(item) | ||
} else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
res
is where we'd needcurrentFolderName
. Currently, ifmoreFiles === true
, this implementation won't reproduce the correct parent's folder names for Google Drive and OneDrive since their IDs are unique, hashed strings instead of folder names (IMHO, Dropbox took the cleverest approach here).FWIW, the
relativePath
in thedata
object is giving/{fileId}
; and this is the reason that the above statement is relevant.Read more at #2605 (comment).