diff options
author | Phil Hughes <me@iamphill.com> | 2019-03-11 16:09:36 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2019-03-11 16:09:36 +0300 |
commit | c36095b2e363b7a2d2c704a917bedf2337631a66 (patch) | |
tree | 507eef2f111846ef3ac4d489dbfe9f9f5c700be3 /app/assets/javascripts/diffs/store | |
parent | 97357c5bb6594be793c1af332bed8f942f2d72d2 (diff) |
Fix expand all button not working
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/51737
Diffstat (limited to 'app/assets/javascripts/diffs/store')
-rw-r--r-- | app/assets/javascripts/diffs/store/actions.js | 3 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/store/mutation_types.js | 1 | ||||
-rw-r--r-- | app/assets/javascripts/diffs/store/mutations.js | 12 |
3 files changed, 15 insertions, 1 deletions
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; + } + }, }; |