Skip to content

Commit 248bf11

Browse files
committed
chore: cleanup
1 parent e34ac90 commit 248bf11

File tree

2 files changed

+35
-22
lines changed

2 files changed

+35
-22
lines changed

site/src/DynamicForm.tsx

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ export function DynamicForm() {
297297
</div>
298298
)}
299299
/>
300+
{renderDiagnostics(param.diagnostics)}
300301
</div>
301302
)
302303
case "radio":
@@ -322,6 +323,7 @@ export function DynamicForm() {
322323
</div>
323324
)}
324325
/>
326+
{renderDiagnostics(param.diagnostics)}
325327
</div>
326328
)
327329
case "switch":
@@ -341,6 +343,7 @@ export function DynamicForm() {
341343
</div>
342344
)}
343345
/>
346+
{renderDiagnostics(param.diagnostics)}
344347
</div>
345348
)
346349
case "checkbox":
@@ -356,6 +359,7 @@ export function DynamicForm() {
356359
</div>
357360
)}
358361
/>
362+
{renderDiagnostics(param.diagnostics)}
359363
</div>
360364
)
361365
case "textarea":
@@ -375,34 +379,43 @@ export function DynamicForm() {
375379
</div>
376380
)}
377381
/>
382+
{renderDiagnostics(param.diagnostics)}
378383
</div>
379384
)
385+
case "input":
386+
return (
387+
<div key={param.name} className="flex flex-col gap-2 text-left">
388+
<ParamInfo param={param} />
389+
<Controller
390+
name={param.name}
391+
control={methods.control}
392+
render={({ field }) => (
393+
<Input
394+
onChange={(e) => {
395+
field.onChange(e);
396+
}}
397+
type={mapParamTypeToInputType(param.type)}
398+
defaultValue={parameterValue(param.default_value)}
399+
disabled={(param.form_type_metadata as { disabled?: boolean })?.disabled}
400+
/>
401+
)}
402+
/>
403+
{renderDiagnostics(param.diagnostics)}
404+
</div>
405+
)
406+
case "tag-select":
407+
return (
408+
<div key={param.name} className="flex flex-col gap-2 text-left">
409+
<ParamInfo param={param} />
410+
{param.form_type} Not implemented
411+
</div>
412+
)
380413
}
381414
}
382415

383-
const label = param.display_name || param.name;
384-
385416
return (
386417
<div key={param.name} className="flex flex-col gap-2 text-left">
387-
<label>
388-
{label}
389-
{param.icon && <img src={param.icon} alt="" style={{ marginLeft: 6 }} />}
390-
</label>
391-
{param.description && <div className="text-content-secondary text-sm text-left">{param.description}</div>}
392-
<Controller
393-
name={param.name}
394-
control={methods.control}
395-
render={({ field }) => (
396-
<Input
397-
onChange={(e) => {
398-
field.onChange(e);
399-
}}
400-
type={mapParamTypeToInputType(param.type)}
401-
defaultValue={parameterValue(param.default_value)}
402-
disabled={(param.form_type_metadata as { disabled?: boolean })?.disabled}
403-
/>
404-
)}
405-
/>
418+
<p style={{ color: "red" }}>form_type is required</p>
406419
{renderDiagnostics(param.diagnostics)}
407420
</div>
408421
);

testdata/formtypes/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,11 @@ data "coder_parameter" "list_string_options" {
164164
}
165165

166166
data "coder_parameter" "list_string_without_options" {
167-
// should be tag-select
168167
name = "list_string_without_options"
169168
display_name = "List(String)"
170169
description = "list(string) with options"
171170
type = "list(string)"
171+
form_type = "tag-select"
172172
order = 9
173173
icon = "/emojis/0031-fe0f-20e3.png"
174174
default = jsonencode(["purple", "blue", "green", "red", "orange"])

0 commit comments

Comments
 (0)