-
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
Provider views rewrite (.files, .folders => .partialTree) #5050
Merged
Merged
Changes from all commits
Commits
Show all changes
187 commits
Select commit
Hold shift + click to select a range
c4ba080
Merge branch 'main' of https://github.com/transloadit/uppy into main
lakesare 631abc6
Merge branch 'main' of https://github.com/transloadit/uppy
lakesare 75eae0a
Merge branch 'main' of https://github.com/transloadit/uppy into main
lakesare 462e61f
Merge branch 'main' of https://github.com/transloadit/uppy
lakesare 47df4a6
Merge branch 'main' of https://github.com/transloadit/uppy into main
lakesare df682a1
Merge branch 'main' of https://github.com/transloadit/uppy
lakesare ac3badf
Merge branch 'main' of https://github.com/transloadit/uppy into main
lakesare 76615a1
Merge branch 'main' of https://github.com/transloadit/uppy into main
lakesare b234045
ProviderView.tsx - fix onedrive breadcrumbs
lakesare 092a390
Merge branch 'lakesare/fix-breadcrumbs' into lakesare/provider-folders
lakesare 10cbbf7
providers - correct ch-unch-indeterminate states
lakesare 8796c35
providers - made .breadcrumbs derived from .partialTree
lakesare e2d0d04
everywhere - { files, folders, isChecked } => .partialTree
lakesare ab42ad6
GoogleDrive - made breadcrumbs work
lakesare 1ba90c7
.getFolder() - remove the `name` argument
lakesare ec532a2
<Breadcrumbs/> - refactors "/"
lakesare 51fc807
Instagram - made files get fetched onScroll
lakesare ba0b097
clearSelection() - recover the functionality
lakesare dc589c8
GoogleDrive - recover custom `.toggleCheckbox()` functionality
lakesare 55ef784
providers - recover `.isDisabled` functionality
lakesare 5f356a0
<SearchProviderView/> - made Unsplash use .partialTree
lakesare 74b01c5
Facebook - change `.files, .folders` => `.partialTree`
lakesare 101032c
everywhere - we don't need to ! `partialTreeFile.data` anymore
lakesare e12b26f
<ProviderView/> - implement folder caching
lakesare 4bc143f
<View/> - enable shift-clicking
lakesare f96f99f
everywhere - get rid of unnecessary `.getNextFolder()`
lakesare 296cae3
everywhere - fixing types
lakesare 7123684
<ProviderView/> - rename `requestPath` to `folderId`
lakesare a5dc9e5
all providers - get rid of `.onFirstRender()`
lakesare 60a9c1e
provider views - get rid of `.onFirstRender()`
lakesare 205bc45
<ProviderView/> - make the root folder cacheable too
lakesare 3cc111e
TEMP - setup for working with FOLDERS + LAZY_LOADING
lakesare ab58d89
<ProviderView/> - get rid of `.#listFilesAndFolders`
lakesare e9d5ee3
<ProviderView/> - make `this.nextPagePath` per-folder
lakesare 750a422
everywhere - more refined types
lakesare 5d6e92c
types - reintroduce `StatusInPartialTree`
lakesare f0b7f81
<SearchProviderView/> - made Unsplash work with the new structure
lakesare 992a913
<ProviderView/> - preemptive cleaning of `.absDirPath` and `.relDirPath`
lakesare e2ab113
<ProviderView/> - give `.nextPagePath` a rigorous type
lakesare 21b0677
<ProviderView/> - make `.nextPagePath` & `.cached` a composite key
lakesare 266fb1f
<ListItem/> - remove unnecessary indirection level
lakesare 9feeb86
css - factor out `.statusClassName`
lakesare 14b93b5
everywhere - refactor `.validateRestrictions()`
lakesare f021b51
nOfSelectedFiles - make "Selected (n)" as smart as possible
lakesare 196be22
<ProviderViews/> - prevent shift-clicking from highlighting file names
lakesare 4c1bef7
`.validateRestrictions()` - make it accept a `CompanionFile` instead …
lakesare fe1ac0d
`.getFolder()` - simplify code
lakesare fbbaa13
everywhere - account for `restrictions` in `.partialTree`
lakesare 095c900
`PartialTreeUtils.ts` - factor out `getPartialTreeAfterTogglingCheckb…
lakesare 9759e76
`PartialTreeUtils.ts` - factor out `clickOnFolder()`
lakesare 56e5284
`PartialTreeUtils.ts` - factor out `getPartialTreeAfterScroll()`
lakesare 3408c5f
`PartialTreeUtils.ts` - rename methods
lakesare 5200d3d
`.donePicking()` - implement using recursion
lakesare d183ce4
`.donePicking()` - integrate with `<ProviderView/>`
lakesare 0cdad8b
`donePicking()` - show notifications after addition
lakesare 216e05a
`#list()` - get rid of unnecessary indirection
lakesare 4c8c336
ProviderView.tsx - add `signal` everywhere, reduce try/catch indents …
lakesare c35cd4c
`handleError()` - make error handling uniform
lakesare fd69102
`state.isSearchVisible` - remove, it's just not used anywhere
lakesare 1bef2b4
state - reuse default state
lakesare dc339f4
state - reset state on close panel (like we discussed in the uppy call)
lakesare 37e9f33
methods - remove unnecessary indirection in state setting
lakesare 2c869d6
`<CloseWrapper/>` - remove CloseWrappers, this is unnecessary indirec…
lakesare 9550ec2
`this.requestClientId` - remove, again - this was unnecessary indirec…
lakesare c8f8066
`getTagFile()` - factor out into a separate file
lakesare 503242b
`recordShiftKeyPress()` - fix chaotic shift-clicking in Grid provider…
lakesare 88c393b
`getNOfSelectedFiles.ts`, `filterItems.ts` - factor out, this removes…
lakesare 8eff1df
<Browser/> - pass `displayedPartialTree` right away (because Search&N…
lakesare c09105a
`searchTerm`, `filterInput` - we only need one of these of course!
lakesare 1302640
<SearchProvider/> - fix the issue where `afterToggleCheckbox()` think…
lakesare 72eee03
<SearchProvider/> - remove `this.nextPageQuery`
lakesare 4dba9ab
<Browser/> - remove unnecessary prop indirection
lakesare 8829a12
<SearchFilterInput/> - make the form controlled, hugely simplifies ev…
lakesare 9b29db1
`filterItems.ts` - move to <ProviderView/>, because it's only used there
lakesare d493b32
/utils/PartialTreeUtils.ts - put every util in a separate file
lakesare d1f764c
`shouldHandleScroll.ts` - factor out into a util
lakesare 51584c1
this.state - make sure state is reset 1. on cancel 2. on close
lakesare decc4cb
`this.xxx` - never leave `this.xxx` variables undefined
lakesare 6db223e
`this.username` - should be in `this.state`
lakesare 03609f2
`SearchProviderPluginState` type - simplify this type, never leave st…
lakesare af66381
<Header/> - remove completely unnecessary indirection, remove unused …
lakesare 03e4cd8
Facebook.tsx - more sane `viewOptions` code
lakesare 2cdbc29
providers - properly type `opts`
lakesare c882dca
`this.isShiftKeyPressed` - move this variable into <Browser/>
lakesare dad1c81
`this.handleError()` - move to /utils
lakesare 13500cf
`this.isHandlingScroll` - move to child classes
lakesare 28df97d
`this.registerRequestClient()` - move to child classes
lakesare fb4fc8f
`this.lastCheckbox` - move to child classes
lakesare b8abc73
`this.setLoading()` - move to child classes
lakesare ddadff9
`this.validateRestrictions()` - move to utils
lakesare e29a662
types - fully simplify provider types, remove `View.ts` parent class
lakesare 1f9b2d2
index.d.ts - we're not using `OnFirstRenderer` anymore
lakesare 7e2ae6e
<ProviderView/>, <SearchProviderView/> - more precise typing for options
lakesare a195157
package.json - remove nanoid
lakesare 9379034
GoogleDrive - make shift-clicking work
lakesare 9f00d46
everywhere - fix types across uppy
lakesare 875ac0f
`afterToggleCheckbox.ts` - less redundant args, pass `ourItem.id` ins…
lakesare 2e569a1
tests - create `afterToggleCheckbox()` tests
lakesare 1e070ce
`getClickedRange.ts` - decouple `getClickedRange()` from `afterToggle…
lakesare f86dbeb
tests - wrote tests for `afterToggleCheckbox.ts`
lakesare 9db9b92
tests - wrote tests for `afterClickOnFolder.ts`
lakesare 11c7a30
everywhere - finally rename `getFolder` => `openFolder`
lakesare 3950933
tests - wrote tests for `afterScrollFolder.ts`
lakesare f6476e0
getPaths.ts - make `absDirPath`, `relDirPath` work like in docs & add…
lakesare 18ca4bb
injectPaths.ts - improve performance
lakesare 8b5f033
getTagFile.ts - handle path injection all in one place
lakesare 3663638
getTagFile.ts - refactor
lakesare c9ca3b0
fill.ts - `provider.list(currentPath, { signal })` => `apiList`
lakesare 6b74df0
tests - wrote tests for `fill.ts`
lakesare 834199e
tests - wrote tests for `getNOfSelectedFiles.ts`
lakesare 6dfbcd2
everywhere - change `JSON.stringify()` => `clone()`
lakesare 8e328fc
`PartialTreeUtils.ts` - more consistent function naming + alphabetica…
lakesare f505d5e
`donePicking()` - superseded a notification to i18n one
lakesare 925cdf9
GoogleDrive - make the shared drive checkable
lakesare ceb52ca
`Item.tsx` - standardize names; remove unnecessary question marks fro…
lakesare af35dbb
ProviderView.tsx - clicking "Cancel" should make all files "unchecked"
lakesare 524e189
everywhere - move `document.getSelection()?.removeAllRanges()` to <Br…
lakesare 7d5eee3
everywhere - standardize names and types of passed props
lakesare 041b743
<Browser/> - only leave "list of files" to the browser
lakesare cc4e77f
TEMP - easier pageSize for alex to play with
lakesare 80b16c4
everywhere - only handle individual-file restrictions
lakesare 49c75a6
everywhere - add aggregate restrictions on top
lakesare 21067a5
SearchProvider, NormalProvider - unite the way we addFiles()
lakesare 6ef9ede
`getTagFile.ts` - pass fewer arguments
lakesare b814da3
`addFiles.ts` - move conversion to tagFiles into `addFiles()`
lakesare 9a506f5
`uppy.validateRestrictions()` - remove legacy method
lakesare 1492e33
`uppy.validateAggregateRestrictions()` - make aggregate restricter re…
lakesare f58d6e5
<FooterActions/> css - make aggregate errors look nice
lakesare eb1951b
`PartialTreeUtils/index.test.ts` - accommodate tests to the latest ch…
lakesare 5dad68d
tests - make all uppy tests work
lakesare 649c062
Merge branch '4.x' into lakesare/provider-folders
lakesare 090376a
prettiness - run `yarn format`
lakesare 1579bba
prettiness - run `yarn lint:fix`
lakesare fd8afda
package.json - add `vitest` as a dev dependency
lakesare f62f40c
eslint - fixing 1
lakesare 14f1a11
<SearchFilterInput/> - add default props as per eslint
lakesare 1bc924b
<SearchFilterInput/> - rename to <SearchInput/>
lakesare 24b4c7f
eslint - fixing 4 (clone.ts)
lakesare d5c7820
Uppy.ts - rewrite `partialTree` docs
lakesare 2df3828
eslint - fixing 5
lakesare 1b97006
eslint - fixing 6
lakesare 8238989
`getBreadcrumbs.ts` - factor out
lakesare a583c8c
tests - fixing 7
lakesare 9d40ec2
everywhere - remove `.toReversed()`, because it's not yet supported i…
lakesare cce8ed2
dev/Dashboard.js - restore to pristine version
lakesare d26ff40
prettiness - run `yarn format`
lakesare e72c709
merge
lakesare ad8f966
fixing 8 (`yarn run build:ts`)
lakesare 1163198
fixing 9 (run `corepack yarn`)
lakesare e447cb7
prettier - undo indentation harm done by prettier
lakesare 0b6571b
`getBreadcrumbs()` - add tests, and rewrite to avoid using `.toRevers…
lakesare 947bba3
merge
lakesare 07ed69b
`<SearchInput/>` - make it work for eslint
lakesare bf0ed8d
everywhere - remove `eslint-disable react/require-default-props`
lakesare d358c9a
<GridItem/>, <ListItem/> - refactor to avoid prop drilling
lakesare 294a301
<ListItem/> - disable checkboxes for GoogleDrive team drives
lakesare a65dae3
merge (fixing up some lines from the previous merge)
lakesare 258c379
merge (fixing up some lines from the previous merge)
lakesare b54d12e
everywhere - remove TEMP development values
lakesare 464f614
`this.validateSingleFile()` - switch to `.restrictionError`
lakesare c94b893
`afterToggleCheckbox.ts` - refactor, add comments
lakesare ab6a13c
`afterToggleCheckbox.ts` - refactor to use ids instead of whole objects
lakesare 55af6d8
`afterToggleCheckbox.ts` - try to satisfy prettier
lakesare 657ef98
fixing 10 (try to satisfy `npx webpack`)
lakesare 4081f06
fixing 11 (try to satisfy `npx webpack`)
lakesare 452800b
Antoine: use Math.min & Math.max in `getClickedRange()`
lakesare 3651e0c
fixing 12 (run `yarn run format`)
lakesare 419e2e2
`clone.ts` - rename to `shallowClone.ts`
lakesare dae378c
Antoine: in `package.json`, move `devDependencies` up
lakesare 1181a46
Antoine: rename `getNOfSelectedFiles()` to `getNumberOfSelectedFiles()`
lakesare 495c92a
`getNumberOfSelectedFiles()` - better comments
lakesare b7e901f
Antoine: remove `<form/>` tag
lakesare 7dccd0e
Antoine: change `{}` to `Object.create(null)`, write tests
lakesare dea7e51
Antoine: `<SearchInput/>` - return dynamic <form/> element
lakesare 563435a
`<SearchInput/>` - return `buttonCSSClassName`
lakesare c68e440
merge
lakesare 6d4ce89
`GoogleDrive.tsx` - make team drive checkboxes visible
lakesare 545e443
merge (quite manual/with non-automatic updates)
lakesare f2de550
merge (more)
lakesare 21986c5
Mifi: update packages/@uppy/provider-views/src/ProviderView/ProviderV…
lakesare 034a603
Merge branch '4.x' into lakesare/provider-folders
lakesare afbc548
merge (more changes)
lakesare 126401c
Merge branch 'lakesare/provider-folders' of https://github.com/transl…
lakesare bb0b2b8
`Facebook.tsx`, `GooglePhotos.tsx` - render in 'grid' style on per-fo…
lakesare fc7c777
`<GridItem/>` - use the `.thumbnail` whenever possible (improves imag…
lakesare 8655bf5
`prettier` - ensure `PartialTree` is always strongly indented in tests
lakesare c073e5d
merge
lakesare 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
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
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
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
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
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 |
---|---|---|
@@ -1,18 +1,22 @@ | ||
import type { | ||
PartialTreeFile, | ||
PartialTreeFolderNode, | ||
} from '@uppy/core/lib/Uppy' | ||
import { ProviderViews } from '@uppy/provider-views' | ||
import type { CompanionFile } from '@uppy/utils/lib/CompanionFile' | ||
import type { Body, Meta } from '@uppy/utils/lib/UppyFile' | ||
|
||
export default class DriveProviderViews< | ||
M extends Meta, | ||
B extends Body, | ||
> extends ProviderViews<M, B> { | ||
toggleCheckbox(e: Event, file: CompanionFile): void { | ||
e.stopPropagation() | ||
e.preventDefault() | ||
|
||
// Shared Drives aren't selectable; for all else, defer to the base ProviderView. | ||
if (!file.custom!.isSharedDrive) { | ||
super.toggleCheckbox(e, file) | ||
toggleCheckbox( | ||
item: PartialTreeFolderNode | PartialTreeFile, | ||
isShiftKeyPressed: boolean, | ||
): void { | ||
// We don't allow to check team drives; but we leave the checkboxes visible to show the 'partial' state | ||
// (For a full explanation, see https://github.com/transloadit/uppy/issues/5232) | ||
if (!item.data.custom?.isSharedDrive) { | ||
super.toggleCheckbox(item, isShiftKeyPressed) | ||
} | ||
} | ||
} |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
maybe
id
,parentId
anddata
can be pulled out into a common type, e.g.PartialTreeBase
and thenPartialTreeFile
andPartialTreeFolderNode
canextend
from it? to reduce duplication and make it more clear which fields they have in commonThere 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.
I think having
PartialTreeBase
would add a level of indirection without making these types more readable/easier to work with.In general - I avoided having many types here, because I want people who work on these files to largely remember existing types by heart (that's just 4 types -
PartialTree
,~File
,~FolderNode
,~FolderRoot
).E.g., one really seductive type was
PartialTreeDisplayedNode = ~File | ~FolderNode
(because these are the only nodes that can be seen in the interface, meaning most functions expect~File | ~FolderNode
as an argument), but I decided against it to cut down on the number of types the developer would have to memorize.