Show More
@@ -1,400 +1,405 b'' | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | ## usage: |
|
2 | ## usage: | |
3 | ## <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/> |
|
3 | ## <%namespace name="comment" file="/changeset/changeset_file_comment.mako"/> | |
4 | ## ${comment.comment_block(comment)} |
|
4 | ## ${comment.comment_block(comment)} | |
5 | ## |
|
5 | ## | |
6 | <%namespace name="base" file="/base/base.mako"/> |
|
6 | <%namespace name="base" file="/base/base.mako"/> | |
7 |
|
7 | |||
8 | <%def name="comment_block(comment, inline=False)"> |
|
8 | <%def name="comment_block(comment, inline=False)"> | |
9 | <% pr_index_ver = comment.get_index_version(getattr(c, 'versions', [])) %> |
|
9 | <% pr_index_ver = comment.get_index_version(getattr(c, 'versions', [])) %> | |
10 | % if inline: |
|
10 | % if inline: | |
11 | <% outdated_at_ver = comment.outdated_at_version(getattr(c, 'at_version_num', None)) %> |
|
11 | <% outdated_at_ver = comment.outdated_at_version(getattr(c, 'at_version_num', None)) %> | |
12 | % else: |
|
12 | % else: | |
13 | <% outdated_at_ver = comment.older_than_version(getattr(c, 'at_version_num', None)) %> |
|
13 | <% outdated_at_ver = comment.older_than_version(getattr(c, 'at_version_num', None)) %> | |
14 | % endif |
|
14 | % endif | |
15 |
|
15 | |||
16 |
|
16 | |||
17 | <div class="comment |
|
17 | <div class="comment | |
18 | ${'comment-inline' if inline else 'comment-general'} |
|
18 | ${'comment-inline' if inline else 'comment-general'} | |
19 | ${'comment-outdated' if outdated_at_ver else 'comment-current'}" |
|
19 | ${'comment-outdated' if outdated_at_ver else 'comment-current'}" | |
20 | id="comment-${comment.comment_id}" |
|
20 | id="comment-${comment.comment_id}" | |
21 | line="${comment.line_no}" |
|
21 | line="${comment.line_no}" | |
22 | data-comment-id="${comment.comment_id}" |
|
22 | data-comment-id="${comment.comment_id}" | |
23 | data-comment-type="${comment.comment_type}" |
|
23 | data-comment-type="${comment.comment_type}" | |
24 | data-comment-inline=${h.json.dumps(inline)} |
|
24 | data-comment-inline=${h.json.dumps(inline)} | |
25 | style="${'display: none;' if outdated_at_ver else ''}"> |
|
25 | style="${'display: none;' if outdated_at_ver else ''}"> | |
26 |
|
26 | |||
27 | <div class="meta"> |
|
27 | <div class="meta"> | |
28 | <div class="comment-type-label"> |
|
28 | <div class="comment-type-label"> | |
29 | <div class="comment-label ${comment.comment_type or 'note'}" id="comment-label-${comment.comment_id}"> |
|
29 | <div class="comment-label ${comment.comment_type or 'note'}" id="comment-label-${comment.comment_id}"> | |
30 | % if comment.comment_type == 'todo': |
|
30 | % if comment.comment_type == 'todo': | |
31 | % if comment.resolved: |
|
31 | % if comment.resolved: | |
32 | <div class="resolved tooltip" title="${_('Resolved by comment #{}').format(comment.resolved.comment_id)}"> |
|
32 | <div class="resolved tooltip" title="${_('Resolved by comment #{}').format(comment.resolved.comment_id)}"> | |
33 | <a href="#comment-${comment.resolved.comment_id}">${comment.comment_type}</a> |
|
33 | <a href="#comment-${comment.resolved.comment_id}">${comment.comment_type}</a> | |
34 | </div> |
|
34 | </div> | |
35 | % else: |
|
35 | % else: | |
36 | <div class="resolved tooltip" style="display: none"> |
|
36 | <div class="resolved tooltip" style="display: none"> | |
37 | <span>${comment.comment_type}</span> |
|
37 | <span>${comment.comment_type}</span> | |
38 | </div> |
|
38 | </div> | |
39 | <div class="resolve tooltip" onclick="return Rhodecode.comments.createResolutionComment(${comment.comment_id});" title="${_('Click to resolve this comment')}"> |
|
39 | <div class="resolve tooltip" onclick="return Rhodecode.comments.createResolutionComment(${comment.comment_id});" title="${_('Click to resolve this comment')}"> | |
40 | ${comment.comment_type} |
|
40 | ${comment.comment_type} | |
41 | </div> |
|
41 | </div> | |
42 | % endif |
|
42 | % endif | |
43 | % else: |
|
43 | % else: | |
44 | % if comment.resolved_comment: |
|
44 | % if comment.resolved_comment: | |
45 | fix |
|
45 | fix | |
46 | % else: |
|
46 | % else: | |
47 | ${comment.comment_type or 'note'} |
|
47 | ${comment.comment_type or 'note'} | |
48 | % endif |
|
48 | % endif | |
49 | % endif |
|
49 | % endif | |
50 | </div> |
|
50 | </div> | |
51 | </div> |
|
51 | </div> | |
52 |
|
52 | |||
53 | <div class="author ${'author-inline' if inline else 'author-general'}"> |
|
53 | <div class="author ${'author-inline' if inline else 'author-general'}"> | |
54 | ${base.gravatar_with_user(comment.author.email, 16)} |
|
54 | ${base.gravatar_with_user(comment.author.email, 16)} | |
55 | </div> |
|
55 | </div> | |
56 | <div class="date"> |
|
56 | <div class="date"> | |
57 | ${h.age_component(comment.modified_at, time_is_local=True)} |
|
57 | ${h.age_component(comment.modified_at, time_is_local=True)} | |
58 | </div> |
|
58 | </div> | |
59 | % if inline: |
|
59 | % if inline: | |
60 | <span></span> |
|
60 | <span></span> | |
61 | % else: |
|
61 | % else: | |
62 | <div class="status-change"> |
|
62 | <div class="status-change"> | |
63 | % if comment.pull_request: |
|
63 | % if comment.pull_request: | |
64 | <a href="${h.url('pullrequest_show',repo_name=comment.pull_request.target_repo.repo_name,pull_request_id=comment.pull_request.pull_request_id)}"> |
|
64 | <a href="${h.url('pullrequest_show',repo_name=comment.pull_request.target_repo.repo_name,pull_request_id=comment.pull_request.pull_request_id)}"> | |
65 | % if comment.status_change: |
|
65 | % if comment.status_change: | |
66 | ${_('pull request #%s') % comment.pull_request.pull_request_id}: |
|
66 | ${_('pull request #%s') % comment.pull_request.pull_request_id}: | |
67 | % else: |
|
67 | % else: | |
68 | ${_('pull request #%s') % comment.pull_request.pull_request_id} |
|
68 | ${_('pull request #%s') % comment.pull_request.pull_request_id} | |
69 | % endif |
|
69 | % endif | |
70 | </a> |
|
70 | </a> | |
71 | % else: |
|
71 | % else: | |
72 | % if comment.status_change: |
|
72 | % if comment.status_change: | |
73 | ${_('Status change on commit')}: |
|
73 | ${_('Status change on commit')}: | |
74 | % endif |
|
74 | % endif | |
75 | % endif |
|
75 | % endif | |
76 | </div> |
|
76 | </div> | |
77 | % endif |
|
77 | % endif | |
78 |
|
78 | |||
79 | % if comment.status_change: |
|
79 | % if comment.status_change: | |
80 | <div class="${'flag_status %s' % comment.status_change[0].status}"></div> |
|
80 | <div class="${'flag_status %s' % comment.status_change[0].status}"></div> | |
81 | <div title="${_('Commit status')}" class="changeset-status-lbl"> |
|
81 | <div title="${_('Commit status')}" class="changeset-status-lbl"> | |
82 | ${comment.status_change[0].status_lbl} |
|
82 | ${comment.status_change[0].status_lbl} | |
83 | </div> |
|
83 | </div> | |
84 | % endif |
|
84 | % endif | |
85 |
|
85 | |||
86 | % if comment.resolved_comment: |
|
86 | % if comment.resolved_comment: | |
87 | <a class="has-spacer-before" href="#comment-${comment.resolved_comment.comment_id}" onclick="Rhodecode.comments.scrollToComment($('#comment-${comment.resolved_comment.comment_id}'), 0, ${h.json.dumps(comment.resolved_comment.outdated)})"> |
|
87 | <a class="has-spacer-before" href="#comment-${comment.resolved_comment.comment_id}" onclick="Rhodecode.comments.scrollToComment($('#comment-${comment.resolved_comment.comment_id}'), 0, ${h.json.dumps(comment.resolved_comment.outdated)})"> | |
88 | ${_('resolves comment #{}').format(comment.resolved_comment.comment_id)} |
|
88 | ${_('resolves comment #{}').format(comment.resolved_comment.comment_id)} | |
89 | </a> |
|
89 | </a> | |
90 | % endif |
|
90 | % endif | |
91 |
|
91 | |||
92 | <a class="permalink" href="#comment-${comment.comment_id}"> ¶</a> |
|
92 | <a class="permalink" href="#comment-${comment.comment_id}"> ¶</a> | |
93 |
|
93 | |||
94 | <div class="comment-links-block"> |
|
94 | <div class="comment-links-block"> | |
95 |
|
95 | % if comment.pull_request and comment.pull_request.author.user_id == comment.author.user_id: | ||
|
96 | <span class="tag authortag tooltip" title="${_('Pull request author')}"> | |||
|
97 | ${_('author')} | |||
|
98 | </span> | |||
|
99 | | | |||
|
100 | % endif | |||
96 | % if inline: |
|
101 | % if inline: | |
97 | <div class="pr-version-inline"> |
|
102 | <div class="pr-version-inline"> | |
98 | <a href="${h.url.current(version=comment.pull_request_version_id, anchor='comment-{}'.format(comment.comment_id))}"> |
|
103 | <a href="${h.url.current(version=comment.pull_request_version_id, anchor='comment-{}'.format(comment.comment_id))}"> | |
99 | % if outdated_at_ver: |
|
104 | % if outdated_at_ver: | |
100 | <code class="pr-version-num" title="${_('Outdated comment from pull request version {0}').format(pr_index_ver)}"> |
|
105 | <code class="pr-version-num" title="${_('Outdated comment from pull request version {0}').format(pr_index_ver)}"> | |
101 | outdated ${'v{}'.format(pr_index_ver)} | |
|
106 | outdated ${'v{}'.format(pr_index_ver)} | | |
102 | </code> |
|
107 | </code> | |
103 | % elif pr_index_ver: |
|
108 | % elif pr_index_ver: | |
104 | <code class="pr-version-num" title="${_('Comment from pull request version {0}').format(pr_index_ver)}"> |
|
109 | <code class="pr-version-num" title="${_('Comment from pull request version {0}').format(pr_index_ver)}"> | |
105 | ${'v{}'.format(pr_index_ver)} | |
|
110 | ${'v{}'.format(pr_index_ver)} | | |
106 | </code> |
|
111 | </code> | |
107 | % endif |
|
112 | % endif | |
108 | </a> |
|
113 | </a> | |
109 | </div> |
|
114 | </div> | |
110 | % else: |
|
115 | % else: | |
111 | % if comment.pull_request_version_id and pr_index_ver: |
|
116 | % if comment.pull_request_version_id and pr_index_ver: | |
112 | | |
|
117 | | | |
113 | <div class="pr-version"> |
|
118 | <div class="pr-version"> | |
114 | % if comment.outdated: |
|
119 | % if comment.outdated: | |
115 | <a href="?version=${comment.pull_request_version_id}#comment-${comment.comment_id}"> |
|
120 | <a href="?version=${comment.pull_request_version_id}#comment-${comment.comment_id}"> | |
116 | ${_('Outdated comment from pull request version {}').format(pr_index_ver)} |
|
121 | ${_('Outdated comment from pull request version {}').format(pr_index_ver)} | |
117 | </a> |
|
122 | </a> | |
118 | % else: |
|
123 | % else: | |
119 | <div title="${_('Comment from pull request version {0}').format(pr_index_ver)}"> |
|
124 | <div title="${_('Comment from pull request version {0}').format(pr_index_ver)}"> | |
120 | <a href="${h.url('pullrequest_show',repo_name=comment.pull_request.target_repo.repo_name,pull_request_id=comment.pull_request.pull_request_id, version=comment.pull_request_version_id)}"> |
|
125 | <a href="${h.url('pullrequest_show',repo_name=comment.pull_request.target_repo.repo_name,pull_request_id=comment.pull_request.pull_request_id, version=comment.pull_request_version_id)}"> | |
121 | <code class="pr-version-num"> |
|
126 | <code class="pr-version-num"> | |
122 | ${'v{}'.format(pr_index_ver)} |
|
127 | ${'v{}'.format(pr_index_ver)} | |
123 | </code> |
|
128 | </code> | |
124 | </a> |
|
129 | </a> | |
125 | </div> |
|
130 | </div> | |
126 | % endif |
|
131 | % endif | |
127 | </div> |
|
132 | </div> | |
128 | % endif |
|
133 | % endif | |
129 | % endif |
|
134 | % endif | |
130 |
|
135 | |||
131 | ## show delete comment if it's not a PR (regular comments) or it's PR that is not closed |
|
136 | ## show delete comment if it's not a PR (regular comments) or it's PR that is not closed | |
132 | ## only super-admin, repo admin OR comment owner can delete, also hide delete if currently viewed comment is outdated |
|
137 | ## only super-admin, repo admin OR comment owner can delete, also hide delete if currently viewed comment is outdated | |
133 | %if not outdated_at_ver and (not comment.pull_request or (comment.pull_request and not comment.pull_request.is_closed())): |
|
138 | %if not outdated_at_ver and (not comment.pull_request or (comment.pull_request and not comment.pull_request.is_closed())): | |
134 | ## permissions to delete |
|
139 | ## permissions to delete | |
135 | %if h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or comment.author.user_id == c.rhodecode_user.user_id: |
|
140 | %if h.HasPermissionAny('hg.admin')() or h.HasRepoPermissionAny('repository.admin')(c.repo_name) or comment.author.user_id == c.rhodecode_user.user_id: | |
136 | ## TODO: dan: add edit comment here |
|
141 | ## TODO: dan: add edit comment here | |
137 | <a onclick="return Rhodecode.comments.deleteComment(this);" class="delete-comment"> ${_('Delete')}</a> |
|
142 | <a onclick="return Rhodecode.comments.deleteComment(this);" class="delete-comment"> ${_('Delete')}</a> | |
138 | %else: |
|
143 | %else: | |
139 | <button class="btn-link" disabled="disabled"> ${_('Delete')}</button> |
|
144 | <button class="btn-link" disabled="disabled"> ${_('Delete')}</button> | |
140 | %endif |
|
145 | %endif | |
141 | %else: |
|
146 | %else: | |
142 | <button class="btn-link" disabled="disabled"> ${_('Delete')}</button> |
|
147 | <button class="btn-link" disabled="disabled"> ${_('Delete')}</button> | |
143 | %endif |
|
148 | %endif | |
144 |
|
149 | |||
145 | % if outdated_at_ver: |
|
150 | % if outdated_at_ver: | |
146 | | <a onclick="return Rhodecode.comments.prevOutdatedComment(this);" class="prev-comment"> ${_('Prev')}</a> |
|
151 | | <a onclick="return Rhodecode.comments.prevOutdatedComment(this);" class="prev-comment"> ${_('Prev')}</a> | |
147 | | <a onclick="return Rhodecode.comments.nextOutdatedComment(this);" class="next-comment"> ${_('Next')}</a> |
|
152 | | <a onclick="return Rhodecode.comments.nextOutdatedComment(this);" class="next-comment"> ${_('Next')}</a> | |
148 | % else: |
|
153 | % else: | |
149 | | <a onclick="return Rhodecode.comments.prevComment(this);" class="prev-comment"> ${_('Prev')}</a> |
|
154 | | <a onclick="return Rhodecode.comments.prevComment(this);" class="prev-comment"> ${_('Prev')}</a> | |
150 | | <a onclick="return Rhodecode.comments.nextComment(this);" class="next-comment"> ${_('Next')}</a> |
|
155 | | <a onclick="return Rhodecode.comments.nextComment(this);" class="next-comment"> ${_('Next')}</a> | |
151 | % endif |
|
156 | % endif | |
152 |
|
157 | |||
153 | </div> |
|
158 | </div> | |
154 | </div> |
|
159 | </div> | |
155 | <div class="text"> |
|
160 | <div class="text"> | |
156 | ${comment.render(mentions=True)|n} |
|
161 | ${comment.render(mentions=True)|n} | |
157 | </div> |
|
162 | </div> | |
158 |
|
163 | |||
159 | </div> |
|
164 | </div> | |
160 | </%def> |
|
165 | </%def> | |
161 |
|
166 | |||
162 | ## generate main comments |
|
167 | ## generate main comments | |
163 | <%def name="generate_comments(comments, include_pull_request=False, is_pull_request=False)"> |
|
168 | <%def name="generate_comments(comments, include_pull_request=False, is_pull_request=False)"> | |
164 | <div class="general-comments" id="comments"> |
|
169 | <div class="general-comments" id="comments"> | |
165 | %for comment in comments: |
|
170 | %for comment in comments: | |
166 | <div id="comment-tr-${comment.comment_id}"> |
|
171 | <div id="comment-tr-${comment.comment_id}"> | |
167 | ## only render comments that are not from pull request, or from |
|
172 | ## only render comments that are not from pull request, or from | |
168 | ## pull request and a status change |
|
173 | ## pull request and a status change | |
169 | %if not comment.pull_request or (comment.pull_request and comment.status_change) or include_pull_request: |
|
174 | %if not comment.pull_request or (comment.pull_request and comment.status_change) or include_pull_request: | |
170 | ${comment_block(comment)} |
|
175 | ${comment_block(comment)} | |
171 | %endif |
|
176 | %endif | |
172 | </div> |
|
177 | </div> | |
173 | %endfor |
|
178 | %endfor | |
174 | ## to anchor ajax comments |
|
179 | ## to anchor ajax comments | |
175 | <div id="injected_page_comments"></div> |
|
180 | <div id="injected_page_comments"></div> | |
176 | </div> |
|
181 | </div> | |
177 | </%def> |
|
182 | </%def> | |
178 |
|
183 | |||
179 |
|
184 | |||
180 | <%def name="comments(post_url, cur_status, is_pull_request=False, is_compare=False, change_status=True, form_extras=None)"> |
|
185 | <%def name="comments(post_url, cur_status, is_pull_request=False, is_compare=False, change_status=True, form_extras=None)"> | |
181 |
|
186 | |||
182 | <div class="comments"> |
|
187 | <div class="comments"> | |
183 | <% |
|
188 | <% | |
184 | if is_pull_request: |
|
189 | if is_pull_request: | |
185 | placeholder = _('Leave a comment on this Pull Request.') |
|
190 | placeholder = _('Leave a comment on this Pull Request.') | |
186 | elif is_compare: |
|
191 | elif is_compare: | |
187 | placeholder = _('Leave a comment on {} commits in this range.').format(len(form_extras)) |
|
192 | placeholder = _('Leave a comment on {} commits in this range.').format(len(form_extras)) | |
188 | else: |
|
193 | else: | |
189 | placeholder = _('Leave a comment on this Commit.') |
|
194 | placeholder = _('Leave a comment on this Commit.') | |
190 | %> |
|
195 | %> | |
191 |
|
196 | |||
192 | % if c.rhodecode_user.username != h.DEFAULT_USER: |
|
197 | % if c.rhodecode_user.username != h.DEFAULT_USER: | |
193 | <div class="js-template" id="cb-comment-general-form-template"> |
|
198 | <div class="js-template" id="cb-comment-general-form-template"> | |
194 | ## template generated for injection |
|
199 | ## template generated for injection | |
195 | ${comment_form(form_type='general', review_statuses=c.commit_statuses, form_extras=form_extras)} |
|
200 | ${comment_form(form_type='general', review_statuses=c.commit_statuses, form_extras=form_extras)} | |
196 | </div> |
|
201 | </div> | |
197 |
|
202 | |||
198 | <div id="cb-comment-general-form-placeholder" class="comment-form ac"> |
|
203 | <div id="cb-comment-general-form-placeholder" class="comment-form ac"> | |
199 | ## inject form here |
|
204 | ## inject form here | |
200 | </div> |
|
205 | </div> | |
201 | <script type="text/javascript"> |
|
206 | <script type="text/javascript"> | |
202 | var lineNo = 'general'; |
|
207 | var lineNo = 'general'; | |
203 | var resolvesCommentId = null; |
|
208 | var resolvesCommentId = null; | |
204 | var generalCommentForm = Rhodecode.comments.createGeneralComment( |
|
209 | var generalCommentForm = Rhodecode.comments.createGeneralComment( | |
205 | lineNo, "${placeholder}", resolvesCommentId); |
|
210 | lineNo, "${placeholder}", resolvesCommentId); | |
206 |
|
211 | |||
207 | // set custom success callback on rangeCommit |
|
212 | // set custom success callback on rangeCommit | |
208 | % if is_compare: |
|
213 | % if is_compare: | |
209 | generalCommentForm.setHandleFormSubmit(function(o) { |
|
214 | generalCommentForm.setHandleFormSubmit(function(o) { | |
210 | var self = generalCommentForm; |
|
215 | var self = generalCommentForm; | |
211 |
|
216 | |||
212 | var text = self.cm.getValue(); |
|
217 | var text = self.cm.getValue(); | |
213 | var status = self.getCommentStatus(); |
|
218 | var status = self.getCommentStatus(); | |
214 | var commentType = self.getCommentType(); |
|
219 | var commentType = self.getCommentType(); | |
215 |
|
220 | |||
216 | if (text === "" && !status) { |
|
221 | if (text === "" && !status) { | |
217 | return; |
|
222 | return; | |
218 | } |
|
223 | } | |
219 |
|
224 | |||
220 | // we can pick which commits we want to make the comment by |
|
225 | // we can pick which commits we want to make the comment by | |
221 | // selecting them via click on preview pane, this will alter the hidden inputs |
|
226 | // selecting them via click on preview pane, this will alter the hidden inputs | |
222 | var cherryPicked = $('#changeset_compare_view_content .compare_select.hl').length > 0; |
|
227 | var cherryPicked = $('#changeset_compare_view_content .compare_select.hl').length > 0; | |
223 |
|
228 | |||
224 | var commitIds = []; |
|
229 | var commitIds = []; | |
225 | $('#changeset_compare_view_content .compare_select').each(function(el) { |
|
230 | $('#changeset_compare_view_content .compare_select').each(function(el) { | |
226 | var commitId = this.id.replace('row-', ''); |
|
231 | var commitId = this.id.replace('row-', ''); | |
227 | if ($(this).hasClass('hl') || !cherryPicked) { |
|
232 | if ($(this).hasClass('hl') || !cherryPicked) { | |
228 | $("input[data-commit-id='{0}']".format(commitId)).val(commitId); |
|
233 | $("input[data-commit-id='{0}']".format(commitId)).val(commitId); | |
229 | commitIds.push(commitId); |
|
234 | commitIds.push(commitId); | |
230 | } else { |
|
235 | } else { | |
231 | $("input[data-commit-id='{0}']".format(commitId)).val('') |
|
236 | $("input[data-commit-id='{0}']".format(commitId)).val('') | |
232 | } |
|
237 | } | |
233 | }); |
|
238 | }); | |
234 |
|
239 | |||
235 | self.setActionButtonsDisabled(true); |
|
240 | self.setActionButtonsDisabled(true); | |
236 | self.cm.setOption("readOnly", true); |
|
241 | self.cm.setOption("readOnly", true); | |
237 | var postData = { |
|
242 | var postData = { | |
238 | 'text': text, |
|
243 | 'text': text, | |
239 | 'changeset_status': status, |
|
244 | 'changeset_status': status, | |
240 | 'comment_type': commentType, |
|
245 | 'comment_type': commentType, | |
241 | 'commit_ids': commitIds, |
|
246 | 'commit_ids': commitIds, | |
242 | 'csrf_token': CSRF_TOKEN |
|
247 | 'csrf_token': CSRF_TOKEN | |
243 | }; |
|
248 | }; | |
244 |
|
249 | |||
245 | var submitSuccessCallback = function(o) { |
|
250 | var submitSuccessCallback = function(o) { | |
246 | location.reload(true); |
|
251 | location.reload(true); | |
247 | }; |
|
252 | }; | |
248 | var submitFailCallback = function(){ |
|
253 | var submitFailCallback = function(){ | |
249 | self.resetCommentFormState(text) |
|
254 | self.resetCommentFormState(text) | |
250 | }; |
|
255 | }; | |
251 | self.submitAjaxPOST( |
|
256 | self.submitAjaxPOST( | |
252 | self.submitUrl, postData, submitSuccessCallback, submitFailCallback); |
|
257 | self.submitUrl, postData, submitSuccessCallback, submitFailCallback); | |
253 | }); |
|
258 | }); | |
254 | % endif |
|
259 | % endif | |
255 |
|
260 | |||
256 |
|
261 | |||
257 | </script> |
|
262 | </script> | |
258 | % else: |
|
263 | % else: | |
259 | ## form state when not logged in |
|
264 | ## form state when not logged in | |
260 | <div class="comment-form ac"> |
|
265 | <div class="comment-form ac"> | |
261 |
|
266 | |||
262 | <div class="comment-area"> |
|
267 | <div class="comment-area"> | |
263 | <div class="comment-area-header"> |
|
268 | <div class="comment-area-header"> | |
264 | <ul class="nav-links clearfix"> |
|
269 | <ul class="nav-links clearfix"> | |
265 | <li class="active"> |
|
270 | <li class="active"> | |
266 | <a class="disabled" href="#edit-btn" disabled="disabled" onclick="return false">${_('Write')}</a> |
|
271 | <a class="disabled" href="#edit-btn" disabled="disabled" onclick="return false">${_('Write')}</a> | |
267 | </li> |
|
272 | </li> | |
268 | <li class=""> |
|
273 | <li class=""> | |
269 | <a class="disabled" href="#preview-btn" disabled="disabled" onclick="return false">${_('Preview')}</a> |
|
274 | <a class="disabled" href="#preview-btn" disabled="disabled" onclick="return false">${_('Preview')}</a> | |
270 | </li> |
|
275 | </li> | |
271 | </ul> |
|
276 | </ul> | |
272 | </div> |
|
277 | </div> | |
273 |
|
278 | |||
274 | <div class="comment-area-write" style="display: block;"> |
|
279 | <div class="comment-area-write" style="display: block;"> | |
275 | <div id="edit-container"> |
|
280 | <div id="edit-container"> | |
276 | <div style="padding: 40px 0"> |
|
281 | <div style="padding: 40px 0"> | |
277 | ${_('You need to be logged in to leave comments.')} |
|
282 | ${_('You need to be logged in to leave comments.')} | |
278 | <a href="${h.route_path('login', _query={'came_from': h.url.current()})}">${_('Login now')}</a> |
|
283 | <a href="${h.route_path('login', _query={'came_from': h.url.current()})}">${_('Login now')}</a> | |
279 | </div> |
|
284 | </div> | |
280 | </div> |
|
285 | </div> | |
281 | <div id="preview-container" class="clearfix" style="display: none;"> |
|
286 | <div id="preview-container" class="clearfix" style="display: none;"> | |
282 | <div id="preview-box" class="preview-box"></div> |
|
287 | <div id="preview-box" class="preview-box"></div> | |
283 | </div> |
|
288 | </div> | |
284 | </div> |
|
289 | </div> | |
285 |
|
290 | |||
286 | <div class="comment-area-footer"> |
|
291 | <div class="comment-area-footer"> | |
287 | <div class="toolbar"> |
|
292 | <div class="toolbar"> | |
288 | <div class="toolbar-text"> |
|
293 | <div class="toolbar-text"> | |
289 | </div> |
|
294 | </div> | |
290 | </div> |
|
295 | </div> | |
291 | </div> |
|
296 | </div> | |
292 | </div> |
|
297 | </div> | |
293 |
|
298 | |||
294 | <div class="comment-footer"> |
|
299 | <div class="comment-footer"> | |
295 | </div> |
|
300 | </div> | |
296 |
|
301 | |||
297 | </div> |
|
302 | </div> | |
298 | % endif |
|
303 | % endif | |
299 |
|
304 | |||
300 | <script type="text/javascript"> |
|
305 | <script type="text/javascript"> | |
301 | bindToggleButtons(); |
|
306 | bindToggleButtons(); | |
302 | </script> |
|
307 | </script> | |
303 | </div> |
|
308 | </div> | |
304 | </%def> |
|
309 | </%def> | |
305 |
|
310 | |||
306 |
|
311 | |||
307 | <%def name="comment_form(form_type, form_id='', lineno_id='{1}', review_statuses=None, form_extras=None)"> |
|
312 | <%def name="comment_form(form_type, form_id='', lineno_id='{1}', review_statuses=None, form_extras=None)"> | |
308 | ## comment injected based on assumption that user is logged in |
|
313 | ## comment injected based on assumption that user is logged in | |
309 |
|
314 | |||
310 | <form ${'id="{}"'.format(form_id) if form_id else '' |n} action="#" method="GET"> |
|
315 | <form ${'id="{}"'.format(form_id) if form_id else '' |n} action="#" method="GET"> | |
311 |
|
316 | |||
312 | <div class="comment-area"> |
|
317 | <div class="comment-area"> | |
313 | <div class="comment-area-header"> |
|
318 | <div class="comment-area-header"> | |
314 | <ul class="nav-links clearfix"> |
|
319 | <ul class="nav-links clearfix"> | |
315 | <li class="active"> |
|
320 | <li class="active"> | |
316 | <a href="#edit-btn" tabindex="-1" id="edit-btn_${lineno_id}">${_('Write')}</a> |
|
321 | <a href="#edit-btn" tabindex="-1" id="edit-btn_${lineno_id}">${_('Write')}</a> | |
317 | </li> |
|
322 | </li> | |
318 | <li class=""> |
|
323 | <li class=""> | |
319 | <a href="#preview-btn" tabindex="-1" id="preview-btn_${lineno_id}">${_('Preview')}</a> |
|
324 | <a href="#preview-btn" tabindex="-1" id="preview-btn_${lineno_id}">${_('Preview')}</a> | |
320 | </li> |
|
325 | </li> | |
321 | <li class="pull-right"> |
|
326 | <li class="pull-right"> | |
322 | <select class="comment-type" id="comment_type_${lineno_id}" name="comment_type"> |
|
327 | <select class="comment-type" id="comment_type_${lineno_id}" name="comment_type"> | |
323 | % for val in c.visual.comment_types: |
|
328 | % for val in c.visual.comment_types: | |
324 | <option value="${val}">${val.upper()}</option> |
|
329 | <option value="${val}">${val.upper()}</option> | |
325 | % endfor |
|
330 | % endfor | |
326 | </select> |
|
331 | </select> | |
327 | </li> |
|
332 | </li> | |
328 | </ul> |
|
333 | </ul> | |
329 | </div> |
|
334 | </div> | |
330 |
|
335 | |||
331 | <div class="comment-area-write" style="display: block;"> |
|
336 | <div class="comment-area-write" style="display: block;"> | |
332 | <div id="edit-container_${lineno_id}"> |
|
337 | <div id="edit-container_${lineno_id}"> | |
333 | <textarea id="text_${lineno_id}" name="text" class="comment-block-ta ac-input"></textarea> |
|
338 | <textarea id="text_${lineno_id}" name="text" class="comment-block-ta ac-input"></textarea> | |
334 | </div> |
|
339 | </div> | |
335 | <div id="preview-container_${lineno_id}" class="clearfix" style="display: none;"> |
|
340 | <div id="preview-container_${lineno_id}" class="clearfix" style="display: none;"> | |
336 | <div id="preview-box_${lineno_id}" class="preview-box"></div> |
|
341 | <div id="preview-box_${lineno_id}" class="preview-box"></div> | |
337 | </div> |
|
342 | </div> | |
338 | </div> |
|
343 | </div> | |
339 |
|
344 | |||
340 | <div class="comment-area-footer"> |
|
345 | <div class="comment-area-footer"> | |
341 | <div class="toolbar"> |
|
346 | <div class="toolbar"> | |
342 | <div class="toolbar-text"> |
|
347 | <div class="toolbar-text"> | |
343 | ${(_('Comments parsed using %s syntax with %s, and %s actions support.') % ( |
|
348 | ${(_('Comments parsed using %s syntax with %s, and %s actions support.') % ( | |
344 | ('<a href="%s">%s</a>' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())), |
|
349 | ('<a href="%s">%s</a>' % (h.url('%s_help' % c.visual.default_renderer), c.visual.default_renderer.upper())), | |
345 | ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user')), |
|
350 | ('<span class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user')), | |
346 | ('<span class="tooltip" title="%s">`/`</span>' % _('Start typing with / for certain actions to be triggered via text box.')) |
|
351 | ('<span class="tooltip" title="%s">`/`</span>' % _('Start typing with / for certain actions to be triggered via text box.')) | |
347 | ) |
|
352 | ) | |
348 | )|n} |
|
353 | )|n} | |
349 | </div> |
|
354 | </div> | |
350 | </div> |
|
355 | </div> | |
351 | </div> |
|
356 | </div> | |
352 | </div> |
|
357 | </div> | |
353 |
|
358 | |||
354 | <div class="comment-footer"> |
|
359 | <div class="comment-footer"> | |
355 |
|
360 | |||
356 | % if review_statuses: |
|
361 | % if review_statuses: | |
357 | <div class="status_box"> |
|
362 | <div class="status_box"> | |
358 | <select id="change_status_${lineno_id}" name="changeset_status"> |
|
363 | <select id="change_status_${lineno_id}" name="changeset_status"> | |
359 | <option></option> ## Placeholder |
|
364 | <option></option> ## Placeholder | |
360 | % for status, lbl in review_statuses: |
|
365 | % for status, lbl in review_statuses: | |
361 | <option value="${status}" data-status="${status}">${lbl}</option> |
|
366 | <option value="${status}" data-status="${status}">${lbl}</option> | |
362 | %if is_pull_request and change_status and status in ('approved', 'rejected'): |
|
367 | %if is_pull_request and change_status and status in ('approved', 'rejected'): | |
363 | <option value="${status}_closed" data-status="${status}">${lbl} & ${_('Closed')}</option> |
|
368 | <option value="${status}_closed" data-status="${status}">${lbl} & ${_('Closed')}</option> | |
364 | %endif |
|
369 | %endif | |
365 | % endfor |
|
370 | % endfor | |
366 | </select> |
|
371 | </select> | |
367 | </div> |
|
372 | </div> | |
368 | % endif |
|
373 | % endif | |
369 |
|
374 | |||
370 | ## inject extra inputs into the form |
|
375 | ## inject extra inputs into the form | |
371 | % if form_extras and isinstance(form_extras, (list, tuple)): |
|
376 | % if form_extras and isinstance(form_extras, (list, tuple)): | |
372 | <div id="comment_form_extras"> |
|
377 | <div id="comment_form_extras"> | |
373 | % for form_ex_el in form_extras: |
|
378 | % for form_ex_el in form_extras: | |
374 | ${form_ex_el|n} |
|
379 | ${form_ex_el|n} | |
375 | % endfor |
|
380 | % endfor | |
376 | </div> |
|
381 | </div> | |
377 | % endif |
|
382 | % endif | |
378 |
|
383 | |||
379 | <div class="action-buttons"> |
|
384 | <div class="action-buttons"> | |
380 | ## inline for has a file, and line-number together with cancel hide button. |
|
385 | ## inline for has a file, and line-number together with cancel hide button. | |
381 | % if form_type == 'inline': |
|
386 | % if form_type == 'inline': | |
382 | <input type="hidden" name="f_path" value="{0}"> |
|
387 | <input type="hidden" name="f_path" value="{0}"> | |
383 | <input type="hidden" name="line" value="${lineno_id}"> |
|
388 | <input type="hidden" name="line" value="${lineno_id}"> | |
384 | <button type="button" class="cb-comment-cancel" onclick="return Rhodecode.comments.cancelComment(this);"> |
|
389 | <button type="button" class="cb-comment-cancel" onclick="return Rhodecode.comments.cancelComment(this);"> | |
385 | ${_('Cancel')} |
|
390 | ${_('Cancel')} | |
386 | </button> |
|
391 | </button> | |
387 | % endif |
|
392 | % endif | |
388 |
|
393 | |||
389 | % if form_type != 'inline': |
|
394 | % if form_type != 'inline': | |
390 | <div class="action-buttons-extra"></div> |
|
395 | <div class="action-buttons-extra"></div> | |
391 | % endif |
|
396 | % endif | |
392 |
|
397 | |||
393 | ${h.submit('save', _('Comment'), class_='btn btn-success comment-button-input')} |
|
398 | ${h.submit('save', _('Comment'), class_='btn btn-success comment-button-input')} | |
394 |
|
399 | |||
395 | </div> |
|
400 | </div> | |
396 | </div> |
|
401 | </div> | |
397 |
|
402 | |||
398 | </form> |
|
403 | </form> | |
399 |
|
404 | |||
400 | </%def> No newline at end of file |
|
405 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now