Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Scroll images in project issues separately from the remaining issue (go-gitea#31683)
  Support issue template assignees (go-gitea#31083)
  • Loading branch information
zjjhot committed Aug 13, 2024
2 parents 6e13951 + 5bcab0b commit 8942c19
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 26 deletions.
12 changes: 7 additions & 5 deletions modules/issue/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ name: Name
title: Title
about: About
labels: ["label1", "label2"]
assignees: ["user1", "user2"]
ref: Ref
body:
- type: markdown
Expand Down Expand Up @@ -523,11 +524,12 @@ body:
visible: [form]
`,
want: &api.IssueTemplate{
Name: "Name",
Title: "Title",
About: "About",
Labels: []string{"label1", "label2"},
Ref: "Ref",
Name: "Name",
Title: "Title",
About: "About",
Labels: []string{"label1", "label2"},
Assignees: []string{"user1", "user2"},
Ref: "Ref",
Fields: []*api.IssueFormField{
{
Type: "markdown",
Expand Down
23 changes: 12 additions & 11 deletions modules/structs/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,20 @@ const (
// IssueTemplate represents an issue template for a repository
// swagger:model
type IssueTemplate struct {
Name string `json:"name" yaml:"name"`
Title string `json:"title" yaml:"title"`
About string `json:"about" yaml:"about"` // Using "description" in a template file is compatible
Labels IssueTemplateLabels `json:"labels" yaml:"labels"`
Ref string `json:"ref" yaml:"ref"`
Content string `json:"content" yaml:"-"`
Fields []*IssueFormField `json:"body" yaml:"body"`
FileName string `json:"file_name" yaml:"-"`
Name string `json:"name" yaml:"name"`
Title string `json:"title" yaml:"title"`
About string `json:"about" yaml:"about"` // Using "description" in a template file is compatible
Labels IssueTemplateStringSlice `json:"labels" yaml:"labels"`
Assignees IssueTemplateStringSlice `json:"assignees" yaml:"assignees"`
Ref string `json:"ref" yaml:"ref"`
Content string `json:"content" yaml:"-"`
Fields []*IssueFormField `json:"body" yaml:"body"`
FileName string `json:"file_name" yaml:"-"`
}

type IssueTemplateLabels []string
type IssueTemplateStringSlice []string

func (l *IssueTemplateLabels) UnmarshalYAML(value *yaml.Node) error {
func (l *IssueTemplateStringSlice) UnmarshalYAML(value *yaml.Node) error {
var labels []string
if value.IsZero() {
*l = labels
Expand Down Expand Up @@ -217,7 +218,7 @@ func (l *IssueTemplateLabels) UnmarshalYAML(value *yaml.Node) error {
*l = labels
return nil
}
return fmt.Errorf("line %d: cannot unmarshal %s into IssueTemplateLabels", value.Line, value.ShortTag())
return fmt.Errorf("line %d: cannot unmarshal %s into IssueTemplateStringSlice", value.Line, value.ShortTag())
}

type IssueConfigContactLink struct {
Expand Down
4 changes: 2 additions & 2 deletions modules/structs/issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestIssueTemplate_Type(t *testing.T) {
}
}

func TestIssueTemplateLabels_UnmarshalYAML(t *testing.T) {
func TestIssueTemplateStringSlice_UnmarshalYAML(t *testing.T) {
tests := []struct {
name string
content string
Expand Down Expand Up @@ -88,7 +88,7 @@ labels:
b: bb
`,
tmpl: &IssueTemplate{},
wantErr: "line 3: cannot unmarshal !!map into IssueTemplateLabels",
wantErr: "line 3: cannot unmarshal !!map into IssueTemplateStringSlice",
},
}
for _, tt := range tests {
Expand Down
13 changes: 13 additions & 0 deletions options/locale/locale_ja-JP.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2868,6 +2868,7 @@ dashboard.reinit_missing_repos=レコードが存在するが見当たらない
dashboard.sync_external_users=外部ユーザーデータの同期
dashboard.cleanup_hook_task_table=hook_taskテーブルのクリーンアップ
dashboard.cleanup_packages=期限切れパッケージのクリーンアップ
dashboard.cleanup_actions=期限切れのActionsリソースのクリーンアップ
dashboard.server_uptime=サーバーの稼働時間
dashboard.current_goroutine=現在のGoroutine数
dashboard.current_memory_usage=現在のメモリ使用量
Expand Down Expand Up @@ -2897,9 +2898,15 @@ dashboard.total_gc_time=GC停止時間の合計
dashboard.total_gc_pause=GC停止時間の合計
dashboard.last_gc_pause=前回のGC停止時間
dashboard.gc_times=GC実行回数
dashboard.delete_old_actions=データベースから古い操作履歴をすべて削除
dashboard.delete_old_actions.started=データベースからの古い操作履歴の削除を開始しました。
dashboard.update_checker=更新チェック
dashboard.delete_old_system_notices=データベースから古いシステム通知をすべて削除
dashboard.gc_lfs=LFSメタオブジェクトのガベージコレクション
dashboard.stop_zombie_tasks=Actionsゾンビタスクを停止
dashboard.stop_endless_tasks=終わらないActionsタスクを停止
dashboard.cancel_abandoned_jobs=放置されたままのActionsジョブをキャンセル
dashboard.start_schedule_tasks=Actionsスケジュールタスクを開始
dashboard.sync_branch.started=ブランチの同期を開始しました
dashboard.sync_tag.started=タグの同期を開始しました
dashboard.rebuild_issue_indexer=イシューインデクサーの再構築
Expand Down Expand Up @@ -2974,6 +2981,10 @@ emails.not_updated=メール設定の更新に失敗しました: %v
emails.duplicate_active=メールアドレスは別のユーザーが既に使用中です。
emails.change_email_header=メール設定の更新
emails.change_email_text=このメールアドレスで更新してもよろしいですか?
emails.delete=メールアドレスの削除
emails.delete_desc=このメールアドレスを削除してよろしいですか?
emails.deletion_success=メールアドレスを削除しました。
emails.delete_primary_email_error=プライマリメールアドレスを削除することはできません。

orgs.org_manage_panel=組織の管理
orgs.name=名称
Expand Down Expand Up @@ -3666,6 +3677,7 @@ runs.no_workflows.quick_start=Gitea Actions の始め方がわからない?
runs.no_workflows.documentation=Gitea Actions の詳細については、<a target="_blank" rel="noopener noreferrer" href="%s">ドキュメント</a>を参照してください。
runs.no_runs=ワークフローはまだ実行されていません。
runs.empty_commit_message=(空のコミットメッセージ)
runs.expire_log_message=ログは古すぎるため消去されています。

workflow.disable=ワークフローを無効にする
workflow.disable_success=ワークフロー '%s' が無効になりました。
Expand All @@ -3692,6 +3704,7 @@ variables.update.failed=変数を更新できませんでした。
variables.update.success=変数を更新しました。

[projects]
deleted.display_name=削除されたプロジェクト
type-1.display_name=個人プロジェクト
type-2.display_name=リポジトリ プロジェクト
type-3.display_name=組織プロジェクト
Expand Down
11 changes: 11 additions & 0 deletions routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -939,12 +939,23 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles
}
}
}
selectedAssigneeIDs := make([]int64, 0, len(template.Assignees))
selectedAssigneeIDStrings := make([]string, 0, len(template.Assignees))
if userIDs, err := user_model.GetUserIDsByNames(ctx, template.Assignees, false); err == nil {
for _, userID := range userIDs {
selectedAssigneeIDs = append(selectedAssigneeIDs, userID)
selectedAssigneeIDStrings = append(selectedAssigneeIDStrings, strconv.FormatInt(userID, 10))
}
}

