diff options
author | Phil Hughes <me@iamphill.com> | 2019-03-11 13:09:36 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-03-11 13:09:36 +0000 |
commit | c36095b2e363b7a2d2c704a917bedf2337631a66 (patch) | |
tree | 507eef2f111846ef3ac4d489dbfe9f9f5c700be3 /app | |
parent | 97357c5bb6594be793c1af332bed8f942f2d72d2 (diff) | |
download | gitlab-ce-c36095b2e363b7a2d2c704a917bedf2337631a66.tar.gz |
Fix expand all button not working
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/51737
Diffstat (limited to 'app')
5 files changed, 28 insertions, 4 deletions
diff --git a/app/assets/javascripts/diffs/components/compare_versions.vue b/app/assets/javascripts/diffs/components/compare_versions.vue index 0bf2dde8b96..fe49dfff10b 100644 --- a/app/assets/javascripts/diffs/components/compare_versions.vue +++ b/app/assets/javascripts/diffs/components/compare_versions.vue @@ -125,9 +125,9 @@ export default { > {{ __('Show latest version') }} </gl-button> - <a v-show="hasCollapsedFile" class="btn btn-default append-right-8" @click="expandAllFiles"> + <gl-button v-show="hasCollapsedFile" class="append-right-8" @click="expandAllFiles"> {{ __('Expand all') }} - </a> + </gl-button> <settings-dropdown /> </div> </div> diff --git a/app/assets/javascripts/diffs/components/diff_file.vue b/app/assets/javascripts/diffs/components/diff_file.vue index 1141a197c6a..0e779e1be9a 100644 --- a/app/assets/javascripts/diffs/components/diff_file.vue +++ b/app/assets/javascripts/diffs/components/diff_file.vue @@ -73,13 +73,23 @@ export default { if (!newVal && oldVal && !this.hasDiffLines) { this.handleLoadCollapsedDiff(); } + + this.setFileCollapsed({ filePath: this.file.file_path, collapsed: newVal }); + }, + 'file.viewer.collapsed': function setIsCollapsed(newVal) { + this.isCollapsed = newVal; }, }, created() { eventHub.$on(`loadCollapsedDiff/${this.file.file_hash}`, this.handleLoadCollapsedDiff); }, methods: { - ...mapActions('diffs', ['loadCollapsedDiff', 'assignDiscussionsToDiff', 'setRenderIt']), + ...mapActions('diffs', [ + 'loadCollapsedDiff', + 'assignDiscussionsToDiff', + 'setRenderIt', + 'setFileCollapsed', + ]), handleToggle() { if (!this.hasDiffLines) { this.handleLoadCollapsedDiff(); diff --git a/app/assets/javascripts/diffs/store/actions.js b/app/assets/javascripts/diffs/store/actions.js index 57ddc923a3e..4a04216d893 100644 --- a/app/assets/javascripts/diffs/store/actions.js +++ b/app/assets/javascripts/diffs/store/actions.js @@ -344,5 +344,8 @@ export const toggleFullDiff = ({ dispatch, getters, state }, filePath) => { } }; +export const setFileCollapsed = ({ commit }, { filePath, collapsed }) => + commit(types.SET_FILE_COLLAPSED, { filePath, collapsed }); + // prevent babel-plugin-rewire from generating an invalid default during karma tests export default () => {}; diff --git a/app/assets/javascripts/diffs/store/mutation_types.js b/app/assets/javascripts/diffs/store/mutation_types.js index b441b1de451..adf56eba3f8 100644 --- a/app/assets/javascripts/diffs/store/mutation_types.js +++ b/app/assets/javascripts/diffs/store/mutation_types.js @@ -27,3 +27,4 @@ export const TOGGLE_FILE_FINDER_VISIBLE = 'TOGGLE_FILE_FINDER_VISIBLE'; export const REQUEST_FULL_DIFF = 'REQUEST_FULL_DIFF'; export const RECEIVE_FULL_DIFF_SUCCESS = 'RECEIVE_FULL_DIFF_SUCCESS'; export const RECEIVE_FULL_DIFF_ERROR = 'RECEIVE_FULL_DIFF_ERROR'; +export const SET_FILE_COLLAPSED = 'SET_FILE_COLLAPSED'; diff --git a/app/assets/javascripts/diffs/store/mutations.js b/app/assets/javascripts/diffs/store/mutations.js index 45187d93fef..856f4eaf00a 100644 --- a/app/assets/javascripts/diffs/store/mutations.js +++ b/app/assets/javascripts/diffs/store/mutations.js @@ -104,7 +104,10 @@ export default { [types.EXPAND_ALL_FILES](state) { state.diffFiles = state.diffFiles.map(file => ({ ...file, - collapsed: false, + viewer: { + ...file.viewer, + collapsed: false, + }, })); }, @@ -300,4 +303,11 @@ export default { }), }); }, + [types.SET_FILE_COLLAPSED](state, { filePath, collapsed }) { + const file = state.diffFiles.find(f => f.file_path === filePath); + + if (file && file.viewer) { + file.viewer.collapsed = collapsed; + } + }, }; |