Commit e354a64e authored by Phil Hughes's avatar Phil Hughes

Show expand all button on merge request diffs

This restores the behaviour of showing the expand all button on diffs
even when only a single file is collapsed.
Previously the button would only show when all files are collapsed.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/51737
parent 2508d7b3
...@@ -36,7 +36,7 @@ export default { ...@@ -36,7 +36,7 @@ export default {
}, },
computed: { computed: {
...mapState('diffs', ['commit', 'showTreeList']), ...mapState('diffs', ['commit', 'showTreeList']),
...mapGetters('diffs', ['isInlineView', 'isParallelView', 'areAllFilesCollapsed']), ...mapGetters('diffs', ['isInlineView', 'isParallelView', 'hasCollapsedFile']),
comparableDiffs() { comparableDiffs() {
return this.mergeRequestDiffs.slice(1); return this.mergeRequestDiffs.slice(1);
}, },
...@@ -113,8 +113,8 @@ export default { ...@@ -113,8 +113,8 @@ export default {
class="inline-parallel-buttons d-none d-md-flex ml-auto" class="inline-parallel-buttons d-none d-md-flex ml-auto"
> >
<a <a
v-if="areAllFilesCollapsed" v-show="hasCollapsedFile"
class="btn btn-default" class="btn btn-default append-right-8"
@click="expandAllFiles" @click="expandAllFiles"
> >
{{ __('Expand all') }} {{ __('Expand all') }}
......
...@@ -5,7 +5,7 @@ export const isParallelView = state => state.diffViewType === PARALLEL_DIFF_VIEW ...@@ -5,7 +5,7 @@ export const isParallelView = state => state.diffViewType === PARALLEL_DIFF_VIEW
export const isInlineView = state => state.diffViewType === INLINE_DIFF_VIEW_TYPE; export const isInlineView = state => state.diffViewType === INLINE_DIFF_VIEW_TYPE;
export const areAllFilesCollapsed = state => state.diffFiles.every(file => file.collapsed); export const hasCollapsedFile = state => state.diffFiles.some(file => file.collapsed);
export const commitId = state => (state.commit && state.commit.id ? state.commit.id : null); export const commitId = state => (state.commit && state.commit.id ? state.commit.id : null);
......
---
title: Show expand all diffs button when a single diff file is collapsed
merge_request:
author:
type: fixed
...@@ -49,17 +49,17 @@ describe('Diffs Module Getters', () => { ...@@ -49,17 +49,17 @@ describe('Diffs Module Getters', () => {
}); });
}); });
describe('areAllFilesCollapsed', () => { describe('hasCollapsedFile', () => {
it('returns true when all files are collapsed', () => { it('returns true when all files are collapsed', () => {
localState.diffFiles = [{ collapsed: true }, { collapsed: true }]; localState.diffFiles = [{ collapsed: true }, { collapsed: true }];
expect(getters.areAllFilesCollapsed(localState)).toEqual(true); expect(getters.hasCollapsedFile(localState)).toEqual(true);
}); });
it('returns false when at least one file is not collapsed', () => { it('returns true when at least one file is collapsed', () => {
localState.diffFiles = [{ collapsed: false }, { collapsed: true }]; localState.diffFiles = [{ collapsed: false }, { collapsed: true }];
expect(getters.areAllFilesCollapsed(localState)).toEqual(false); expect(getters.hasCollapsedFile(localState)).toEqual(true);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment