##// END OF EJS Templates
comments: "Comment on pull request" feels more natural
Mads Kiilerich -
r3608:87b0a652 beta
parent child Browse files
Show More
@@ -1,191 +1,191
1 ## -*- coding: utf-8 -*-
1 ## -*- coding: utf-8 -*-
2 ## usage:
2 ## usage:
3 ## <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
3 ## <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
4 ## ${comment.comment_block(co)}
4 ## ${comment.comment_block(co)}
5 ##
5 ##
6 <%def name="comment_block(co)">
6 <%def name="comment_block(co)">
7 <div class="comment" id="comment-${co.comment_id}" line="${co.line_no}">
7 <div class="comment" id="comment-${co.comment_id}" line="${co.line_no}">
8 <div class="comment-wrapp">
8 <div class="comment-wrapp">
9 <div class="meta">
9 <div class="meta">
10 <div style="float:left"> <img src="${h.gravatar_url(co.author.email, 20)}" /> </div>
10 <div style="float:left"> <img src="${h.gravatar_url(co.author.email, 20)}" /> </div>
11 <div class="user">
11 <div class="user">
12 ${co.author.username}
12 ${co.author.username}
13 </div>
13 </div>
14 <div class="date">
14 <div class="date">
15 ${h.age(co.modified_at)} <a class="permalink" href="#comment-${co.comment_id}">&para;</a>
15 ${h.age(co.modified_at)} <a class="permalink" href="#comment-${co.comment_id}">&para;</a>
16 </div>
16 </div>
17 %if co.status_change:
17 %if co.status_change:
18 <div style="float:left" class="changeset-status-container">
18 <div style="float:left" class="changeset-status-container">
19 <div style="float:left;padding:0px 2px 0px 2px"><span style="font-size: 18px;">&rsaquo;</span></div>
19 <div style="float:left;padding:0px 2px 0px 2px"><span style="font-size: 18px;">&rsaquo;</span></div>
20 <div title="${_('Changeset status')}" class="changeset-status-lbl"> ${co.status_change[0].status_lbl}</div>
20 <div title="${_('Changeset status')}" class="changeset-status-lbl"> ${co.status_change[0].status_lbl}</div>
21 <div class="changeset-status-ico"><img src="${h.url(str('/images/icons/flag_status_%s.png' % co.status_change[0].status))}" /></div>
21 <div class="changeset-status-ico"><img src="${h.url(str('/images/icons/flag_status_%s.png' % co.status_change[0].status))}" /></div>
22 </div>
22 </div>
23 %endif
23 %endif
24
24
25 <div style="float:left;padding:3px 0px 0px 5px">
25 <div style="float:left;padding:3px 0px 0px 5px">
26 <span class="">
26 <span class="">
27 %if co.pull_request:
27 %if co.pull_request:
28 <a href="${h.url('pullrequest_show',repo_name=co.pull_request.other_repo.repo_name,pull_request_id=co.pull_request.pull_request_id)}">
28 <a href="${h.url('pullrequest_show',repo_name=co.pull_request.other_repo.repo_name,pull_request_id=co.pull_request.pull_request_id)}">
29 %if co.status_change:
29 %if co.status_change:
30 ${_('Status change from pull request #%s') % co.pull_request.pull_request_id}
30 ${_('Status change on pull request #%s') % co.pull_request.pull_request_id}
31 %else:
31 %else:
32 ${_('Comment from pull request #%s') % co.pull_request.pull_request_id}
32 ${_('Comment on pull request #%s') % co.pull_request.pull_request_id}
33 %endif
33 %endif
34 </a>
34 </a>
35 %endif
35 %endif
36 </span>
36 </span>
37 </div>
37 </div>
38
38
39 %if h.HasPermissionAny('hg.admin', 'repository.admin')() or co.author.user_id == c.rhodecode_user.user_id:
39 %if h.HasPermissionAny('hg.admin', 'repository.admin')() or co.author.user_id == c.rhodecode_user.user_id:
40 <div class="buttons">
40 <div class="buttons">
41 <span onClick="deleteComment(${co.comment_id})" class="delete-comment ui-btn">${_('Delete')}</span>
41 <span onClick="deleteComment(${co.comment_id})" class="delete-comment ui-btn">${_('Delete')}</span>
42 </div>
42 </div>
43 %endif
43 %endif
44 </div>
44 </div>
45 <div class="text">
45 <div class="text">
46 ${h.rst_w_mentions(co.text)|n}
46 ${h.rst_w_mentions(co.text)|n}
47 </div>
47 </div>
48 </div>
48 </div>
49 </div>
49 </div>
50 </%def>
50 </%def>
51
51
52
52
53 <%def name="comment_inline_form()">
53 <%def name="comment_inline_form()">
54 <div id='comment-inline-form-template' style="display:none">
54 <div id='comment-inline-form-template' style="display:none">
55 <div class="comment-inline-form ac">
55 <div class="comment-inline-form ac">
56 %if c.rhodecode_user.username != 'default':
56 %if c.rhodecode_user.username != 'default':
57 <div class="overlay"><div class="overlay-text">${_('Submitting...')}</div></div>
57 <div class="overlay"><div class="overlay-text">${_('Submitting...')}</div></div>
58 ${h.form('#', class_='inline-form')}
58 ${h.form('#', class_='inline-form')}
59 <div class="clearfix">
59 <div class="clearfix">
60 <div class="comment-help">${_('Commenting on line {1}.')}
60 <div class="comment-help">${_('Commenting on line {1}.')}
61 ${(_('Comments parsed using %s syntax with %s support.') % (
61 ${(_('Comments parsed using %s syntax with %s support.') % (
62 ('<a href="%s">RST</a>' % h.url('rst_help')),
62 ('<a href="%s">RST</a>' % h.url('rst_help')),
63 ('<span style="color:#003367" class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user'))
63 ('<span style="color:#003367" class="tooltip" title="%s">@mention</span>' % _('Use @username inside this text to send notification to this RhodeCode user'))
64 )
64 )
65 )|n
65 )|n
66 }
66 }
67 </div>
67 </div>
68 <div class="mentions-container" id="mentions_container_{1}"></div>
68 <div class="mentions-container" id="mentions_container_{1}"></div>
69 <textarea id="text_{1}" name="text" class="yui-ac-input"></textarea>
69 <textarea id="text_{1}" name="text" class="yui-ac-input"></textarea>
70 </div>
70 </div>
71 <div class="comment-button">
71 <div class="comment-button">
72 <input type="hidden" name="f_path" value="{0}">
72 <input type="hidden" name="f_path" value="{0}">
73 <input type="hidden" name="line" value="{1}">
73 <input type="hidden" name="line" value="{1}">
74 ${h.submit('save', _('Comment'), class_='ui-btn save-inline-form')}
74 ${h.submit('save', _('Comment'), class_='ui-btn save-inline-form')}
75 ${h.reset('hide-inline-form', _('Cancel'), class_='ui-btn hide-inline-form')}
75 ${h.reset('hide-inline-form', _('Cancel'), class_='ui-btn hide-inline-form')}
76 </div>
76 </div>
77 ${h.end_form()}
77 ${h.end_form()}
78 %else:
78 %else:
79 ${h.form('')}
79 ${h.form('')}
80 <div class="clearfix">
80 <div class="clearfix">
81 <div class="comment-help">
81 <div class="comment-help">
82 ${_('You need to be logged in to comment.')} <a href="${h.url('login_home',came_from=h.url.current())}">${_('Login now')}</a>
82 ${_('You need to be logged in to comment.')} <a href="${h.url('login_home',came_from=h.url.current())}">${_('Login now')}</a>
83 </div>
83 </div>
84 </div>
84 </div>
85 <div class="comment-button">
85 <div class="comment-button">
86 ${h.reset('hide-inline-form', _('Hide'), class_='ui-btn hide-inline-form')}
86 ${h.reset('hide-inline-form', _('Hide'), class_='ui-btn hide-inline-form')}
87 </div>
87 </div>
88 ${h.end_form()}
88 ${h.end_form()}
89 %endif
89 %endif
90 </div>
90 </div>
91 </div>
91 </div>
92 </%def>
92 </%def>
93
93
94
94
95 ## generates inlines taken from c.comments var
95 ## generates inlines taken from c.comments var
96 <%def name="inlines()">
96 <%def name="inlines()">
97 <div class="comments-number">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}</div>
97 <div class="comments-number">${ungettext("%d comment", "%d comments", len(c.comments)) % len(c.comments)} ${ungettext("(%d inline)", "(%d inline)", c.inline_cnt) % c.inline_cnt}</div>
98 %for path, lines in c.inline_comments:
98 %for path, lines in c.inline_comments:
99 % for line,comments in lines.iteritems():
99 % for line,comments in lines.iteritems():
100 <div style="display:none" class="inline-comment-placeholder" path="${path}" target_id="${h.safeid(h.safe_unicode(path))}">
100 <div style="display:none" class="inline-comment-placeholder" path="${path}" target_id="${h.safeid(h.safe_unicode(path))}">
101 %for co in comments:
101 %for co in comments:
102 ${comment_block(co)}
102 ${comment_block(co)}
103 %endfor
103 %endfor
104 </div>
104 </div>
105 %endfor
105 %endfor
106 %endfor
106 %endfor
107
107
108 </%def>
108 </%def>
109
109
110 ## generate inline comments and the main ones
110 ## generate inline comments and the main ones
111 <%def name="generate_comments(include_pr=False)">
111 <%def name="generate_comments(include_pr=False)">
112 <div class="comments">
112 <div class="comments">
113 <div id="inline-comments-container">
113 <div id="inline-comments-container">
114 ## generate inlines for this changeset
114 ## generate inlines for this changeset
115 ${inlines()}
115 ${inlines()}
116 </div>
116 </div>
117
117
118 %for co in c.comments:
118 %for co in c.comments:
119 <div id="comment-tr-${co.comment_id}">
119 <div id="comment-tr-${co.comment_id}">
120 ## only render comments that are not from pull request, or from
120 ## only render comments that are not from pull request, or from
121 ## pull request and a status change
121 ## pull request and a status change
122 %if not co.pull_request or (co.pull_request and co.status_change) or include_pr:
122 %if not co.pull_request or (co.pull_request and co.status_change) or include_pr:
123 ${comment_block(co)}
123 ${comment_block(co)}
124 %endif
124 %endif
125 </div>
125 </div>
126 %endfor
126 %endfor
127 </div>
127 </div>
128 </%def>
128 </%def>
129
129
130 ## MAIN COMMENT FORM
130 ## MAIN COMMENT FORM
131 <%def name="comments(post_url, cur_status, close_btn=False, change_status=True)">
131 <%def name="comments(post_url, cur_status, close_btn=False, change_status=True)">
132
132
133 <div class="comments">
133 <div class="comments">
134 %if c.rhodecode_user.username != 'default':
134 %if c.rhodecode_user.username != 'default':
135 <div class="comment-form ac">
135 <div class="comment-form ac">
136 ${h.form(post_url)}
136 ${h.form(post_url)}
137 <div class="clearfix">
137 <div class="clearfix">
138 <div class="comment-help">
138 <div class="comment-help">
139 ${(_('Comments parsed using %s syntax with %s support.') % (('<a href="%s">RST</a>' % h.url('rst_help')),
139 ${(_('Comments parsed using %s syntax with %s support.') % (('<a href="%s">RST</a>' % h.url('rst_help')),
140 '<span style="color:#003367" class="tooltip" title="%s">@mention</span>' %
140 '<span style="color:#003367" class="tooltip" title="%s">@mention</span>' %
141 _('Use @username inside this text to send notification to this RhodeCode user')))|n}
141 _('Use @username inside this text to send notification to this RhodeCode user')))|n}
142 %if change_status:
142 %if change_status:
143 | <a id="show_changeset_link" onClick="change_status_show();"> ${_('Change status')}</a>
143 | <a id="show_changeset_link" onClick="change_status_show();"> ${_('Change status')}</a>
144 <input id="show_changeset_status_box" type="checkbox" name="change_changeset_status" style="display: none;" />
144 <input id="show_changeset_status_box" type="checkbox" name="change_changeset_status" style="display: none;" />
145 %endif
145 %endif
146 </div>
146 </div>
147 %if change_status:
147 %if change_status:
148 <div id="status_block_container" class="status-block" style="display:none">
148 <div id="status_block_container" class="status-block" style="display:none">
149 %for status,lbl in c.changeset_statuses:
149 %for status,lbl in c.changeset_statuses:
150 <div class="">
150 <div class="">
151 <img src="${h.url('/images/icons/flag_status_%s.png' % status)}" /> <input ${'checked="checked"' if status == cur_status else ''}" type="radio" class="status_change_radio" name="changeset_status" id="${status}" value="${status}">
151 <img src="${h.url('/images/icons/flag_status_%s.png' % status)}" /> <input ${'checked="checked"' if status == cur_status else ''}" type="radio" class="status_change_radio" name="changeset_status" id="${status}" value="${status}">
152 <label for="${status}">${lbl}</label>
152 <label for="${status}">${lbl}</label>
153 </div>
153 </div>
154 %endfor
154 %endfor
155 </div>
155 </div>
156 %endif
156 %endif
157 <div class="mentions-container" id="mentions_container"></div>
157 <div class="mentions-container" id="mentions_container"></div>
158 ${h.textarea('text')}
158 ${h.textarea('text')}
159 </div>
159 </div>
160 <div class="comment-button">
160 <div class="comment-button">
161 ${h.submit('save', _('Comment'), class_="ui-btn large")}
161 ${h.submit('save', _('Comment'), class_="ui-btn large")}
162 %if close_btn and change_status:
162 %if close_btn and change_status:
163 ${h.submit('save_close', _('Comment and close'), class_='ui-btn blue large %s' % ('hidden' if cur_status in ['not_reviewed','under_review'] else ''))}
163 ${h.submit('save_close', _('Comment and close'), class_='ui-btn blue large %s' % ('hidden' if cur_status in ['not_reviewed','under_review'] else ''))}
164 %endif
164 %endif
165 </div>
165 </div>
166 ${h.end_form()}
166 ${h.end_form()}
167 </div>
167 </div>
168 %endif
168 %endif
169 </div>
169 </div>
170 <script>
170 <script>
171 var change_status_show = function(){
171 var change_status_show = function(){
172 var show = ! YUD.get('show_changeset_status_box').checked;
172 var show = ! YUD.get('show_changeset_status_box').checked;
173 YUD.get('show_changeset_status_box').checked = show;
173 YUD.get('show_changeset_status_box').checked = show;
174 YUD.setStyle('status_block_container', 'display', show?'':'none');
174 YUD.setStyle('status_block_container', 'display', show?'':'none');
175 };
175 };
176
176
177 YUE.onDOMReady(function () {
177 YUE.onDOMReady(function () {
178 MentionsAutoComplete('text', 'mentions_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
178 MentionsAutoComplete('text', 'mentions_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
179
179
180 YUE.on(YUQ('.status_change_radio'), 'change',function(e){
180 YUE.on(YUQ('.status_change_radio'), 'change',function(e){
181 var val = e.currentTarget.value;
181 var val = e.currentTarget.value;
182 if (val == 'approved' || val == 'rejected') {
182 if (val == 'approved' || val == 'rejected') {
183 YUD.removeClass('save_close', 'hidden');
183 YUD.removeClass('save_close', 'hidden');
184 }else{
184 }else{
185 YUD.addClass('save_close', 'hidden');
185 YUD.addClass('save_close', 'hidden');
186 }
186 }
187 })
187 })
188
188
189 });
189 });
190 </script>
190 </script>
191 </%def>
191 </%def>
General Comments 0
You need to be logged in to leave comments. Login now