Skip to content

Commit c85f7d2

Browse files
committed
Add new frontend for rendering parameters
1 parent bc6c788 commit c85f7d2

File tree

7 files changed

+458
-13
lines changed

7 files changed

+458
-13
lines changed

codersdk/templateversions.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ type TemplateVersionParameter struct {
3434
DefaultValue string `json:"default_value"`
3535
Icon string `json:"icon"`
3636
Options []TemplateVersionParameterOption `json:"options"`
37+
ValidationError string `json:"validation_error"`
3738
ValidationRegex string `json:"validation_regex"`
3839
ValidationMin int32 `json:"validation_min"`
3940
ValidationMax int32 `json:"validation_max"`

provisioner/terraform/testdata/parameters/parameters.tf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ terraform {
88
}
99

1010
data "coder_parameter" "example" {
11-
name = "Example"
12-
type = "string"
13-
option {
14-
name = "First Option"
15-
value = "first"
16-
}
17-
option {
18-
name = "Second Option"
19-
value = "second"
20-
}
11+
name = "Example"
12+
type = "string"
13+
option {
14+
name = "First Option"
15+
value = "first"
16+
}
17+
option {
18+
name = "Second Option"
19+
value = "second"
20+
}
2121
}
2222

2323
resource "coder_agent" "dev" {

site/src/api/typesGenerated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ export interface TemplateVersionParameter {
459459
readonly default_value: string
460460
readonly icon: string
461461
readonly options: TemplateVersionParameterOption[]
462+
readonly validation_error: string
462463
readonly validation_regex: string
463464
readonly validation_min: number
464465
readonly validation_max: number
Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
import { Story } from "@storybook/react"
2+
import { WorkspaceParameter, WorkspaceParameterProps } from "./WorkspaceParameter"
3+
4+
export default {
5+
title: "components/WorkspaceParameter",
6+
component: WorkspaceParameter,
7+
}
8+
9+
const Template: Story<WorkspaceParameterProps> = (args) => <WorkspaceParameter {...args} />
10+
11+
export const Region = Template.bind({})
12+
Region.args = {
13+
templateParameter: {
14+
name: "Region",
15+
default_value: "canada",
16+
description: "Select a location for your workspace to live.",
17+
icon: "/emojis/1f30e.png",
18+
mutable: false,
19+
options: [
20+
{
21+
name: "Toronto, Canada",
22+
description: "",
23+
icon: "/emojis/1f1e8-1f1e6.png",
24+
value: "canada",
25+
},
26+
{
27+
name: "Hamina, Finland",
28+
description: "",
29+
icon: "/emojis/1f1eb-1f1ee.png",
30+
value: "finland",
31+
},
32+
{
33+
name: "Warsaw, Poland",
34+
description: "",
35+
icon: "/emojis/1f1f5-1f1f1.png",
36+
value: "poland",
37+
},
38+
{
39+
name: "Madrid, Spain",
40+
description: "",
41+
icon: "/emojis/1f1ea-1f1f8.png",
42+
value: "spain",
43+
},
44+
{
45+
name: "London, England",
46+
description: "",
47+
icon: "/emojis/1f1ec-1f1e7.png",
48+
value: "england",
49+
},
50+
{
51+
name: "Dallas, Texas",
52+
description: "",
53+
icon: "/emojis/1f920.png",
54+
value: "texas",
55+
},
56+
],
57+
type: "string",
58+
validation_max: 0,
59+
validation_min: 0,
60+
validation_regex: "",
61+
validation_error: "",
62+
},
63+
workspaceBuildParameter: {
64+
name: "Region",
65+
value: "canada",
66+
},
67+
}
68+
69+
export const Repo = Template.bind({})
70+
Repo.args = {
71+
templateParameter: {
72+
name: "Repo",
73+
default_value: "coder",
74+
description: "Select a repository to work on. This will automatically be cloned.",
75+
icon: "/icon/github.svg",
76+
mutable: false,
77+
options: [
78+
{
79+
name: "coder/coder",
80+
description:
81+
"Remote development environments on your infrastructure provisioned with Terraform",
82+
icon: "",
83+
value: "https://github.com/coder/coder",
84+
},
85+
{
86+
name: "coder/v1",
87+
description: "The home for Coder v1!",
88+
icon: "",
89+
value: "https://github.com/coder/v1",
90+
},
91+
],
92+
type: "string",
93+
validation_max: 0,
94+
validation_min: 0,
95+
validation_regex: "",
96+
validation_error: "",
97+
},
98+
workspaceBuildParameter: {
99+
name: "Repo",
100+
value: "https://github.com/coder/coder",
101+
},
102+
}
103+
104+
export const Size = Template.bind({})
105+
Size.args = {
106+
templateParameter: {
107+
name: "Instance Size",
108+
default_value: "8",
109+
description: "",
110+
icon: "/emojis/1f916.png",
111+
mutable: true,
112+
options: [
113+
{
114+
name: "Small",
115+
description: "A tiny 4 core machine for small projects.",
116+
icon: "/emojis/1f90f.png",
117+
value: "4",
118+
},
119+
{
120+
name: "Medium",
121+
description: "A larger 8 core machine for heavy-ish workloads.",
122+
icon: "/emojis/1f44c.png",
123+
value: "8",
124+
},
125+
{
126+
name: "Large",
127+
description: "A beefy 16 core machine that can power most workloads.",
128+
icon: "/emojis/1f4aa.png",
129+
value: "16",
130+
},
131+
],
132+
type: "string",
133+
validation_max: 0,
134+
validation_min: 0,
135+
validation_regex: "",
136+
validation_error: "",
137+
},
138+
workspaceBuildParameter: {
139+
name: "Instance Size",
140+
value: "8",
141+
},
142+
}
143+
144+
export const Dotfiles = Template.bind({})
145+
Dotfiles.args = {
146+
templateParameter: {
147+
name: "Dotfiles URL",
148+
default_value: "https://github.com/ammario/dotfiles",
149+
description:
150+
"A Git URL that points to your personal dotfiles! These will be automatically cloned at start.",
151+
icon: "/emojis/1f3a8.png",
152+
mutable: true,
153+
type: "string",
154+
options: [],
155+
validation_max: 0,
156+
validation_min: 0,
157+
validation_regex: "((git|ssh|http(s)?)|(git@[w.]+))(:(//)?)([w.@:/-~]+)(/)?",
158+
validation_error: "Must be a valid Git URL!",
159+
},
160+
workspaceBuildParameter: {
161+
name: "Dotfiles URL",
162+
value: "",
163+
},
164+
}
165+
166+
export const DiskSize = Template.bind({})
167+
DiskSize.args = {
168+
templateParameter: {
169+
name: "Disk Size",
170+
default_value: "10",
171+
description: "The number of gigabytes for your persistent home volume.",
172+
icon: "",
173+
mutable: true,
174+
type: "number",
175+
options: [],
176+
validation_max: 200,
177+
validation_min: 10,
178+
validation_regex: "",
179+
validation_error: "Some GB",
180+
},
181+
workspaceBuildParameter: {
182+
name: "Dotfiles URL",
183+
value: "",
184+
},
185+
}

0 commit comments

Comments
 (0)