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

Filetable rewrite hooks #342

Merged
merged 42 commits into from Jan 20, 2023
Merged

Filetable rewrite hooks #342

merged 42 commits into from Jan 20, 2023

Conversation

warpdesign
Copy link
Owner

@warpdesign warpdesign commented Dec 16, 2022

This PR rewrites the FileView/FileTable component using useVirtual hook with the following benefits:

  • butter smooth scrolling
  • a new useLayout hook has been added that will allow to switch display type on the fly
  • lots of integration tests have been added
  • file selection has been rewritten and works much better
  • inline rename now uses a proper React component instead of hacky contenteditable stuff
  • memfs virtual fs is used in Cypress too

This PR also adds the following hooks:

  • useLayout
  • useKeyDown
  • useAccelerator

Only drawback is that some end to end tests have been removed for now: I have no time to fix them and we'll be moving to Playwright soon anyway.

In order to prepare the use of different layouts for the main view (now FileView), these interfaces
have been renamed:

- File -> FileDescriptor (should have been done a long time ago since File it conflicts with built-in File node object)
- TableRow -> FileViewItem (more generic)
- FileTable -> FileView

Also, moved DraggedObject interface from RowRenderer to main types file.
A new useLayout hook has been added and returns the layout for the fileview contents.

Lots of code will be moved from FileView into this layout: this will not only reduce
the size of FileView but also allow to have different layouts (eg. IconView,...) for
the FileView :)

Lots of events are not implemented yet: this will need more work and a lot of testing
but should worth the pain ;)
- added react-virtual (more work needed: header,...) to replace react-virtualized
- cleaned-up selection (state only modified in fileState)
- files sorted on fileState object
- removed flickering on StatusBar + SideView when changing directory
Also: refactored sameID utility to receive id and not File as input.
Also removed stupid reactions/useEffect from SideView: we now use proper
observer() instead. This not only fixes missed updates when switching tabs
but should also speed up some updates.
Check that files are visually selected/not selected instead.
This will allow to remove lots of mocks Cypress tests.
Since lots of changes have been made, most tests were broken. This PR fixes
most of them and disable some that will be enabled once the new FileView
is ready.

This allows to fix some bugs:
- closing a tab would trigger an out of bound mobx read
- Overlay component would not get active after it has been activated once
- React-Virtual would render every items because its ref was incorrectly set
Also cleaned-up FileCache: scrollTop property should not be needed anymore.
Most cases should be handled now, including extending selection from top/bottom.
Also added new useAccelerator hook to handle accelerators.
Also added 'SHELL_OPEN_FAILED' to the list of known errors.
The placeholder is displayed when current folder is empty or an error ocurred.

Note: maybe this could be used into the parent FileView instead? I guess this shouldn't
change when changing layouts.
Also: do not move selection if an input has focus
Need to work on the preview element when multiple files are selected.
Note: need to select leftpart and rename file.
This allows us to not opt out of React lifecycle
Also removed react-virtualized package + cleanup unused files/code.
Also fixed useLayout so that ref is always defined (it wasn't defined in jest
unless the component was rerendered).
Prior to this change, clicking on the size column of a selected element
would enable inline edit. This would save current change if the file
was already being editing.
Also added missing test for contextMenu in FileView.
@warpdesign warpdesign merged commit 0d0a738 into master Jan 20, 2023
@warpdesign warpdesign deleted the filetable-rewrite-hooks branch January 20, 2023 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant