Skip to content

Commit fa921ef

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated translations via Crowdin Support setting the `default` attribute of the issue template dropdown field (go-gitea#31045) Alpine 3.20 has been released (go-gitea#31047)
2 parents 8c7e0bf + ec771fd commit fa921ef

File tree

7 files changed

+124
-6
lines changed

7 files changed

+124
-6
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.22-alpine3.19 AS build-env
2+
FROM docker.io/library/golang:1.22-alpine3.20 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY ${GOPROXY:-direct}
@@ -41,7 +41,7 @@ RUN chmod 755 /tmp/local/usr/bin/entrypoint \
4141
/go/src/code.gitea.io/gitea/environment-to-ini
4242
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
4343

44-
FROM docker.io/library/alpine:3.19
44+
FROM docker.io/library/alpine:3.20
4545
LABEL maintainer="[email protected]"
4646

4747
EXPOSE 22 3000

Dockerfile.rootless

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM docker.io/library/golang:1.22-alpine3.19 AS build-env
2+
FROM docker.io/library/golang:1.22-alpine3.20 AS build-env
33

44
ARG GOPROXY
55
ENV GOPROXY ${GOPROXY:-direct}
@@ -39,7 +39,7 @@ RUN chmod 755 /tmp/local/usr/local/bin/docker-entrypoint.sh \
3939
/go/src/code.gitea.io/gitea/environment-to-ini
4040
RUN chmod 644 /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete
4141

42-
FROM docker.io/library/alpine:3.19
42+
FROM docker.io/library/alpine:3.20
4343
LABEL maintainer="[email protected]"
4444

4545
EXPOSE 2222 3000

modules/issue/template/template.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ func validateYaml(template *api.IssueTemplate) error {
9191
if err := validateOptions(field, idx); err != nil {
9292
return err
9393
}
94+
if err := validateDropdownDefault(position, field.Attributes); err != nil {
95+
return err
96+
}
9497
case api.IssueFormFieldTypeCheckboxes:
9598
if err := validateStringItem(position, field.Attributes, false, "description"); err != nil {
9699
return err
@@ -249,6 +252,28 @@ func validateBoolItem(position errorPosition, m map[string]any, names ...string)
249252
return nil
250253
}
251254

255+
func validateDropdownDefault(position errorPosition, attributes map[string]any) error {
256+
v, ok := attributes["default"]
257+
if !ok {
258+
return nil
259+
}
260+
defaultValue, ok := v.(int)
261+
if !ok {
262+
return position.Errorf("'default' should be an int")
263+
}
264+
265+
options, ok := attributes["options"].([]any)
266+
if !ok {
267+
// should not happen
268+
return position.Errorf("'options' is required and should be a array")
269+
}
270+
if defaultValue < 0 || defaultValue >= len(options) {
271+
return position.Errorf("the value of 'default' is out of range")
272+
}
273+
274+
return nil
275+
}
276+
252277
type errorPosition string
253278

254279
func (p errorPosition) Errorf(format string, a ...any) error {

modules/issue/template/template_test.go

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,96 @@ body:
355355
`,
356356
wantErr: "body[0](checkboxes), option[1]: can not require a hidden checkbox",
357357
},
358+
{
359+
name: "dropdown default is not an integer",
360+
content: `
361+
name: "test"
362+
about: "this is about"
363+
body:
364+
- type: dropdown
365+
id: "1"
366+
attributes:
367+
label: Label of dropdown
368+
description: Description of dropdown
369+
multiple: true
370+
options:
371+
- Option 1 of dropdown
372+
- Option 2 of dropdown
373+
- Option 3 of dropdown
374+
default: "def"
375+
validations:
376+
required: true
377+
`,
378+
wantErr: "body[0](dropdown): 'default' should be an int",
379+
},
380+
{
381+
name: "dropdown default is out of range",
382+
content: `
383+
name: "test"
384+
about: "this is about"
385+
body:
386+
- type: dropdown
387+
id: "1"
388+
attributes:
389+
label: Label of dropdown
390+
description: Description of dropdown
391+
multiple: true
392+
options:
393+
- Option 1 of dropdown
394+
- Option 2 of dropdown
395+
- Option 3 of dropdown
396+
default: 3
397+
validations:
398+
required: true
399+
`,
400+
wantErr: "body[0](dropdown): the value of 'default' is out of range",
401+
},
402+
{
403+
name: "dropdown without default is valid",
404+
content: `
405+
name: "test"
406+
about: "this is about"
407+
body:
408+
- type: dropdown
409+
id: "1"
410+
attributes:
411+
label: Label of dropdown
412+
description: Description of dropdown
413+
multiple: true
414+
options:
415+
- Option 1 of dropdown
416+
- Option 2 of dropdown
417+
- Option 3 of dropdown
418+
validations:
419+
required: true
420+
`,
421+
want: &api.IssueTemplate{
422+
Name: "test",
423+
About: "this is about",
424+
Fields: []*api.IssueFormField{
425+
{
426+
Type: "dropdown",
427+
ID: "1",
428+
Attributes: map[string]any{
429+
"label": "Label of dropdown",
430+
"description": "Description of dropdown",
431+
"multiple": true,
432+
"options": []any{
433+
"Option 1 of dropdown",
434+
"Option 2 of dropdown",
435+
"Option 3 of dropdown",
436+
},
437+
},
438+
Validations: map[string]any{
439+
"required": true,
440+
},
441+
Visible: []api.IssueFormFieldVisible{api.IssueFormFieldVisibleForm, api.IssueFormFieldVisibleContent},
442+
},
443+
},
444+
FileName: "test.yaml",
445+
},
446+
wantErr: "",
447+
},
358448
{
359449
name: "valid",
360450
content: `
@@ -399,6 +489,7 @@ body:
399489
- Option 1 of dropdown
400490
- Option 2 of dropdown
401491
- Option 3 of dropdown
492+
default: 1
402493
validations:
403494
required: true
404495
- type: checkboxes
@@ -475,6 +566,7 @@ body:
475566
"Option 2 of dropdown",
476567
"Option 3 of dropdown",
477568
},
569+
"default": 1,
478570
},
479571
Validations: map[string]any{
480572
"required": true,

options/locale/locale_pt-PT.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1595,7 +1595,7 @@ issues.label_title=Nome do rótulo
15951595
issues.label_description=Descrição do rótulo
15961596
issues.label_color=Cor do rótulo
15971597
issues.label_exclusive=Exclusivo
1598-
issues.label_archive=Rótulo de arquivo
1598+
issues.label_archive=Arquivar rótulo
15991599
issues.label_archived_filter=Mostrar rótulos arquivados
16001600
issues.label_archive_tooltip=Os rótulos arquivados são, por norma, excluídos das sugestões ao pesquisar por rótulo.
16011601
issues.label_exclusive_desc=Nomeie o rótulo <code>âmbito/item</code> para torná-lo mutuamente exclusivo com outros rótulos do <code>âmbito/</code>.

options/locale/locale_zh-CN.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3415,6 +3415,7 @@ error.unit_not_allowed=您没有权限访问此仓库单元
34153415
title=软件包
34163416
desc=管理仓库软件包。
34173417
empty=还没有软件包。
3418+
no_metadata=没有元数据。
34183419
empty.documentation=关于软件包注册中心的更多信息,请参阅 <a target="_blank" rel="noopener noreferrer" href="%s"> 文档 </a>。
34193420
empty.repo=您上传了一个包,但没有显示在这里吗?转到 <a href="%[1]s">包设置</a> 并将其链接到这个仓库中。
34203421
registry.documentation=关于 %s 注册中心的更多信息,请参阅 <a target="_blank" rel="noopener noreferrer" href="%s">文档</a>。

templates/repo/issue/fields/dropdown.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{template "repo/issue/fields/header" .}}
33
{{/* FIXME: required validation */}}
44
<div class="ui fluid selection dropdown {{if .item.Attributes.multiple}}multiple clearable{{end}}">
5-
<input type="hidden" name="form-field-{{.item.ID}}" value="0">
5+
<input type="hidden" name="form-field-{{.item.ID}}" value="{{.item.Attributes.default}}">
66
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
77
{{if not .item.Validations.required}}
88
{{svg "octicon-x" 14 "remove icon"}}

0 commit comments

Comments
 (0)