diff --git a/pagure/templates/repo_new_pull_request.html b/pagure/templates/repo_new_pull_request.html index d92da05..f466870 100644 --- a/pagure/templates/repo_new_pull_request.html +++ b/pagure/templates/repo_new_pull_request.html @@ -26,21 +26,36 @@ {% block repo %} -{% if form and (g.repo_committer or remote_git) %} -

Create pull request

-{% else %} -

Diff - (tree)

- - {% if origin == 'compare_commits' %} -
{{ commit1 }} .. {{ commit2 }}
- {% endif %} -{% endif%} +

+
+
+ {% if form and (g.repo_committer or remote_git) %} + Create Pull Request + {% else %} + Diff + {% endif%} +
+
+
+ {% if diff %} + {{diff_commits | length}} commit{{'s' if diff_commits | length > 1 }}, + {{diff.stats.files_changed}} file{{'s' if diff.stats.files_changed > 1 }} changed + {% else %} + no changes + {% endif %} +
+
+
+ {% if diff %} + +{{diff.stats.insertions}} + -{{diff.stats.deletions}} + {% else %} + +0 + -0 + {% endif %} +
+
+

@@ -68,79 +83,142 @@ {% endif %}
Pull from - {% - if remote_git -%}{{ remote_git }}{%- - else -%} - {{ repo.fullname }} {%- - endif -%} + + {%- if remote_git -%} + {{ remote_git }} + {%- else -%} + {%- if repo.is_fork -%} +   + {%- else -%} +   + {%- endif -%} + {%- if repo.namespace -%} + {{repo.namespace}}/ + {%- endif -%} + {%- if repo.is_fork -%} + {{ repo.user.user }}/ + {%- endif -%} + {{repo.name}} + {%- endif -%} + + + + {{ branch_from }} + + + to + + + {%- if parent.is_fork -%} +   + {%- else -%} +   + {%- endif -%} + {%- if parent.namespace -%} + {{parent.namespace}}/ + {%- endif -%} + {%- if parent.is_fork -%} + {{ parent.user.user }}/ + {%- endif -%} + {{parent.name}} - - - + - into - - - {#{ parent.fullname }#} - -   - +
{% if contributing %}
{{ contributing | markdown | noJS | safe}}
{% endif %} - {{ render_bootstrap_field(form.title) }} -
- - - Preview - - {{ form.initial_comment(class_="form-control")|safe }} -
- - {% if form.initial_comment.errors %} - - - {% for error in form.initial_comment.errors %} - {{ error }}  - {% endfor %} - - - {% endif %} -
- -
-

- - {{ form.csrf_token }} - - Cancel - -

+ + +
+ {{ form.title(class_="form-control", placeholder="Pull Request Title", required="required")|safe }} + {% if form.title.errors %} + + + {% for error in form.title.errors %} + {{ error }}  + {% endfor %} + + + {% endif %} + +
+
+
+
+
+
+ +
+
+
+
+ + {% if form.initial_comment.errors %} + + + {% for error in form.initial_comment.errors %} + {{ error }}  + {% endfor %} + + + {% endif %} +
+
+
+ +
+ {{ form.csrf_token }} +
+ + {% endif %} @@ -165,7 +243,7 @@ -
+
@@ -236,7 +314,7 @@
-{# modal to change the target repo #} +{# modal to change the target repo
-
+
#} {% endblock %} {% block jscripts %} @@ -300,42 +378,26 @@ function showTab(){ $(document).ready(function() { - var branchselect = $('#branch_select').selectize({ - create: false, - sortField: 'text', - allowEmptyOption: false, - onChange: function(value) { - if (value != ""){ - var sel = $('#branch_select'); - var final_url = "{{ url_for('ui_ns.new_request_pull', username=username, - namespace=repo.namespace, repo=repo.name, - branch_from=branch_from, branch_to='--', project_to=project_to) }}"; - final_url = final_url.replace('--', sel.val()); - window.location.href = final_url; - } - } + $('.branch_from_item').click(function(e){ + var final_url = "{{ url_for('ui_ns.new_request_pull', username=username, + namespace=repo.namespace, repo=repo.name, + branch_from='--', branch_to=branch_to, project_to=project_to) }}"; + final_url = final_url.replace('--', $(this).attr("data-value")); + window.location.href = final_url; }); - var branchselect = $('#branch_from_select').selectize({ - create: false, - sortField: 'text', - allowEmptyOption: false, - onChange: function(value) { - if (value != ""){ - var sel = $('#branch_from_select'); - var final_url = "{{ url_for('ui_ns.new_request_pull', username=username, - namespace=repo.namespace, repo=repo.name, - branch_from='--', branch_to=branch_to, project_to=project_to) }}"; - final_url = final_url.replace('--', sel.val()); - console.log(final_url); - //return false; - window.location.href = final_url; - } - } + $('.branch_to_item').click(function(e){ + var final_url = "{{ url_for('ui_ns.new_request_pull', username=username, + namespace=repo.namespace, repo=repo.name, + branch_from=branch_from, branch_to='--', project_to=project_to) }}"; + final_url = final_url.replace('--', $(this).attr("data-value")); + window.location.href = final_url; }); + {% if form %} - $('#target_modal').on('shown.bs.modal', function (e) { + $('#family-toggle').click( function (e) { + $('#family-spinner').show(); var _url = '{{ url_for( 'internal_ns.get_project_family', repo=repo.name, @@ -349,25 +411,64 @@ $(document).ready(function() { csrf_token: "{{ g.confirmationform.csrf_token.current_token }}", }, success: function(res) { + $('#family-spinner').hide(); var _text = '' for (el in res.family) { - var _t = '
' - + ' ' - + ' ' - + '
'; + + ''; _t = _t.replace('---', res.family[el]); _text += _t; } - var _el = $('#family_list'); + var _el = $('#family-list'); _el.html(_text); }, }); }); + + $( "#preview" ).hide(); + + $( "#previewinmarkdown" ).click( + function(event, ui) { + var _text = $( "#initial_comment" ).val(); + var _url = "{{ url_for('ui_ns.markdown_preview', + repo=repo.name, + user=repo.user.user if repo.is_fork, + namespace=repo.namespace) | safe}}"; + $.ajax({ + url: _url , + type: 'POST', + data: { + content: _text, + csrf_token: "{{ g.confirmationform.csrf_token.current_token }}", + }, + dataType: 'html', + success: function(res) { + var preview = emojione.toImage(res); + $( "#preview" ).html(preview); + $( "#previewinmarkdown" ).toggleClass("active"); + $( "#editinmarkdown" ).toggleClass("active"); + $( "#initial_comment" ).hide(); + $( "#preview" ).show(); + }, + error: function(error) { + alert('Unable to generate preview!'+error); + console.log(error); + } + }); + return false; + } + ); + + $( "#editinmarkdown" ).click( + function(event, ui) { + $( "#editinmarkdown" ).toggleClass("active"); + $( "#previewinmarkdown" ).toggleClass("active"); + $( "#initial_comment" ).show(); + $( "#preview" ).hide(); + } + ); {% endif %} }); diff --git a/tests/test_pagure_flask_ui_fork.py b/tests/test_pagure_flask_ui_fork.py index a235e68..be59e7f 100644 --- a/tests/test_pagure_flask_ui_fork.py +++ b/tests/test_pagure_flask_ui_fork.py @@ -2009,7 +2009,7 @@ index 0000000..2a552bb 'Create new Pull Request for master - test\n - ' 'Pagure', output_text) self.assertIn( - '', + '\n', output_text) csrf_token = self.get_csrf(output=output) @@ -2094,7 +2094,7 @@ index 0000000..2a552bb 'This project enforces the ' 'Signed-off-by statement on all commits', output_text) self.assertNotIn( - '', + '\n', output_text) self.assertNotIn( 'This repo enforces that ' @@ -2137,7 +2137,7 @@ index 0000000..2a552bb 'This project enforces the ' 'Signed-off-by statement on all commits', output_text) self.assertIn( - '', + '\n', output_text) csrf_token = self.get_csrf(output=output) @@ -2165,7 +2165,7 @@ index 0000000..2a552bb 'This repo enforces that ' 'all commits are signed off by their author.', output_text) self.assertIn( - '', + '\n', output_text) @patch('pagure.lib.notify.send_email') @@ -2194,7 +2194,7 @@ index 0000000..2a552bb 'Create new Pull Request for master - test\n - ' 'Pagure', output_text) self.assertIn( - '', + '\n', output_text) csrf_token = self.get_csrf(output=output) @@ -2361,7 +2361,7 @@ index 0000000..2a552bb 'Create new Pull Request for master - fork/ralph/test\n - ' 'Pagure', output_text) self.assertIn( - '', + '\n', output_text) csrf_token = self.get_csrf(output=output) @@ -2456,7 +2456,7 @@ index 0000000..2a552bb 'Create new Pull Request for master - fork/ralph/test\n - ' 'Pagure', output_text) self.assertIn( - '', + '\n', output_text) csrf_token = self.get_csrf(output=output) diff --git a/tests/test_pagure_flask_ui_remote_pr.py b/tests/test_pagure_flask_ui_remote_pr.py index a96ccb9..688f945 100644 --- a/tests/test_pagure_flask_ui_remote_pr.py +++ b/tests/test_pagure_flask_ui_remote_pr.py @@ -216,7 +216,7 @@ class PagureRemotePRtests(tests.Modeltests): output = self.app.post('/test/diff/remote', data=data) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) - self.assertIn('

Create pull request

', output_text) + self.assertIn('Create Pull Request\n \n', output_text) self.assertIn( '
', output_text) self.assertIn( @@ -349,7 +349,7 @@ class PagureRemotePRtests(tests.Modeltests): output = self.app.post('/test/diff/remote', data=data) self.assertEqual(output.status_code, 200) output_text = output.get_data(as_text=True) - self.assertIn('

Create pull request

', output_text) + self.assertIn('Create Pull Request\n
\n', output_text) self.assertIn( '
', output_text) self.assertNotIn(