if template.Ref != "" && !strings.HasPrefix(template.Ref, "refs/") { // Assume that the ref intended is always a branch - for tags users should use refs/tags/<ref>
template.Ref = git.BranchPrefix + template.Ref
}
ctx.Data["HasSelectedLabel"] = len(labelIDs) > 0
ctx.Data["label_ids"] = strings.Join(labelIDs, ",")
ctx.Data["HasSelectedAssignee"] = len(selectedAssigneeIDs) > 0
ctx.Data["assignee_ids"] = strings.Join(selectedAssigneeIDStrings, ",")
ctx.Data["SelectedAssigneeIDs"] = selectedAssigneeIDs
ctx.Data["Reference"] = template.Ref
ctx.Data["RefEndName"] = git.RefName(template.Ref).ShortName()
return true, templateErrs
Expand Down
8 changes: 4 additions & 4 deletions templates/repo/issue/new_form.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@
</div>
<div class="no-select item">{{ctx.Locale.Tr "repo.issues.new.clear_assignees"}}</div>
{{range .Assignees}}
<a class="item muted" href="#" data-id="{{.ID}}" data-id-selector="#assignee_{{.ID}}">
<span class="octicon-check tw-invisible">{{svg "octicon-check"}}</span>
<a class="{{if SliceUtils.Contains $.SelectedAssigneeIDs .ID}}checked{{end}} item muted" href="#" data-id="{{.ID}}" data-id-selector="#assignee_{{.ID}}">
<span class="octicon-check {{if not (SliceUtils.Contains $.SelectedAssigneeIDs .ID)}}tw-invisible{{end}}">{{svg "octicon-check"}}</span>
<span class="text">
{{ctx.AvatarUtils.Avatar . 28 "tw-mr-2"}}{{template "repo/search_name" .}}
</span>
Expand All @@ -165,12 +165,12 @@
</div>
</div>
<div class="ui assignees list">
<span class="no-select item {{if .HasSelectedLabel}}tw-hidden{{end}}">
<span class="no-select item {{if .HasSelectedAssignee}}tw-hidden{{end}}">
{{ctx.Locale.Tr "repo.issues.new.no_assignees"}}
</span>
<div class="selected">
{{range .Assignees}}
<a class="item tw-p-1 muted tw-hidden" id="assignee_{{.ID}}" href="{{$.RepoLink}}/issues?assignee={{.ID}}">
<a class="item tw-p-1 muted {{if not (SliceUtils.Contains $.SelectedAssigneeIDs .ID)}}tw-hidden{{end}}" id="assignee_{{.ID}}" href="{{$.RepoLink}}/issues?assignee={{.ID}}">
{{ctx.AvatarUtils.Avatar . 28 "tw-mr-2 tw-align-middle"}}{{.GetDisplayName}}
</a>
{{end}}
Expand Down
7 changes: 5 additions & 2 deletions templates/swagger/v1_json.tmpl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion web_src/css/features/projects.css
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,20 @@
.card-attachment-images {
display: inline-block;
white-space: nowrap;
overflow: hidden;
overflow: scroll;
cursor: default;
scroll-snap-type: x mandatory;
text-align: center;
}

.card-attachment-images img {
display: inline-block;
max-height: 50px;
border-radius: var(--border-radius);
text-align: left;
scroll-snap-align: center;
margin-right: 2px;
aspect-ratio: 1;
}

.card-attachment-images img:only-child {
Expand Down
2 changes: 1 addition & 1 deletion web_src/css/repo/issue-card.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
display: flex;
flex-direction: column;
gap: 4px;
align-items: start;
align-items: stretch;
border-radius: var(--border-radius);
padding: 8px 10px;
border: 1px solid var(--color-secondary);
Expand Down

0 comments on commit 8942c19

Please sign in to comment.