Merge pull request '[gitea] week 2024-30 cherry pick (gitea/main -> forgejo)' (#4607) from algernon/wcp/2024-30 into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/4607 Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
This commit is contained in:
commit
ded237ee77
31 changed files with 544 additions and 66 deletions
|
@ -88,6 +88,9 @@ func validateYaml(template *api.IssueTemplate) error {
|
|||
if err := validateBoolItem(position, field.Attributes, "multiple"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateBoolItem(position, field.Attributes, "list"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateOptions(field, idx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -340,7 +343,13 @@ func (f *valuedField) WriteTo(builder *strings.Builder) {
|
|||
}
|
||||
}
|
||||
if len(checkeds) > 0 {
|
||||
_, _ = fmt.Fprintf(builder, "%s\n", strings.Join(checkeds, ", "))
|
||||
if list, ok := f.Attributes["list"].(bool); ok && list {
|
||||
for _, check := range checkeds {
|
||||
_, _ = fmt.Fprintf(builder, "- %s\n", check)
|
||||
}
|
||||
} else {
|
||||
_, _ = fmt.Fprintf(builder, "%s\n", strings.Join(checkeds, ", "))
|
||||
}
|
||||
} else {
|
||||
_, _ = fmt.Fprint(builder, blankPlaceholder)
|
||||
}
|
||||
|
|
|
@ -216,6 +216,20 @@ body:
|
|||
`,
|
||||
wantErr: "body[0](dropdown): 'multiple' should be a bool",
|
||||
},
|
||||
{
|
||||
name: "dropdown invalid list",
|
||||
content: `
|
||||
name: "test"
|
||||
about: "this is about"
|
||||
body:
|
||||
- type: "dropdown"
|
||||
id: "1"
|
||||
attributes:
|
||||
label: "a"
|
||||
list: "on"
|
||||
`,
|
||||
wantErr: "body[0](dropdown): 'list' should be a bool",
|
||||
},
|
||||
{
|
||||
name: "checkboxes invalid description",
|
||||
content: `
|
||||
|
@ -807,7 +821,7 @@ body:
|
|||
- type: dropdown
|
||||
id: id5
|
||||
attributes:
|
||||
label: Label of dropdown
|
||||
label: Label of dropdown (one line)
|
||||
description: Description of dropdown
|
||||
multiple: true
|
||||
options:
|
||||
|
@ -816,8 +830,21 @@ body:
|
|||
- Option 3 of dropdown
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
- type: dropdown
|
||||
id: id6
|
||||
attributes:
|
||||
label: Label of dropdown (list)
|
||||
description: Description of dropdown
|
||||
multiple: true
|
||||
list: true
|
||||
options:
|
||||
- Option 1 of dropdown
|
||||
- Option 2 of dropdown
|
||||
- Option 3 of dropdown
|
||||
validations:
|
||||
required: true
|
||||
- type: checkboxes
|
||||
id: id7
|
||||
attributes:
|
||||
label: Label of checkboxes
|
||||
description: Description of checkboxes
|
||||
|
@ -836,8 +863,9 @@ body:
|
|||
"form-field-id3": {"Value of id3"},
|
||||
"form-field-id4": {"Value of id4"},
|
||||
"form-field-id5": {"0,1"},
|
||||
"form-field-id6-0": {"on"},
|
||||
"form-field-id6-2": {"on"},
|
||||
"form-field-id6": {"1,2"},
|
||||
"form-field-id7-0": {"on"},
|
||||
"form-field-id7-2": {"on"},
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -849,10 +877,15 @@ body:
|
|||
|
||||
Value of id4
|
||||
|
||||
### Label of dropdown
|
||||
### Label of dropdown (one line)
|
||||
|
||||
Option 1 of dropdown, Option 2 of dropdown
|
||||
|
||||
### Label of dropdown (list)
|
||||
|
||||
- Option 2 of dropdown
|
||||
- Option 3 of dropdown
|
||||
|
||||
### Label of checkboxes
|
||||
|
||||
- [x] Option 1 of checkboxes
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"net"
|
||||
"net/mail"
|
||||
"strings"
|
||||
"text/template"
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
|
@ -46,6 +47,10 @@ type Mailer struct {
|
|||
SendmailArgs []string `ini:"-"`
|
||||
SendmailTimeout time.Duration `ini:"SENDMAIL_TIMEOUT"`
|
||||
SendmailConvertCRLF bool `ini:"SENDMAIL_CONVERT_CRLF"`
|
||||
|
||||
// Customization
|
||||
FromDisplayNameFormat string `ini:"FROM_DISPLAY_NAME_FORMAT"`
|
||||
FromDisplayNameFormatTemplate *template.Template `ini:"-"`
|
||||
}
|
||||
|
||||
// MailService the global mailer
|
||||
|
@ -234,6 +239,16 @@ func loadMailerFrom(rootCfg ConfigProvider) {
|
|||
log.Error("no mailer.FROM provided, email system may not work.")
|
||||
}
|
||||
|
||||
MailService.FromDisplayNameFormatTemplate, _ = template.New("mailFrom").Parse("{{ .DisplayName }}")
|
||||
if MailService.FromDisplayNameFormat != "" {
|
||||
template, err := template.New("mailFrom").Parse(MailService.FromDisplayNameFormat)
|
||||
if err != nil {
|
||||
log.Error("mailer.FROM_DISPLAY_NAME_FORMAT is no valid template: %v", err)
|
||||
} else {
|
||||
MailService.FromDisplayNameFormatTemplate = template
|
||||
}
|
||||
}
|
||||
|
||||
switch MailService.EnvelopeFrom {
|
||||
case "":
|
||||
MailService.OverrideEnvelopeFrom = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue