mirror of
https://github.com/go-gitea/gitea
synced 2025-11-02 04:18:25 +00:00
Extend issue template yaml engine (#29274)
Add new option:
`visible`: witch can hide a specific field of the form or the created
content afterwards
It is a string array witch can contain `form` and `content`. If only
`form` is present, it wont show up in the created issue afterwards and
the other way around. By default it sets both except for markdown
As they are optional and github don't have any similar thing, it is non
breaking and also do not conflict with it.
With this you can:
- define "post issue creation" elements like a TODO list to track an
issue state
- make sure to have a checkbox that reminds the user to check for a
thing but dont have it in the created issue afterwards
- define markdown for the created issue (was the downside of using yaml
instead of md in the past)
- ...
## Demo
```yaml
name: New Contribution
description: External Contributor creating a pull
body:
- type: checkboxes
id: extern-todo
visible: [form]
attributes:
label: Contribution Guidelines
options:
- label: I checked there exist no similar feature to be extended
required: true
- label: I did read the CONTRIBUTION.MD
required: true
- type: checkboxes
id: intern-todo
visible: [content]
attributes:
label: Maintainer Check-List
options:
- label: Does this pull follow the KISS principe
- label: Checked if internal bord was notifyed
# ....
```
[Demo
Video](https://cloud.obermui.de/s/tm34fSAbJp9qw9z/download/vid-20240220-152751.mkv)
---
*Sponsored by Kithara Software GmbH*
---------
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
This commit is contained in:
@@ -6,6 +6,7 @@ package structs
|
||||
import (
|
||||
"fmt"
|
||||
"path"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -141,12 +142,37 @@ const (
|
||||
// IssueFormField represents a form field
|
||||
// swagger:model
|
||||
type IssueFormField struct {
|
||||
Type IssueFormFieldType `json:"type" yaml:"type"`
|
||||
ID string `json:"id" yaml:"id"`
|
||||
Attributes map[string]any `json:"attributes" yaml:"attributes"`
|
||||
Validations map[string]any `json:"validations" yaml:"validations"`
|
||||
Type IssueFormFieldType `json:"type" yaml:"type"`
|
||||
ID string `json:"id" yaml:"id"`
|
||||
Attributes map[string]any `json:"attributes" yaml:"attributes"`
|
||||
Validations map[string]any `json:"validations" yaml:"validations"`
|
||||
Visible []IssueFormFieldVisible `json:"visible,omitempty"`
|
||||
}
|
||||
|
||||
func (iff IssueFormField) VisibleOnForm() bool {
|
||||
if len(iff.Visible) == 0 {
|
||||
return true
|
||||
}
|
||||
return slices.Contains(iff.Visible, IssueFormFieldVisibleForm)
|
||||
}
|
||||
|
||||
func (iff IssueFormField) VisibleInContent() bool {
|
||||
if len(iff.Visible) == 0 {
|
||||
// we have our markdown exception
|
||||
return iff.Type != IssueFormFieldTypeMarkdown
|
||||
}
|
||||
return slices.Contains(iff.Visible, IssueFormFieldVisibleContent)
|
||||
}
|
||||
|
||||
// IssueFormFieldVisible defines issue form field visible
|
||||
// swagger:model
|
||||
type IssueFormFieldVisible string
|
||||
|
||||
const (
|
||||
IssueFormFieldVisibleForm IssueFormFieldVisible = "form"
|
||||
IssueFormFieldVisibleContent IssueFormFieldVisible = "content"
|
||||
)
|
||||
|
||||
// IssueTemplate represents an issue template for a repository
|
||||
// swagger:model
|
||||
type IssueTemplate struct {
|
||||
|
||||
Reference in New Issue
Block a user