diff options
author | Tim Zallmann <tzallmann@gitlab.com> | 2018-09-07 17:57:07 +0200 |
---|---|---|
committer | Tim Zallmann <tzallmann@gitlab.com> | 2018-09-07 17:57:07 +0200 |
commit | af688bd6e8a20a87924c03e6e30f9ebf68cb5c5b (patch) | |
tree | 6be524dc3a0e1d6014ba00ce3c63dfefe4ad2743 | |
parent | d2cbe07398c3f824ffecbd78ff5749daca678d3e (diff) | |
download | gitlab-ce-af688bd6e8a20a87924c03e6e30f9ebf68cb5c5b.tar.gz |
Cosmetic changes to let setup
-rw-r--r-- | app/assets/javascripts/diffs/store/mutations.js | 95 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/store/utils.js | 9 | ||||
-rw-r--r-- | app/assets/javascripts/notes/stores/actions.js | 1 |
3 files changed, 48 insertions, 57 deletions
diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js index 6fce8ed5df3..7bd2ece4aa7 100644 --- a/app/assets/javascripts/diffs/store/mutations.js +++ b/app/assets/javascripts/diffs/store/mutations.js @@ -86,68 +86,61 @@ export default { [types.SET_LINE_DISCUSSIONS_FOR_FILE](state, { fileHash, discussions }) { const selectedFile = state.diffFiles.find(f => f.fileHash === fileHash); - if (selectedFile) { - const targetLine = selectedFile.parallelDiffLines.find( - line => - (line.left && line.left.lineCode === discussions[0].line_code) || - (line.right && line.right.lineCode === discussions[0].line_code), - ); - if (targetLine) { - if (targetLine.left && targetLine.left.lineCode === discussions[0].line_code) { - Object.assign(targetLine.left, { - discussions, - }); - } else { - Object.assign(targetLine.right, { - discussions, - }); - } + const firstDiscussion = discussions[0]; + const targetLine = selectedFile.parallelDiffLines.find( + line => + (line.left && line.left.lineCode === firstDiscussion.line_code) || + (line.right && line.right.lineCode === firstDiscussion.line_code), + ); + if (targetLine) { + if (targetLine.left && targetLine.left.lineCode === firstDiscussion.line_code) { + Object.assign(targetLine.left, { + discussions, + }); + } else { + Object.assign(targetLine.right, { + discussions, + }); } + } - if (selectedFile.highlightedDiffLines) { - const targetInlineLine = selectedFile.highlightedDiffLines.find( - line => line.lineCode === discussions[0].line_code, - ); + if (selectedFile.highlightedDiffLines) { + const targetInlineLine = selectedFile.highlightedDiffLines.find( + line => line.lineCode === firstDiscussion.line_code, + ); - if (targetInlineLine) { - Object.assign(targetInlineLine, { - discussions, - }); - } + if (targetInlineLine) { + Object.assign(targetInlineLine, { + discussions, + }); } } }, [types.REMOVE_LINE_DISCUSSIONS_FOR_FILE](state, { fileHash, lineCode }) { const selectedFile = state.diffFiles.find(f => f.fileHash === fileHash); - if (selectedFile) { - const targetLine = selectedFile.parallelDiffLines.find( - line => - (line.left && line.left.lineCode === lineCode) || - (line.right && line.right.lineCode === lineCode), - ); - if (targetLine) { - if (targetLine.left && targetLine.left.lineCode === lineCode) { - Object.assign(targetLine.left, { - discussions: [], - }); - } else { - Object.assign(targetLine.right, { - discussions: [], - }); - } - } + const targetLine = selectedFile.parallelDiffLines.find( + line => + (line.left && line.left.lineCode === lineCode) || + (line.right && line.right.lineCode === lineCode), + ); + if (targetLine) { + const side = targetLine.left && targetLine.left.lineCode === lineCode ? 'left' : 'right'; + + Object.assign(targetline[side], { + discussions: [], + }); + } - if (selectedFile.highlightedDiffLines) { - const targetInlineLine = selectedFile.highlightedDiffLines.find( - line => line.lineCode === lineCode, - ); + if (selectedFile.highlightedDiffLines) { + const targetInlineLine = selectedFile.highlightedDiffLines.find( + line => line.lineCode === lineCode, + ); - if (targetInlineLine) { - Object.assign(targetInlineLine, { - discussions: [], - }); - } + if (targetInlineLine) { + Object.assign(targetInlineLine, { + discussions: [], + }); } } }, diff --git a/app/assets/javascripts/diffs/store/utils.js b/app/assets/javascripts/diffs/store/utils.js index 7772dac89a7..6b1659a412c 100644 --- a/app/assets/javascripts/diffs/store/utils.js +++ b/app/assets/javascripts/diffs/store/utils.js @@ -186,14 +186,12 @@ export function trimFirstCharOfLineContent(line = {}) { export function prepareDiffData(diffData) { const filesLength = diffData.diffFiles.length; let showingLines = 0; - let i; - for (i = 0; i < filesLength; i += 1) { + for (let i = 0; i < filesLength; i += 1) { const file = diffData.diffFiles[i]; if (file.parallelDiffLines) { const linesLength = file.parallelDiffLines.length; - let u = 0; - for (u = 0; u < linesLength; u += 1) { + for (let u = 0; u < linesLength; u += 1) { const line = file.parallelDiffLines[u]; if (line.left) { line.left = trimFirstCharOfLineContent(line.left); @@ -206,8 +204,7 @@ export function prepareDiffData(diffData) { if (file.highlightedDiffLines) { const linesLength = file.highlightedDiffLines.length; - let u; - for (u = 0; u < linesLength; u += 1) { + for (let u = 0; u < linesLength; u += 1) { trimFirstCharOfLineContent(file.highlightedDiffLines[u]); } showingLines += file.parallelDiffLines.length; diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js index 351d4e25a52..9a2ec15debd 100644 --- a/app/assets/javascripts/notes/stores/actions.js +++ b/app/assets/javascripts/notes/stores/actions.js @@ -54,6 +54,7 @@ export const refetchDiscussionById = ({ commit, state }, { path, discussionId }) commit(types.UPDATE_DISCUSSION, selectedDiscussion); // We need to refetch as it is now the transformed one in state const discussion = utils.findNoteObjectById(state.discussions, discussionId); + resolve(discussion); } }) |