From 8e5c0e68ec837fe247df271a58a819238b8c20b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Lu=C3=ADs?= Date: Sat, 6 Oct 2018 17:16:40 +0000 Subject: Backport CE changes for: [Frontend only] Batch comments on merge requests --- app/assets/javascripts/diffs/components/app.vue | 1 - app/assets/javascripts/diffs/store/utils.js | 12 ++++++-- app/assets/javascripts/mr_notes/stores/index.js | 17 +++++----- .../javascripts/notes/components/note_actions.vue | 33 ++++++++++++++++++-- .../javascripts/notes/components/note_body.vue | 2 +- .../javascripts/notes/components/note_form.vue | 2 +- .../javascripts/notes/components/note_header.vue | 36 +++++++++++++--------- .../javascripts/notes/components/noteable_note.vue | 28 ++++++++++++----- app/assets/javascripts/notes/stores/actions.js | 19 ++++++++++-- app/assets/javascripts/notes/stores/getters.js | 3 ++ .../stylesheets/framework/contextual_sidebar.scss | 8 ++--- app/assets/stylesheets/pages/notes.scss | 6 +++- app/helpers/notes_helper.rb | 2 +- app/views/projects/issues/_discussion.html.haml | 2 +- app/views/projects/merge_requests/show.html.haml | 2 +- 15 files changed, 123 insertions(+), 50 deletions(-) diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue index e60c53338fe..edca45f22f9 100644 --- a/app/assets/javascripts/diffs/components/app.vue +++ b/app/assets/javascripts/diffs/components/app.vue @@ -127,7 +127,6 @@ export default { 'startRenderDiffsQueue', 'assignDiscussionsToDiff', ]), - fetchData() { this.fetchDiffFiles() .then(() => { diff --git a/app/assets/javascripts/diffs/store/utils.js b/app/assets/javascripts/diffs/store/utils.js index c39403f1021..a482a2b82c0 100644 --- a/app/assets/javascripts/diffs/store/utils.js +++ b/app/assets/javascripts/diffs/store/utils.js @@ -25,7 +25,7 @@ export const getReversePosition = linePosition => { return LINE_POSITION_RIGHT; }; -export function getNoteFormData(params) { +export function getFormData(params) { const { note, noteableType, @@ -70,9 +70,15 @@ export function getNoteFormData(params) { }, }; + return postData; +} + +export function getNoteFormData(params) { + const data = getFormData(params); + return { - endpoint: noteableData.create_note_path, - data: postData, + endpoint: params.noteableData.create_note_path, + data, }; } diff --git a/app/assets/javascripts/mr_notes/stores/index.js b/app/assets/javascripts/mr_notes/stores/index.js index 446eb477efc..c4225c8ec08 100644 --- a/app/assets/javascripts/mr_notes/stores/index.js +++ b/app/assets/javascripts/mr_notes/stores/index.js @@ -6,10 +6,13 @@ import mrPageModule from './modules'; Vue.use(Vuex); -export default new Vuex.Store({ - modules: { - page: mrPageModule, - notes: notesModule(), - diffs: diffsModule(), - }, -}); +export const createStore = () => + new Vuex.Store({ + modules: { + page: mrPageModule, + notes: notesModule(), + diffs: diffsModule(), + }, + }); + +export default createStore(); diff --git a/app/assets/javascripts/notes/components/note_actions.vue b/app/assets/javascripts/notes/components/note_actions.vue index beb53da0e6d..e075f94b82b 100644 --- a/app/assets/javascripts/notes/components/note_actions.vue +++ b/app/assets/javascripts/notes/components/note_actions.vue @@ -7,10 +7,14 @@ import editSvg from 'icons/_icon_pencil.svg'; import resolveDiscussionSvg from 'icons/_icon_resolve_discussion.svg'; import resolvedDiscussionSvg from 'icons/_icon_status_success_solid.svg'; import ellipsisSvg from 'icons/_ellipsis_v.svg'; +import Icon from '~/vue_shared/components/icon.vue'; import tooltip from '~/vue_shared/directives/tooltip'; export default { name: 'NoteActions', + components: { + Icon, + }, directives: { tooltip, }, @@ -20,7 +24,7 @@ export default { required: true, }, noteId: { - type: String, + type: [String, Number], required: true, }, noteUrl: { @@ -35,7 +39,8 @@ export default { }, reportAbusePath: { type: String, - required: true, + required: false, + default: null, }, canEdit: { type: Boolean, @@ -84,6 +89,9 @@ export default { shouldShowActionsDropdown() { return this.currentUserId && (this.canEdit || this.canReportAsAbuse); }, + showDeleteAction() { + return this.canDelete && !this.canReportAsAbuse && !this.noteUrl; + }, isAuthoredByCurrentUser() { return this.authorId === this.currentUserId; }, @@ -201,7 +209,26 @@ export default {
+ +
+