Skip to content

Commit 5b7addb

Browse files
committed
ui: change time-line event icons tyle
* Fix timeline icons offset #10864 Co-authored-by: Sorien <[email protected]> * change icons style on time-line to a more meaningfull icon like github instead of primitive-dot * change merge comment style to distinguish it from close Signed-off-by: a1012112796 <[email protected]>
1 parent 57cca44 commit 5b7addb

File tree

8 files changed

+157
-50
lines changed

8 files changed

+157
-50
lines changed

models/issue.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ func updateIssueCols(e Engine, issue *Issue, cols ...string) error {
554554
return nil
555555
}
556556

557-
func (issue *Issue) changeStatus(e *xorm.Session, doer *User, isClosed bool) (*Comment, error) {
557+
func (issue *Issue) changeStatus(e *xorm.Session, doer *User, isClosed, isMerge bool) (*Comment, error) {
558558
// Reload the issue
559559
currentIssue, err := getIssueByID(e, issue.ID)
560560
if err != nil {
@@ -623,10 +623,11 @@ func (issue *Issue) changeStatus(e *xorm.Session, doer *User, isClosed bool) (*C
623623
}
624624

625625
return createComment(e, &CreateCommentOptions{
626-
Type: cmtType,
627-
Doer: doer,
628-
Repo: issue.Repo,
629-
Issue: issue,
626+
Type: cmtType,
627+
Doer: doer,
628+
Repo: issue.Repo,
629+
Issue: issue,
630+
RemovedAssignee: isMerge, // use RemovedAssignee as isMerge
630631
})
631632
}
632633

@@ -645,7 +646,7 @@ func (issue *Issue) ChangeStatus(doer *User, isClosed bool) (*Comment, error) {
645646
return nil, err
646647
}
647648

648-
comment, err := issue.changeStatus(sess, doer, isClosed)
649+
comment, err := issue.changeStatus(sess, doer, isClosed, false)
649650
if err != nil {
650651
return nil, err
651652
}

models/issue_comment.go

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,10 @@ type Comment struct {
158158
RefAction references.XRefAction `xorm:"SMALLINT"` // What hapens if RefIssueID resolves
159159
RefIsPull bool
160160

161-
RefRepo *Repository `xorm:"-"`
162-
RefIssue *Issue `xorm:"-"`
163-
RefComment *Comment `xorm:"-"`
161+
RefRepo *Repository `xorm:"-"`
162+
RefIssue *Issue `xorm:"-"`
163+
RefComment *Comment `xorm:"-"`
164+
IsOfficeReview bool `xorm:"-"`
164165
}
165166

166167
// LoadIssue loads issue from database
@@ -502,6 +503,24 @@ func (c *Comment) UnsignedLine() uint64 {
502503
return uint64(c.Line)
503504
}
504505

506+
// LoadIsOfficeReview check if this is an office review
507+
func (c *Comment) LoadIsOfficeReview() (err error) {
508+
if c.Type == CommentTypeReview {
509+
c.IsOfficeReview, err = IsOfficialReviewer(c.Issue, c.Poster)
510+
if err != nil {
511+
return err
512+
}
513+
if !c.IsOfficeReview {
514+
perm, err := GetUserRepoPermission(c.Issue.Repo, c.Poster)
515+
if err != nil {
516+
return err
517+
}
518+
c.IsOfficeReview = perm.CanAccessAny(AccessModeWrite, UnitTypePullRequests)
519+
}
520+
}
521+
return
522+
}
523+
505524
// CodeCommentURL returns the url to a comment in code
506525
func (c *Comment) CodeCommentURL() string {
507526
err := c.LoadIssue()

models/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ func (pr *PullRequest) SetMerged() (bool, error) {
561561
return false, err
562562
}
563563

564-
if _, err := pr.Issue.changeStatus(sess, pr.Merger, true); err != nil {
564+
if _, err := pr.Issue.changeStatus(sess, pr.Merger, true, true); err != nil {
565565
return false, fmt.Errorf("Issue.changeStatus: %v", err)
566566
}
567567

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,7 @@ issues.context.edit = Edit
913913
issues.context.delete = Delete
914914
issues.no_content = There is no content yet.
915915
issues.close_issue = Close
916+
issues.pull_merged_at = `merged commit <a href="%[1]s">%[2]s</a> into <code>%[3]s</code> %[4]s`
916917
issues.close_comment_issue = Comment and Close
917918
issues.reopen_issue = Reopen
918919
issues.reopen_comment_issue = Comment and Reopen

routers/repo/issue.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,10 @@ func ViewIssue(ctx *context.Context) {
939939
ctx.ServerError("LoadReview", err)
940940
return
941941
}
942+
if err = comment.LoadIsOfficeReview(); err != nil {
943+
ctx.ServerError("LoadIsOfficeReview", err)
944+
return
945+
}
942946
participants = addParticipant(comment.Poster, participants)
943947
if comment.Review == nil {
944948
continue

templates/repo/issue/view_content/comments.tmpl

Lines changed: 53 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
{{ $createdStr:= TimeSinceUnix .CreatedUnix $.Lang }}
44

55
<!-- 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE_REF, 4 = COMMIT_REF,
6-
5 = COMMENT_REF, 6 = PULL_REF, 7 = COMMENT_LABEL, 12 = START_TRACKING,
7-
13 = STOP_TRACKING, 14 = ADD_TIME_MANUAL, 16 = ADDED_DEADLINE, 17 = MODIFIED_DEADLINE,
6+
5 = COMMENT_REF, 6 = PULL_REF, 7 = COMMENT_LABEL, 8 = COMMENT_MIlESTONE, 9 = COMMENT_ASSIGNEES,
7+
10 = COMMENT_CHANGE_TITLE, 11 = DELETE_BRANCH, 12 = START_TRACKING, 13 = STOP_TRACKING,
8+
14 = ADD_TIME_MANUAL, 15 = CANCEL_TRACKING, 16 = ADDED_DEADLINE, 17 = MODIFIED_DEADLINE,
89
18 = REMOVED_DEADLINE, 19 = ADD_DEPENDENCY, 20 = REMOVE_DEPENDENCY, 21 = CODE,
910
22 = REVIEW, 23 = ISSUE_LOCKED, 24 = ISSUE_UNLOCKED, 25 = TARGET_BRANCH_CHANGED,
1011
26 = DELETE_TIME_MANUAL -->
@@ -70,20 +71,35 @@
7071
</div>
7172
{{else if eq .Type 1}}
7273
<div class="event" id="{{.HashTag}}">
73-
{{svg "octicon-primitive-dot" 16}}
74+
<span class="issue-symbol bg-green white">{{svg "octicon-primitive-dot" 16}}</span>
7475
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
7576
<img src="{{.Poster.RelAvatarLink}}">
7677
</a>
7778
<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.GetDisplayName}}</a> {{$.i18n.Tr "repo.issues.reopened_at" .EventTag $createdStr | Safe}}</span>
7879
</div>
7980
{{else if eq .Type 2}}
8081
<div class="event" id="{{.HashTag}}">
81-
<span class="issue-symbol">{{svg "octicon-circle-slash" 16}}</span>
82+
<span class="issue-symbol {{if .RemovedAssignee}} bg-purple {{else}} bg-red {{end}} white">
83+
{{if .RemovedAssignee}}
84+
{{svg "octicon-git-merge" 16}}
85+
{{else}}
86+
{{svg "octicon-circle-slash" 16}}
87+
{{end}}
88+
</span>
8289
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
8390
<img src="{{.Poster.RelAvatarLink}}">
8491
</a>
85-
<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.GetDisplayName}}</a> {{$.i18n.Tr "repo.issues.closed_at" .EventTag $createdStr | Safe}}</span>
92+
<span class="text grey">
93+
<a href="{{.Poster.HomeLink}}">{{.Poster.GetDisplayName}}</a>
94+
{{if .RemovedAssignee}}
95+
{{$link := printf "%s/commit/%s" $.Repository.HTMLURL $.Issue.PullRequest.MergedCommitID}}
96+
{{$.i18n.Tr "repo.issues.pull_merged_at" $link (ShortSha $.Issue.PullRequest.MergedCommitID) $.BaseTarget $createdStr | Str2html}}
97+
{{else}}
98+
{{$.i18n.Tr "repo.issues.closed_at" .EventTag $createdStr | Safe}}
99+
{{end}}
100+
</span>
86101
</div>
102+
<div class="ui divider"></div>
87103
{{else if eq .Type 3 5 6}}
88104
{{ $refFrom:= "" }}
89105
{{if ne .RefRepoID .Issue.RepoID}}
@@ -99,7 +115,7 @@
99115
{{end}}
100116
{{ $createdStr:= TimeSinceUnix .CreatedUnix $.Lang }}
101117
<div class="event" id="{{.HashTag}}">
102-
{{svg "octicon-bookmark" 16}}
118+
<span class="issue-symbol green">{{svg "octicon-bookmark" 16}}</span>
103119
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
104120
<img src="{{.Poster.RelAvatarLink}}">
105121
</a>
@@ -115,7 +131,7 @@
115131
</div>
116132
{{else if eq .Type 4}}
117133
<div class="event" id="{{.HashTag}}">
118-
{{svg "octicon-bookmark" 16}}
134+
<span class="issue-symbol green">{{svg "octicon-bookmark" 16}}</span>
119135
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
120136
<img src="{{.Poster.RelAvatarLink}}">
121137
</a>
@@ -129,7 +145,7 @@
129145
{{else if eq .Type 7}}
130146
{{if .Label}}
131147
<div class="event" id="{{.HashTag}}">
132-
{{svg "octicon-primitive-dot" 16}}
148+
<span class="issue-symbol green">{{svg "octicon-tag" 16}}</span>
133149
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
134150
<img src="{{.Poster.RelAvatarLink}}">
135151
</a>
@@ -139,7 +155,7 @@
139155
{{end}}
140156
{{else if eq .Type 8}}
141157
<div class="event" id="{{.HashTag}}">
142-
{{svg "octicon-primitive-dot" 16}}
158+
<span class="issue-symbol green">{{svg "octicon-milestone" 16}}</span>
143159
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
144160
<img src="{{.Poster.RelAvatarLink}}">
145161
</a>
@@ -148,7 +164,7 @@
148164
</div>
149165
{{else if eq .Type 9}}
150166
<div class="event" id="{{.HashTag}}">
151-
{{svg "octicon-primitive-dot" 16}}
167+
<span class="issue-symbol green">{{svg "octicon-person" 16}}</span>
152168
{{if gt .AssigneeID 0}}
153169
{{if .RemovedAssignee}}
154170
<a class="ui avatar image" href="{{.Assignee.HomeLink}}">
@@ -179,7 +195,7 @@
179195
</div>
180196
{{else if eq .Type 10}}
181197
<div class="event" id="{{.HashTag}}">
182-
{{svg "octicon-primitive-dot" 16}}
198+
<span class="issue-symbol green">{{svg "octicon-pencil" 16}}</span>
183199
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
184200
<img src="{{.Poster.RelAvatarLink}}">
185201
</a>
@@ -189,7 +205,7 @@
189205
</div>
190206
{{else if eq .Type 11}}
191207
<div class="event" id="{{.HashTag}}">
192-
{{svg "octicon-primitive-dot" 16}}
208+
<span class="issue-symbol green">{{svg "octicon-git-branch" 16}}</span>
193209
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
194210
<img src="{{.Poster.RelAvatarLink}}">
195211
</a>
@@ -199,15 +215,15 @@
199215
</div>
200216
{{else if eq .Type 12}}
201217
<div class="event" id="{{.HashTag}}">
202-
{{svg "octicon-primitive-dot" 16}}
218+
<span class="issue-symbol green">{{svg "octicon-clock" 16}}</span>
203219
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
204220
<img src="{{.Poster.RelAvatarLink}}">
205221
</a>
206222
<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.GetDisplayName}}</a> {{$.i18n.Tr "repo.issues.start_tracking_history" $createdStr | Safe}}</span>
207223
</div>
208224
{{else if eq .Type 13}}
209225
<div class="event" id="{{.HashTag}}">
210-
{{svg "octicon-primitive-dot" 16}}
226+
<span class="issue-symbol green">{{svg "octicon-clock" 16}}</span>
211227
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
212228
<img src="{{.Poster.RelAvatarLink}}">
213229
</a>
@@ -220,7 +236,7 @@
220236
</div>
221237
{{else if eq .Type 14}}
222238
<div class="event" id="{{.HashTag}}">
223-
{{svg "octicon-primitive-dot" 16}}
239+
<span class="issue-symbol green">{{svg "octicon-clock" 16}}</span>
224240
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
225241
<img src="{{.Poster.RelAvatarLink}}">
226242
</a>
@@ -232,15 +248,15 @@
232248
</div>
233249
{{else if eq .Type 15}}
234250
<div class="event" id="{{.HashTag}}">
235-
{{svg "octicon-primitive-dot" 16}}
251+
<span class="issue-symbol green">{{svg "octicon-clock" 16}}</span>
236252
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
237253
<img src="{{.Poster.RelAvatarLink}}">
238254
</a>
239255
<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.GetDisplayName}}</a> {{$.i18n.Tr "repo.issues.cancel_tracking_history" $createdStr | Safe}}</span>
240256
</div>
241257
{{else if eq .Type 16}}
242258
<div class="event" id="{{.HashTag}}">
243-
{{svg "octicon-primitive-dot" 16}}
259+
<span class="issue-symbol green">{{svg "octicon-clock" 16}}</span>
244260
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
245261
<img src="{{.Poster.RelAvatarLink}}">
246262
</a>
@@ -250,7 +266,7 @@
250266
</div>
251267
{{else if eq .Type 17}}
252268
<div class="event" id="{{.HashTag}}">
253-
{{svg "octicon-primitive-dot" 16}}
269+
<span class="issue-symbol green">{{svg "octicon-clock" 16}}</span>
254270
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
255271
<img src="{{.Poster.RelAvatarLink}}">
256272
</a>
@@ -260,7 +276,7 @@
260276
</div>
261277
{{else if eq .Type 18}}
262278
<div class="event" id="{{.HashTag}}">
263-
{{svg "octicon-primitive-dot" 16}}
279+
<span class="issue-symbol green">{{svg "octicon-clock" 16}}</span>
264280
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
265281
<img src="{{.Poster.RelAvatarLink}}">
266282
</a>
@@ -270,7 +286,7 @@
270286
</div>
271287
{{else if eq .Type 19}}
272288
<div class="event" id="{{.HashTag}}">
273-
{{svg "octicon-primitive-dot" 16}}
289+
<span class="issue-symbol green">{{svg "octicon-dependent" 16}}</span>
274290
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
275291
<img src="{{.Poster.RelAvatarLink}}">
276292
</a>
@@ -294,7 +310,7 @@
294310
</div>
295311
{{else if eq .Type 20}}
296312
<div class="event" id="{{.HashTag}}">
297-
{{svg "octicon-primitive-dot" 16}}
313+
<span class="issue-symbol green">{{svg "octicon-dependent" 16}}</span>
298314
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
299315
<img src="{{.Poster.RelAvatarLink}}">
300316
</a>
@@ -318,10 +334,18 @@
318334
</div>
319335
{{else if eq .Type 22}}
320336
<div class="event" id="{{.HashTag}}">
321-
<span class="issue-symbol {{if eq .Review.Type 1}}green
322-
{{- else if eq .Review.Type 2}}grey
323-
{{- else if eq .Review.Type 3}}red
324-
{{- else}}grey{{end}}">{{svg (printf "octicon-%s" .Review.Type.Icon) 16}}</span>
337+
<span class="issue-symbol
338+
{{- if .IsOfficeReview}}
339+
{{- if eq .Review.Type 1}} bg-green white
340+
{{- else if eq .Review.Type 3}} bg-red white
341+
{{- else }} grey {{end}}
342+
{{- end}}
343+
{{- if not .IsOfficeReview}}
344+
{{- if eq .Review.Type 1}} green
345+
{{- else if eq .Review.Type 2}} grey
346+
{{- else if eq .Review.Type 3}} red
347+
{{- else}} grey{{end}}
348+
{{- end}}">{{svg (printf "octicon-%s" .Review.Type.Icon) 16}}</span>
325349
{{if .OriginalAuthor }}
326350
{{else}}
327351
<a class="ui avatar image"{{if gt .Poster.ID 0}} href="{{.Poster.HomeLink}}"{{end}}>
@@ -420,7 +444,7 @@
420444
</div>
421445
{{else if eq .Type 23}}
422446
<div class="event" id="{{.HashTag}}">
423-
<span class="issue-symbol">{{svg "octicon-lock" 16}}</span>
447+
<span class="issue-symbol green">{{svg "octicon-lock" 16}}</span>
424448
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
425449
<img src="{{.Poster.RelAvatarLink}}">
426450
</a>
@@ -437,7 +461,7 @@
437461
</div>
438462
{{else if eq .Type 24}}
439463
<div class="event" id="{{.HashTag}}">
440-
<span class="issue-symbol">{{svg "octicon-key" 16}}</span>
464+
<span class="issue-symbol green">{{svg "octicon-key" 16}}</span>
441465
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
442466
<img src="{{.Poster.RelAvatarLink}}">
443467
</a>
@@ -448,7 +472,7 @@
448472
</div>
449473
{{else if eq .Type 25}}
450474
<div class="event">
451-
{{svg "octicon-primitive-dot" 16}}
475+
<span class="issue-symbol green">{{svg "octicon-git-branch" 16}}</span>
452476
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
453477
<img src="{{.Poster.RelAvatarLink}}">
454478
</a>
@@ -458,13 +482,12 @@
458482
</div>
459483
{{else if eq .Type 26}}
460484
<div class="event" id="{{.HashTag}}">
461-
{{svg "octicon-primitive-dot" 16}}
485+
<span class="issue-symbol green">{{svg "octicon-clock" 16}}</span>
462486
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
463487
<img src="{{.Poster.RelAvatarLink}}">
464488
</a>
465489
<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.GetDisplayName}}</a> {{$.i18n.Tr "repo.issues.del_time_history" $createdStr | Safe}}</span>
466490
<div class="detail">
467-
{{svg "octicon-clock" 16}}
468491
<span class="text grey">{{.Content}}</span>
469492
</div>
470493
</div>

web_src/less/_base.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,9 @@ i.icon.centerlock {
11861186
span.purple & {
11871187
color: #a333c8;
11881188
}
1189+
span.white & {
1190+
color: white;
1191+
}
11891192
}
11901193

11911194
.ui.popup .ui.label {

0 commit comments

Comments
 (0)