Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow issue templates to not render title #22589

Merged
merged 3 commits into from
Jan 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion modules/issue/template/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ func (f *valuedField) WriteTo(builder *strings.Builder) {
}

// write label
_, _ = fmt.Fprintf(builder, "### %s\n\n", f.Label())
if !f.HideLabel() {
_, _ = fmt.Fprintf(builder, "### %s\n\n", f.Label())
}

blankPlaceholder := "_No response_\n"

Expand Down Expand Up @@ -311,6 +313,13 @@ func (f *valuedField) Label() string {
return ""
}

func (f *valuedField) HideLabel() bool {
if label, ok := f.Attributes["hide_label"].(bool); ok {
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I'm not quite sure if we should use snake case.
Also, shouldn't it be hide_title?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was thinking the same with the name of the attr, but I went with hide_label to keep the name consistent throughout.

As for snakecase, the yaml marshal will make the map like this, and is consistent with other yaml parsing.

return label
}
return false
}

func (f *valuedField) Render() string {
if render, ok := f.Attributes["render"].(string); ok {
return render
Expand Down
3 changes: 1 addition & 2 deletions modules/issue/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ body:
description: Description of input
placeholder: Placeholder of input
value: Value of input
hide_label: true
Copy link
Member

Choose a reason for hiding this comment

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

Just as a question: Wouldn't omitting the label five lines above produce the same result?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but in this situation you want to display the label on the form just not the output.

validations:
required: true
is_number: true
Expand Down Expand Up @@ -681,8 +682,6 @@ body:

` + "```bash\nValue of id2\n```" + `

### Label of input

Value of id3

### Label of dropdown
Expand Down