feat: support icon and description in preset (#18977)

## Description 

This PR adds support for `description` and `icon` fields to
`template_version_presets`. These fields will allow displaying richer
information for presets in the UI, improving the user experience when
creating a workspace.
Both fields are optional, non-nullable, and default to empty strings.

## Changes

* Database migration with the addition of `description VARCHAR(128)` and
`icon VARCHAR(256)` columns to the `template_version_presets` table.
* Updated the `CreateWorkspacePageView` in the UI

Note: UI changes will be addressed in a separate PR
This commit is contained in:
Susana Ferreira
2025-07-28 15:02:26 +01:00
committed by GitHub
parent 58123e17ca
commit 0672bf5084
24 changed files with 707 additions and 579 deletions
+8
View File
@@ -162,6 +162,8 @@ export interface Preset {
parameters: PresetParameter[];
prebuild: Prebuild | undefined;
default: boolean;
description: string;
icon: string;
}
export interface PresetParameter {
@@ -715,6 +717,12 @@ export const Preset = {
if (message.default === true) {
writer.uint32(32).bool(message.default);
}
if (message.description !== "") {
writer.uint32(42).string(message.description);
}
if (message.icon !== "") {
writer.uint32(50).string(message.icon);
}
return writer;
},
};
+2
View File
@@ -1998,6 +1998,8 @@ export interface Preset {
readonly Parameters: readonly PresetParameter[];
readonly Default: boolean;
readonly DesiredPrebuildInstances: number | null;
readonly Description: string;
readonly Icon: string;
}
// From codersdk/presets.go
@@ -126,6 +126,8 @@ export const PresetsButNoneSelected: Story = {
{
ID: "preset-1",
Name: "Preset 1",
Description: "",
Icon: "",
Default: false,
Parameters: [
{
@@ -138,6 +140,9 @@ export const PresetsButNoneSelected: Story = {
{
ID: "preset-2",
Name: "Preset 2",
Description:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse imperdiet ultricies massa, eu dapibus ex fermentum ac.",
Icon: "/emojis/1f60e.png",
Default: false,
Parameters: [
{
@@ -252,6 +257,8 @@ export const PresetsWithDefault: Story = {
{
ID: "preset-1",
Name: "Preset 1",
Icon: "",
Description: "",
Default: false,
Parameters: [
{
@@ -264,6 +271,9 @@ export const PresetsWithDefault: Story = {
{
ID: "preset-2",
Name: "Preset 2",
Icon: "/emojis/1f60e.png",
Description:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse imperdiet ultricies massa, eu dapibus ex fermentum ac.",
Default: true,
Parameters: [
{
+10
View File
@@ -4577,6 +4577,8 @@ export const MockPresets: TypesGen.Preset[] = [
{
ID: "preset-1",
Name: "Development",
Description: "",
Icon: "",
Parameters: [
{ Name: "cpu", Value: "4" },
{ Name: "memory", Value: "8GB" },
@@ -4587,6 +4589,8 @@ export const MockPresets: TypesGen.Preset[] = [
{
ID: "preset-2",
Name: "Testing",
Description: "",
Icon: "",
Parameters: [
{ Name: "cpu", Value: "2" },
{ Name: "memory", Value: "4GB" },
@@ -4597,6 +4601,8 @@ export const MockPresets: TypesGen.Preset[] = [
{
ID: "preset-3",
Name: "Production",
Description: "",
Icon: "",
Parameters: [
{ Name: "cpu", Value: "8" },
{ Name: "memory", Value: "16GB" },
@@ -4610,6 +4616,8 @@ export const MockAIPromptPresets: TypesGen.Preset[] = [
{
ID: "ai-preset-1",
Name: "Code Review",
Description: "",
Icon: "",
Parameters: [
{ Name: "AI Prompt", Value: "Review the code for best practices" },
{ Name: "cpu", Value: "4" },
@@ -4621,6 +4629,8 @@ export const MockAIPromptPresets: TypesGen.Preset[] = [
{
ID: "ai-preset-2",
Name: "Custom Prompt",
Description: "",
Icon: "",
Parameters: [
{ Name: "cpu", Value: "4" },
{ Name: "memory", Value: "8GB" },