Skip to content

Commit ccd1012

Browse files
committed
chore: add type for ParameterStyling
1 parent bfd58e2 commit ccd1012

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

site/src/types/preview.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ export interface ParameterData {
3535
readonly type: ParameterType;
3636
// this is likely an enum in an external package "github.com/coder/terraform-provider-coder/v2/provider.ParameterFormType"
3737
readonly form_type: string;
38-
// empty interface{} type, falling back to unknown
39-
readonly styling: unknown;
38+
readonly styling: ParameterStyling;
4039
readonly mutable: boolean;
4140
readonly default_value: NullHCLString;
4241
readonly icon: string;
@@ -55,6 +54,13 @@ export interface ParameterOption {
5554
readonly icon: string;
5655
}
5756

57+
// From types/parameter.go
58+
export interface ParameterStyling {
59+
readonly placeholder?: string;
60+
readonly disabled?: boolean;
61+
readonly label?: string;
62+
}
63+
5864
// From types/enum.go
5965
export type ParameterType = "bool" | "list(string)" | "number" | "string";
6066

types/parameter.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ type ParameterData struct {
5050
Description string `json:"description"`
5151
Type ParameterType `json:"type"`
5252
FormType provider.ParameterFormType `json:"form_type"`
53-
Styling any `json:"styling"`
53+
Styling ParameterStyling `json:"styling"`
5454
Mutable bool `json:"mutable"`
5555
DefaultValue HCLString `json:"default_value"`
5656
Icon string `json:"icon"`
@@ -76,6 +76,12 @@ type ParameterValidation struct {
7676
Invalid *bool `json:"validation_invalid"`
7777
}
7878

79+
type ParameterStyling struct {
80+
Placeholder *string `json:"placeholder,omitempty"`
81+
Disabled *bool `json:"disabled,omitempty"`
82+
Label *string `json:"label,omitempty"`
83+
}
84+
7985
// Valid takes the type of the value and the value itself and returns an error
8086
// if the value is invalid.
8187
func (v ParameterValidation) Valid(typ string, value string) error {

0 commit comments

Comments
 (0)