Skip to content

chore: improve the design of the create workspace page for dynamic parameters #17654

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 3 commits into from
May 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions site/src/components/Badge/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ const badgeVariants = cva(
sm: "text-2xs font-regular h-5.5 [&_svg]:size-icon-xs",
md: "text-xs font-medium [&_svg]:size-icon-sm",
},
border: {
none: "border-transparent",
solid: "border border-solid",
},
},
defaultVariants: {
variant: "default",
size: "md",
border: "solid",
},
},
);
Expand All @@ -41,14 +46,14 @@ export interface BadgeProps
}

export const Badge = forwardRef<HTMLDivElement, BadgeProps>(
({ className, variant, size, asChild = false, ...props }, ref) => {
({ className, variant, size, border, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "div";

return (
<Comp
{...props}
ref={ref}
className={cn(badgeVariants({ variant, size }), className)}
className={cn(badgeVariants({ variant, size, border }), className)}
/>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const ParameterLabel: FC<ParameterLabelProps> = ({ parameter, isPreset }) => {
<Tooltip>
<TooltipTrigger asChild>
<span className="flex items-center">
<Badge size="sm" variant="warning">
<Badge size="sm" variant="warning" border="none">
<TriangleAlert />
Immutable
</Badge>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ import { ErrorAlert } from "components/Alert/ErrorAlert";
import { Avatar } from "components/Avatar/Avatar";
import { Button } from "components/Button/Button";
import { FeatureStageBadge } from "components/FeatureStageBadge/FeatureStageBadge";
import { SelectFilter } from "components/Filter/SelectFilter";
import { Input } from "components/Input/Input";
import { Label } from "components/Label/Label";
import { Pill } from "components/Pill/Pill";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "components/Select/Select";
import { Spinner } from "components/Spinner/Spinner";
import { Stack } from "components/Stack/Stack";
import { Switch } from "components/Switch/Switch";
import { UserAutocomplete } from "components/UserAutocomplete/UserAutocomplete";
import { type FormikContextType, useFormik } from "formik";
Expand Down Expand Up @@ -153,11 +158,11 @@ export const CreateWorkspacePageViewExperimental: FC<
}, [form.submitCount, form.errors]);

const [presetOptions, setPresetOptions] = useState([
{ label: "None", value: "" },
{ label: "None", value: "None" },
]);
useEffect(() => {
setPresetOptions([
{ label: "None", value: "" },
{ label: "None", value: "None" },
...presets.map((preset) => ({
label: preset.Name,
value: preset.ID,
Expand Down Expand Up @@ -421,38 +426,47 @@ export const CreateWorkspacePageViewExperimental: FC<
)}

{parameters.length > 0 && (
<section className="flex flex-col gap-6">
<section className="flex flex-col gap-9">
<hgroup>
<h2 className="text-xl font-semibold m-0">Parameters</h2>
<p className="text-sm text-content-secondary m-0">
These are the settings used by your template. Immutable
parameters cannot be modified once the workspace is created.
</p>
</hgroup>
<Diagnostics diagnostics={diagnostics} />
{diagnostics.length > 0 && (
<Diagnostics diagnostics={diagnostics} />
)}
{presets.length > 0 && (
<Stack direction="column" spacing={2}>
<div className="flex flex-col gap-2">
<div className="flex gap-2 items-center">
<Label className="text-sm">Preset</Label>
<FeatureStageBadge contentType={"beta"} size="md" />
</div>
<div className="flex">
<SelectFilter
label="Preset"
options={presetOptions}
onSelect={(option) => {
<div className="flex flex-col gap-2">
<div className="flex gap-2 items-center">
<Label className="text-sm">Preset</Label>
<FeatureStageBadge contentType={"beta"} size="md" />
</div>
<div className="flex flex-col gap-4">
<div className="max-w-lg">
<Select
onValueChange={(option) => {
const index = presetOptions.findIndex(
(preset) => preset.value === option?.value,
(preset) => preset.value === option,
);
if (index === -1) {
return;
}
setSelectedPresetIndex(index);
}}
placeholder="Select a preset"
selectedOption={presetOptions[selectedPresetIndex]}
/>
>
<SelectTrigger>
<SelectValue placeholder={"Select a preset"} />
</SelectTrigger>
<SelectContent>
{presetOptions.map((option) => (
<SelectItem key={option.value} value={option.value}>
{option.label}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
<span className="flex items-center gap-3">
<Switch
Expand All @@ -465,7 +479,7 @@ export const CreateWorkspacePageViewExperimental: FC<
</Label>
</span>
</div>
</Stack>
</div>
)}

<div className="flex flex-col gap-9">
Expand Down
Loading