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

Replace Text Fields with Dropdowns for Enum Parameters in API Sandbox UI #306

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

arian0zen
Copy link
Contributor

This PR introduces dropdowns and multi-selects in the Zudoku sandbox UI for parameters with constrained values, using the enum metadata from the OpenAPI spec. Instead of displaying text fields for these parameters, the updated UI now automatically populates dropdowns or multi-selects, streamlining the experience for users exploring the API.

This enhancement addresses issue ZUP-3767.

🎥 Watch the Demo

  • added a custom MultiSelect.tsx component ( as Radix react select does not support multi-select primitive in existing dropdown )

Copy link

vercel bot commented Oct 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
zudoku-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 30, 2024 9:30am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
zudoku-www ⬜️ Skipped (Inspect) Oct 30, 2024 9:30am

@vercel vercel bot temporarily deployed to Preview – zudoku-www October 28, 2024 20:11 Inactive
Copy link

vercel bot commented Oct 28, 2024

@arian0zen is attempting to deploy a commit to the Zuplo WWW Team on Vercel.

A member of the Team first needs to authorize it.

@vengroff
Copy link

Awesome. Thanks for making quick work of this issue.

@vercel vercel bot temporarily deployed to Preview – zudoku-www October 29, 2024 15:22 Inactive
@dan-lee
Copy link
Contributor

dan-lee commented Oct 30, 2024

Thanks for your contribution @arian0zen! Looks great so far 🙏 Can you provide the changes you made to the OpenAPI schema so we can test it?

(and sorry for the merging all the time, the CI doesn't work properly with forks yet)

@arian0zen
Copy link
Contributor Author

Thanks for your contribution @arian0zen! Looks great so far 🙏 Can you provide the changes you made to the OpenAPI schema so we can test it?

(and sorry for the merging all the time, the CI doesn't work properly with forks yet)

  • for testing you can :
    a. set a few enum for type string in query param schema (line 131)
    b. also you can set type array and set enum for its items (line 156-159)

openapi.json

🫱🏽‍🫲🏾 I am very much open to any suggestions, let me know if any changes are required!

Copy link
Contributor

@dan-lee dan-lee left a comment

Choose a reason for hiding this comment

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

Awesome work! Thanks for the deep dive into the code base and the changes you’re proposing!
Some things:

  • With the select fields now, when we select/change the values the table columns jump and change the layout. Can we avoid this?
  • The multi select is a tricky component that is hard to get exactly right, e.g., some things I noticed:
    • When selecting a value, the dialog closes. I think it should stay open
    • I can’t unselect the last item if there’s only one item selected
    • A selected item should not have a background color because you can’t see hovered/active item. The checkmark should suffice
  • Maybe we can get some inspiration from here: Multi select ? shadcn-ui/ui#66 (comment). E.g. this implementation: https://shadcnui-expansions.typeart.cc/docs/multiple-selector.

I don’t want to block this but I think if we add such a versatile component it should be solid :)
Because we want to expose the components to be used by Zudoku users (in Markdown, custom pages, etc.)

Comment on lines +124 to +130
<SelectTrigger
className="w-full flex"
placeholder="Choose an option"
value={field.value}
>
<SelectValue />
</SelectTrigger>
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's just use placeholder that SelectValue provides. Then we don't need to add this prop to SelectTrigger
So:

Suggested change
<SelectTrigger
className="w-full flex"
placeholder="Choose an option"
value={field.value}
>
<SelectValue />
</SelectTrigger>
<SelectTrigger
className="w-full flex"
value={field.value}
>
<SelectValue placeholder="Choose an option" />
</SelectTrigger>

))
) : (
<Fragment key={p.name}>
{p.name}={encodeURIComponent(p.value)}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should leave the replacement for %20 to + in.

@arian0zen
Copy link
Contributor Author

@dan-lee these are very solid suggestions. Working on it🙌

@vengroff
Copy link

Hi,

Thanks for putting this code together.

I just wanted to check back in on the status and when it might be mergable. We could really use this for some APIs we are working on.

Let me know if there is anything I can do to help.

Thanks!

@ntotten ntotten added the feature New feature or request label Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Development

Successfully merging this pull request may close these issues.

5 participants