summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-07 17:29:08 +0100
committerPhil Hughes <me@iamphill.com>2017-04-14 15:30:43 +0100
commit115d1afeb386d2b1fef4ca437fafd8227d72c0ad (patch)
treed28a241e28d35328239f3dc49df941d581a74c4e
parent3c9318a8c58f638f57cfe86cb2f84625445996c8 (diff)
downloadgitlab-ce-remove-double-newline-for-single-attachments.tar.gz
Only add newlines for multiple uploadsremove-double-newline-for-single-attachments
-rw-r--r--app/assets/javascripts/dropzone_input.js10
-rw-r--r--changelogs/unreleased/remove-double-newline-for-single-attachments.yml4
-rw-r--r--spec/features/issues_spec.rb4
3 files changed, 13 insertions, 5 deletions
diff --git a/app/assets/javascripts/dropzone_input.js b/app/assets/javascripts/dropzone_input.js
index f2963a5eb19..df0e3f46827 100644
--- a/app/assets/javascripts/dropzone_input.js
+++ b/app/assets/javascripts/dropzone_input.js
@@ -66,7 +66,10 @@ window.DropzoneInput = (function() {
form_textarea.focus();
},
success: function(header, response) {
- pasteText(response.link.markdown);
+ const processingFileCount = this.getQueuedFiles().length + this.getUploadingFiles().length;
+ const shouldPad = processingFileCount >= 1;
+
+ pasteText(response.link.markdown, shouldPad);
},
error: function(temp) {
var checkIfMsgExists, errorAlert;
@@ -123,9 +126,10 @@ window.DropzoneInput = (function() {
}
return false;
};
- pasteText = function(text) {
+ pasteText = function(text, shouldPad) {
var afterSelection, beforeSelection, caretEnd, caretStart, textEnd;
- var formattedText = text + "\n\n";
+ var formattedText = text;
+ if (shouldPad) formattedText += "\n\n";
caretStart = $(child)[0].selectionStart;
caretEnd = $(child)[0].selectionEnd;
textEnd = $(child).val().length;
diff --git a/changelogs/unreleased/remove-double-newline-for-single-attachments.yml b/changelogs/unreleased/remove-double-newline-for-single-attachments.yml
new file mode 100644
index 00000000000..98a28e1ede1
--- /dev/null
+++ b/changelogs/unreleased/remove-double-newline-for-single-attachments.yml
@@ -0,0 +1,4 @@
+---
+title: Only add newlines between multiple uploads
+merge_request: 10545
+author:
diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb
index e3213d24f6a..362d167befa 100644
--- a/spec/features/issues_spec.rb
+++ b/spec/features/issues_spec.rb
@@ -601,10 +601,10 @@ describe 'Issues', feature: true do
expect(page.find_field("issue_description").value).to have_content 'banana_sample'
end
- it 'adds double newline to end of attachment markdown' do
+ it "doesn't add double newline to end of a single attachment markdown" do
dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif')
- expect(page.find_field("issue_description").value).to match /\n\n$/
+ expect(page.find_field("issue_description").value).not_to match /\n\n$/
end
end