summaryrefslogtreecommitdiff
path: root/app/assets
diff options
context:
space:
mode:
authorTim Zallmann <tzallmann@gitlab.com>2018-09-02 23:26:25 +0200
committerTim Zallmann <tzallmann@gitlab.com>2018-09-07 12:25:50 +0200
commit8563499b0faf5712ae12feaef086d8be9a692980 (patch)
tree84a3daa2ec4b4b2ac4465399cbade2bffe303bdf /app/assets
parenta424e8141bc42dec5d3caaf87ee08a7d6308866a (diff)
downloadgitlab-ce-8563499b0faf5712ae12feaef086d8be9a692980.tar.gz
Fix for Getter + Linting
Diffstat (limited to 'app/assets')
-rw-r--r--app/assets/javascripts/diffs/store/getters.js40
-rw-r--r--app/assets/javascripts/diffs/store/utils.js2
-rw-r--r--app/assets/javascripts/notes/stores/actions.js5
3 files changed, 5 insertions, 42 deletions
diff --git a/app/assets/javascripts/diffs/store/getters.js b/app/assets/javascripts/diffs/store/getters.js
index 2a9191cde8a..968ba3c5e13 100644
--- a/app/assets/javascripts/diffs/store/getters.js
+++ b/app/assets/javascripts/diffs/store/getters.js
@@ -72,44 +72,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;
- }, {});
-};
-
export const shouldRenderParallelCommentRow = state => line => {
const hasDiscussion =
(line.left && line.left.discussions && line.left.discussions.length) ||
@@ -137,7 +99,7 @@ export const shouldRenderParallelCommentRow = state => line => {
export const shouldRenderInlineCommentRow = state => line => {
if (state.diffLineCommentForms[line.lineCode]) return true;
- if (!line.discussions && line.discussions.length === 0) {
+ if (!line.discussions || line.discussions.length === 0) {
return false;
}
diff --git a/app/assets/javascripts/diffs/store/utils.js b/app/assets/javascripts/diffs/store/utils.js
index 31a5c8bbbec..5a29d3e1ac7 100644
--- a/app/assets/javascripts/diffs/store/utils.js
+++ b/app/assets/javascripts/diffs/store/utils.js
@@ -161,7 +161,9 @@ export function addContextLines(options) {
* @returns {Object}
*/
export function trimFirstCharOfLineContent(line = {}) {
+ // eslint-disable-next-line no-param-reassign
delete line.text;
+ // eslint-disable-next-line no-param-reassign
line.discussions = [];
const parsedLine = Object.assign({}, line);
diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js
index 8c894f5718b..44f1c0f63fd 100644
--- a/app/assets/javascripts/notes/stores/actions.js
+++ b/app/assets/javascripts/notes/stores/actions.js
@@ -43,8 +43,8 @@ export const fetchDiscussions = ({ commit }, path) =>
commit(types.SET_INITIAL_DISCUSSIONS, discussions);
});
-export const refetchDiscussionById = ({ commit }, { path, discussionId }) => {
- return new Promise(resolve => {
+export const refetchDiscussionById = ({ commit }, { path, discussionId }) =>
+ new Promise(resolve => {
service
.fetchDiscussions(path)
.then(res => res.json())
@@ -57,7 +57,6 @@ export const refetchDiscussionById = ({ commit }, { path, discussionId }) => {
})
.catch(() => {});
});
-};
export const deleteNote = ({ commit }, note) =>
service.deleteNote(note.path).then(() => {