Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[UI v2] feat: Introducing declarative useSet custom hook and replacing selected tags state for this hook #16143

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

devinvillarosa
Copy link
Contributor

@devinvillarosa devinvillarosa commented Nov 28, 2024

What does this PR do and why?

  1. Adds a custom hook useSet. This custom hook is a declarative way of keeping state for "selected" types. Most likely in the app we will need to keep state of selected IDs for a list. This hook can be used for convenience and uniqueness for the selected items in a declarative way.
  2. Adds an example test on how to test hooks only using renderHook. I haven't seen an example of this in the codebase yet
  3. Attempts to replace the imperative way of keeping track of selected tags from useState to useSet as en example.
    ⚠️ I haven't been able to run this locally, and cannot validate if this replacement works. I can revert this change if needed

Checklist

  • This pull request references any related issue by including "closes <link to issue>"
    • If no issue exists and your change is not a small fix, please create an issue first.
  • If this pull request adds new functionality, it includes unit tests that cover the changes
  • If this pull request removes docs files, it includes redirect settings in mint.json.
  • If this pull request adds functions or classes, it includes helpful docstrings.

Related to #15512

@devinvillarosa devinvillarosa added enhancement An improvement of an existing feature ui Related to the Prefect web interface labels Nov 28, 2024
@devinvillarosa devinvillarosa marked this pull request as ready for review November 28, 2024 01:30
Copy link
Member

@desertaxle desertaxle left a comment

Choose a reason for hiding this comment

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

Nice! This looks like it will be very useful!

I tested the TagsInput component via Storybook and it looks like it's working as expected.

ui-v2/src/hooks/use-set.test.ts Outdated Show resolved Hide resolved
@devinvillarosa devinvillarosa merged commit 4084c0d into main Nov 28, 2024
7 checks passed
@devinvillarosa devinvillarosa deleted the use-set-and-data-table branch November 28, 2024 20:03
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement An improvement of an existing feature ui Related to the Prefect web interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants