##// END OF EJS Templates
pull requests: when creating, disable other_ref on other_repo change until new data has been loaded
Mads Kiilerich -
r4557:cb360bf4 default
parent child Browse files
Show More
@@ -1,271 +1,273
1 <%inherit file="/base/base.html"/>
1 <%inherit file="/base/base.html"/>
2
2
3 <%def name="title()">
3 <%def name="title()">
4 ${c.repo_name} ${_('New Pull Request')}
4 ${c.repo_name} ${_('New Pull Request')}
5 </%def>
5 </%def>
6
6
7 <%def name="breadcrumbs_links()">
7 <%def name="breadcrumbs_links()">
8 ${_('New Pull Request')}
8 ${_('New Pull Request')}
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 ${h.form(url('pullrequest', repo_name=c.repo_name), method='post', id='pull_request_form')}
23 ${h.form(url('pullrequest', repo_name=c.repo_name), method='post', id='pull_request_form')}
24 <div class="form">
24 <div class="form">
25 <!-- fields -->
25 <!-- fields -->
26
26
27 <div class="fields" style="float:left;width:50%;padding-right:30px;">
27 <div class="fields" style="float:left;width:50%;padding-right:30px;">
28
28
29 <div class="field">
29 <div class="field">
30 <div class="label">
30 <div class="label">
31 <label for="pullrequest_title">${_('Title')}:</label>
31 <label for="pullrequest_title">${_('Title')}:</label>
32 </div>
32 </div>
33 <div class="input">
33 <div class="input">
34 ${h.text('pullrequest_title',class_="large",placeholder=_('Summarize the changes - or leave empty'))}
34 ${h.text('pullrequest_title',class_="large",placeholder=_('Summarize the changes - or leave empty'))}
35 </div>
35 </div>
36 </div>
36 </div>
37
37
38 <div class="field">
38 <div class="field">
39 <div class="label label-textarea">
39 <div class="label label-textarea">
40 <label for="pullrequest_desc">${_('Description')}:</label>
40 <label for="pullrequest_desc">${_('Description')}:</label>
41 </div>
41 </div>
42 <div class="textarea text-area editor">
42 <div class="textarea text-area editor">
43 ${h.textarea('pullrequest_desc',size=30,placeholder=_('Write a short description on this pull request'))}
43 ${h.textarea('pullrequest_desc',size=30,placeholder=_('Write a short description on this pull request'))}
44 </div>
44 </div>
45 </div>
45 </div>
46
46
47 <div class="field">
47 <div class="field">
48 <div class="label label-textarea">
48 <div class="label label-textarea">
49 <label for="pullrequest_desc">${_('Changeset flow')}:</label>
49 <label for="pullrequest_desc">${_('Changeset flow')}:</label>
50 </div>
50 </div>
51 <div class="input">
51 <div class="input">
52 ##ORG
52 ##ORG
53 <div>
53 <div>
54 <div>
54 <div>
55 <div style="padding:5px 3px 3px 3px;">
55 <div style="padding:5px 3px 3px 3px;">
56 <b>${_('Origin repository')}:</b> <span id="org_repo_desc">${c.db_repo.description.split('\n')[0]}</span>
56 <b>${_('Origin repository')}:</b> <span id="org_repo_desc">${c.db_repo.description.split('\n')[0]}</span>
57 </div>
57 </div>
58 <div>
58 <div>
59 ${h.select('org_repo','',c.cs_repos,class_='refs')}:${h.select('org_ref',c.default_cs_ref,c.cs_refs,class_='refs')}
59 ${h.select('org_repo','',c.cs_repos,class_='refs')}:${h.select('org_ref',c.default_cs_ref,c.cs_refs,class_='refs')}
60 </div>
60 </div>
61 <div style="padding:5px 3px 3px 3px;">
61 <div style="padding:5px 3px 3px 3px;">
62 <b>${_('Revision')}:</b> <span id="org_rev_span">-</span>
62 <b>${_('Revision')}:</b> <span id="org_rev_span">-</span>
63 </div>
63 </div>
64 </div>
64 </div>
65 </div>
65 </div>
66
66
67 ##OTHER, most Probably the PARENT OF THIS FORK
67 ##OTHER, most Probably the PARENT OF THIS FORK
68 <div style="border-top: 1px solid #EEE; margin: 5px 0px 0px 0px">
68 <div style="border-top: 1px solid #EEE; margin: 5px 0px 0px 0px">
69 <div>
69 <div>
70 ## filled with JS
70 ## filled with JS
71 <div style="padding:5px 3px 3px 3px;">
71 <div style="padding:5px 3px 3px 3px;">
72 <b>${_('Destination repository')}:</b> <span id="other_repo_desc">${c.a_repo.description.split('\n')[0]}</span>
72 <b>${_('Destination repository')}:</b> <span id="other_repo_desc">${c.a_repo.description.split('\n')[0]}</span>
73 </div>
73 </div>
74 <div>
74 <div>
75 ${h.select('other_repo',c.a_repo.repo_name,c.a_repos,class_='refs')}:${h.select('other_ref',c.default_a_ref,c.a_refs,class_='refs')}
75 ${h.select('other_repo',c.a_repo.repo_name,c.a_repos,class_='refs')}:${h.select('other_ref',c.default_a_ref,c.a_refs,class_='refs')}
76 </div>
76 </div>
77 <div style="padding:5px 3px 3px 3px;">
77 <div style="padding:5px 3px 3px 3px;">
78 <b>${_('Revision')}:</b> <span id="other_rev_span">-</span>
78 <b>${_('Revision')}:</b> <span id="other_rev_span">-</span>
79 </div>
79 </div>
80 </div>
80 </div>
81 </div>
81 </div>
82 <div style="clear:both"></div>
82 <div style="clear:both"></div>
83 </div>
83 </div>
84 </div>
84 </div>
85
85
86 <div class="field">
86 <div class="field">
87 <div class="buttons">
87 <div class="buttons">
88 ${h.submit('save',_('Create Pull Request'),class_="btn")}
88 ${h.submit('save',_('Create Pull Request'),class_="btn")}
89 ${h.reset('reset',_('Reset'),class_="btn")}
89 ${h.reset('reset',_('Reset'),class_="btn")}
90 </div>
90 </div>
91 </div>
91 </div>
92
92
93 </div>
93 </div>
94
94
95 ## Reviewers
95 ## Reviewers
96 <div style="float:left; border-left:1px dashed #eee">
96 <div style="float:left; border-left:1px dashed #eee">
97 <div class="pr-details-title">${_('Pull Request Reviewers')}</div>
97 <div class="pr-details-title">${_('Pull Request Reviewers')}</div>
98 <div id="reviewers" style="padding:0px 0px 0px 15px">
98 <div id="reviewers" style="padding:0px 0px 0px 15px">
99 ## members goes here !
99 ## members goes here !
100 <div>
100 <div>
101 <ul id="review_members" class="group_members">
101 <ul id="review_members" class="group_members">
102 %for member in [c.a_repo.user]:
102 %for member in [c.a_repo.user]:
103 <li id="reviewer_${member.user_id}">
103 <li id="reviewer_${member.user_id}">
104 <div class="reviewers_member">
104 <div class="reviewers_member">
105 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(member.email, 14)}"/> </div>
105 <div class="gravatar"><img alt="gravatar" src="${h.gravatar_url(member.email, 14)}"/> </div>
106 <div style="float:left">${member.firstname} ${member.lastname} (${_('owner')})</div>
106 <div style="float:left">${member.firstname} ${member.lastname} (${_('owner')})</div>
107 <input type="hidden" value="${member.user_id}" name="review_members" />
107 <input type="hidden" value="${member.user_id}" name="review_members" />
108 <span class="action_button" style="padding: 3px" onclick="removeReviewMember(${member.user_id})" title="${_('Remove reviewer')}">
108 <span class="action_button" style="padding: 3px" onclick="removeReviewMember(${member.user_id})" title="${_('Remove reviewer')}">
109 <i class="icon-remove-sign" style="color: #FF4444;"></i>
109 <i class="icon-remove-sign" style="color: #FF4444;"></i>
110 </span>
110 </span>
111 </div>
111 </div>
112 </li>
112 </li>
113 %endfor
113 %endfor
114 </ul>
114 </ul>
115 </div>
115 </div>
116
116
117 <div class='ac'>
117 <div class='ac'>
118 <div class="reviewer_ac">
118 <div class="reviewer_ac">
119 ${h.text('user', class_='yui-ac-input',placeholder=_('Type name of reviewer to add'))}
119 ${h.text('user', class_='yui-ac-input',placeholder=_('Type name of reviewer to add'))}
120 <div id="reviewers_container"></div>
120 <div id="reviewers_container"></div>
121 </div>
121 </div>
122 </div>
122 </div>
123 </div>
123 </div>
124 </div>
124 </div>
125
125
126 <div style="clear:both;padding: 0 0 30px 0;"></div>
126 <div style="clear:both;padding: 0 0 30px 0;"></div>
127
127
128 <h4>${_('Changesets')}</h4>
128 <h4>${_('Changesets')}</h4>
129 <div style="float:left;padding:0px 30px 30px 30px">
129 <div style="float:left;padding:0px 30px 30px 30px">
130 ## overview pulled by ajax
130 ## overview pulled by ajax
131 <div style="float:left" id="pull_request_overview"></div>
131 <div style="float:left" id="pull_request_overview"></div>
132 </div>
132 </div>
133 <div style="clear:both;"></div>
133 <div style="clear:both;"></div>
134
134
135 </div>
135 </div>
136
136
137 ${h.end_form()}
137 ${h.end_form()}
138
138
139 </div>
139 </div>
140
140
141 <script type="text/javascript" src="${h.url('/js/graph.js')}"></script>
141 <script type="text/javascript" src="${h.url('/js/graph.js')}"></script>
142 <script type="text/javascript">
142 <script type="text/javascript">
143 var _USERS_AC_DATA = ${c.users_array|n};
143 var _USERS_AC_DATA = ${c.users_array|n};
144 var _GROUPS_AC_DATA = ${c.user_groups_array|n};
144 var _GROUPS_AC_DATA = ${c.user_groups_array|n};
145 PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
145 PullRequestAutoComplete('user', 'reviewers_container', _USERS_AC_DATA, _GROUPS_AC_DATA);
146
146
147 pyroutes.register('pullrequest_repo_info', "${url('pullrequest_repo_info',repo_name='%(repo_name)s')}", ['repo_name']);
147 pyroutes.register('pullrequest_repo_info', "${url('pullrequest_repo_info',repo_name='%(repo_name)s')}", ['repo_name']);
148
148
149 var pendingajax = undefined;
149 var pendingajax = undefined;
150 var otherrepoChanged = function(){
150 var otherrepoChanged = function(){
151 var $other_ref = $('#other_ref');
152 $other_ref.prop('disabled', true);
151 var repo_name = $('#other_repo').val();
153 var repo_name = $('#other_repo').val();
152 if (pendingajax) {
154 if (pendingajax) {
153 pendingajax.abort();
155 pendingajax.abort();
154 pendingajax = undefined;
156 pendingajax = undefined;
155 }
157 }
156 pendingajax = ajaxGET(pyroutes.url('pullrequest_repo_info', {"repo_name": repo_name}),
158 pendingajax = ajaxGET(pyroutes.url('pullrequest_repo_info', {"repo_name": repo_name}),
157 function(o){
159 function(o){
158 pendingajax = undefined;
160 pendingajax = undefined;
159 var data = JSON.parse(o.responseText);
161 var data = JSON.parse(o.responseText);
160 $('#other_repo_desc').html(data.description);
162 $('#other_repo_desc').html(data.description);
161
163
162 // replace options of other_ref with the ones for the current other_repo
164 // replace options of other_ref with the ones for the current other_repo
163 var $other_ref = $('#other_ref');
164 $other_ref.empty();
165 $other_ref.empty();
165 for(var i = 0; i < data.refs.length; i++)
166 for(var i = 0; i < data.refs.length; i++)
166 {
167 {
167 var $optgroup = $('<optgroup/>').attr('label', data.refs[i][1]);
168 var $optgroup = $('<optgroup/>').attr('label', data.refs[i][1]);
168 var options = data.refs[i][0];
169 var options = data.refs[i][0];
169 var length = options.length;
170 var length = options.length;
170 for(var j = 0; j < length; j++)
171 for(var j = 0; j < length; j++)
171 {
172 {
172 $optgroup.append($('<option/>').text(options[j][1]).val(options[j][0]));
173 $optgroup.append($('<option/>').text(options[j][1]).val(options[j][0]));
173 }
174 }
174 $other_ref.append($optgroup);
175 $other_ref.append($optgroup);
175 }
176 }
176 $other_ref.val(data.selected_ref);
177 $other_ref.val(data.selected_ref);
177
178
178 // reset && add the reviewer based on selected repo
179 // reset && add the reviewer based on selected repo
179 YUD.get('review_members').innerHTML = '';
180 YUD.get('review_members').innerHTML = '';
180 addReviewMember(data.user.user_id, data.user.firstname,
181 addReviewMember(data.user.user_id, data.user.firstname,
181 data.user.lastname, data.user.username,
182 data.user.lastname, data.user.username,
182 data.user.gravatar_link);
183 data.user.gravatar_link);
183
184
184 // re-populate the select2 thingie
185 // re-populate the select2 thingie
185 $("#other_ref").select2({
186 $("#other_ref").select2({
186 dropdownAutoWidth: true
187 dropdownAutoWidth: true
187 });
188 });
188
189
190 $other_ref.prop('disabled', false);
189 loadPreview();
191 loadPreview();
190 });
192 });
191 };
193 };
192
194
193 var loadPreview = function(){
195 var loadPreview = function(){
194 //url template
196 //url template
195 var url = "${h.url('compare_url',
197 var url = "${h.url('compare_url',
196 repo_name='__other_repo__',
198 repo_name='__other_repo__',
197 org_ref_type='rev',
199 org_ref_type='rev',
198 org_ref_name='__other_ref_name__',
200 org_ref_name='__other_ref_name__',
199 other_repo='__org_repo__',
201 other_repo='__org_repo__',
200 other_ref_type='rev',
202 other_ref_type='rev',
201 other_ref_name='__org_ref_name__',
203 other_ref_name='__org_ref_name__',
202 as_form=True,
204 as_form=True,
203 merge=True,
205 merge=True,
204 )}";
206 )}";
205 var org_repo = YUQ('#pull_request_form #org_repo')[0].value;
207 var org_repo = YUQ('#pull_request_form #org_repo')[0].value;
206 var org_ref = YUQ('#pull_request_form #org_ref')[0].value.split(':');
208 var org_ref = YUQ('#pull_request_form #org_ref')[0].value.split(':');
207 ## TODO: make nice link like link_to_ref() do
209 ## TODO: make nice link like link_to_ref() do
208 YUD.get('org_rev_span').innerHTML = org_ref[2].substr(0,12);
210 YUD.get('org_rev_span').innerHTML = org_ref[2].substr(0,12);
209
211
210 var other_repo = YUQ('#pull_request_form #other_repo')[0].value;
212 var other_repo = YUQ('#pull_request_form #other_repo')[0].value;
211 var other_ref = YUQ('#pull_request_form #other_ref')[0].value.split(':');
213 var other_ref = YUQ('#pull_request_form #other_ref')[0].value.split(':');
212 YUD.get('other_rev_span').innerHTML = other_ref[2].substr(0,12);
214 YUD.get('other_rev_span').innerHTML = other_ref[2].substr(0,12);
213
215
214 var select_refs = YUQ('#pull_request_form select.refs')
216 var select_refs = YUQ('#pull_request_form select.refs')
215 var rev_data = {
217 var rev_data = {
216 '__org_repo__': org_repo,
218 '__org_repo__': org_repo,
217 '__org_ref_name__': org_ref[2],
219 '__org_ref_name__': org_ref[2],
218 '__other_repo__': other_repo,
220 '__other_repo__': other_repo,
219 '__other_ref_name__': other_ref[2]
221 '__other_ref_name__': other_ref[2]
220 }; // gather the org/other ref and repo here
222 }; // gather the org/other ref and repo here
221
223
222 for (k in rev_data){
224 for (k in rev_data){
223 url = url.replace(k,rev_data[k]);
225 url = url.replace(k,rev_data[k]);
224 }
226 }
225
227
226 if (pendingajax) {
228 if (pendingajax) {
227 pendingajax.abort();
229 pendingajax.abort();
228 pendingajax = undefined;
230 pendingajax = undefined;
229 }
231 }
230 pendingajax = asynchtml(url, $('#pull_request_overview'), function(o){
232 pendingajax = asynchtml(url, $('#pull_request_overview'), function(o){
231 pendingajax = undefined;
233 pendingajax = undefined;
232 var jsdata = eval('('+YUD.get('jsdata').innerHTML+')'); // TODO: just get json
234 var jsdata = eval('('+YUD.get('jsdata').innerHTML+')'); // TODO: just get json
233 var r = new BranchRenderer('graph_canvas', 'graph_content_pr');
235 var r = new BranchRenderer('graph_canvas', 'graph_content_pr');
234 r.render(jsdata,100);
236 r.render(jsdata,100);
235 });
237 });
236 }
238 }
237
239
238 $(document).ready(function(){
240 $(document).ready(function(){
239 $("#org_repo").select2({
241 $("#org_repo").select2({
240 dropdownAutoWidth: true
242 dropdownAutoWidth: true
241 });
243 });
242 ## (org_repo can't change)
244 ## (org_repo can't change)
243
245
244 $("#org_ref").select2({
246 $("#org_ref").select2({
245 dropdownAutoWidth: true
247 dropdownAutoWidth: true
246 });
248 });
247 $("#org_ref").on("change", function(e){
249 $("#org_ref").on("change", function(e){
248 loadPreview();
250 loadPreview();
249 });
251 });
250
252
251 $("#other_repo").select2({
253 $("#other_repo").select2({
252 dropdownAutoWidth: true
254 dropdownAutoWidth: true
253 });
255 });
254 $("#other_repo").on("change", function(e){
256 $("#other_repo").on("change", function(e){
255 otherrepoChanged();
257 otherrepoChanged();
256 });
258 });
257
259
258 $("#other_ref").select2({
260 $("#other_ref").select2({
259 dropdownAutoWidth: true
261 dropdownAutoWidth: true
260 });
262 });
261 $("#other_ref").on("change", function(e){
263 $("#other_ref").on("change", function(e){
262 loadPreview();
264 loadPreview();
263 });
265 });
264
266
265 //lazy load overview after 0.5s
267 //lazy load overview after 0.5s
266 setTimeout(loadPreview, 500);
268 setTimeout(loadPreview, 500);
267 });
269 });
268
270
269 </script>
271 </script>
270
272
271 </%def>
273 </%def>
General Comments 0
You need to be logged in to leave comments. Login now