summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2019-04-12 10:27:24 +0100
committerPhil Hughes <me@iamphill.com>2019-04-12 10:27:24 +0100
commitb13ecdd6cc0d972a4563e1509d499969676f1488 (patch)
treed02fed2f5bf132c96192d75d0454f3c04fe995be
parent0276b8682e37d361adbd1ac89d9ba6992f0d1b60 (diff)
downloadgitlab-ce-b13ecdd6cc0d972a4563e1509d499969676f1488.tar.gz
CE backport of image-comment-reviews
-rw-r--r--app/assets/javascripts/diffs/components/diff_content.vue21
-rw-r--r--app/assets/javascripts/diffs/components/image_diff_overlay.vue9
-rw-r--r--app/assets/javascripts/diffs/mixins/draft_comments.js3
-rw-r--r--app/assets/javascripts/diffs/mixins/image_diff.js13
-rw-r--r--app/assets/javascripts/diffs/store/mutations.js4
5 files changed, 39 insertions, 11 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_content.vue b/app/assets/javascripts/diffs/components/diff_content.vue
index cb92093db32..8d09c2a7399 100644
--- a/app/assets/javascripts/diffs/components/diff_content.vue
+++ b/app/assets/javascripts/diffs/components/diff_content.vue
@@ -1,5 +1,7 @@
<script>
import { mapActions, mapGetters, mapState } from 'vuex';
+import diffLineNoteFormMixin from 'ee_else_ce/notes/mixins/diff_line_note_form';
+import draftCommentsMixin from 'ee_else_ce/diffs/mixins/draft_comments';
import DiffViewer from '~/vue_shared/components/diff_viewer/diff_viewer.vue';
import NotDiffableViewer from '~/vue_shared/components/diff_viewer/viewers/not_diffable.vue';
import NoPreviewViewer from '~/vue_shared/components/diff_viewer/viewers/no_preview.vue';
@@ -22,7 +24,9 @@ export default {
ImageDiffOverlay,
NotDiffableViewer,
NoPreviewViewer,
+ DiffFileDrafts: () => import('ee_component/batch_comments/components/diff_file_drafts.vue'),
},
+ mixins: [diffLineNoteFormMixin, draftCommentsMixin],
props: {
diffFile: {
type: Object,
@@ -58,10 +62,13 @@ export default {
return this.diffViewerMode === diffViewerModes.not_diffable;
},
diffFileCommentForm() {
- return this.getCommentFormForDiffFile(this.diffFile.file_hash);
+ return this.getCommentFormForDiffFile(this.diffFileHash);
},
showNotesContainer() {
- return this.diffFile.discussions.length || this.diffFileCommentForm;
+ return this.imageDiscussions.length || this.diffFileCommentForm;
+ },
+ diffFileHash() {
+ return this.diffFile.file_hash;
},
},
methods: {
@@ -112,15 +119,15 @@ export default {
:new-sha="diffFile.diff_refs.head_sha"
:old-path="diffFile.old_path"
:old-sha="diffFile.diff_refs.base_sha"
- :file-hash="diffFile.file_hash"
+ :file-hash="diffFileHash"
:project-path="projectPath"
:a-mode="diffFile.a_mode"
:b-mode="diffFile.b_mode"
>
<image-diff-overlay
slot="image-overlay"
- :discussions="diffFile.discussions"
- :file-hash="diffFile.file_hash"
+ :discussions="imageDiscussions"
+ :file-hash="diffFileHash"
:can-comment="getNoteableData.current_user.can_create_note"
/>
<div v-if="showNotesContainer" class="note-container">
@@ -131,14 +138,16 @@ export default {
:should-collapse-discussions="true"
:render-avatar-badge="true"
/>
+ <diff-file-drafts :file-hash="diffFileHash" class="diff-file-discussions" />
<note-form
v-if="diffFileCommentForm"
ref="noteForm"
:is-editing="false"
:save-button-title="__('Comment')"
class="diff-comment-form new-note discussion-form discussion-form-container"
+ @handleFormUpdateAddToReview="addToReview"
@handleFormUpdate="handleSaveNote"
- @cancelForm="closeDiffFileCommentForm(diffFile.file_hash)"
+ @cancelForm="closeDiffFileCommentForm(diffFileHash)"
/>
</div>
</diff-viewer>
diff --git a/app/assets/javascripts/diffs/components/image_diff_overlay.vue b/app/assets/javascripts/diffs/components/image_diff_overlay.vue
index 4a83c5a72a5..703a281308e 100644
--- a/app/assets/javascripts/diffs/components/image_diff_overlay.vue
+++ b/app/assets/javascripts/diffs/components/image_diff_overlay.vue
@@ -1,6 +1,7 @@
<script>
import { mapActions, mapGetters } from 'vuex';
import _ from 'underscore';
+import imageDiffMixin from 'ee_else_ce/diffs/mixins/image_diff';
import Icon from '~/vue_shared/components/icon.vue';
export default {
@@ -8,6 +9,7 @@ export default {
components: {
Icon,
},
+ mixins: [imageDiffMixin],
props: {
discussions: {
type: [Array, Object],
@@ -48,7 +50,6 @@ export default {
},
},
methods: {
- ...mapActions(['toggleDiscussion']),
...mapActions('diffs', ['openDiffFileCommentForm']),
getImageDimensions() {
return {
@@ -105,15 +106,15 @@ export default {
v-for="(discussion, index) in allDiscussions"
:key="discussion.id"
:style="getPosition(discussion)"
- :class="badgeClass"
+ :class="[badgeClass, { 'is-draft': discussion.isDraft }]"
:disabled="!shouldToggleDiscussion"
class="js-image-badge"
type="button"
- @click="toggleDiscussion({ discussionId: discussion.id })"
+ @click="clickedToggle(discussion)"
>
<icon v-if="showCommentIcon" name="image-comment-dark" />
<template v-else>
- {{ index + 1 }}
+ {{ toggleText(discussion, index) }}
</template>
</button>
<button
diff --git a/app/assets/javascripts/diffs/mixins/draft_comments.js b/app/assets/javascripts/diffs/mixins/draft_comments.js
index cfa722b27f1..dfb71bf38ce 100644
--- a/app/assets/javascripts/diffs/mixins/draft_comments.js
+++ b/app/assets/javascripts/diffs/mixins/draft_comments.js
@@ -3,5 +3,8 @@ export default {
shouldRenderDraftRow: () => () => false,
shouldRenderParallelDraftRow: () => () => false,
draftForLine: () => () => ({}),
+ imageDiscussions() {
+ return this.diffFile.discussions;
+ },
},
};
diff --git a/app/assets/javascripts/diffs/mixins/image_diff.js b/app/assets/javascripts/diffs/mixins/image_diff.js
new file mode 100644
index 00000000000..9067ea6f8b3
--- /dev/null
+++ b/app/assets/javascripts/diffs/mixins/image_diff.js
@@ -0,0 +1,13 @@
+import { mapActions } from 'vuex';
+
+export default {
+ methods: {
+ ...mapActions(['toggleDiscussion']),
+ clickedToggle(discussion) {
+ this.toggleDiscussion({ discussionId: discussion.id });
+ },
+ toggleText(discussion, index) {
+ return index + 1;
+ },
+ },
+};
diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js
index 856f4eaf00a..572fbfb5be4 100644
--- a/app/assets/javascripts/diffs/store/mutations.js
+++ b/app/assets/javascripts/diffs/store/mutations.js
@@ -160,7 +160,9 @@ export default {
}
if (!file.parallel_diff_lines || !file.highlighted_diff_lines) {
- file.discussions = (file.discussions || []).concat(discussion);
+ file.discussions = (file.discussions || [])
+ .filter(d => d.id !== discussion.id)
+ .concat(discussion);
}
return file;