diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-14 21:07:45 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-14 21:07:45 +0000 |
commit | 0b12a5312c9701fbfed25fbb334d47900ced736b (patch) | |
tree | a29a27e297134f573fd8e5c298d241f3156c207a /app/assets/javascripts/diffs | |
parent | 92f95ccac81911d1fcc32e999a7f1ce04624a56c (diff) | |
download | gitlab-ce-0b12a5312c9701fbfed25fbb334d47900ced736b.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/diffs')
5 files changed, 25 insertions, 10 deletions
diff --git a/app/assets/javascripts/diffs/components/app.vue b/app/assets/javascripts/diffs/components/app.vue index c6d32ffef34..23b8458aa6b 100644 --- a/app/assets/javascripts/diffs/components/app.vue +++ b/app/assets/javascripts/diffs/components/app.vue @@ -95,6 +95,7 @@ export default { return { treeWidth, + diffFilesLength: 0, }; }, computed: { @@ -241,7 +242,8 @@ export default { fetchData(toggleTree = true) { if (this.glFeatures.diffsBatchLoad) { this.fetchDiffFilesMeta() - .then(() => { + .then(({ real_size }) => { + this.diffFilesLength = parseInt(real_size, 10); if (toggleTree) this.hideTreeListIfJustOneFile(); this.startDiffRendering(); @@ -264,7 +266,8 @@ export default { }); } else { this.fetchDiffFiles() - .then(() => { + .then(({ real_size }) => { + this.diffFilesLength = parseInt(real_size, 10); if (toggleTree) { this.hideTreeListIfJustOneFile(); } @@ -351,6 +354,7 @@ export default { :merge-request-diff="mergeRequestDiff" :target-branch="targetBranch" :is-limited-container="isLimitedContainer" + :diff-files-length="diffFilesLength" /> <hidden-files-warning diff --git a/app/assets/javascripts/diffs/components/compare_versions.vue b/app/assets/javascripts/diffs/components/compare_versions.vue index 2e57a47f2f7..24542126b07 100644 --- a/app/assets/javascripts/diffs/components/compare_versions.vue +++ b/app/assets/javascripts/diffs/components/compare_versions.vue @@ -42,9 +42,13 @@ export default { required: false, default: false, }, + diffFilesLength: { + type: Number, + required: true, + }, }, computed: { - ...mapGetters('diffs', ['hasCollapsedFile', 'diffFilesLength']), + ...mapGetters('diffs', ['hasCollapsedFile']), ...mapState('diffs', [ 'commit', 'showTreeList', diff --git a/app/assets/javascripts/diffs/store/actions.js b/app/assets/javascripts/diffs/store/actions.js index 6714f4e62b8..b920e041135 100644 --- a/app/assets/javascripts/diffs/store/actions.js +++ b/app/assets/javascripts/diffs/store/actions.js @@ -64,6 +64,7 @@ export const fetchDiffFiles = ({ state, commit }) => { const urlParams = { w: state.showWhitespace ? '0' : '1', }; + let returnData; if (state.useSingleDiffStyle) { urlParams.view = state.diffViewType; @@ -87,9 +88,13 @@ export const fetchDiffFiles = ({ state, commit }) => { worker.postMessage(state.diffFiles); + returnData = res.data; return Vue.nextTick(); }) - .then(handleLocationHash) + .then(() => { + handleLocationHash(); + return returnData; + }) .catch(() => worker.terminate()); }; @@ -147,6 +152,7 @@ export const fetchDiffFilesMeta = ({ commit, state }) => { prepareDiffData(data); worker.postMessage(data.diff_files); + return data; }) .catch(() => worker.terminate()); }; diff --git a/app/assets/javascripts/diffs/store/getters.js b/app/assets/javascripts/diffs/store/getters.js index bc27e263bff..c4737090a70 100644 --- a/app/assets/javascripts/diffs/store/getters.js +++ b/app/assets/javascripts/diffs/store/getters.js @@ -95,8 +95,6 @@ export const allBlobs = (state, getters) => return acc; }, []); -export const diffFilesLength = state => state.diffFiles.length; - export const getCommentFormForDiffFile = state => fileHash => state.commentForms.find(form => form.fileHash === fileHash); diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js index 8cfdded1f9b..1505be1a0b2 100644 --- a/app/assets/javascripts/diffs/store/mutations.js +++ b/app/assets/javascripts/diffs/store/mutations.js @@ -179,16 +179,19 @@ export default { const mapDiscussions = (line, extraCheck = () => true) => ({ ...line, discussions: extraCheck() - ? line.discussions + ? line.discussions && + line.discussions .filter(() => !line.discussions.some(({ id }) => discussion.id === id)) .concat(lineCheck(line) ? discussion : line.discussions) : [], }); const setDiscussionsExpanded = line => { - const isLineNoteTargeted = line.discussions.some( - disc => disc.notes && disc.notes.find(note => hash === `note_${note.id}`), - ); + const isLineNoteTargeted = + line.discussions && + line.discussions.some( + disc => disc.notes && disc.notes.find(note => hash === `note_${note.id}`), + ); return { ...line, |