From 7c167ffa9adc681e4fb585bfc07d1323c8d86102 Mon Sep 17 00:00:00 2001 From: Bram Hagens Date: Mon, 29 Jan 2024 15:50:04 +0100 Subject: [PATCH 1/5] add 'draft' field to issue api --- modules/structs/issue.go | 1 + services/convert/issue.go | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/structs/issue.go b/modules/structs/issue.go index 1aec5cc6b86c8..b134fb142fbdb 100644 --- a/modules/structs/issue.go +++ b/modules/structs/issue.go @@ -28,6 +28,7 @@ const ( type PullRequestMeta struct { HasMerged bool `json:"merged"` Merged *time.Time `json:"merged_at"` + IsDraft bool `json:"draft"` } // RepositoryMeta basic repository information diff --git a/services/convert/issue.go b/services/convert/issue.go index 39d785e108332..8fc13bf60e053 100644 --- a/services/convert/issue.go +++ b/services/convert/issue.go @@ -99,6 +99,7 @@ func toIssue(ctx context.Context, issue *issues_model.Issue, getDownloadURL func if issue.PullRequest != nil { apiIssue.PullRequest = &api.PullRequestMeta{ HasMerged: issue.PullRequest.HasMerged, + IsDraft: issue.PullRequest.IsWorkInProgress(ctx), } if issue.PullRequest.HasMerged { apiIssue.PullRequest.Merged = issue.PullRequest.MergedUnix.AsTimePtr() From cd44c27864c223ed935a6ce64116a2f277ca9381 Mon Sep 17 00:00:00 2001 From: Bram Hagens Date: Mon, 29 Jan 2024 16:01:18 +0100 Subject: [PATCH 2/5] update swagger documentation --- templates/swagger/v1_json.tmpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index dc04a97b833c7..a589fc8c011a4 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -21610,6 +21610,10 @@ "description": "PullRequestMeta PR info if an issue is a PR", "type": "object", "properties": { + "draft": { + "type": "boolean", + "x-go-name": "IsDraft" + }, "merged": { "type": "boolean", "x-go-name": "HasMerged" From 0e8365d2ca6e2aca5d7651c170031f7cc61b5307 Mon Sep 17 00:00:00 2001 From: Bram Hagens Date: Mon, 29 Jan 2024 15:50:30 +0100 Subject: [PATCH 3/5] show correct pr icon in ContextPopups --- web_src/js/components/ContextPopup.vue | 16 ++++++++++++---- web_src/js/svg.js | 2 ++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/web_src/js/components/ContextPopup.vue b/web_src/js/components/ContextPopup.vue index 303e6d0c8912c..87cdb060ecfcb 100644 --- a/web_src/js/components/ContextPopup.vue +++ b/web_src/js/components/ContextPopup.vue @@ -30,6 +30,9 @@ export default { icon() { if (this.issue.pull_request !== null) { if (this.issue.state === 'open') { + if (this.issue.pull_request.draft === true) { + return 'octicon-git-pull-request-draft'; // Draft PR + } return 'octicon-git-pull-request'; // Open PR } else if (this.issue.pull_request.merged === true) { return 'octicon-git-merge'; // Merged PR @@ -42,12 +45,17 @@ export default { }, color() { + if (this.issue.pull_request !== null) { + if (this.issue.pull_request.draft === true) { + return 'grey'; // Draft PR + } else if (this.issue.pull_request.merged === true) { + return 'purple'; // Merged PR + } + } if (this.issue.state === 'open') { - return 'green'; - } else if (this.issue.pull_request !== null && this.issue.pull_request.merged === true) { - return 'purple'; + return 'green'; // Open Issue } - return 'red'; + return 'red'; // Closed Issue }, labels() { diff --git a/web_src/js/svg.js b/web_src/js/svg.js index c2a96fba3f040..084256587c518 100644 --- a/web_src/js/svg.js +++ b/web_src/js/svg.js @@ -33,6 +33,7 @@ import octiconGitBranch from '../../public/assets/img/svg/octicon-git-branch.svg import octiconGitCommit from '../../public/assets/img/svg/octicon-git-commit.svg'; import octiconGitMerge from '../../public/assets/img/svg/octicon-git-merge.svg'; import octiconGitPullRequest from '../../public/assets/img/svg/octicon-git-pull-request.svg'; +import octiconGitPullRequestDraft from '../../public/assets/img/svg/octicon-git-pull-request-draft.svg'; import octiconHeading from '../../public/assets/img/svg/octicon-heading.svg'; import octiconHorizontalRule from '../../public/assets/img/svg/octicon-horizontal-rule.svg'; import octiconImage from '../../public/assets/img/svg/octicon-image.svg'; @@ -104,6 +105,7 @@ const svgs = { 'octicon-git-commit': octiconGitCommit, 'octicon-git-merge': octiconGitMerge, 'octicon-git-pull-request': octiconGitPullRequest, + 'octicon-git-pull-request-draft': octiconGitPullRequestDraft, 'octicon-heading': octiconHeading, 'octicon-horizontal-rule': octiconHorizontalRule, 'octicon-image': octiconImage, From c8f2b69e17d6e2f82d3d57d7d99586586798c872 Mon Sep 17 00:00:00 2001 From: Bram Hagens Date: Mon, 29 Jan 2024 16:23:35 +0100 Subject: [PATCH 4/5] rename draft -> wip --- modules/structs/issue.go | 6 +++--- services/convert/issue.go | 4 ++-- templates/swagger/v1_json.tmpl | 8 ++++---- web_src/js/components/ContextPopup.vue | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/structs/issue.go b/modules/structs/issue.go index b134fb142fbdb..5d8d14783ebbf 100644 --- a/modules/structs/issue.go +++ b/modules/structs/issue.go @@ -26,9 +26,9 @@ const ( // PullRequestMeta PR info if an issue is a PR type PullRequestMeta struct { - HasMerged bool `json:"merged"` - Merged *time.Time `json:"merged_at"` - IsDraft bool `json:"draft"` + HasMerged bool `json:"merged"` + Merged *time.Time `json:"merged_at"` + IsWorkInProgress bool `json:"wip"` } // RepositoryMeta basic repository information diff --git a/services/convert/issue.go b/services/convert/issue.go index 8fc13bf60e053..c6e06180c8386 100644 --- a/services/convert/issue.go +++ b/services/convert/issue.go @@ -98,8 +98,8 @@ func toIssue(ctx context.Context, issue *issues_model.Issue, getDownloadURL func } if issue.PullRequest != nil { apiIssue.PullRequest = &api.PullRequestMeta{ - HasMerged: issue.PullRequest.HasMerged, - IsDraft: issue.PullRequest.IsWorkInProgress(ctx), + HasMerged: issue.PullRequest.HasMerged, + IsWorkInProgress: issue.PullRequest.IsWorkInProgress(ctx), } if issue.PullRequest.HasMerged { apiIssue.PullRequest.Merged = issue.PullRequest.MergedUnix.AsTimePtr() diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index a589fc8c011a4..1b1b60876e90d 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -21610,10 +21610,6 @@ "description": "PullRequestMeta PR info if an issue is a PR", "type": "object", "properties": { - "draft": { - "type": "boolean", - "x-go-name": "IsDraft" - }, "merged": { "type": "boolean", "x-go-name": "HasMerged" @@ -21622,6 +21618,10 @@ "type": "string", "format": "date-time", "x-go-name": "Merged" + }, + "wip": { + "type": "boolean", + "x-go-name": "IsWorkInProgress" } }, "x-go-package": "code.gitea.io/gitea/modules/structs" diff --git a/web_src/js/components/ContextPopup.vue b/web_src/js/components/ContextPopup.vue index 87cdb060ecfcb..50149f286206f 100644 --- a/web_src/js/components/ContextPopup.vue +++ b/web_src/js/components/ContextPopup.vue @@ -30,8 +30,8 @@ export default { icon() { if (this.issue.pull_request !== null) { if (this.issue.state === 'open') { - if (this.issue.pull_request.draft === true) { - return 'octicon-git-pull-request-draft'; // Draft PR + if (this.issue.pull_request.wip === true) { + return 'octicon-git-pull-request-draft'; // WIP PR } return 'octicon-git-pull-request'; // Open PR } else if (this.issue.pull_request.merged === true) { @@ -46,8 +46,8 @@ export default { color() { if (this.issue.pull_request !== null) { - if (this.issue.pull_request.draft === true) { - return 'grey'; // Draft PR + if (this.issue.pull_request.wip === true) { + return 'grey'; // WIP PR } else if (this.issue.pull_request.merged === true) { return 'purple'; // Merged PR } From 756b2b56d1655cd3a52e72b02e6b0978d67084bd Mon Sep 17 00:00:00 2001 From: Bram Hagens Date: Thu, 1 Feb 2024 11:13:27 +0100 Subject: [PATCH 5/5] rename wip field back to draft --- modules/structs/issue.go | 2 +- templates/swagger/v1_json.tmpl | 8 ++++---- web_src/js/components/ContextPopup.vue | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/modules/structs/issue.go b/modules/structs/issue.go index 5d8d14783ebbf..34eae693299ac 100644 --- a/modules/structs/issue.go +++ b/modules/structs/issue.go @@ -28,7 +28,7 @@ const ( type PullRequestMeta struct { HasMerged bool `json:"merged"` Merged *time.Time `json:"merged_at"` - IsWorkInProgress bool `json:"wip"` + IsWorkInProgress bool `json:"draft"` } // RepositoryMeta basic repository information diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index 1b1b60876e90d..403f241d72787 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -21610,6 +21610,10 @@ "description": "PullRequestMeta PR info if an issue is a PR", "type": "object", "properties": { + "draft": { + "type": "boolean", + "x-go-name": "IsWorkInProgress" + }, "merged": { "type": "boolean", "x-go-name": "HasMerged" @@ -21618,10 +21622,6 @@ "type": "string", "format": "date-time", "x-go-name": "Merged" - }, - "wip": { - "type": "boolean", - "x-go-name": "IsWorkInProgress" } }, "x-go-package": "code.gitea.io/gitea/modules/structs" diff --git a/web_src/js/components/ContextPopup.vue b/web_src/js/components/ContextPopup.vue index 50149f286206f..d9e6da316cbcf 100644 --- a/web_src/js/components/ContextPopup.vue +++ b/web_src/js/components/ContextPopup.vue @@ -30,7 +30,7 @@ export default { icon() { if (this.issue.pull_request !== null) { if (this.issue.state === 'open') { - if (this.issue.pull_request.wip === true) { + if (this.issue.pull_request.draft === true) { return 'octicon-git-pull-request-draft'; // WIP PR } return 'octicon-git-pull-request'; // Open PR @@ -46,7 +46,7 @@ export default { color() { if (this.issue.pull_request !== null) { - if (this.issue.pull_request.wip === true) { + if (this.issue.pull_request.draft === true) { return 'grey'; // WIP PR } else if (this.issue.pull_request.merged === true) { return 'purple'; // Merged PR