Skip to content

Add filetable context menu#301

Merged
warpdesign merged 14 commits into
masterfrom
add-filetable-context-menu
Nov 18, 2022
Merged

Add filetable context menu#301
warpdesign merged 14 commits into
masterfrom
add-filetable-context-menu

Conversation

@warpdesign
Copy link
Copy Markdown
Owner

@warpdesign warpdesign commented Nov 18, 2022

This PR adds a new context menu on FileTable:

Capture d’écran 2022-11-18 à 12 29 02

The menu is always displayed but each item is disabled if not possible (for example paste is disabled if there are no items in the clipboard).

Rules:

Copy

Enabled if

  • file/dir under cursor

files to be copied

  • mouse under selection: selection
  • mouse under non selected file: file

Paste

Enabled if clipboard not empty and:

  • mouse over file && file.isDir
    or
  • mouse over empty area

Delete

Enabled if

  • mouse is over at least one element

Files to be deleted:

  • mouse over a selected element: the whole selection
  • mouse is not over a selected element: the hovered element

Lots of refactoring was done:

  • clipboard related state has been moved to a new ClipboardState that's accessible by using appState.clipboard
  • delete function has been moved into appState and can be accessed by calling appState.delete

Fixes #235

Still needs to do:
- disable menus on some conditions
- run actions
- would be nice to have: highlight menu target (like in the finder)

Note that we use the depreciated Menu from blueprint since Menu2
only has a declarative version.

Also, we have to pass the appState to the component but that's not
a good idea.
Added detection of ability to copy/paste: we had to add
a new state to FileTable: rightClickFile which keeps track
of the file that's under the mouse when a right click happens.

The FileContextMenu now has access to MobX stores and is only
rendered when the context menu is opened.

Still need to do:
- check when delete should be enabled
- implement copy/paste/delete

Streched goal:
- add a new outline that indicates which elements the action will act on
- update copy paste menu+context menu to include the number of elements (ie: "Paste 4 elements")
Also made appState.setClipboard to accept a list of files: will be used
when hovering a non selected file & clicking on the copy menu.
Todo: also move alerts displayed after copying data to the clipboard
into the clipboard state.
Tests was referencing un-used appState.caches property which was removed.
Also: moved copied to clipboard toast to Clipboard.setClipboard
The paste function was moved to the appState object because most file/batch
related functions are stored in this object. Maybe we should move this
elsewhere ? There is also a Batch state (which is defined in its own transfers dir ?!)...

We should do some cleanup here!
Still need to do:
- fix showDeleteConfirmDialog: Trans doesn't use the selected language, it sticks to English :/
- cleanup Toolbar.tsx: call appState.delete and remove unused code
Also added a check in appState.delete to return if there are no elements to delete:
we wouldn't want to show a useless dialog in this case.
@warpdesign warpdesign merged commit 934e252 into master Nov 18, 2022
@warpdesign warpdesign deleted the add-filetable-context-menu branch November 18, 2022 14:12
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.

No context menu on Linux!

1 participant