summaryrefslogtreecommitdiffstats
path: root/templates/repo/issue/view_content/comments.tmpl
blob: ee10ff56f04aa42e9bdf94edaa5c0fc38afe3e4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
{{range .Issue.Comments}}
	{{ $createdStr:= TimeSinceUnix .CreatedUnix $.Lang }}

	<!-- 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE_REF, 4 = COMMIT_REF, 5 = COMMENT_REF, 6 = PULL_REF, 7 = COMMENT_LABEL, 12 = START_TRACKING, 13 = STOP_TRACKING, 14 = ADD_TIME_MANUAL, 16 = ADDED_DEADLINE, 17 = MODIFIED_DEADLINE, 18 = REMOVED_DEADLINE, 19 = ADD_DEPENDENCY, 20 = REMOVE_DEPENDENCY, 21 = CODE, 22 = REVIEW -->
	{{if eq .Type 0}}
		<div class="comment" id="{{.HashTag}}">
			<a class="avatar" {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<div class="content">
				<div class="ui top attached header">
					<span class="text grey"><a {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdStr | Safe}}</span>
					<div class="ui right actions">
						{{if gt .ShowTag 0}}
							<div class="item tag">
								{{if eq .ShowTag 1}}
									{{$.i18n.Tr "repo.issues.poster"}}
								{{else if eq .ShowTag 2}}
									{{$.i18n.Tr "repo.issues.collaborator"}}
								{{else if eq .ShowTag 3}}
									{{$.i18n.Tr "repo.issues.owner"}}
								{{end}}
							</div>
						{{end}}
						{{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) }}
						{{if or $.IsRepositoryAdmin (eq .Poster.ID $.SignedUserID)}}
							<div class="item action">
								<a class="edit-content" href="#"><i class="octicon octicon-pencil"></i></a>
								<a class="delete-comment" href="#" data-comment-id={{.HashTag}} data-url="{{$.RepoLink}}/comments/{{.ID}}/delete" data-locale="{{$.i18n.Tr "repo.issues.delete_comment_confirm"}}"><i class="octicon octicon-x"></i></a>
							</div>
						{{end}}
					</div>
				</div>
				<div class="ui attached segment">
					<div class="render-content markdown has-emoji">
						{{if .RenderedContent}}
							{{.RenderedContent|Str2html}}
						{{else}}
							<span class="no-content">{{$.i18n.Tr "repo.issues.no_content"}}</span>
						{{end}}
					</div>
					<div class="raw-content hide">{{.Content}}</div>
					<div class="edit-content-zone hide" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}"></div>
				</div>
				{{$reactions := .Reactions.GroupByType}}
				{{if $reactions}}
					<div class="ui attached segment reactions">
						{{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions }}
					</div>
				{{end}}
				{{if .Attachments}}
					<div class="ui bottom attached segment">
						<div class="ui small images">
							{{range .Attachments}}
								<a target="_blank" rel="noopener noreferrer" href="{{AppSubUrl}}/attachments/{{.UUID}}">
									{{if FilenameIsImage .Name}}
										<img class="ui image" src="{{AppSubUrl}}/attachments/{{.UUID}}" title='{{$.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'>
									{{else}}
										<span class="ui image octicon octicon-desktop-download" title='{{$.i18n.Tr "repo.issues.attachment.download" .Name}}'></span>
									{{end}}
								</a>
							{{end}}
						</div>
					</div>
				{{end}}
			</div>
		</div>
	{{else if eq .Type 1}}
		<div class="event">
			<span class="octicon octicon-primitive-dot"></span>
			<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.reopened_at" .EventTag $createdStr | Safe}}</span>
		</div>
	{{else if eq .Type 2}}
		<div class="event">
			<span class="octicon octicon-circle-slash"></span>
			<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.closed_at" .EventTag $createdStr | Safe}}</span>
		</div>
	{{else if eq .Type 4}}
		<div class="event">
			<span class="octicon octicon-bookmark"></span>
			<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.commit_ref_at" .EventTag $createdStr | Safe}}</span>

			<div class="detail">
				<span class="octicon octicon-git-commit"></span>
				<span class="text grey">{{.Content | Str2html}}</span>
			</div>
		</div>
	{{else if eq .Type 7}}
		{{if .Label}}
			<div class="event">
				<span class="octicon octicon-primitive-dot"></span>
				<a class="ui avatar image" href="{{.Poster.HomeLink}}">
					<img src="{{.Poster.RelAvatarLink}}">
				</a>
				<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
				{{if .Content}}{{$.i18n.Tr "repo.issues.add_label_at" .Label.ForegroundColor .Label.Color (.Label.Name|Escape) $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_label_at" .Label.ForegroundColor .Label.Color (.Label.Name|Escape) $createdStr | Safe}}{{end}}</span>
			</div>
		{{end}}
	{{else if eq .Type 8}}
		<div class="event">
			<span class="octicon octicon-primitive-dot"></span>
			<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
			{{if gt .OldMilestoneID 0}}{{if gt .MilestoneID 0}}{{$.i18n.Tr "repo.issues.change_milestone_at" (.OldMilestone.Name|Escape) (.Milestone.Name|Escape) $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_milestone_at" (.OldMilestone.Name|Escape) $createdStr | Safe}}{{end}}{{else if gt .MilestoneID 0}}{{$.i18n.Tr "repo.issues.add_milestone_at" (.Milestone.Name|Escape) $createdStr | Safe}}{{end}}</span>
		</div>
	{{else if eq .Type 9}}
		<div class="event">
			<span class="octicon octicon-primitive-dot"></span>
			{{if gt .AssigneeID 0}}
				{{if .RemovedAssignee}}
					<a class="ui avatar image" href="{{.Assignee.HomeLink}}">
						<img src="{{.Assignee.RelAvatarLink}}">
					</a>
					<span class="text grey">
						<a href="{{.Assignee.HomeLink}}">{{.Assignee.Name}}</a>
						{{$.i18n.Tr "repo.issues.remove_assignee_at" $createdStr | Safe}}
					</span>
				{{else}}
					<a class="ui avatar image" href="{{.Assignee.HomeLink}}">
						<img src="{{.Assignee.RelAvatarLink}}">
					</a>
					<span class="text grey">
						<a href="{{.Assignee.HomeLink}}">{{.Assignee.Name}}</a>
						{{if eq .Poster.ID .AssigneeID}}
							{{$.i18n.Tr "repo.issues.self_assign_at" $createdStr | Safe}}
						{{else}}
							{{$.i18n.Tr "repo.issues.add_assignee_at" .Poster.Name $createdStr | Safe}}
						{{end}}
					</span>
				{{end}}
			{{end}}
		</div>
	{{else if eq .Type 10}}
		<div class="event">
			<span class="octicon octicon-primitive-dot"></span>
			<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
			{{$.i18n.Tr "repo.issues.change_title_at" (.OldTitle|Escape) (.NewTitle|Escape) $createdStr | Safe}}
			</span>
		</div>
	{{else if eq .Type 11}}
		<div class="event">
			<span class="octicon octicon-primitive-dot"></span>
			<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
			{{$.i18n.Tr "repo.issues.delete_branch_at" (.CommitSHA|Escape) $createdStr | Safe}}
			</span>
		</div>
    {{else if eq .Type 12}}
		<div class="event">
			<span class="octicon octicon-primitive-dot"></span>
			<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.start_tracking_history"  $createdStr | Safe}}</span>
		</div>
	{{else if eq .Type 13}}
		<div class="event">
			<span class="octicon octicon-primitive-dot"></span>
			<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.stop_tracking_history"  $createdStr | Safe}}</span>

			<div class="detail">
				<span class="octicon octicon-clock"></span>
				<span class="text grey">{{.Content}}</span>
			</div>
		</div>
	{{else if eq .Type 14}}
		<div class="event">
			<span class="octicon octicon-primitive-dot"></span>
			<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.add_time_history"  $createdStr | Safe}}</span>
			<div class="detail">
				<span class="octicon octicon-clock"></span>
				<span class="text grey">{{.Content}}</span>
			</div>
		</div>
	{{else if eq .Type 15}}
		<div class="event">
			<span class="octicon octicon-primitive-dot"></span>
			<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.cancel_tracking_history"  $createdStr | Safe}}</span>
		</div>
	{{else if eq .Type 16}}
		<div class="event">
			<span class="octicon octicon-primitive-dot"></span>
			<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
			{{$.i18n.Tr "repo.issues.due_date_added" .Content $createdStr | Safe}}
			</span>
		</div>
	{{else if eq .Type 17}}
		<div class="event">
			<span class="octicon octicon-primitive-dot"></span>
			<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
			{{$.i18n.Tr "repo.issues.due_date_modified" (.Content | ParseDeadline) $createdStr | Safe}}
			</span>
		</div>
	{{else if eq .Type 18}}
		<div class="event">
			<span class="octicon octicon-primitive-dot"></span>
			<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
			</a>
			<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
			{{$.i18n.Tr "repo.issues.due_date_remove" .Content $createdStr | Safe}}
			</span>
		</div>
	{{else if eq .Type 19}}
		<div class="event">
	    	<span class="octicon octicon-primitive-dot"></span>
	    	<a class="ui avatar image" href="{{.Poster.HomeLink}}">
				<img src="{{.Poster.RelAvatarLink}}">
	     	</a>
	     	<span class="text grey">
		     	{{$.i18n.Tr "repo.issues.dependency.added_dependency" .Poster.HomeLink .Poster.Name $createdStr | Safe}}
	     	</span>
	     	<div class="detail">
		    	<span class="octicon octicon-plus"></span>
			 	<span class="text grey"><a href="{{$.RepoLink}}/issues/{{.DependentIssue.Index}}">#{{.DependentIssue.Index}} {{.DependentIssue.Title}}</a></span>
		 	</div>
     	</div>
	{{else if eq .Type 20}}
		<div class="event">
	     	<span class="octicon octicon-primitive-dot"></span>
	     	<a class="ui avatar image" href="{{.Poster.HomeLink}}">
		     	<img src="{{.Poster.RelAvatarLink}}">
	     	</a>
	     	<span class="text grey">
		     	{{$.i18n.Tr "repo.issues.dependency.removed_dependency" .Poster.HomeLink .Poster.Name $createdStr | Safe}}
	     	</span>
	     	<div class="detail">
		     	<span class="text grey octicon octicon-trashcan"></span>
			 	<span class="text grey"><a href="{{$.RepoLink}}/issues/{{.DependentIssue.Index}}">#{{.DependentIssue.Index}} {{.DependentIssue.Title}}</a></span>
	     	</div>
     	</div>
	{{else if eq .Type 22}}
	    <div class="event" id="{{.HashTag}}">
	    	<span class="octicon octicon-{{.Review.Type.Icon}}"></span>
	    	<a class="ui avatar image" href="{{.Poster.HomeLink}}">
	    		<img src="{{.Poster.RelAvatarLink}}">
	    	</a>
	    	<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
	    		{{if eq .Review.Type 1}}
	    			{{$.i18n.Tr "repo.issues.review.approve" $createdStr | Safe}}
	    		{{else if eq .Review.Type 2}}
	    			{{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
	    		{{else if eq .Review.Type 3}}
	    			{{$.i18n.Tr "repo.issues.review.reject" $createdStr | Safe}}
	    		{{else}}
	    			{{$.i18n.Tr "repo.issues.review.comment" $createdStr | Safe}}
	    		{{end}}
	    	</span>
	    	{{if .Content}}
	    		<div class="detail">
					<span class="octicon octicon-quote"></span>
	    			<span class="text grey">{{.Content}}</span>
	    		</div>
	    	{{end}}
			{{ range $filename, $lines := .Review.CodeComments}}
				{{range $line, $comms := $lines}}
						<div class="ui segments">
							<div class="ui segment">
								{{$invalid := (index $comms 0).Invalidated}}
							{{if $invalid}}
								<button id="show-outdated-{{(index $comms 0).ID}}" data-comment="{{(index $comms 0).ID}}" class="ui compact right labeled button show-outdated">
									<i class="octicon octicon-fold"></i>
									{{$.i18n.Tr "repo.issues.review.show_outdated"}}
								</button>
								<button id="hide-outdated-{{(index $comms 0).ID}}" data-comment="{{(index $comms 0).ID}}" class="hide ui compact right labeled button hide-outdated">
									<i class="octicon octicon-fold"></i>
									{{$.i18n.Tr "repo.issues.review.hide_outdated"}}
								</button>
							{{end}}
								<a href="{{(index $comms 0).CodeCommentURL}}" class="file-comment">{{$filename}}</a>
							</div>
							{{$diff := ((index $comms 0).MustAsDiff)}}
							{{if $diff}}
								{{$file := (index $diff.Files 0)}}
								<div id="code-preview-{{(index $comms 0).ID}}" class="ui table segment{{if $invalid}} hide{{end}}">
									<div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}">
										<div class="file-body file-code code-view code-diff code-diff-unified">
											<table>
												<tbody>
													{{template "repo/diff/section_unified" dict "file" $file "root" $}}
												</tbody>
											</table>
										</div>
									</div>
								</div>
							{{end}}
							<div id="code-comments-{{(index $comms 0).ID}}" class="ui segment{{if $invalid}} hide{{end}}">
								<div class="ui comments">
									{{range $comms}}
										{{ $createdSubStr:= TimeSinceUnix .CreatedUnix $.Lang }}
										<div class="comment" id="{{.HashTag}}">
											<a class="avatar">
												<img src="{{.Poster.RelAvatarLink}}">
											</a>
											<div class="content">
												<a class="author" {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.Name}}</a>
												<div class="metadata">
													<span class="date">{{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdSubStr | Safe}}</span>
												</div>
												<div class="text">
													<div class="render-content markdown has-emoji">
													{{if .RenderedContent}}
														{{.RenderedContent|Str2html}}
													{{else}}
														<span class="no-content">{{$.i18n.Tr "repo.issues.no_content"}}</span>
													{{end}}
													</div>
													<div class="raw-content hide">{{.Content}}</div>
												</div>
											</div>
										</div>
									{{end}}
								</div>
								{{template "repo/diff/comment_form_datahandler" dict "hidden" true "reply" true "root" $ "comment" (index $comms 0)}}
							</div>
						</div>
				{{end}}
			{{end}}
	    </div>
	{{end}}
{{end}}