-
Notifications
You must be signed in to change notification settings - Fork 156
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
Keyboard Actions composables in Search Results #9447
Conversation
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
Please let me know how do you feel about this approach. |
import { eventBus } from 'web-pkg' | ||
import { useGettext } from 'vue3-gettext' | ||
|
||
export const useKeyboardActionsSearchTable = (keyActions, paginatedResources) => { |
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.
Is this really SearchTable specific?
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.
I agree we should make this more general, something like useKeyboardActionsResourceTable
. Then we can use it for the regular files table as well and eventually kick the KeyboardActions.vue
component. But I'm fine with doing that in a second PR. Always a fan of keeping scopes of PRs fairly small 🙂
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.
So here's a thing. At this point, the goal is to provide a search table with actions in a new way.
Technically the search table is the same as a normal table, except you don't have defined space and have fewer actions you can perform.
This means we can later get rid of KeyboardAction.vue
, and split it into 2 composables or some abstraction that would combine paginatedResources
action only and space
related actions only.
Then it all depends on personal preference if you want to create a composable that would define each table or you want to define different combinations in the setup of component
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.
So here's a thing. At this point, the goal is to provide a search table with actions in a new way.
Yes 👍 The scope of this PR is fine as it is, I wouldn't change that. Let's get it merged first.
The next step after that IMO is to refactor KeyboardAction.vue
into a separate composable like this one (it would be something like useKeyboardActionsGenericSpaceTable
then) and use in in GenericSpace.vue
.
After that we can determine the exact differences between both composables and decide if we want to try to combine those two, or if we need to abstract some more logic.
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.
Awesome stuff, I really like it! Only a few ideas for improvement from my side.
packages/web-pkg/src/composables/keyboardActions/useKeyboardActions.ts
Outdated
Show resolved
Hide resolved
import { eventBus } from 'web-pkg' | ||
import { useGettext } from 'vue3-gettext' | ||
|
||
export const useKeyboardActionsSearchTable = (keyActions, paginatedResources) => { |
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.
I agree we should make this more general, something like useKeyboardActionsResourceTable
. Then we can use it for the regular files table as well and eventually kick the KeyboardActions.vue
component. But I'm fine with doing that in a second PR. Always a fan of keeping scopes of PRs fairly small 🙂
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.
really nice 🎉
packages/web-pkg/src/composables/keyboardActions/useKeyboardActions.ts
Outdated
Show resolved
Hide resolved
SonarCloud Quality Gate failed. 1 Bug 37.8% Coverage Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
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.
👏🏻
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.
Awesome! 🚀
* Keyboard Actions composables in Search Results * key params rewritten * List removing duplication, KeyboardAction improving modifier readability
* Keyboard Actions composables in Search Results * key params rewritten * List removing duplication, KeyboardAction improving modifier readability
Description
Core logic of keyboard actions moved to useKeyboardActions composable to web-pkg (this seems to make sense based on repo-structure.md).
Single Keyboard Actions mount to a single element, if no element is filled, it's bound to the document.
Provides 2 functions.
bindKeyAction which accepts the modifier key (based on ModifierKey enum), key (based on Key enum) and callback.
These actions are saved and called if the event matches the modifier and key. The function returns the index key of action.
removeKeyAction allows to remove binded action allowing for dynamic adding / removing key actions.
useKeyboardActionsSearchTable is composable utilizing instance of useKeyboardActions, allowing for contextually setting the desired keyActions specifcially for Search Table.
Related Issue
Motivation and Context
Keyboard Actions reusability and extensibility
Types of changes
Checklist: