##// END OF EJS Templates
pull request: urlify PRs and fix javascript injection
Mads Kiilerich -
r3998:6133e598 default
parent child Browse files
Show More
@@ -1,252 +1,252 b''
1 <%inherit file="/base/base.html"/>
1 <%inherit file="/base/base.html"/>
2
2
3 <%def name="title()">
3 <%def name="title()">
4 ${_('%s Pull Request #%s') % (c.repo_name, c.pull_request.pull_request_id)} &middot; ${c.rhodecode_name}
4 ${_('%s Pull Request #%s') % (c.repo_name, c.pull_request.pull_request_id)} &middot; ${c.rhodecode_name}
5 </%def>
5 </%def>
6
6
7 <%def name="breadcrumbs_links()">
7 <%def name="breadcrumbs_links()">
8 ${_('Pull request #%s') % c.pull_request.pull_request_id}
8 ${_('Pull request #%s') % c.pull_request.pull_request_id}
9 </%def>
9 </%def>
10
10
11 <%def name="page_nav()">
11 <%def name="page_nav()">
12 ${self.menu('repositories')}
12 ${self.menu('repositories')}
13 </%def>
13 </%def>
14
14
15 <%def name="main()">
15 <%def name="main()">
16 ${self.repo_context_bar('showpullrequest')}
16 ${self.repo_context_bar('showpullrequest')}
17 <div class="box">
17 <div class="box">
18 <!-- box / title -->
18 <!-- box / title -->
19 <div class="title">
19 <div class="title">
20 ${self.breadcrumbs()}
20 ${self.breadcrumbs()}
21 </div>
21 </div>
22
22
23 <h3 class="${'closed' if c.pull_request.is_closed() else ''}">
23 <h3 class="${'closed' if c.pull_request.is_closed() else ''}">
24 <img src="${h.url('/images/icons/flag_status_%s.png' % str(c.pull_request.last_review_status))}" />
24 <img src="${h.url('/images/icons/flag_status_%s.png' % str(c.pull_request.last_review_status))}" />
25 ${_('Title')}: ${c.pull_request.title}
25 ${_('Title')}: ${c.pull_request.title}
26 %if c.pull_request.is_closed():
26 %if c.pull_request.is_closed():
27 (${_('Closed')})
27 (${_('Closed')})
28 %endif
28 %endif
29 </h3>
29 </h3>
30
30
31 <div class="form">
31 <div class="form">
32 <div id="summary" class="fields">
32 <div id="summary" class="fields">
33 <div class="field">
33 <div class="field">
34 <div class="label-summary">
34 <div class="label-summary">
35 <label>${_('Review status')}:</label>
35 <label>${_('Review status')}:</label>
36 </div>
36 </div>
37 <div class="input">
37 <div class="input">
38 <div class="changeset-status-container" style="float:none;clear:both">
38 <div class="changeset-status-container" style="float:none;clear:both">
39 %if c.current_changeset_status:
39 %if c.current_changeset_status:
40 <div title="${_('Pull request status')}" class="changeset-status-lbl">
40 <div title="${_('Pull request status')}" class="changeset-status-lbl">
41 %if c.pull_request.is_closed():
41 %if c.pull_request.is_closed():
42 ${_('Closed')},
42 ${_('Closed')},
43 %endif
43 %endif
44 ${h.changeset_status_lbl(c.current_changeset_status)}
44 ${h.changeset_status_lbl(c.current_changeset_status)}
45 </div>
45 </div>
46 <div class="changeset-status-ico" style="padding:1px 4px"><img src="${h.url('/images/icons/flag_status_%s.png' % c.current_changeset_status)}" /></div>
46 <div class="changeset-status-ico" style="padding:1px 4px"><img src="${h.url('/images/icons/flag_status_%s.png' % c.current_changeset_status)}" /></div>
47 %endif
47 %endif
48 </div>
48 </div>
49 </div>
49 </div>
50 </div>
50 </div>
51 <div class="field">
51 <div class="field">
52 <div class="label-summary">
52 <div class="label-summary">
53 <label>${_('Still not reviewed by')}:</label>
53 <label>${_('Still not reviewed by')}:</label>
54 </div>
54 </div>
55 <div class="input">
55 <div class="input">
56 % if len(c.pull_request_pending_reviewers) > 0:
56 % if len(c.pull_request_pending_reviewers) > 0:
57 <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>
57 <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>
58 %else:
58 %else:
59 <div>${_('Pull request was reviewed by all reviewers')}</div>
59 <div>${_('Pull request was reviewed by all reviewers')}</div>
60 %endif
60 %endif
61 </div>
61 </div>
62 </div>
62 </div>
63 <div class="field">
63 <div class="field">
64 <div class="label-summary">
64 <div class="label-summary">
65 <label>${_('Origin repository')}:</label>
65 <label>${_('Origin repository')}:</label>
66 </div>
66 </div>
67 <div class="input">
67 <div class="input">
68 <div>
68 <div>
69 ##%if h.is_hg(c.pull_request.org_repo):
69 ##%if h.is_hg(c.pull_request.org_repo):
70 ## <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
70 ## <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
71 ##%elif h.is_git(c.pull_request.org_repo):
71 ##%elif h.is_git(c.pull_request.org_repo):
72 ## <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/>
72 ## <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/>
73 ##%endif
73 ##%endif
74 <span class="spantag">${c.pull_request.org_ref_parts[0]}: ${c.pull_request.org_ref_parts[1]}</span>
74 <span class="spantag">${c.pull_request.org_ref_parts[0]}: ${c.pull_request.org_ref_parts[1]}</span>
75 <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>
75 <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>
76 </div>
76 </div>
77 </div>
77 </div>
78 </div>
78 </div>
79 <div class="field">
79 <div class="field">
80 <div class="label-summary">
80 <div class="label-summary">
81 <label>${_('Description')}:</label>
81 <label>${_('Description')}:</label>
82 </div>
82 </div>
83 <div class="input">
83 <div class="input">
84 <div style="white-space:pre-wrap">${h.literal(c.pull_request.description)}</div>
84 <div style="white-space:pre-wrap">${h.urlify_commit(c.pull_request.description)}</div>
85 </div>
85 </div>
86 </div>
86 </div>
87 <div class="field">
87 <div class="field">
88 <div class="label-summary">
88 <div class="label-summary">
89 <label>${_('Created on')}:</label>
89 <label>${_('Created on')}:</label>
90 </div>
90 </div>
91 <div class="input">
91 <div class="input">
92 <div>${h.fmt_date(c.pull_request.created_on)}</div>
92 <div>${h.fmt_date(c.pull_request.created_on)}</div>
93 </div>
93 </div>
94 </div>
94 </div>
95 </div>
95 </div>
96 </div>
96 </div>
97
97
98 <div style="overflow: auto;">
98 <div style="overflow: auto;">
99 ##DIFF
99 ##DIFF
100 <div class="table" style="float:left;clear:none">
100 <div class="table" style="float:left;clear:none">
101 <div id="body" class="diffblock">
101 <div id="body" class="diffblock">
102 <div style="white-space:pre-wrap;padding:5px">${_('Compare view')}</div>
102 <div style="white-space:pre-wrap;padding:5px">${_('Compare view')}</div>
103 </div>
103 </div>
104 <div id="changeset_compare_view_content">
104 <div id="changeset_compare_view_content">
105 ##CS
105 ##CS
106 <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>
106 <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>
107 <%include file="/compare/compare_cs.html" />
107 <%include file="/compare/compare_cs.html" />
108
108
109 ## FILES
109 ## FILES
110 <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
110 <div style="font-size:1.1em;font-weight: bold;clear:both;padding-top:10px">
111
111
112 % if c.limited_diff:
112 % if c.limited_diff:
113 ${ungettext('%s file changed', '%s files changed', len(c.files)) % len(c.files)}
113 ${ungettext('%s file changed', '%s files changed', len(c.files)) % len(c.files)}
114 % else:
114 % else:
115 ${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)}:
115 ${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)}:
116 %endif
116 %endif
117
117
118 </div>
118 </div>
119 <div class="cs_files">
119 <div class="cs_files">
120 %if not c.files:
120 %if not c.files:
121 <span class="empty_data">${_('No files')}</span>
121 <span class="empty_data">${_('No files')}</span>
122 %endif
122 %endif
123 %for fid, change, f, stat in c.files:
123 %for fid, change, f, stat in c.files:
124 <div class="cs_${change}">
124 <div class="cs_${change}">
125 <div class="node">${h.link_to(h.safe_unicode(f),h.url.current(anchor=fid))}</div>
125 <div class="node">${h.link_to(h.safe_unicode(f),h.url.current(anchor=fid))}</div>
126 <div class="changes">${h.fancy_file_stats(stat)}</div>
126 <div class="changes">${h.fancy_file_stats(stat)}</div>
127 </div>
127 </div>
128 %endfor
128 %endfor
129 </div>
129 </div>
130 % if c.limited_diff:
130 % if c.limited_diff:
131 <h5>${_('Changeset was too big and was cut off...')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}" onclick="return confirm('${_("Showing a huge diff might take some time and resources")}')">${_('Show full diff')}</a></h5>
131 <h5>${_('Changeset was too big and was cut off...')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}" onclick="return confirm('${_("Showing a huge diff might take some time and resources")}')">${_('Show full diff')}</a></h5>
132 % endif
132 % endif
133 </div>
133 </div>
134 </div>
134 </div>
135 ## REVIEWERS
135 ## REVIEWERS
136 <div style="float:left; border-left:1px dashed #eee">
136 <div style="float:left; border-left:1px dashed #eee">
137 <h4>${_('Pull request reviewers')}</h4>
137 <h4>${_('Pull request reviewers')}</h4>
138 <div id="reviewers" style="padding:0px 0px 5px 10px">
138 <div id="reviewers" style="padding:0px 0px 5px 10px">
139 ## members goes here !
139 ## members goes here !
140 <div class="group_members_wrap" style="min-height:45px">
140 <div class="group_members_wrap" style="min-height:45px">
141 <ul id="review_members" class="group_members">
141 <ul id="review_members" class="group_members">
142 %for member,status in c.pull_request_reviewers:
142 %for member,status in c.pull_request_reviewers:
143 <li id="reviewer_${member.user_id}">
143 <li id="reviewer_${member.user_id}">
144 <div class="reviewers_member">
144 <div class="reviewers_member">
145 <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'))}">
145 <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'))}">
146 <img src="${h.url(str('/images/icons/flag_status_%s.png' % (status[0][1].status if status else 'not_reviewed')))}"/>
146 <img src="${h.url(str('/images/icons/flag_status_%s.png' % (status[0][1].status if status else 'not_reviewed')))}"/>
147 </div>
147 </div>
148 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(member.email,14)}"/> </div>
148 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(member.email,14)}"/> </div>
149 <div style="float:left">${member.full_name} (${_('owner') if c.pull_request.user_id == member.user_id else _('reviewer')})</div>
149 <div style="float:left">${member.full_name} (${_('owner') if c.pull_request.user_id == member.user_id else _('reviewer')})</div>
150 <input type="hidden" value="${member.user_id}" name="review_members" />
150 <input type="hidden" value="${member.user_id}" name="review_members" />
151 %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):
151 %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):
152 <span class="delete_icon action_button" onclick="removeReviewMember(${member.user_id})"></span>
152 <span class="delete_icon action_button" onclick="removeReviewMember(${member.user_id})"></span>
153 %endif
153 %endif
154 </div>
154 </div>
155 </li>
155 </li>
156 %endfor
156 %endfor
157 </ul>
157 </ul>
158 </div>
158 </div>
159 %if not c.pull_request.is_closed():
159 %if not c.pull_request.is_closed():
160 <div class='ac'>
160 <div class='ac'>
161 %if h.HasPermissionAny('hg.admin', 'repository.admin')() or c.pull_request.author.user_id == c.rhodecode_user.user_id:
161 %if h.HasPermissionAny('hg.admin', 'repository.admin')() or c.pull_request.author.user_id == c.rhodecode_user.user_id:
162 <div class="reviewer_ac">
162 <div class="reviewer_ac">
163 ${h.text('user', class_='yui-ac-input')}
163 ${h.text('user', class_='yui-ac-input')}
164 <span class="help-block">${_('Add or remove reviewer to this pull request.')}</span>
164 <span class="help-block">${_('Add or remove reviewer to this pull request.')}</span>
165 <div id="reviewers_container"></div>
165 <div id="reviewers_container"></div>
166 </div>
166 </div>
167 <div style="padding:0px 10px">
167 <div style="padding:0px 10px">
168 <span id="update_pull_request" class="ui-btn xsmall">${_('Save changes')}</span>
168 <span id="update_pull_request" class="ui-btn xsmall">${_('Save changes')}</span>
169 </div>
169 </div>
170 %endif
170 %endif
171 </div>
171 </div>
172 %endif
172 %endif
173 </div>
173 </div>
174 </div>
174 </div>
175 </div>
175 </div>
176 <script>
176 <script>
177 var _USERS_AC_DATA = ${c.users_array|n};
177 var _USERS_AC_DATA = ${c.users_array|n};
178 var _GROUPS_AC_DATA = ${c.users_groups_array|n};
178 var _GROUPS_AC_DATA = ${c.users_groups_array|n};
179 // TODO: switch this to pyroutes
179 // TODO: switch this to pyroutes
180 AJAX_COMMENT_URL = "${url('pullrequest_comment',repo_name=c.repo_name,pull_request_id=c.pull_request.pull_request_id)}";
180 AJAX_COMMENT_URL = "${url('pullrequest_comment',repo_name=c.repo_name,pull_request_id=c.pull_request.pull_request_id)}";
181 AJAX_COMMENT_DELETE_URL = "${url('pullrequest_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}";
181 AJAX_COMMENT_DELETE_URL = "${url('pullrequest_comment_delete',repo_name=c.repo_name,comment_id='__COMMENT_ID__')}";
182
182
183 pyroutes.register('pullrequest_comment', "${url('pullrequest_comment',repo_name='%(repo_name)s',pull_request_id='%(pull_request_id)s')}", ['repo_name', 'pull_request_id']);
183 pyroutes.register('pullrequest_comment', "${url('pullrequest_comment',repo_name='%(repo_name)s',pull_request_id='%(pull_request_id)s')}", ['repo_name', 'pull_request_id']);
184 pyroutes.register('pullrequest_comment_delete', "${url('pullrequest_comment_delete',repo_name='%(repo_name)s',comment_id='%(comment_id)s')}", ['repo_name', 'comment_id']);
184 pyroutes.register('pullrequest_comment_delete', "${url('pullrequest_comment_delete',repo_name='%(repo_name)s',comment_id='%(comment_id)s')}", ['repo_name', 'comment_id']);
185 pyroutes.register('pullrequest_update', "${url('pullrequest_update',repo_name='%(repo_name)s',pull_request_id='%(pull_request_id)s')}", ['repo_name', 'pull_request_id']);
185 pyroutes.register('pullrequest_update', "${url('pullrequest_update',repo_name='%(repo_name)s',pull_request_id='%(pull_request_id)s')}", ['repo_name', 'pull_request_id']);
186
186
187 </script>
187 </script>
188
188
189 ## diff block
189 ## diff block
190 <%namespace name="diff_block" file="/changeset/diff_block.html"/>
190 <%namespace name="diff_block" file="/changeset/diff_block.html"/>
191 %for fid, change, f, stat in c.files:
191 %for fid, change, f, stat in c.files:
192 ${diff_block.diff_block_simple([c.changes[fid]])}
192 ${diff_block.diff_block_simple([c.changes[fid]])}
193 %endfor
193 %endfor
194 % if c.limited_diff:
194 % if c.limited_diff:
195 <h4>${_('Changeset was too big and was cut off...')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}" onclick="return confirm('${_("Showing a huge diff might take some time and resources")}')">${_('Show full diff')}</a></h4>
195 <h4>${_('Changeset was too big and was cut off...')} <a href="${h.url.current(fulldiff=1, **request.GET.mixed())}" onclick="return confirm('${_("Showing a huge diff might take some time and resources")}')">${_('Show full diff')}</a></h4>
196 % endif
196 % endif
197
197
198
198
199 ## template for inline comment form
199 ## template for inline comment form
200 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
200 <%namespace name="comment" file="/changeset/changeset_file_comment.html"/>
201 ${comment.comment_inline_form()}
201 ${comment.comment_inline_form()}
202
202
203 ## render comments and inlines
203 ## render comments and inlines
204 ${comment.generate_comments(include_pr=True)}
204 ${comment.generate_comments(include_pr=True)}
205
205
206 % if not c.pull_request.is_closed():
206 % if not c.pull_request.is_closed():
207 ## main comment form and it status
207 ## main comment form and it status
208 ${comment.comments(h.url('pullrequest_comment', repo_name=c.repo_name,
208 ${comment.comments(h.url('pullrequest_comment', repo_name=c.repo_name,
209 pull_request_id=c.pull_request.pull_request_id),
209 pull_request_id=c.pull_request.pull_request_id),
210 c.current_changeset_status,
210 c.current_changeset_status,
211 close_btn=True, change_status=c.allowed_to_change_status)}
211 close_btn=True, change_status=c.allowed_to_change_status)}
212 %endif
212 %endif
213
213
214 <script type="text/javascript">
214 <script type="text/javascript">
215 YUE.onDOMReady(function(){
215 YUE.onDOMReady(function(){
216 PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
216 PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
217
217
218 YUE.on(YUQ('.show-inline-comments'),'change',function(e){
218 YUE.on(YUQ('.show-inline-comments'),'change',function(e){
219 var show = 'none';
219 var show = 'none';
220 var target = e.currentTarget;
220 var target = e.currentTarget;
221 if(target.checked){
221 if(target.checked){
222 var show = ''
222 var show = ''
223 }
223 }
224 var boxid = YUD.getAttribute(target,'id_for');
224 var boxid = YUD.getAttribute(target,'id_for');
225 var comments = YUQ('#{0} .inline-comments'.format(boxid));
225 var comments = YUQ('#{0} .inline-comments'.format(boxid));
226 for(c in comments){
226 for(c in comments){
227 YUD.setStyle(comments[c],'display',show);
227 YUD.setStyle(comments[c],'display',show);
228 }
228 }
229 var btns = YUQ('#{0} .inline-comments-button'.format(boxid));
229 var btns = YUQ('#{0} .inline-comments-button'.format(boxid));
230 for(c in btns){
230 for(c in btns){
231 YUD.setStyle(btns[c],'display',show);
231 YUD.setStyle(btns[c],'display',show);
232 }
232 }
233 })
233 })
234
234
235 YUE.on(YUQ('.line'),'click',function(e){
235 YUE.on(YUQ('.line'),'click',function(e){
236 var tr = e.currentTarget;
236 var tr = e.currentTarget;
237 injectInlineForm(tr);
237 injectInlineForm(tr);
238 });
238 });
239
239
240 // inject comments into they proper positions
240 // inject comments into they proper positions
241 var file_comments = YUQ('.inline-comment-placeholder');
241 var file_comments = YUQ('.inline-comment-placeholder');
242 renderInlineComments(file_comments);
242 renderInlineComments(file_comments);
243
243
244 YUE.on(YUD.get('update_pull_request'),'click',function(e){
244 YUE.on(YUD.get('update_pull_request'),'click',function(e){
245 updateReviewers(undefined, "${c.repo_name}", "${c.pull_request.pull_request_id}");
245 updateReviewers(undefined, "${c.repo_name}", "${c.pull_request.pull_request_id}");
246 })
246 })
247 })
247 })
248 </script>
248 </script>
249
249
250 </div>
250 </div>
251
251
252 </%def>
252 </%def>
General Comments 0
You need to be logged in to leave comments. Login now