-
Notifications
You must be signed in to change notification settings - Fork 875
feat: orgs IDP sync - add combobox to select claim field value when sync field is set #16335
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e5d88c8
feat: add dropdown to select claim field value when sync field is set
jaaydenh 47bf431
fix: update command styles
jaaydenh 0df2ddc
fix: replace dropdown with combobox
jaaydenh a11762e
chore: use shadcn table
jaaydenh e61b2dc
fix: set claim field when retrieving sync settings
jaaydenh 324f594
chore: extract combobox component
jaaydenh 1f1086d
chore: PR comments
jaaydenh 2d98f7e
fix: update test
jaaydenh cff6e01
fix: format
jaaydenh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import { Button } from "components/Button/Button"; | ||
import { | ||
Command, | ||
CommandEmpty, | ||
CommandGroup, | ||
CommandInput, | ||
CommandItem, | ||
CommandList, | ||
} from "components/Command/Command"; | ||
import { | ||
Popover, | ||
PopoverContent, | ||
PopoverTrigger, | ||
} from "components/Popover/Popover"; | ||
import { Check, ChevronDown, CornerDownLeft } from "lucide-react"; | ||
import type { FC, KeyboardEventHandler } from "react"; | ||
import { cn } from "utils/cn"; | ||
|
||
interface ComboboxProps { | ||
value: string; | ||
options?: string[]; | ||
placeholder?: string; | ||
open: boolean; | ||
onOpenChange: (open: boolean) => void; | ||
inputValue: string; | ||
onInputChange: (value: string) => void; | ||
onKeyDown?: KeyboardEventHandler<HTMLInputElement>; | ||
onSelect: (value: string) => void; | ||
} | ||
|
||
export const Combobox: FC<ComboboxProps> = ({ | ||
value, | ||
options = [], | ||
placeholder = "Select option", | ||
open, | ||
onOpenChange, | ||
inputValue, | ||
onInputChange, | ||
onKeyDown, | ||
onSelect, | ||
}) => { | ||
return ( | ||
<Popover open={open} onOpenChange={onOpenChange}> | ||
<PopoverTrigger asChild> | ||
<Button | ||
variant="outline" | ||
aria-expanded={open} | ||
className="w-72 justify-between group" | ||
> | ||
<span className={cn(!value && "text-content-secondary")}> | ||
{value || placeholder} | ||
</span> | ||
<ChevronDown className="size-icon-sm text-content-secondary group-hover:text-content-primary" /> | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverContent className="w-72"> | ||
<Command> | ||
<CommandInput | ||
placeholder="Search or enter custom value" | ||
value={inputValue} | ||
onValueChange={onInputChange} | ||
onKeyDown={onKeyDown} | ||
/> | ||
<CommandList> | ||
<CommandEmpty> | ||
<p>No results found</p> | ||
<span className="flex flex-row items-center justify-center gap-1"> | ||
Enter custom value | ||
<CornerDownLeft className="size-icon-sm bg-surface-tertiary rounded-sm p-1" /> | ||
</span> | ||
</CommandEmpty> | ||
<CommandGroup> | ||
{options.map((option) => ( | ||
<CommandItem | ||
key={option} | ||
value={option} | ||
onSelect={(currentValue) => { | ||
onSelect(currentValue === value ? "" : currentValue); | ||
}} | ||
> | ||
{option} | ||
{value === option && ( | ||
<Check className="size-icon-sm ml-auto" /> | ||
)} | ||
</CommandItem> | ||
))} | ||
</CommandGroup> | ||
</CommandList> | ||
</Command> | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
lot of duplication between this and the
ChevronDown
35 lines upThere 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.
Thats sort of the way of Tailwind, duplication of styles is ok to a certain extent. It would feel strange to create a separate component just because 2 icons have the same styles.
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.
doesn't need to be a component, it could be a string constant or something
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.
Extracting classNames into strings is a pattern that I would argue we don't want to go down. I follow the idealogy that it is sometimes ok to have repeated classNames until it makes sense to use some technique like creating a new component to manage the duplication. https://v3.tailwindcss.com/docs/reusing-styles