Skip to content

Commit 2a93e84

Browse files
committed
Code review UI improvements
1 parent acb6f8a commit 2a93e84

File tree

7 files changed

+47
-17
lines changed

7 files changed

+47
-17
lines changed

public/css/index.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/css/theme-arc-green.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ function initPullRequestReview() {
780780
$("#show-outdated-" + id).removeClass('hide');
781781
});
782782

783-
$('.comment-form-reply').on('click', function (e) {
783+
$('button.comment-form-reply').on('click', function (e) {
784784
e.preventDefault();
785785
$(this).hide();
786786
var form = $(this).parent().find('.comment-form')
@@ -2649,7 +2649,7 @@ function cancelCodeComment(btn) {
26492649
var form = $(btn).closest("form");
26502650
if(form.length > 0 && form.hasClass('comment-form')) {
26512651
form.addClass('hide');
2652-
form.parent().find('.comment-form-reply').show();
2652+
form.parent().find('button.comment-form-reply').show();
26532653
}else {
26542654
console.log("Hey");
26552655
form.closest('.comment-code-cloud').remove()

public/less/_review.less

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,21 @@
4242
top: -13px;
4343
}
4444

45-
.attached.tab {
46-
border: none;
47-
padding: 0;
48-
margin: 0;
49-
50-
&.markdown {
51-
padding: 1em;
52-
min-height: 168px;
45+
.attached
46+
{
47+
&.tab {
48+
border: none;
49+
padding: 0;
50+
margin: 0;
51+
52+
&.markdown {
53+
padding: 1em;
54+
min-height: 168px;
55+
}
56+
}
57+
58+
&.header {
59+
padding: .1rem 1rem;
5360
}
5461
}
5562

@@ -92,8 +99,12 @@
9299
}
93100
}
94101

95-
.comment-form-reply {
96-
margin: 0.5em !important;
102+
button.comment-form-reply {
103+
margin: 0.5em 0.5em 0.5em 4.5em;
104+
}
105+
106+
form.comment-form-reply {
107+
margin: 0 0 0 4em;
97108
}
98109
}
99110

public/less/themes/arc-green.less

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,3 +772,10 @@
772772
background-color: inherit;
773773
}
774774
}
775+
776+
.comment-code-cloud {
777+
.ui.attached.tabular.menu {
778+
background: none transparent;
779+
border: none;
780+
}
781+
}

routers/repo/pull_review.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,23 @@ func SubmitReview(ctx *context.Context, form auth.SubmitReviewForm) {
128128
}
129129
}
130130

131-
if form.HasEmptyContent() {
131+
review, err = models.GetCurrentReview(ctx.User, issue)
132+
if err == nil {
133+
review.Issue = issue
134+
if errl := review.LoadCodeComments(); errl != nil {
135+
ctx.ServerError("LoadCodeComments", err)
136+
return
137+
}
138+
}
139+
140+
if ((err == nil && len(review.CodeComments) == 0) ||
141+
(err != nil && models.IsErrReviewNotExist(err))) &&
142+
form.HasEmptyContent() {
132143
ctx.Flash.Error(ctx.Tr("repo.issues.review.content.empty"))
133144
ctx.Redirect(fmt.Sprintf("%s/pulls/%d/files", ctx.Repo.RepoLink, issue.Index))
134145
return
135146
}
136147

137-
review, err = models.GetCurrentReview(ctx.User, issue)
138148
if err != nil {
139149
if !models.IsErrReviewNotExist(err) {
140150
ctx.ServerError("GetCurrentReview", err)

templates/repo/diff/comment_form.tmpl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{{if $.hidden}}
33
<button class="comment-form-reply ui green labeled icon tiny button"><i class="reply icon"></i> {{$.root.i18n.Tr "repo.diff.comment.reply"}}</button>
44
{{end}}
5-
<form class="ui form {{if $.hidden}}hide comment-form{{end}}" action="{{$.root.Issue.HTMLURL}}/files/reviews/comments" method="post">
5+
<form class="ui form {{if $.hidden}}hide comment-form comment-form-reply{{end}}" action="{{$.root.Issue.HTMLURL}}/files/reviews/comments" method="post">
66
{{$.root.CsrfTokenHtml}}
77
<input type="hidden" name="side" value="{{if $.Side}}{{$.Side}}{{end}}">
88
<input type="hidden" name="line" value="{{if $.Line}}{{$.Line}}{{end}}">
@@ -34,8 +34,10 @@
3434
class="ui submit green tiny button btn-start-review">{{$.root.i18n.Tr "repo.diff.comment.start_review"}}</button>
3535
{{end}}
3636
{{end}}
37+
{{if not $.root.CurrentReview}}
3738
<button type="submit"
3839
class="ui submit tiny basic button btn-add-single">{{$.root.i18n.Tr "repo.diff.comment.add_single_comment"}}</button>
40+
{{end}}
3941
{{if or (not $.HasComments) $.hidden}}
4042
<button type="button" class="ui submit tiny basic button btn-cancel" onclick="cancelCodeComment(this);">{{$.root.i18n.Tr "cancel"}}</button>
4143
{{end}}

0 commit comments

Comments
 (0)