summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAndré Luís <aluis@gitlab.com>2018-07-31 01:51:23 +0100
committerAndré Luís <aluis@gitlab.com>2018-08-01 13:45:16 +0100
commit09c1b008eb4b90c0a8becdf7ebb5723a8bd05468 (patch)
tree136f242cc97e9c696b0f514f28cc5607619a45a8 /app
parente3eab3661997a3a698d0763f0625add6413b4732 (diff)
downloadgitlab-ce-09c1b008eb4b90c0a8becdf7ebb5723a8bd05468.tar.gz
Revert "Merge branch '_acet-fix-outdated-discussions' into 'master'"
This reverts commit 740ae2d194f3833e224c326cc909d833c5807484, reversing changes made to 1ba47de5fef7a86a453e97a574741d3dba85c521.
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/diffs/components/diff_line_gutter_content.vue3
-rw-r--r--app/assets/javascripts/diffs/components/inline_diff_comment_row.vue7
-rw-r--r--app/assets/javascripts/diffs/components/inline_diff_view.vue3
-rw-r--r--app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue2
-rw-r--r--app/assets/javascripts/diffs/components/parallel_diff_view.vue3
-rw-r--r--app/assets/javascripts/diffs/store/getters.js40
-rw-r--r--app/assets/javascripts/diffs/store/utils.js21
-rw-r--r--app/assets/javascripts/notes/stores/getters.js12
-rw-r--r--app/serializers/discussion_entity.rb1
9 files changed, 20 insertions, 72 deletions
diff --git a/app/assets/javascripts/diffs/components/diff_line_gutter_content.vue b/app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
index 3b36bab206b..ad838a32518 100644
--- a/app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
+++ b/app/assets/javascripts/diffs/components/diff_line_gutter_content.vue
@@ -77,8 +77,7 @@ export default {
diffViewType: state => state.diffs.diffViewType,
diffFiles: state => state.diffs.diffFiles,
}),
- ...mapGetters(['isLoggedIn']),
- ...mapGetters('diffs', ['discussionsByLineCode']),
+ ...mapGetters(['isLoggedIn', 'discussionsByLineCode']),
lineHref() {
return this.lineCode ? `#${this.lineCode}` : '#';
},
diff --git a/app/assets/javascripts/diffs/components/inline_diff_comment_row.vue b/app/assets/javascripts/diffs/components/inline_diff_comment_row.vue
index a6f011ff31e..ca265dd892c 100644
--- a/app/assets/javascripts/diffs/components/inline_diff_comment_row.vue
+++ b/app/assets/javascripts/diffs/components/inline_diff_comment_row.vue
@@ -26,16 +26,13 @@ export default {
...mapState({
diffLineCommentForms: state => state.diffs.diffLineCommentForms,
}),
- ...mapGetters('diffs', ['discussionsByLineCode']),
+ ...mapGetters(['discussionsByLineCode']),
discussions() {
return this.discussionsByLineCode[this.line.lineCode] || [];
},
className() {
return this.discussions.length ? '' : 'js-temp-notes-holder';
},
- hasCommentForm() {
- return this.diffLineCommentForms[this.line.lineCode];
- },
},
};
</script>
@@ -56,7 +53,7 @@ export default {
:discussions="discussions"
/>
<diff-line-note-form
- v-if="hasCommentForm"
+ v-if="diffLineCommentForms[line.lineCode]"
:diff-file-hash="diffFileHash"
:line="line"
:note-target-line="line"
diff --git a/app/assets/javascripts/diffs/components/inline_diff_view.vue b/app/assets/javascripts/diffs/components/inline_diff_view.vue
index 8e491d293e5..9fd19b74cd7 100644
--- a/app/assets/javascripts/diffs/components/inline_diff_view.vue
+++ b/app/assets/javascripts/diffs/components/inline_diff_view.vue
@@ -20,7 +20,8 @@ export default {
},
},
computed: {
- ...mapGetters('diffs', ['commitId', 'discussionsByLineCode']),
+ ...mapGetters('diffs', ['commitId']),
+ ...mapGetters(['discussionsByLineCode']),
...mapState({
diffLineCommentForms: state => state.diffs.diffLineCommentForms,
}),
diff --git a/app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue b/app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue
index 05e5cafc717..cc5248c25d9 100644
--- a/app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue
+++ b/app/assets/javascripts/diffs/components/parallel_diff_comment_row.vue
@@ -26,7 +26,7 @@ export default {
...mapState({
diffLineCommentForms: state => state.diffs.diffLineCommentForms,
}),
- ...mapGetters('diffs', ['discussionsByLineCode']),
+ ...mapGetters(['discussionsByLineCode']),
leftLineCode() {
return this.line.left.lineCode;
},
diff --git a/app/assets/javascripts/diffs/components/parallel_diff_view.vue b/app/assets/javascripts/diffs/components/parallel_diff_view.vue
index 8f8d6bbc818..32528c9e7ab 100644
--- a/app/assets/javascripts/diffs/components/parallel_diff_view.vue
+++ b/app/assets/javascripts/diffs/components/parallel_diff_view.vue
@@ -21,7 +21,8 @@ export default {
},
},
computed: {
- ...mapGetters('diffs', ['commitId', 'discussionsByLineCode']),
+ ...mapGetters('diffs', ['commitId']),
+ ...mapGetters(['discussionsByLineCode']),
...mapState({
diffLineCommentForms: state => state.diffs.diffLineCommentForms,
}),
diff --git a/app/assets/javascripts/diffs/store/getters.js b/app/assets/javascripts/diffs/store/getters.js
index d3881fa1a0a..855de79adf8 100644
--- a/app/assets/javascripts/diffs/store/getters.js
+++ b/app/assets/javascripts/diffs/store/getters.js
@@ -1,7 +1,5 @@
import _ from 'underscore';
-import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import { PARALLEL_DIFF_VIEW_TYPE, INLINE_DIFF_VIEW_TYPE } from '../constants';
-import { getDiffRefsByLineCode } from './utils';
export const isParallelView = state => state.diffViewType === PARALLEL_DIFF_VIEW_TYPE;
@@ -58,44 +56,6 @@ export const getDiffFileDiscussions = (state, getters, rootState, rootGetters) =
discussion.diff_discussion && _.isEqual(discussion.diff_file.file_hash, diff.fileHash),
) || [];
-/**
- * Returns an Object with discussions by their diff line code
- * To avoid rendering outdated discussions on the Changes tab we should do a bunch of SHA
- * comparisions. `note.position.formatter` have the current version diff refs but
- * `note.original_position.formatter` will have the first version's diff refs.
- * If line diff refs matches with one of them, we should render it as a discussion on Changes tab.
- *
- * @param {Object} diff
- * @returns {Array}
- */
-export const discussionsByLineCode = (state, getters, rootState, rootGetters) => {
- const diffRefsByLineCode = getDiffRefsByLineCode(state.diffFiles);
-
- return rootGetters.discussions.reduce((acc, note) => {
- const isDiffDiscussion = note.diff_discussion;
- const hasLineCode = note.line_code;
- const isResolvable = note.resolvable;
- const diffRefs = diffRefsByLineCode[note.line_code];
-
- if (isDiffDiscussion && hasLineCode && isResolvable && diffRefs) {
- const refs = convertObjectPropsToCamelCase(note.position.formatter);
- const originalRefs = convertObjectPropsToCamelCase(note.original_position.formatter);
-
- if (_.isEqual(refs, diffRefs) || _.isEqual(originalRefs, diffRefs)) {
- const lineCode = note.line_code;
-
- if (acc[lineCode]) {
- acc[lineCode].push(note);
- } else {
- acc[lineCode] = [note];
- }
- }
- }
-
- return acc;
- }, {});
-};
-
// prevent babel-plugin-rewire from generating an invalid default during karma∂ tests
export const getDiffFileByHash = state => fileHash =>
state.diffFiles.find(file => file.fileHash === fileHash);
diff --git a/app/assets/javascripts/diffs/store/utils.js b/app/assets/javascripts/diffs/store/utils.js
index 82082ac508a..d9589baa76e 100644
--- a/app/assets/javascripts/diffs/store/utils.js
+++ b/app/assets/javascripts/diffs/store/utils.js
@@ -173,24 +173,3 @@ export function trimFirstCharOfLineContent(line = {}) {
return parsedLine;
}
-
-export function getDiffRefsByLineCode(diffFiles) {
- return diffFiles.reduce((acc, diffFile) => {
- const { baseSha, headSha, startSha } = diffFile.diffRefs;
- const { newPath, oldPath } = diffFile;
-
- // We can only use highlightedDiffLines to create the map of diff lines because
- // highlightedDiffLines will also include every parallel diff line in it.
- if (diffFile.highlightedDiffLines) {
- diffFile.highlightedDiffLines.forEach(line => {
- const { lineCode, oldLine, newLine } = line;
-
- if (lineCode) {
- acc[lineCode] = { baseSha, headSha, startSha, newPath, oldPath, oldLine, newLine };
- }
- });
- }
-
- return acc;
- }, {});
-}
diff --git a/app/assets/javascripts/notes/stores/getters.js b/app/assets/javascripts/notes/stores/getters.js
index e9e95dd4219..5c65e1c3bb5 100644
--- a/app/assets/javascripts/notes/stores/getters.js
+++ b/app/assets/javascripts/notes/stores/getters.js
@@ -28,6 +28,18 @@ export const notesById = state =>
return acc;
}, {});
+export const discussionsByLineCode = state =>
+ state.discussions.reduce((acc, note) => {
+ if (note.diff_discussion && note.line_code && note.resolvable) {
+ // For context about line notes: there might be multiple notes with the same line code
+ const items = acc[note.line_code] || [];
+ items.push(note);
+
+ Object.assign(acc, { [note.line_code]: items });
+ }
+ return acc;
+ }, {});
+
export const noteableType = state => {
const { ISSUE_NOTEABLE_TYPE, MERGE_REQUEST_NOTEABLE_TYPE, EPIC_NOTEABLE_TYPE } = constants;
diff --git a/app/serializers/discussion_entity.rb b/app/serializers/discussion_entity.rb
index 6f95e6f9ca1..b8321037fa5 100644
--- a/app/serializers/discussion_entity.rb
+++ b/app/serializers/discussion_entity.rb
@@ -6,7 +6,6 @@ class DiscussionEntity < Grape::Entity
expose :id, :reply_id
expose :position, if: -> (d, _) { d.diff_discussion? && !d.legacy_diff_discussion? }
- expose :original_position, if: -> (d, _) { d.diff_discussion? && !d.legacy_diff_discussion? }
expose :line_code, if: -> (d, _) { d.diff_discussion? }
expose :expanded?, as: :expanded
expose :active?, as: :active, if: -> (d, _) { d.diff_discussion? }