Commit d90cedfd authored by Annabel Dunstone Gray's avatar Annabel Dunstone Gray

Merge branch '327890-review-bar-hides-sidebar' into 'master'

Fix MR review bar hiding part of the right sidebar

See merge request gitlab-org/gitlab!69067
parents 8ca47ccd d6a977b0
<script> <script>
import { mapActions, mapGetters } from 'vuex'; import { mapActions, mapGetters } from 'vuex';
import { REVIEW_BAR_VISIBLE_CLASS_NAME } from '../constants';
import PreviewDropdown from './preview_dropdown.vue'; import PreviewDropdown from './preview_dropdown.vue';
import PublishButton from './publish_button.vue'; import PublishButton from './publish_button.vue';
...@@ -18,6 +19,12 @@ export default { ...@@ -18,6 +19,12 @@ export default {
} }
}, },
}, },
mounted() {
document.body.classList.add(REVIEW_BAR_VISIBLE_CLASS_NAME);
},
beforeDestroy() {
document.body.classList.remove(REVIEW_BAR_VISIBLE_CLASS_NAME);
},
methods: { methods: {
...mapActions('batchComments', ['expandAllDiscussions']), ...mapActions('batchComments', ['expandAllDiscussions']),
}, },
......
export const CHANGES_TAB = 'diffs'; export const CHANGES_TAB = 'diffs';
export const DISCUSSION_TAB = 'notes'; export const DISCUSSION_TAB = 'notes';
export const SHOW_TAB = 'show'; export const SHOW_TAB = 'show';
export const REVIEW_BAR_VISIBLE_CLASS_NAME = 'review-bar-visible';
...@@ -229,7 +229,6 @@ export default { ...@@ -229,7 +229,6 @@ export default {
'isBatchLoading', 'isBatchLoading',
'isBatchLoadingError', 'isBatchLoadingError',
]), ]),
...mapGetters('batchComments', ['draftsCount']),
...mapGetters(['isNotesFetched', 'getNoteableData']), ...mapGetters(['isNotesFetched', 'getNoteableData']),
diffs() { diffs() {
if (!this.viewDiffsFileByFile) { if (!this.viewDiffsFileByFile) {
...@@ -664,7 +663,6 @@ export default { ...@@ -664,7 +663,6 @@ export default {
<div <div
v-if="renderFileTree" v-if="renderFileTree"
:style="{ width: `${treeWidth}px` }" :style="{ width: `${treeWidth}px` }"
:class="{ 'review-bar-visible': draftsCount > 0 }"
class="diff-tree-list js-diff-tree-list px-3 pr-md-0" class="diff-tree-list js-diff-tree-list px-3 pr-md-0"
> >
<panel-resizer <panel-resizer
......
...@@ -122,7 +122,9 @@ ...@@ -122,7 +122,9 @@
.right-sidebar { .right-sidebar {
position: fixed; position: fixed;
top: $header-height; top: $header-height;
bottom: 0; // Default value for CSS var must contain a unit
// stylelint-disable-next-line length-zero-no-unit
bottom: var(--review-bar-height, 0px);
right: 0; right: 0;
transition: width $sidebar-transition-duration; transition: width $sidebar-transition-duration;
background: $gray-light; background: $gray-light;
......
import { shallowMount } from '@vue/test-utils';
import ReviewBar from '~/batch_comments/components/review_bar.vue';
import { REVIEW_BAR_VISIBLE_CLASS_NAME } from '~/batch_comments/constants';
import createStore from '../create_batch_comments_store';
describe('Batch comments review bar component', () => {
let store;
let wrapper;
const createComponent = (propsData = {}) => {
store = createStore();
wrapper = shallowMount(ReviewBar, {
store,
propsData,
});
};
beforeEach(() => {
document.body.className = '';
});
afterEach(() => {
wrapper.destroy();
});
it('it adds review-bar-visible class to body when review bar is mounted', async () => {
expect(document.body.classList.contains(REVIEW_BAR_VISIBLE_CLASS_NAME)).toBe(false);
createComponent();
expect(document.body.classList.contains(REVIEW_BAR_VISIBLE_CLASS_NAME)).toBe(true);
});
it('it removes review-bar-visible class to body when review bar is destroyed', async () => {
createComponent();
wrapper.destroy();
expect(document.body.classList.contains(REVIEW_BAR_VISIBLE_CLASS_NAME)).toBe(false);
});
});
import Vue from 'vue';
import Vuex from 'vuex';
import batchCommentsModule from '~/batch_comments/stores/modules/batch_comments';
import notesModule from '~/notes/stores/modules';
Vue.use(Vuex);
export default function createDiffsStore() {
return new Vuex.Store({
modules: {
notes: notesModule(),
batchComments: batchCommentsModule(),
},
});
}
...@@ -705,24 +705,4 @@ describe('diffs/components/app', () => { ...@@ -705,24 +705,4 @@ describe('diffs/components/app', () => {
); );
}); });
}); });
describe('diff file tree is aware of review bar', () => {
it('it does not have review-bar-visible class when review bar is not visible', () => {
createComponent({}, ({ state }) => {
state.diffs.diffFiles = [{ file_hash: '111', file_path: '111.js' }];
});
expect(wrapper.find('.js-diff-tree-list').exists()).toBe(true);
expect(wrapper.find('.js-diff-tree-list.review-bar-visible').exists()).toBe(false);
});
it('it does have review-bar-visible class when review bar is visible', () => {
createComponent({}, ({ state }) => {
state.diffs.diffFiles = [{ file_hash: '111', file_path: '111.js' }];
state.batchComments.drafts = ['draft message'];
});
expect(wrapper.find('.js-diff-tree-list.review-bar-visible').exists()).toBe(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