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

Keyboard Actions composables in Search Results #9447

Merged
merged 3 commits into from
Jul 21, 2023

Conversation

jacob-nv
Copy link
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added
  • Documentation ticket raised:

@update-docs
Copy link

update-docs bot commented Jul 19, 2023

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.

@jacob-nv
Copy link
Contributor Author

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) => {
Copy link
Member

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?

Copy link
Contributor

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 🙂

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

@JammingBen JammingBen left a 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.

import { eventBus } from 'web-pkg'
import { useGettext } from 'vue3-gettext'

export const useKeyboardActionsSearchTable = (keyActions, paginatedResources) => {
Copy link
Contributor

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 🙂

Copy link
Member

@dschmidt dschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really nice 🎉

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug C 1 Bug
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

37.8% 37.8% Coverage
19.2% 19.2% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@jacob-nv jacob-nv requested review from dschmidt and JammingBen July 21, 2023 10:22
Copy link
Member

@dschmidt dschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏻

Copy link
Contributor

@JammingBen JammingBen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! 🚀

@JammingBen JammingBen merged commit f7e871a into owncloud:master Jul 21, 2023
AlexAndBear pushed a commit that referenced this pull request Aug 15, 2023
* Keyboard Actions composables in Search Results

* key params rewritten

* List removing duplication, KeyboardAction improving modifier readability
AlexAndBear pushed a commit that referenced this pull request Dec 13, 2023
* Keyboard Actions composables in Search Results

* key params rewritten

* List removing duplication, KeyboardAction improving modifier readability
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.

[web] Provide keyboard selection for search results
3 participants