Commit 15acb6c5 authored by Filipa Lacerda's avatar Filipa Lacerda

Merge branch '27614-instant-comments' into 'master'

Add instant comments support

Closes #27614

See merge request !10760
parents a5347fe5 645593e5
...@@ -43,8 +43,8 @@ $(document).on('keydown.quick_submit', '.js-quick-submit', (e) => { ...@@ -43,8 +43,8 @@ $(document).on('keydown.quick_submit', '.js-quick-submit', (e) => {
const $submitButton = $form.find('input[type=submit], button[type=submit]'); const $submitButton = $form.find('input[type=submit], button[type=submit]');
if (!$submitButton.attr('disabled')) { if (!$submitButton.attr('disabled')) {
$submitButton.trigger('click', [e]);
$submitButton.disable(); $submitButton.disable();
$form.submit();
} }
}); });
......
...@@ -35,6 +35,14 @@ ...@@ -35,6 +35,14 @@
}); });
}; };
w.gl.utils.ajaxPost = function(url, data) {
return $.ajax({
type: 'POST',
url: url,
data: data,
});
};
w.gl.utils.extractLast = function(term) { w.gl.utils.extractLast = function(term) {
return this.split(term).pop(); return this.split(term).pop();
}; };
......
This diff is collapsed.
...@@ -159,3 +159,31 @@ a { ...@@ -159,3 +159,31 @@ a {
.fade-in { .fade-in {
animation: fadeIn $fade-in-duration 1; animation: fadeIn $fade-in-duration 1;
} }
@keyframes fadeInHalf {
0% {
opacity: 0;
}
100% {
opacity: 0.5;
}
}
.fade-in-half {
animation: fadeInHalf $fade-in-duration 1;
}
@keyframes fadeInFull {
0% {
opacity: 0.5;
}
100% {
opacity: 1;
}
}
.fade-in-full {
animation: fadeInFull $fade-in-duration 1;
}
...@@ -57,6 +57,25 @@ ul.notes { ...@@ -57,6 +57,25 @@ ul.notes {
position: relative; position: relative;
border-bottom: 1px solid $white-normal; border-bottom: 1px solid $white-normal;
&.being-posted {
pointer-events: none;
opacity: 0.5;
.dummy-avatar {
display: inline-block;
height: 40px;
width: 40px;
border-radius: 50%;
background-color: $kdb-border;
border: 1px solid darken($kdb-border, 25%);
}
.note-headline-light,
.fa-spinner {
margin-left: 3px;
}
}
&.note-discussion { &.note-discussion {
&.timeline-entry { &.timeline-entry {
padding: 14px 10px; padding: 14px 10px;
...@@ -687,6 +706,10 @@ ul.notes { ...@@ -687,6 +706,10 @@ ul.notes {
} }
} }
.discussion-notes .flash-container {
margin-bottom: 0;
}
// Merge request notes in diffs // Merge request notes in diffs
.diff-file { .diff-file {
// Diff is side by side // Diff is side by side
......
.discussion-notes .discussion-notes
%ul.notes{ data: { discussion_id: discussion.id } } %ul.notes{ data: { discussion_id: discussion.id } }
= render partial: "shared/notes/note", collection: discussion.notes, as: :note = render partial: "shared/notes/note", collection: discussion.notes, as: :note
.flash-container
- if current_user - if current_user
.discussion-reply-holder .discussion-reply-holder
......
...@@ -9,6 +9,6 @@ ...@@ -9,6 +9,6 @@
.note-form-actions.clearfix .note-form-actions.clearfix
.settings-message.note-edit-warning.js-finish-edit-warning .settings-message.note-edit-warning.js-finish-edit-warning
Finish editing this message first! Finish editing this message first!
= submit_tag 'Save comment', class: 'btn btn-nr btn-save js-comment-button' = submit_tag 'Save comment', class: 'btn btn-nr btn-save js-comment-save-button'
%button.btn.btn-nr.btn-cancel.note-edit-cancel{ type: 'button' } %button.btn.btn-nr.btn-cancel.note-edit-cancel{ type: 'button' }
Cancel Cancel
---
title: Add support for instantly updating comments
merge_request: 10760
author:
...@@ -458,6 +458,8 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps ...@@ -458,6 +458,8 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
click_button "Comment" click_button "Comment"
end end
wait_for_ajax
page.within ".files>div:nth-child(2) .note-body > .note-text" do page.within ".files>div:nth-child(2) .note-body > .note-text" do
expect(page).to have_content "Line is correct" expect(page).to have_content "Line is correct"
end end
...@@ -470,6 +472,8 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps ...@@ -470,6 +472,8 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
fill_in "note_note", with: "Line is wrong on here" fill_in "note_note", with: "Line is wrong on here"
click_button "Comment" click_button "Comment"
end end
wait_for_ajax
end end
step 'I should still see a comment like "Line is correct" in the second file' do step 'I should still see a comment like "Line is correct" in the second file' do
...@@ -574,6 +578,9 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps ...@@ -574,6 +578,9 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
fill_in "note_note", with: message fill_in "note_note", with: message
click_button "Comment" click_button "Comment"
end end
wait_for_ajax
page.within(".notes_holder", visible: true) do page.within(".notes_holder", visible: true) do
expect(page).to have_content message expect(page).to have_content message
end end
......
...@@ -24,6 +24,8 @@ module SharedNote ...@@ -24,6 +24,8 @@ module SharedNote
fill_in "note[note]", with: "XML attached" fill_in "note[note]", with: "XML attached"
click_button "Comment" click_button "Comment"
end end
wait_for_ajax
end end
step 'I preview a comment text like "Bug fixed :smile:"' do step 'I preview a comment text like "Bug fixed :smile:"' do
...@@ -37,6 +39,8 @@ module SharedNote ...@@ -37,6 +39,8 @@ module SharedNote
page.within(".js-main-target-form") do page.within(".js-main-target-form") do
click_button "Comment" click_button "Comment"
end end
wait_for_ajax
end end
step 'I write a comment like ":+1: Nice"' do step 'I write a comment like ":+1: Nice"' do
......
...@@ -98,6 +98,7 @@ describe 'Merge requests > User posts notes', :js do ...@@ -98,6 +98,7 @@ describe 'Merge requests > User posts notes', :js do
find('.btn-save').click find('.btn-save').click
end end
wait_for_ajax
find('.note').hover find('.note').hover
find('.js-note-edit').click find('.js-note-edit').click
......
...@@ -160,6 +160,7 @@ feature 'Merge Requests > User uses slash commands', feature: true, js: true do ...@@ -160,6 +160,7 @@ feature 'Merge Requests > User uses slash commands', feature: true, js: true do
it 'changes target branch from a note' do it 'changes target branch from a note' do
write_note("message start \n/target_branch merge-test\n message end.") write_note("message start \n/target_branch merge-test\n message end.")
wait_for_ajax
expect(page).not_to have_content('/target_branch') expect(page).not_to have_content('/target_branch')
expect(page).to have_content('message start') expect(page).to have_content('message start')
expect(page).to have_content('message end.') expect(page).to have_content('message end.')
......
...@@ -362,5 +362,16 @@ require('~/lib/utils/common_utils'); ...@@ -362,5 +362,16 @@ require('~/lib/utils/common_utils');
gl.utils.setCiStatusFavicon(BUILD_URL); gl.utils.setCiStatusFavicon(BUILD_URL);
}); });
}); });
describe('gl.utils.ajaxPost', () => {
it('should perform `$.ajax` call and do `POST` request', () => {
const requestURL = '/some/random/api';
const data = { keyname: 'value' };
const ajaxSpy = spyOn($, 'ajax').and.callFake(() => {});
gl.utils.ajaxPost(requestURL, data);
expect(ajaxSpy.calls.allArgs()[0][0].type).toEqual('POST');
});
});
}); });
})(); })();
This diff is collapsed.
...@@ -58,6 +58,7 @@ shared_examples 'issuable record that supports slash commands in its description ...@@ -58,6 +58,7 @@ shared_examples 'issuable record that supports slash commands in its description
expect(page).not_to have_content '/label ~bug' expect(page).not_to have_content '/label ~bug'
expect(page).not_to have_content '/milestone %"ASAP"' expect(page).not_to have_content '/milestone %"ASAP"'
wait_for_ajax
issuable.reload issuable.reload
note = issuable.notes.user.first note = issuable.notes.user.first
......
...@@ -8,6 +8,7 @@ shared_examples 'issuable time tracker' do ...@@ -8,6 +8,7 @@ shared_examples 'issuable time tracker' do
it 'updates the sidebar component when estimate is added' do it 'updates the sidebar component when estimate is added' do
submit_time('/estimate 3w 1d 1h') submit_time('/estimate 3w 1d 1h')
wait_for_ajax
page.within '.time-tracking-estimate-only-pane' do page.within '.time-tracking-estimate-only-pane' do
expect(page).to have_content '3w 1d 1h' expect(page).to have_content '3w 1d 1h'
end end
...@@ -16,6 +17,7 @@ shared_examples 'issuable time tracker' do ...@@ -16,6 +17,7 @@ shared_examples 'issuable time tracker' do
it 'updates the sidebar component when spent is added' do it 'updates the sidebar component when spent is added' do
submit_time('/spend 3w 1d 1h') submit_time('/spend 3w 1d 1h')
wait_for_ajax
page.within '.time-tracking-spend-only-pane' do page.within '.time-tracking-spend-only-pane' do
expect(page).to have_content '3w 1d 1h' expect(page).to have_content '3w 1d 1h'
end end
...@@ -25,6 +27,7 @@ shared_examples 'issuable time tracker' do ...@@ -25,6 +27,7 @@ shared_examples 'issuable time tracker' do
submit_time('/estimate 3w 1d 1h') submit_time('/estimate 3w 1d 1h')
submit_time('/spend 3w 1d 1h') submit_time('/spend 3w 1d 1h')
wait_for_ajax
page.within '.time-tracking-comparison-pane' do page.within '.time-tracking-comparison-pane' do
expect(page).to have_content '3w 1d 1h' expect(page).to have_content '3w 1d 1h'
end end
...@@ -34,6 +37,7 @@ shared_examples 'issuable time tracker' do ...@@ -34,6 +37,7 @@ shared_examples 'issuable time tracker' do
submit_time('/estimate 3w 1d 1h') submit_time('/estimate 3w 1d 1h')
submit_time('/remove_estimate') submit_time('/remove_estimate')
wait_for_ajax
page.within '#issuable-time-tracker' do page.within '#issuable-time-tracker' do
expect(page).to have_content 'No estimate or time spent' expect(page).to have_content 'No estimate or time spent'
end end
...@@ -43,6 +47,7 @@ shared_examples 'issuable time tracker' do ...@@ -43,6 +47,7 @@ shared_examples 'issuable time tracker' do
submit_time('/spend 3w 1d 1h') submit_time('/spend 3w 1d 1h')
submit_time('/remove_time_spent') submit_time('/remove_time_spent')
wait_for_ajax
page.within '#issuable-time-tracker' do page.within '#issuable-time-tracker' do
expect(page).to have_content 'No estimate or time spent' expect(page).to have_content 'No estimate or time spent'
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment