##// END OF EJS Templates
added a flag for generating pull-request comments, and force display on pull-requests
marcink -
r3229:aad51f79 beta
parent child Browse files
Show More
@@ -1,195 +1,195 b''
1 1 ## -*- coding: utf-8 -*-
2 2 ## usage:
3 3 ## <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
4 4 ## ${comment.comment_block(co)}
5 5 ##
6 6 <%def name="comment_block(co)">
7 7 <div class="comment" id="comment-${co.comment_id}" line="${co.line_no}">
8 8 <div class="comment-wrapp">
9 9 <div class="meta">
10 10 <div style="float:left"> <img src="${h.gravatar_url(co.author.email, 20)}" /> </div>
11 11 <div class="user">
12 12 ${co.author.username}
13 13 </div>
14 14 <div class="date">
15 15 ${h.age(co.modified_at)} <a class="permalink" href="#comment-${co.comment_id}">&para;</a>
16 16 </div>
17 17 %if co.status_change:
18 18 <div style="float:left" class="changeset-status-container">
19 19 <div style="float:left;padding:0px 2px 0px 2px"><span style="font-size: 18px;">&rsaquo;</span></div>
20 20 <div title="${_('Changeset status')}" class="changeset-status-lbl"> ${co.status_change[0].status_lbl}</div>
21 21 <div class="changeset-status-ico"><img src="${h.url(str('/images/icons/flag_status_%s.png' % co.status_change[0].status))}" /></div>
22 22 </div>
23 23 %endif
24 24
25 25 <div style="float:left;padding:3px 0px 0px 5px">
26 26 <span class="">
27 27 %if co.pull_request:
28 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 29 %if co.status_change:
30 30 ${_('Status from pull request %s') % co.pull_request.pull_request_id}
31 31 %else:
32 32 ${_('Comment from pull request %s') % co.pull_request.pull_request_id}
33 33 %endif
34 34 </a>
35 35 %endif
36 36 </span>
37 37 </div>
38 38
39 39 %if h.HasPermissionAny('hg.admin', 'repository.admin')() or co.author.user_id == c.rhodecode_user.user_id:
40 40 <div class="buttons">
41 41 <span onClick="deleteComment(${co.comment_id})" class="delete-comment ui-btn">${_('Delete')}</span>
42 42 </div>
43 43 %endif
44 44 </div>
45 45 <div class="text">
46 46 ${h.rst_w_mentions(co.text)|n}
47 47 </div>
48 48 </div>
49 49 </div>
50 50 </%def>
51 51
52 52
53 53 <%def name="comment_inline_form()">
54 54 <div id='comment-inline-form-template' style="display:none">
55 55 <div class="comment-inline-form ac">
56 56 %if c.rhodecode_user.username != 'default':
57 57 <div class="overlay"><div class="overlay-text">${_('Submitting...')}</div></div>
58 58 ${h.form('#', class_='inline-form')}
59 59 <div class="clearfix">
60 60 <div class="comment-help">${_('Commenting on line {1}.')}
61 61 ${(_('Comments parsed using %s syntax with %s support.') % (
62 62 ('<a href="%s">RST</a>' % h.url('rst_help')),
63 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 65 )|n
66 66 }
67 67 </div>
68 68 <div class="mentions-container" id="mentions_container_{1}"></div>
69 69 <textarea id="text_{1}" name="text" class="yui-ac-input"></textarea>
70 70 </div>
71 71 <div class="comment-button">
72 72 <input type="hidden" name="f_path" value="{0}">
73 73 <input type="hidden" name="line" value="{1}">
74 74 ${h.submit('save', _('Comment'), class_='ui-btn save-inline-form')}
75 75 ${h.reset('hide-inline-form', _('Hide'), class_='ui-btn hide-inline-form')}
76 76 </div>
77 77 ${h.end_form()}
78 78 %else:
79 79 ${h.form('')}
80 80 <div class="clearfix">
81 81 <div class="comment-help">
82 82 ${_('You need to be logged in to comment.')} <a href="${h.url('login_home',came_from=h.url.current())}">${_('Login now')}</a>
83 83 </div>
84 84 </div>
85 85 <div class="comment-button">
86 86 ${h.reset('hide-inline-form', _('Hide'), class_='ui-btn hide-inline-form')}
87 87 </div>
88 88 ${h.end_form()}
89 89 %endif
90 90 </div>
91 91 </div>
92 92 </%def>
93 93
94 94
95 95 ## generates inlines taken from c.comments var
96 96 <%def name="inlines()">
97 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 98 %for path, lines in c.inline_comments:
99 99 % for line,comments in lines.iteritems():
100 100 <div style="display:none" class="inline-comment-placeholder" path="${path}" target_id="${h.safeid(h.safe_unicode(path))}">
101 101 %for co in comments:
102 102 ${comment_block(co)}
103 103 %endfor
104 104 </div>
105 105 %endfor
106 106 %endfor
107 107
108 108 </%def>
109 109
110 110 ## generate inline comments and the main ones
111 <%def name="generate_comments()">
111 <%def name="generate_comments(include_pr=False)">
112 112 <div class="comments">
113 113 <div id="inline-comments-container">
114 114 ## generate inlines for this changeset
115 115 ${inlines()}
116 116 </div>
117 117
118 118 %for co in c.comments:
119 119 <div id="comment-tr-${co.comment_id}">
120 120 ## only render comments that are not from pull request, or from
121 121 ## pull request and a status change
122 %if not co.pull_request or co.pull_request and co.status_change:
122 %if not co.pull_request or (co.pull_request and co.status_change) or include_pr:
123 123 ${comment_block(co)}
124 124 %endif
125 125 </div>
126 126 %endfor
127 127 </div>
128 128 </%def>
129 129
130 130 ## MAIN COMMENT FORM
131 131 <%def name="comments(post_url, cur_status, close_btn=False, change_status=True)">
132 132
133 133 <div class="comments">
134 134 %if c.rhodecode_user.username != 'default':
135 135 <div class="comment-form ac">
136 136 ${h.form(post_url)}
137 137 <strong>${_('Leave a comment')}</strong>
138 138 <div class="clearfix">
139 139 <div class="comment-help">
140 140 ${(_('Comments parsed using %s syntax with %s support.') % (('<a href="%s">RST</a>' % h.url('rst_help')),
141 141 '<span style="color:#003367" class="tooltip" title="%s">@mention</span>' %
142 142 _('Use @username inside this text to send notification to this RhodeCode user')))|n}
143 143 %if change_status:
144 144 | <label for="show_changeset_status_box" class="tooltip" title="${_('Check this to change current status of code-review for this changeset')}"> ${_('change status')}</label>
145 145 <input style="vertical-align: bottom;margin-bottom:-2px" id="show_changeset_status_box" type="checkbox" name="change_changeset_status" />
146 146 %endif
147 147 </div>
148 148 %if change_status:
149 149 <div id="status_block_container" class="status-block" style="display:none">
150 150 %for status,lbl in c.changeset_statuses:
151 151 <div class="">
152 152 <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}">
153 153 <label for="${status}">${lbl}</label>
154 154 </div>
155 155 %endfor
156 156 </div>
157 157 %endif
158 158 <div class="mentions-container" id="mentions_container"></div>
159 159 ${h.textarea('text')}
160 160 </div>
161 161 <div class="comment-button">
162 162 ${h.submit('save', _('Comment'), class_="ui-btn large")}
163 163 %if close_btn and change_status:
164 164 ${h.submit('save_close', _('Comment and close'), class_='ui-btn blue large %s' % ('hidden' if cur_status in ['not_reviewed','under_review'] else ''))}
165 165 %endif
166 166 </div>
167 167 ${h.end_form()}
168 168 </div>
169 169 %endif
170 170 </div>
171 171 <script>
172 172 YUE.onDOMReady(function () {
173 173 MentionsAutoComplete('text', 'mentions_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
174 174
175 175 // changeset status box listener
176 176 YUE.on(YUD.get('show_changeset_status_box'),'change',function(e){
177 177 if(e.currentTarget.checked){
178 178 YUD.setStyle('status_block_container','display','');
179 179 }
180 180 else{
181 181 YUD.setStyle('status_block_container','display','none');
182 182 }
183 183 })
184 184 YUE.on(YUQ('.status_change_radio'), 'change',function(e){
185 185 var val = e.currentTarget.value;
186 186 if (val == 'approved' || val == 'rejected') {
187 187 YUD.removeClass('save_close', 'hidden');
188 188 }else{
189 189 YUD.addClass('save_close', 'hidden');
190 190 }
191 191 })
192 192
193 193 });
194 194 </script>
195 195 </%def>
@@ -1,228 +1,228 b''
1 1 <%inherit file="/base/base.html"/>
2 2
3 3 <%def name="title()">
4 4 ${c.repo_name} ${_('Pull request #%s') % c.pull_request.pull_request_id}
5 5 </%def>
6 6
7 7 <%def name="breadcrumbs_links()">
8 8 ${h.link_to(_(u'Home'),h.url('/'))}
9 9 &raquo;
10 10 ${h.link_to(c.repo_name,h.url('changelog_home',repo_name=c.repo_name))}
11 11 &raquo;
12 12 ${_('Pull request #%s') % c.pull_request.pull_request_id}
13 13 </%def>
14 14
15 15 <%def name="main()">
16 16
17 17 <div class="box">
18 18 <!-- box / title -->
19 19 <div class="title">
20 20 ${self.breadcrumbs()}
21 21 </div>
22 22 %if c.pull_request.is_closed():
23 23 <div style="padding:10px; font-size:22px;width:100%;text-align: center; color:#88D882">${_('Closed %s') % (h.age(c.pull_request.updated_on))} ${_('with status %s') % h.changeset_status_lbl(c.current_changeset_status)}</div>
24 24 %endif
25 25 <h3>${_('Title')}: ${c.pull_request.title}</h3>
26 26
27 27 <div class="form">
28 28 <div id="summary" class="fields">
29 29 <div class="field">
30 30 <div class="label-summary">
31 31 <label>${_('Status')}:</label>
32 32 </div>
33 33 <div class="input">
34 34 <div class="changeset-status-container" style="float:none;clear:both">
35 35 %if c.current_changeset_status:
36 36 <div title="${_('Pull request status')}" class="changeset-status-lbl">[${h.changeset_status_lbl(c.current_changeset_status)}]</div>
37 37 <div class="changeset-status-ico" style="padding:1px 4px"><img src="${h.url('/images/icons/flag_status_%s.png' % c.current_changeset_status)}" /></div>
38 38 %endif
39 39 </div>
40 40 </div>
41 41 </div>
42 42 <div class="field">
43 43 <div class="label-summary">
44 44 <label>${_('Still not reviewed by')}:</label>
45 45 </div>
46 46 <div class="input">
47 47 % if len(c.pull_request_pending_reviewers) > 0:
48 48 <div class="tooltip" title="${h.tooltip(','.join([x.username for x in c.pull_request_pending_reviewers]))}">${ungettext('%d reviewer', '%d reviewers',len(c.pull_request_pending_reviewers)) % len(c.pull_request_pending_reviewers)}</div>
49 49 %else:
50 50 <div>${_('pull request was reviewed by all reviewers')}</div>
51 51 %endif
52 52 </div>
53 53 </div>
54 54 <div class="field">
55 55 <div class="label-summary">
56 56 <label>${_('Origin repository')}:</label>
57 57 </div>
58 58 <div class="input">
59 59 <div>
60 60 ##%if h.is_hg(c.pull_request.org_repo):
61 61 ## <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
62 62 ##%elif h.is_git(c.pull_request.org_repo):
63 63 ## <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/>
64 64 ##%endif
65 65 <span class="spantag">${c.pull_request.org_ref_parts[0]}</span>
66 66 :
67 67 <span class="spantag">${c.pull_request.org_ref_parts[1]}</span>
68 68 <span><a href="${h.url('summary_home', repo_name=c.pull_request.org_repo.repo_name)}">${c.pull_request.org_repo.clone_url()}</a></span>
69 69 </div>
70 70 </div>
71 71 </div>
72 72 </div>
73 73 </div>
74 74 <div style="white-space:pre-wrap;padding:3px 3px 5px 20px">${h.literal(c.pull_request.description)}</div>
75 75 <div style="padding:4px 4px 10px 20px">
76 76 <div>${_('Created on')}: ${h.fmt_date(c.pull_request.created_on)}</div>
77 77 </div>
78 78
79 79 <div style="overflow: auto;">
80 80 ##DIFF
81 81 <div class="table" style="float:left;clear:none">
82 82 <div id="body" class="diffblock">
83 83 <div style="white-space:pre-wrap;padding:5px">${_('Compare view')}</div>
84 84 </div>
85 85 <div id="changeset_compare_view_content">
86 86 ##CS
87 87 <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">${ungettext('Showing %s commit','Showing %s commits', len(c.cs_ranges)) % len(c.cs_ranges)}</div>
88 88 <%include file="/compare/compare_cs.html" />
89 89
90 90 ## FILES
91 91 <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
92 92
93 93 % if c.limited_diff:
94 94 ${ungettext('%s file changed', '%s files changed', len(c.files)) % len(c.files)}
95 95 % else:
96 96 ${ungettext('%s file changed with %s insertions and %s deletions','%s files changed with %s insertions and %s deletions', len(c.files)) % (len(c.files),c.lines_added,c.lines_deleted)}:
97 97 %endif
98 98
99 99 </div>
100 100 <div class="cs_files">
101 101 %if not c.files:
102 102 <span class="empty_data">${_('No files')}</span>
103 103 %endif
104 104 %for fid, change, f, stat in c.files:
105 105 <div class="cs_${change}">
106 106 <div class="node">${h.link_to(h.safe_unicode(f),h.url.current(anchor=fid))}</div>
107 107 <div class="changes">${h.fancy_file_stats(stat)}</div>
108 108 </div>
109 109 %endfor
110 110 </div>
111 111 % if c.limited_diff:
112 112 <h5>${_('Changeset was too big and was cut off...')}</h5>
113 113 % endif
114 114 </div>
115 115 </div>
116 116 ## REVIEWERS
117 117 <div style="float:left; border-left:1px dashed #eee">
118 118 <h4>${_('Pull request reviewers')}</h4>
119 119 <div id="reviewers" style="padding:0px 0px 5px 10px">
120 120 ## members goes here !
121 121 <div class="group_members_wrap" style="min-height:45px">
122 122 <ul id="review_members" class="group_members">
123 123 %for member,status in c.pull_request_reviewers:
124 124 <li id="reviewer_${member.user_id}">
125 125 <div class="reviewers_member">
126 126 <div style="float:left;padding:0px 3px 0px 0px" class="tooltip" title="${h.tooltip(h.changeset_status_lbl(status[0][1].status if status else 'not_reviewed'))}">
127 127 <img src="${h.url(str('/images/icons/flag_status_%s.png' % (status[0][1].status if status else 'not_reviewed')))}"/>
128 128 </div>
129 129 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(member.email,14)}"/> </div>
130 130 <div style="float:left">${member.full_name} (${_('owner') if c.pull_request.user_id == member.user_id else _('reviewer')})</div>
131 131 <input type="hidden" value="${member.user_id}" name="review_members" />
132 132 %if not c.pull_request.is_closed() and (h.HasPermissionAny('hg.admin', 'repository.admin')() or c.pull_request.user_id == c.rhodecode_user.user_id):
133 133 <span class="delete_icon action_button" onclick="removeReviewer(${member.user_id})"></span>
134 134 %endif
135 135 </div>
136 136 </li>
137 137 %endfor
138 138 </ul>
139 139 </div>
140 140 %if not c.pull_request.is_closed():
141 141 <div class='ac'>
142 142 %if h.HasPermissionAny('hg.admin', 'repository.admin')() or c.pull_request.author.user_id == c.rhodecode_user.user_id:
143 143 <div class="reviewer_ac">
144 144 ${h.text('user', class_='yui-ac-input')}
145 145 <span class="help-block">${_('Add reviewer to this pull request.')}</span>
146 146 <div id="reviewers_container"></div>
147 147 </div>
148 148 <div style="padding:0px 10px">
149 149 <span id="update_pull_request" class="ui-btn xsmall">${_('save')}</span>
150 150 </div>
151 151 %endif
152 152 </div>
153 153 %endif
154 154 </div>
155 155 </div>
156 156 </div>
157 157 <script>
158 158 var _USERS_AC_DATA = ${c.users_array|n};
159 159 var _GROUPS_AC_DATA = ${c.users_groups_array|n};
160 160 AJAX_COMMENT_URL = "${url('pullrequest_comment',repo_name=c.repo_name,pull_request_id=c.pull_request.pull_request_id)}";
161 161 AJAX_COMMENT_DELETE_URL = "${url('pullrequest_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}";
162 162 AJAX_UPDATE_PULLREQUEST = "${url('pullrequest_update',repo_name=c.repo_name,pull_request_id=c.pull_request.pull_request_id)}"
163 163 </script>
164 164
165 165 ## diff block
166 166 <%namespace name="diff_block" file="/changeset/diff_block.html"/>
167 167 %for fid, change, f, stat in c.files:
168 168 ${diff_block.diff_block_simple([c.changes[fid]])}
169 169 %endfor
170 170 % if c.limited_diff:
171 171 <h4>${_('Changeset was too big and was cut off...')}</h4>
172 172 % endif
173 173
174 174
175 175 ## template for inline comment form
176 176 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
177 177 ${comment.comment_inline_form()}
178 178
179 179 ## render comments and inlines
180 ${comment.generate_comments()}
180 ${comment.generate_comments(include_pr=True)}
181 181
182 182 % if not c.pull_request.is_closed():
183 183 ## main comment form and it status
184 184 ${comment.comments(h.url('pullrequest_comment', repo_name=c.repo_name,
185 185 pull_request_id=c.pull_request.pull_request_id),
186 186 c.current_changeset_status,
187 187 close_btn=True, change_status=c.allowed_to_change_status)}
188 188 %endif
189 189
190 190 <script type="text/javascript">
191 191 YUE.onDOMReady(function(){
192 192 PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
193 193
194 194 YUE.on(YUQ('.show-inline-comments'),'change',function(e){
195 195 var show = 'none';
196 196 var target = e.currentTarget;
197 197 if(target.checked){
198 198 var show = ''
199 199 }
200 200 var boxid = YUD.getAttribute(target,'id_for');
201 201 var comments = YUQ('#{0} .inline-comments'.format(boxid));
202 202 for(c in comments){
203 203 YUD.setStyle(comments[c],'display',show);
204 204 }
205 205 var btns = YUQ('#{0} .inline-comments-button'.format(boxid));
206 206 for(c in btns){
207 207 YUD.setStyle(btns[c],'display',show);
208 208 }
209 209 })
210 210
211 211 YUE.on(YUQ('.line'),'click',function(e){
212 212 var tr = e.currentTarget;
213 213 injectInlineForm(tr);
214 214 });
215 215
216 216 // inject comments into they proper positions
217 217 var file_comments = YUQ('.inline-comment-placeholder');
218 218 renderInlineComments(file_comments);
219 219
220 220 YUE.on(YUD.get('update_pull_request'),'click',function(e){
221 221 updateReviewers();
222 222 })
223 223 })
224 224 </script>
225 225
226 226 </div>
227 227
228 228 </%def>
General Comments 0
You need to be logged in to leave comments. Login now