summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/diffs/store/actions.js
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-10-18 08:50:38 +0100
committerPhil Hughes <me@iamphill.com>2018-11-05 14:02:41 +0000
commitf7df9ddb52be8a03b8fbd8c9a870f3e3af577562 (patch)
tree9ee176674a1aa2a4d57b2ffcb88c03e522891529 /app/assets/javascripts/diffs/store/actions.js
parent7d4b717c92d0e2f1db07fb3de0ce356b15d2f7df (diff)
downloadgitlab-ce-f7df9ddb52be8a03b8fbd8c9a870f3e3af577562.tar.gz
Re-implemented image commenting on diffs
This re-implements image commenting in merge request diffs. This feature was previously lost when the merge request page was refactored into Vue. With this, we create an overlay component. The overlay component handles displaying the comment badges and the comment form badge. Badges are displayed based on the position attribute sent with the discussion. Comment forms for diff files are controlled through a different state property. This is so we don't tie comment forms to diff files directly creating deep nested state. Instead we create a flat array which holds the file hash & the X & Y position of the comment form. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/48956
Diffstat (limited to 'app/assets/javascripts/diffs/store/actions.js')
-rw-r--r--app/assets/javascripts/diffs/store/actions.js19
1 files changed, 17 insertions, 2 deletions
diff --git a/app/assets/javascripts/diffs/store/actions.js b/app/assets/javascripts/diffs/store/actions.js
index ca8ae605cb4..d3e9c7c88f0 100644
--- a/app/assets/javascripts/diffs/store/actions.js
+++ b/app/assets/javascripts/diffs/store/actions.js
@@ -50,8 +50,8 @@ export const assignDiscussionsToDiff = (
};
export const removeDiscussionsFromDiff = ({ commit }, removeDiscussion) => {
- const { fileHash, line_code } = removeDiscussion;
- commit(types.REMOVE_LINE_DISCUSSIONS_FOR_FILE, { fileHash, lineCode: line_code });
+ const { fileHash, line_code, id } = removeDiscussion;
+ commit(types.REMOVE_LINE_DISCUSSIONS_FOR_FILE, { fileHash, lineCode: line_code, id });
};
export const startRenderDiffsQueue = ({ state, commit }) => {
@@ -189,6 +189,7 @@ export const saveDiffDiscussion = ({ dispatch }, { note, formData }) => {
return dispatch('saveNote', postData, { root: true })
.then(result => dispatch('updateDiscussion', result.discussion, { root: true }))
.then(discussion => dispatch('assignDiscussionsToDiff', [discussion]))
+ .then(() => dispatch('closeDiffFileCommentForm', formData.diffFile.fileHash))
.catch(() => createFlash(s__('MergeRequests|Saving the comment failed')));
};
@@ -210,5 +211,19 @@ export const toggleShowTreeList = ({ commit, state }) => {
localStorage.setItem(MR_TREE_SHOW_KEY, state.showTreeList);
};
+export const openDiffFileCommentForm = ({ commit, getters }, formData) => {
+ const form = getters.getCommentFormForDiffFile(formData.fileHash);
+
+ if (form) {
+ commit(types.UPDATE_DIFF_FILE_COMMENT_FORM, formData);
+ } else {
+ commit(types.OPEN_DIFF_FILE_COMMENT_FORM, formData);
+ }
+};
+
+export const closeDiffFileCommentForm = ({ commit }, fileHash) => {
+ commit(types.CLOSE_DIFF_FILE_COMMENT_FORM, fileHash);
+};
+
// prevent babel-plugin-rewire from generating an invalid default during karma tests
export default () => {};