Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat:form_type andstyling metadata arguments added#375

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 35 commits intomainfromstevenmasley/form_control
Apr 8, 2025

Conversation

Emyrk
Copy link
Member

@EmyrkEmyrk commentedApr 3, 2025
edited
Loading

This PR is in support of dynamic parameters. Changes to coder/coder intends to support this experimentally by the end of April. For current versions of coder, these arguments will be ignored.

What is this?

This addsform_type as a field to parameters. By default, legacy behavior is maintained by deducing the defaultform_type value from the existing inputs.

Why do this?

To support more form type options in the UI. See the truth table here of all the new types:

// formTypeTruthTable is a map of [`type`][`optionCount` > 0] to `form_type`.
// The first value in the slice is the default value assuming `form_type` is
// not specified.
//
// The boolean key indicates whether the `options` field is specified.
// | Type | Options | Specified Form Type | form_type | Notes |
// |-------------------|---------|---------------------|----------------|--------------------------------|
// | `string` `number` | Y | | `radio` | |
// | `string` `number` | Y | `dropdown` | `dropdown` | |
// | `string` `number` | N | | `input` | |
// | `string` | N | 'textarea' | `textarea` | |
// | `number` | N | 'slider' | `slider` | min/max validation |
// | `bool` | Y | | `radio` | |
// | `bool` | N | | `checkbox` | |
// | `bool` | N | `switch` | `switch` | |
// | `list(string)` | Y | | `radio` | |
// | `list(string)` | N | | `tag-select` | |
// | `list(string)` | Y | `multi-select` | `multi-select` | Option values will be `string` |

Example new param

data"coder_parameter""tools" {name="Tools"description="What tools do you want to install?"type="list(string)"form_type="multi-select"styling=jsonencode({# Arbitrary JSON object to be passed to the frontend  })default=jsonencode(["git","docker"])option {value="Docker"name="docker"icon="/icon/docker.svg"  }option {value="Git"name="git"icon="/icon/git.svg"  }option {value="Golang"name="go"icon="/icon/go.svg"  }option {value="Typescript"name="ts"icon="/icon/typescript.svg"  }}

Note on docs

I am unable to add more example params to the docs, as they are used in integration tests that seem to use provider versions without this change? I get this error for above:

2025-04-07T18:26:57.1664097Z     examples_test.go:30: Step 1/1 error: Error running pre-apply refresh: exit status 12025-04-07T18:26:57.1664830Z         2025-04-07T18:26:57.1665915Z         Error: default value "[\"git\",\"docker\"]" is not a valid option, values "git, docker" are missing from the option2025-04-07T18:26:57.1666653Z         2025-04-07T18:26:57.1667135Z           with data.coder_parameter.tools,2025-04-07T18:26:57.1668078Z           on terraform_plugin_test.tf line 119, in data "coder_parameter" "tools":2025-04-07T18:26:57.1668889Z          119: data "coder_parameter" "tools" {

That error is the error you get using this param on theexisting terraform provider. Maybe I have to do some skips with past versions. Regardless, I will update the docs when this gets further upstream to a release.

@EmyrkEmyrk changed the titlefeat:form_type andform_type metadata arguments addedfeat:form_type andstyling metadata arguments addedApr 4, 2025
@EmyrkEmyrk marked this pull request as ready for reviewApril 7, 2025 15:59
@EmyrkEmyrk mentioned this pull requestApr 7, 2025
8 tasks
The example needs the release. So it's invalid until we push atag
@EmyrkEmyrk requested a review fromjohnstcnApril 7, 2025 19:17
Comment on lines 14 to 15
// The value have to be string literals, as type constraint keywords are not
// supported in providers. :'(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

For future readers wishing to understand the source of our woes, it might be good to add some relevant links to existing issues.

Emyrk reacted with thumbs up emoji
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I actually do not know what to link 🤔.

Comment on lines +37 to +38
// For example, "multi-select" has the type "list(string)" but the option
// values are "string".
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Might be good to explicitly document each type + option value for the possible values ofParameterFormType below.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'd rather defer that to the truth table below. I do not want to document it in 2 places.

Comment on lines +194 to +198
// TODO: We do this unmarshal in a few spots. It should be standardized.
err = json.Unmarshal([]byte(parameter.Default), &defaultValues)
if err != nil {
return diag.Errorf("default value %q is not a list of strings", parameter.Default)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good spot! 👍

@EmyrkEmyrk requested a review fromjohnstcnApril 8, 2025 13:38
@EmyrkEmyrk merged commit8804c44 intomainApr 8, 2025
1 check passed
@EmyrkEmyrk deleted the stevenmasley/form_control branchApril 8, 2025 18:04
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsApr 8, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

Assignees

@EmyrkEmyrk

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@Emyrk@johnstcn@aslilac

[8]ページ先頭

©2009-2025 Movatter.jp