From 8883d99184e6d425cf5279cd2ab0b1664895c673 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Mon, 12 Aug 2024 16:00:40 +0800 Subject: [PATCH 1/3] Support issue template assignees (#31083) Resolve #13955 --- modules/issue/template/template_test.go | 12 +++++++----- modules/structs/issue.go | 23 ++++++++++++----------- modules/structs/issue_test.go | 4 ++-- routers/web/repo/issue.go | 11 +++++++++++ templates/repo/issue/new_form.tmpl | 8 ++++---- templates/swagger/v1_json.tmpl | 7 +++++-- 6 files changed, 41 insertions(+), 24 deletions(-) diff --git a/modules/issue/template/template_test.go b/modules/issue/template/template_test.go index 349dbeabb0894..689a285b4795e 100644 --- a/modules/issue/template/template_test.go +++ b/modules/issue/template/template_test.go @@ -466,6 +466,7 @@ name: Name title: Title about: About labels: ["label1", "label2"] +assignees: ["user1", "user2"] ref: Ref body: - type: markdown @@ -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", diff --git a/modules/structs/issue.go b/modules/structs/issue.go index 3c06e383560a3..3682191be5751 100644 --- a/modules/structs/issue.go +++ b/modules/structs/issue.go @@ -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 @@ -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 { diff --git a/modules/structs/issue_test.go b/modules/structs/issue_test.go index fa7a20db8b5b8..55bd01df49631 100644 --- a/modules/structs/issue_test.go +++ b/modules/structs/issue_test.go @@ -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 @@ -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 { diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 691de94290f00..856e2f7392bae 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -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/ 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 diff --git a/templates/repo/issue/new_form.tmpl b/templates/repo/issue/new_form.tmpl index 88a6c39e522c0..e56d1b9ecc7bd 100644 --- a/templates/repo/issue/new_form.tmpl +++ b/templates/repo/issue/new_form.tmpl @@ -155,8 +155,8 @@
{{ctx.Locale.Tr "repo.issues.new.clear_assignees"}}
{{range .Assignees}} - - {{svg "octicon-check"}} + + {{svg "octicon-check"}} {{ctx.AvatarUtils.Avatar . 28 "tw-mr-2"}}{{template "repo/search_name" .}} @@ -165,12 +165,12 @@
- + {{ctx.Locale.Tr "repo.issues.new.no_assignees"}}
{{range .Assignees}} - + {{ctx.AvatarUtils.Avatar . 28 "tw-mr-2 tw-align-middle"}}{{.GetDisplayName}} {{end}} diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 18ea4a62b58f4..52d37547374a9 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -22345,6 +22345,9 @@ "type": "string", "x-go-name": "About" }, + "assignees": { + "$ref": "#/definitions/IssueTemplateStringSlice" + }, "body": { "type": "array", "items": { @@ -22361,7 +22364,7 @@ "x-go-name": "FileName" }, "labels": { - "$ref": "#/definitions/IssueTemplateLabels" + "$ref": "#/definitions/IssueTemplateStringSlice" }, "name": { "type": "string", @@ -22378,7 +22381,7 @@ }, "x-go-package": "code.gitea.io/gitea/modules/structs" }, - "IssueTemplateLabels": { + "IssueTemplateStringSlice": { "type": "array", "items": { "type": "string" From fe7c9416777243264e8482d3af29e30c2b671074 Mon Sep 17 00:00:00 2001 From: Simon Priet <105607989+SimonPistache@users.noreply.github.com> Date: Tue, 13 Aug 2024 01:36:28 +0200 Subject: [PATCH 2/3] Scroll images in project issues separately from the remaining issue (#31683) As discussed in #31667 & #26561, when a card on a Project contains images, they can overflow the card on its containing column. This aims to fix this issue via snapping scrollbars. --- Issue #31667 is open to discussion as there should be room for improvement. --- web_src/css/features/projects.css | 7 ++++++- web_src/css/repo/issue-card.css | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/web_src/css/features/projects.css b/web_src/css/features/projects.css index 151b0a23d9dc7..4a0205c910a33 100644 --- a/web_src/css/features/projects.css +++ b/web_src/css/features/projects.css @@ -70,7 +70,9 @@ .card-attachment-images { display: inline-block; white-space: nowrap; - overflow: hidden; + overflow: scroll; + cursor: default; + scroll-snap-type: x mandatory; text-align: center; } @@ -78,7 +80,10 @@ 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 { diff --git a/web_src/css/repo/issue-card.css b/web_src/css/repo/issue-card.css index 390bfb6a01419..fb832bd05ab0f 100644 --- a/web_src/css/repo/issue-card.css +++ b/web_src/css/repo/issue-card.css @@ -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); From 5bcab0b702274e137ff3e40f3ffa9078605fc2a2 Mon Sep 17 00:00:00 2001 From: GiteaBot Date: Tue, 13 Aug 2024 00:28:59 +0000 Subject: [PATCH 3/3] [skip ci] Updated translations via Crowdin --- options/locale/locale_ja-JP.ini | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/options/locale/locale_ja-JP.ini b/options/locale/locale_ja-JP.ini index e4348d302487d..b36b320439637 100644 --- a/options/locale/locale_ja-JP.ini +++ b/options/locale/locale_ja-JP.ini @@ -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=現在のメモリ使用量 @@ -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=イシューインデクサーの再構築 @@ -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=名称 @@ -3666,6 +3677,7 @@ runs.no_workflows.quick_start=Gitea Actions の始め方がわからない? runs.no_workflows.documentation=Gitea Actions の詳細については、ドキュメントを参照してください。 runs.no_runs=ワークフローはまだ実行されていません。 runs.empty_commit_message=(空のコミットメッセージ) +runs.expire_log_message=ログは古すぎるため消去されています。 workflow.disable=ワークフローを無効にする workflow.disable_success=ワークフロー '%s' が無効になりました。 @@ -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=組織プロジェクト