- Notifications
You must be signed in to change notification settings - Fork1k
feat(site): support icon and description in preset#19063
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from5 commits
8fea22d
e1e3d37
9b5e5b7
8a1aa2c
477ce03
3256320
b3e8854
f95e375
d895d42
da8bab8
c4444ec
a46a698
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -103,7 +103,8 @@ export const SearchAndFilter: Story = { | ||
screen.queryByRole("option", { name: "Kotlin" }), | ||
).not.toBeInTheDocument(); | ||
}); | ||
// Accessible name includes both image alt text and text content: "Rust Rust" | ||
await userEvent.click(screen.getByRole("option", { name: "Rust Rust" })); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Since we changed the icon image to be an ExternalImage with Member
| ||
}, | ||
}; | ||
@@ -137,9 +138,11 @@ export const ClearSelectedOption: Story = { | ||
await userEvent.click(canvas.getByRole("button")); | ||
// const goOption = screen.getByText("Go"); | ||
// First select an option | ||
// Accessible name includes both image alt text and text content: "Go Go" | ||
await userEvent.click(await screen.findByRole("option", { name: "Go Go" })); | ||
// Then clear it by selecting it again | ||
// Accessible name includes both image alt text and text content: "Go Go" | ||
await userEvent.click(await screen.findByRole("option", { name: "Go Go" })); | ||
await waitFor(() => | ||
expect(canvas.getByRole("button")).toHaveTextContent("Select option"), | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { Button } from "components/Button/Button"; | ||
import { | ||
Command, | ||
@@ -23,6 +22,7 @@ import { Check, ChevronDown, CornerDownLeft } from "lucide-react"; | ||
import { Info } from "lucide-react"; | ||
import { type FC, type KeyboardEventHandler, useState } from "react"; | ||
import { cn } from "utils/cn"; | ||
import { ExternalImage } from "../ExternalImage/ExternalImage"; | ||
interface ComboboxProps { | ||
value: string; | ||
@@ -118,13 +118,16 @@ export const Combobox: FC<ComboboxProps> = ({ | ||
onSelect(currentValue === value ? "" : currentValue); | ||
}} | ||
> | ||
{showIcons && | ||
(option.icon ? ( | ||
<ExternalImage | ||
className="w-4 h-4 object-contain" | ||
src={option.icon} | ||
alt={option.displayName} | ||
/> | ||
) : ( | ||
<span className="w-4 h-4"> </span> | ||
bpmct marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
))} | ||
{option.displayName} | ||
<div className="flex flex-row items-center ml-auto gap-1"> | ||
{value === option.value && ( | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -6,7 +6,6 @@ import { Alert } from "components/Alert/Alert"; | ||
import { ErrorAlert } from "components/Alert/ErrorAlert"; | ||
import { Avatar } from "components/Avatar/Avatar"; | ||
import { Button } from "components/Button/Button"; | ||
import { | ||
FormFields, | ||
FormFooter, | ||
@@ -44,6 +43,7 @@ import { | ||
useValidationSchemaForRichParameters, | ||
} from "utils/richParameters"; | ||
import * as Yup from "yup"; | ||
import { Combobox } from "../../components/Combobox/Combobox"; | ||
bpmct marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
import type { CreateWorkspaceMode } from "./CreateWorkspacePage"; | ||
import { ExternalAuthButton } from "./ExternalAuthButton"; | ||
import type { CreateWorkspacePermissions } from "./permissions"; | ||
@@ -158,16 +158,18 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({ | ||
); | ||
const [presetOptions, setPresetOptions] = useState([ | ||
{displayName: "None", value: "", icon: "", description: "" }, | ||
]); | ||
const [selectedPresetIndex, setSelectedPresetIndex] = useState(0); | ||
// Build options and keep default label/value in sync | ||
useEffect(() => { | ||
const options = [ | ||
{ displayName: "None", value: "", icon: "", description: "" }, | ||
...presets.map((preset) => ({ | ||
displayName: preset.Default ? `${preset.Name} (Default)` : preset.Name, | ||
value: preset.ID, | ||
icon: preset.Icon, | ||
description: preset.Description, | ||
})), | ||
]; | ||
setPresetOptions(options); | ||
@@ -392,12 +394,15 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({ | ||
</Stack> | ||
<Stack direction="column" spacing={2}> | ||
<Stack direction="row" spacing={2}> | ||
<Combobox | ||
value={ | ||
presetOptions[selectedPresetIndex]?.displayName || "" | ||
} | ||
options={presetOptions} | ||
placeholder="Select a preset" | ||
onSelect={(value) => { | ||
const index = presetOptions.findIndex( | ||
(preset) => preset.value === value, | ||
); | ||
if (index === -1) { | ||
return; | ||
@@ -406,11 +411,11 @@ export const CreateWorkspacePageView: FC<CreateWorkspacePageViewProps> = ({ | ||
form.setFieldValue( | ||
"template_version_preset_id", | ||
// Empty string is equivalent to using None | ||
presetOptions[index].value === "" | ||
? undefined | ||
: presetOptions[index].value, | ||
); | ||
}} | ||
/> | ||
</Stack> | ||
{/* Only show the preset parameter visibility toggle if preset parameters are actually being modified, otherwise it has no effect. */} | ||
Uh oh!
There was an error while loading.Please reload this page.