mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: rich parameters: introduce display_name (#6919)
* model * DB * fix: DisplayName * proto * Proto * Update go dep * fixme * fix format * config * fmt * fix * Fix * fix * chore(UI): redirecting from workspace page if 404 (#6880) * model * CLI: Display parameter * fix * update dep * fix * fix * fix * UI changes * fmt --------- Co-authored-by: Kira Pilot <kira@coder.com>
This commit is contained in:
co-authored by
Kira Pilot
parent
d9d44c1188
commit
633dfbdb2e
@@ -62,7 +62,12 @@ func ParameterSchema(inv *clibase.Invocation, parameterSchema codersdk.Parameter
|
||||
}
|
||||
|
||||
func RichParameter(inv *clibase.Invocation, templateVersionParameter codersdk.TemplateVersionParameter) (string, error) {
|
||||
_, _ = fmt.Fprintln(inv.Stdout, Styles.Bold.Render(templateVersionParameter.Name))
|
||||
label := templateVersionParameter.Name
|
||||
if templateVersionParameter.DisplayName != "" {
|
||||
label = templateVersionParameter.DisplayName
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprintln(inv.Stdout, Styles.Bold.Render(label))
|
||||
if templateVersionParameter.DescriptionPlaintext != "" {
|
||||
_, _ = fmt.Fprintln(inv.Stdout, " "+strings.TrimSpace(strings.Join(strings.Split(templateVersionParameter.DescriptionPlaintext, "\n"), "\n "))+"\n")
|
||||
}
|
||||
|
||||
+7
-2
@@ -366,6 +366,7 @@ func TestCreateWithRichParameters(t *testing.T) {
|
||||
firstParameterValue = "1"
|
||||
|
||||
secondParameterName = "second_parameter"
|
||||
secondParameterDisplayName = "Second Parameter"
|
||||
secondParameterDescription = "This is second parameter"
|
||||
secondParameterValue = "2"
|
||||
|
||||
@@ -382,7 +383,7 @@ func TestCreateWithRichParameters(t *testing.T) {
|
||||
Complete: &proto.Provision_Complete{
|
||||
Parameters: []*proto.RichParameter{
|
||||
{Name: firstParameterName, Description: firstParameterDescription, Mutable: true},
|
||||
{Name: secondParameterName, Description: secondParameterDescription, Mutable: true},
|
||||
{Name: secondParameterName, DisplayName: secondParameterDisplayName, Description: secondParameterDescription, Mutable: true},
|
||||
{Name: immutableParameterName, Description: immutableParameterDescription, Mutable: false},
|
||||
},
|
||||
},
|
||||
@@ -418,6 +419,7 @@ func TestCreateWithRichParameters(t *testing.T) {
|
||||
|
||||
matches := []string{
|
||||
firstParameterDescription, firstParameterValue,
|
||||
secondParameterDisplayName, "",
|
||||
secondParameterDescription, secondParameterValue,
|
||||
immutableParameterDescription, immutableParameterValue,
|
||||
"Confirm create?", "yes",
|
||||
@@ -426,7 +428,10 @@ func TestCreateWithRichParameters(t *testing.T) {
|
||||
match := matches[i]
|
||||
value := matches[i+1]
|
||||
pty.ExpectMatch(match)
|
||||
pty.WriteLine(value)
|
||||
|
||||
if value != "" {
|
||||
pty.WriteLine(value)
|
||||
}
|
||||
}
|
||||
<-doneChan
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user