summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authora1012112796 <1012112796@qq.com>2021-02-12 01:32:25 +0800
committerGitHub <noreply@github.com>2021-02-11 18:32:25 +0100
commitac701637b42d2d6bb5fe9b258f3f54959b6a505e (patch)
tree3020b45f25405036036c7d0cc0a7fc5007b5ab60 /templates
parentc69c01d2b6b08a89448b5596fd2233fa4e802ac3 (diff)
downloadgitea-ac701637b42d2d6bb5fe9b258f3f54959b6a505e.tar.gz
gitea-ac701637b42d2d6bb5fe9b258f3f54959b6a505e.zip
Add dismiss review feature (#12674)
* Add dismiss review feature refs: https://github.blog/2016-10-12-dismissing-reviews-on-pull-requests/ https://developer.github.com/v3/pulls/reviews/#dismiss-a-review-for-a-pull-request * change modal ui and error message * Add unDismissReview api Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'templates')
-rw-r--r--templates/mail/issue/default.tmpl2
-rw-r--r--templates/repo/issue/view_content/comments.tmpl45
-rw-r--r--templates/repo/issue/view_content/pull.tmpl33
-rw-r--r--templates/swagger/v1_json.tmpl133
-rw-r--r--templates/user/dashboard/feeds.tmpl7
5 files changed, 216 insertions, 4 deletions
diff --git a/templates/mail/issue/default.tmpl b/templates/mail/issue/default.tmpl
index e062dca7f1..b7d576bef4 100644
--- a/templates/mail/issue/default.tmpl
+++ b/templates/mail/issue/default.tmpl
@@ -49,6 +49,8 @@
<b>@{{.Doer.Name}}</b> requested changes on this pull request.
{{else if eq .ActionName "review"}}
<b>@{{.Doer.Name}}</b> commented on this pull request.
+ {{else if eq .ActionName "review_dismissed"}}
+ <b>@{{.Doer.Name}}</b> dismissed last review from {{.Comment.Review.Reviewer.Name}} for this pull request.
{{end}}
{{- if eq .Body ""}}
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl
index 63fe73857c..b971c6b1ae 100644
--- a/templates/repo/issue/view_content/comments.tmpl
+++ b/templates/repo/issue/view_content/comments.tmpl
@@ -8,7 +8,8 @@
18 = REMOVED_DEADLINE, 19 = ADD_DEPENDENCY, 20 = REMOVE_DEPENDENCY, 21 = CODE,
22 = REVIEW, 23 = ISSUE_LOCKED, 24 = ISSUE_UNLOCKED, 25 = TARGET_BRANCH_CHANGED,
26 = DELETE_TIME_MANUAL, 27 = REVIEW_REQUEST, 28 = MERGE_PULL_REQUEST,
- 29 = PULL_PUSH_EVENT, 30 = PROJECT_CHANGED, 31 = PROJECT_BOARD_CHANGED -->
+ 29 = PULL_PUSH_EVENT, 30 = PROJECT_CHANGED, 31 = PROJECT_BOARD_CHANGED
+ 32 = DISMISSED_REVIEW -->
{{if eq .Type 0}}
<div class="timeline-item comment" id="{{.HashTag}}">
{{if .OriginalAuthor }}
@@ -415,6 +416,9 @@
{{else}}
{{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
{{end}}
+ {{if .Review.Dismissed}}
+ <div class="ui small label">{{$.i18n.Tr "repo.issues.review.dismissed_label"}}</div>
+ {{end}}
</span>
</div>
{{if .Content}}
@@ -698,5 +702,44 @@
</span>
</div>
{{end}}
+ {{else if eq .Type 32}}
+ <div class="timeline-item-group">
+ <div class="timeline-item event" id="{{.HashTag}}">
+ <a class="timeline-avatar"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>
+ <img src="{{.Poster.RelAvatarLink}}">
+ </a>
+ <span class="badge grey">{{svg "octicon-x" 16}}</span>
+ <span class="text grey">
+ <a class="author"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.GetDisplayName}}</a>
+ {{$reviewerName := ""}}
+ {{if eq .Review.OriginalAuthor ""}}
+ {{$reviewerName = .Review.Reviewer.Name}}
+ {{else}}
+ {{$reviewerName = .Review.OriginalAuthor}}
+ {{end}}
+ {{$.i18n.Tr "repo.issues.review.dismissed" $reviewerName $createdStr | Safe}}
+ </span>
+ </div>
+ {{if .Content}}
+ <div class="timeline-item comment">
+ <div class="content">
+ <div class="ui top attached header arrow-top">
+ <span class="text grey">
+ {{$.i18n.Tr "action.review_dismissed_reason"}}
+ </span>
+ </div>
+ <div class="ui attached segment">
+ <div class="render-content markdown">
+ {{if .RenderedContent}}
+ {{.RenderedContent|Str2html}}
+ {{else}}
+ <span class="no-content">{{$.i18n.Tr "repo.issues.no_content"}}</span>
+ {{end}}
+ </div>
+ </div>
+ </div>
+ </div>
+ {{end}}
+ </div>
{{end}}
{{end}}
diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl
index 34eaa83eb2..9e883c0a93 100644
--- a/templates/repo/issue/view_content/pull.tmpl
+++ b/templates/repo/issue/view_content/pull.tmpl
@@ -34,9 +34,36 @@
</div>
<div class="review-item-right">
{{if .Review.Stale}}
- <span class="ui poping up type-icon text grey" data-content="{{$.i18n.Tr "repo.issues.is_stale"}}">
- <i class="octicon icon fa-hourglass-end"></i>
- </span>
+ <span class="ui poping up type-icon text grey" data-content="{{$.i18n.Tr "repo.issues.is_stale"}}">
+ <i class="octicon icon fa-hourglass-end"></i>
+ </span>
+ {{end}}
+ {{if (and $.Permission.IsAdmin (or (eq .Review.Type 1) (eq .Review.Type 3)) (not $.Issue.IsClosed))}}
+ <a href="#" class="ui grey poping up icon dismiss-review-btn" data-review-id="dismiss-review-{{.Review.ID}}" data-content="{{$.i18n.Tr "repo.issues.dismiss_review"}}">
+ {{svg "octicon-x" 16}}
+ </a>
+ <div class="ui small modal" id="dismiss-review-modal">
+ <div class="header">
+ {{$.i18n.Tr "repo.issues.dismiss_review"}}
+ </div>
+ <div class="content">
+ <div class="ui warning message text left">
+ {{$.i18n.Tr "repo.issues.dismiss_review_warning"}}
+ </div>
+ <form class="ui form dismiss-review-form" id="dismiss-review-{{.Review.ID}}" action="{{$.RepoLink}}/issues/dismiss_review" method="post">
+ {{$.CsrfTokenHtml}}
+ <input type="hidden" name="review_id" value="{{.Review.ID}}">
+ <div class="field">
+ <label for="message">{{$.i18n.Tr "action.review_dismissed_reason"}}</label>
+ <input id="message" name="message">
+ </div>
+ <div class="text right actions">
+ <div class="ui cancel button">{{$.i18n.Tr "settings.cancel"}}</div>
+ <button class="ui red button" type="submit">{{$.i18n.Tr "ok"}}</button>
+ </div>
+ </form>
+ </div>
+ </div>
{{end}}
<span class="type-icon text {{if eq .Review.Type 1}}green
{{- else if eq .Review.Type 2}}grey
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl
index 28aa617799..94493749af 100644
--- a/templates/swagger/v1_json.tmpl
+++ b/templates/swagger/v1_json.tmpl
@@ -7761,6 +7761,124 @@
}
}
},
+ "/repos/{owner}/{repo}/pulls/{index}/reviews/{id}/dismissals": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "repository"
+ ],
+ "summary": "Dismiss a review for a pull request",
+ "operationId": "repoDismissPullReview",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "owner of the repo",
+ "name": "owner",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "name of the repo",
+ "name": "repo",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "integer",
+ "format": "int64",
+ "description": "index of the pull request",
+ "name": "index",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "integer",
+ "format": "int64",
+ "description": "id of the review",
+ "name": "id",
+ "in": "path",
+ "required": true
+ },
+ {
+ "name": "body",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/DismissPullReviewOptions"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "$ref": "#/responses/PullReview"
+ },
+ "403": {
+ "$ref": "#/responses/forbidden"
+ },
+ "422": {
+ "$ref": "#/responses/validationError"
+ }
+ }
+ }
+ },
+ "/repos/{owner}/{repo}/pulls/{index}/reviews/{id}/undismissals": {
+ "post": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "repository"
+ ],
+ "summary": "Cancel to dismiss a review for a pull request",
+ "operationId": "repoUnDismissPullReview",
+ "parameters": [
+ {
+ "type": "string",
+ "description": "owner of the repo",
+ "name": "owner",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "string",
+ "description": "name of the repo",
+ "name": "repo",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "integer",
+ "format": "int64",
+ "description": "index of the pull request",
+ "name": "index",
+ "in": "path",
+ "required": true
+ },
+ {
+ "type": "integer",
+ "format": "int64",
+ "description": "id of the review",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "$ref": "#/responses/PullReview"
+ },
+ "403": {
+ "$ref": "#/responses/forbidden"
+ },
+ "422": {
+ "$ref": "#/responses/validationError"
+ }
+ }
+ }
+ },
"/repos/{owner}/{repo}/pulls/{index}/update": {
"post": {
"produces": [
@@ -13036,6 +13154,17 @@
},
"x-go-package": "code.gitea.io/gitea/modules/structs"
},
+ "DismissPullReviewOptions": {
+ "description": "DismissPullReviewOptions are options to dismiss a pull review",
+ "type": "object",
+ "properties": {
+ "message": {
+ "type": "string",
+ "x-go-name": "Message"
+ }
+ },
+ "x-go-package": "code.gitea.io/gitea/modules/structs"
+ },
"EditAttachmentOptions": {
"description": "EditAttachmentOptions options for editing attachments",
"type": "object",
@@ -15199,6 +15328,10 @@
"type": "string",
"x-go-name": "CommitID"
},
+ "dismissed": {
+ "type": "boolean",
+ "x-go-name": "Dismissed"
+ },
"html_url": {
"type": "string",
"x-go-name": "HTMLURL"
diff --git a/templates/user/dashboard/feeds.tmpl b/templates/user/dashboard/feeds.tmpl
index 744e028bc2..d25920a24e 100644
--- a/templates/user/dashboard/feeds.tmpl
+++ b/templates/user/dashboard/feeds.tmpl
@@ -78,6 +78,10 @@
{{ $branchLink := .GetBranch | EscapePound | Escape}}
{{ $linkText := .Content | RenderEmoji }}
{{$.i18n.Tr "action.publish_release" .GetRepoLink $branchLink .ShortRepoPath $linkText | Str2html}}
+ {{else if eq .GetOpType 25}}
+ {{ $index := index .GetIssueInfos 0}}
+ {{ $reviewer := index .GetIssueInfos 1}}
+ {{$.i18n.Tr "action.review_dismissed" .GetRepoLink $index .ShortRepoPath $reviewer | Str2html}}
{{end}}
</p>
{{if or (eq .GetOpType 5) (eq .GetOpType 18)}}
@@ -111,6 +115,9 @@
<p class="text light grey">{{index .GetIssueInfos 1}}</p>
{{else if or (eq .GetOpType 12) (eq .GetOpType 13) (eq .GetOpType 14) (eq .GetOpType 15)}}
<span class="text truncate issue title">{{.GetIssueTitle | RenderEmoji}}</span>
+ {{else if eq .GetOpType 25}}
+ <p class="text light grey">{{$.i18n.Tr "action.review_dismissed_reason"}}</p>
+ <p class="text light grey">{{index .GetIssueInfos 2 | RenderEmoji}}</p>
{{end}}
<p class="text italic light grey">{{TimeSince .GetCreate $.i18n.Lang}}</p>
</div>