Commit c38b5519 authored by Florie Guibert's avatar Florie Guibert Committed by Natalia Tepluhina

Epic board sidebar - Confidentiality [RUN AS-IF-FOSS]

parent 7d443c22
...@@ -18,8 +18,15 @@ export default { ...@@ -18,8 +18,15 @@ export default {
GlSprintf, GlSprintf,
GlButton, GlButton,
}, },
inject: ['fullPath', 'iid'],
props: { props: {
iid: {
type: String,
required: true,
},
fullPath: {
type: String,
required: true,
},
confidential: { confidential: {
required: true, required: true,
type: Boolean, type: Boolean,
......
...@@ -27,8 +27,20 @@ export default { ...@@ -27,8 +27,20 @@ export default {
SidebarConfidentialityContent, SidebarConfidentialityContent,
SidebarConfidentialityForm, SidebarConfidentialityForm,
}, },
inject: ['fullPath', 'iid'], inject: {
isClassicSidebar: {
default: false,
},
},
props: { props: {
iid: {
type: String,
required: true,
},
fullPath: {
type: String,
required: true,
},
issuableType: { issuableType: {
required: true, required: true,
type: String, type: String,
...@@ -126,6 +138,7 @@ export default { ...@@ -126,6 +138,7 @@ export default {
v-if="!isLoading" v-if="!isLoading"
:confidential="confidential" :confidential="confidential"
:issuable-type="issuableType" :issuable-type="issuableType"
:class="{ 'gl-mt-3': !isClassicSidebar }"
@expandSidebar="expandSidebar" @expandSidebar="expandSidebar"
/> />
</div> </div>
...@@ -133,6 +146,8 @@ export default { ...@@ -133,6 +146,8 @@ export default {
<template #default> <template #default>
<sidebar-confidentiality-content :confidential="confidential" :issuable-type="issuableType" /> <sidebar-confidentiality-content :confidential="confidential" :issuable-type="issuableType" />
<sidebar-confidentiality-form <sidebar-confidentiality-form
:iid="iid"
:full-path="fullPath"
:confidential="confidential" :confidential="confidential"
:issuable-type="issuableType" :issuable-type="issuableType"
@closeForm="closeForm" @closeForm="closeForm"
......
...@@ -151,14 +151,14 @@ function mountConfidentialComponent() { ...@@ -151,14 +151,14 @@ function mountConfidentialComponent() {
SidebarConfidentialityWidget, SidebarConfidentialityWidget,
}, },
provide: { provide: {
iid: String(iid),
fullPath,
canUpdate: initialData.is_editable, canUpdate: initialData.is_editable,
}, },
render: (createElement) => render: (createElement) =>
createElement('sidebar-confidentiality-widget', { createElement('sidebar-confidentiality-widget', {
props: { props: {
iid: String(iid),
fullPath,
issuableType: issuableType:
isInIssuePage() || isInIncidentPage() || isInDesignPage() isInIssuePage() || isInIncidentPage() || isInDesignPage()
? IssuableType.Issue ? IssuableType.Issue
......
...@@ -468,6 +468,12 @@ ...@@ -468,6 +468,12 @@
} }
} }
.boards-sidebar {
.sidebar-collapsed-icon {
display: none;
}
}
.board-header-collapsed-info-icon:hover { .board-header-collapsed-info-icon:hover {
color: var(--gray-900, $gray-900); color: var(--gray-900, $gray-900);
} }
......
...@@ -5,6 +5,7 @@ import BoardSidebarLabelsSelect from '~/boards/components/sidebar/board_sidebar_ ...@@ -5,6 +5,7 @@ import BoardSidebarLabelsSelect from '~/boards/components/sidebar/board_sidebar_
import BoardSidebarTitle from '~/boards/components/sidebar/board_sidebar_title.vue'; import BoardSidebarTitle from '~/boards/components/sidebar/board_sidebar_title.vue';
import { ISSUABLE } from '~/boards/constants'; import { ISSUABLE } from '~/boards/constants';
import { contentTop } from '~/lib/utils/common_utils'; import { contentTop } from '~/lib/utils/common_utils';
import SidebarConfidentialityWidget from '~/sidebar/components/confidential/sidebar_confidentiality_widget.vue';
export default { export default {
headerHeight: `${contentTop()}px`, headerHeight: `${contentTop()}px`,
...@@ -12,10 +13,11 @@ export default { ...@@ -12,10 +13,11 @@ export default {
GlDrawer, GlDrawer,
BoardSidebarLabelsSelect, BoardSidebarLabelsSelect,
BoardSidebarTitle, BoardSidebarTitle,
SidebarConfidentialityWidget,
}, },
computed: { computed: {
...mapGetters(['isSidebarOpen', 'activeBoardItem']), ...mapGetters(['isSidebarOpen', 'activeBoardItem']),
...mapState(['sidebarType']), ...mapState(['sidebarType', 'fullPath']),
isIssuableSidebar() { isIssuableSidebar() {
return this.sidebarType === ISSUABLE; return this.sidebarType === ISSUABLE;
}, },
...@@ -24,7 +26,7 @@ export default { ...@@ -24,7 +26,7 @@ export default {
}, },
}, },
methods: { methods: {
...mapActions(['toggleBoardItem']), ...mapActions(['toggleBoardItem', 'setActiveEpicConfidential']),
handleClose() { handleClose() {
this.toggleBoardItem({ boardItem: this.activeBoardItem, sidebarType: this.sidebarType }); this.toggleBoardItem({ boardItem: this.activeBoardItem, sidebarType: this.sidebarType });
}, },
...@@ -43,6 +45,12 @@ export default { ...@@ -43,6 +45,12 @@ export default {
<template #default> <template #default>
<board-sidebar-title data-testid="sidebar-title" /> <board-sidebar-title data-testid="sidebar-title" />
<board-sidebar-labels-select class="labels" /> <board-sidebar-labels-select class="labels" />
<sidebar-confidentiality-widget
:iid="activeBoardItem.iid"
:full-path="fullPath"
issuable-type="epic"
@confidentialityUpdated="setActiveEpicConfidential($event)"
/>
</template> </template>
</gl-drawer> </gl-drawer>
</template> </template>
...@@ -799,4 +799,13 @@ export default { ...@@ -799,4 +799,13 @@ export default {
value: data.updateEpic.epic.labels.nodes, value: data.updateEpic.epic.labels.nodes,
}); });
}, },
setActiveEpicConfidential: ({ commit, getters }, confidential) => {
const { activeBoardItem } = getters;
commit(typesCE.UPDATE_BOARD_ITEM_BY_ID, {
itemId: activeBoardItem.id,
prop: 'confidential',
value: confidential,
});
},
}; };
...@@ -30,6 +30,7 @@ export default { ...@@ -30,6 +30,7 @@ export default {
SidebarSubscription, SidebarSubscription,
SidebarConfidentialityWidget, SidebarConfidentialityWidget,
}, },
inject: ['iid'],
data() { data() {
return { return {
sidebarExpandedOnClick: false, sidebarExpandedOnClick: false,
...@@ -225,6 +226,8 @@ export default { ...@@ -225,6 +226,8 @@ export default {
<ancestors-tree :ancestors="ancestors" :is-fetching="false" data-testid="ancestors" /> <ancestors-tree :ancestors="ancestors" :is-fetching="false" data-testid="ancestors" />
</div> </div>
<sidebar-confidentiality-widget <sidebar-confidentiality-widget
:iid="String(iid)"
:full-path="fullPath"
issuable-type="epic" issuable-type="epic"
@closeForm="handleSidebarToggle" @closeForm="handleSidebarToggle"
@expandSidebar="handleSidebarToggle" @expandSidebar="handleSidebarToggle"
......
...@@ -106,4 +106,25 @@ RSpec.describe 'Epic boards sidebar', :js do ...@@ -106,4 +106,25 @@ RSpec.describe 'Epic boards sidebar', :js do
expect(card).to have_content(bug.title) expect(card).to have_content(bug.title)
end end
end end
context 'confidentiality' do
it 'make epic confidential' do
click_card(card)
page.within('.confidentiality') do
expect(page).to have_content('Not confidential')
find('[data-testid="edit-button"]').click
expect(page).to have_css('.sidebar-item-warning-message')
within('.sidebar-item-warning-message') do
find('[data-testid="confidential-toggle"]').click
end
wait_for_requests
expect(page).to have_content('This epic is confidential')
end
end
end
end end
...@@ -5,6 +5,7 @@ import EpicBoardContentSidebar from 'ee_component/boards/components/epic_board_c ...@@ -5,6 +5,7 @@ import EpicBoardContentSidebar from 'ee_component/boards/components/epic_board_c
import { stubComponent } from 'helpers/stub_component'; import { stubComponent } from 'helpers/stub_component';
import BoardSidebarLabelsSelect from '~/boards/components/sidebar/board_sidebar_labels_select.vue'; import BoardSidebarLabelsSelect from '~/boards/components/sidebar/board_sidebar_labels_select.vue';
import { ISSUABLE } from '~/boards/constants'; import { ISSUABLE } from '~/boards/constants';
import SidebarConfidentialityWidget from '~/sidebar/components/confidential/sidebar_confidentiality_widget.vue';
import { mockEpic } from '../mock_data'; import { mockEpic } from '../mock_data';
describe('EpicBoardContentSidebar', () => { describe('EpicBoardContentSidebar', () => {
...@@ -18,6 +19,7 @@ describe('EpicBoardContentSidebar', () => { ...@@ -18,6 +19,7 @@ describe('EpicBoardContentSidebar', () => {
boardItems: { [mockEpic.id]: mockEpic }, boardItems: { [mockEpic.id]: mockEpic },
activeId: mockEpic.id, activeId: mockEpic.id,
issuableType: 'epic', issuableType: 'epic',
fullPath: 'gitlab-org',
}, },
getters: { getters: {
activeBoardItem: () => { activeBoardItem: () => {
...@@ -74,6 +76,10 @@ describe('EpicBoardContentSidebar', () => { ...@@ -74,6 +76,10 @@ describe('EpicBoardContentSidebar', () => {
expect(wrapper.find(BoardSidebarLabelsSelect).exists()).toBe(true); expect(wrapper.find(BoardSidebarLabelsSelect).exists()).toBe(true);
}); });
it('renders SidebarConfidentialityWidget', () => {
expect(wrapper.find(SidebarConfidentialityWidget).exists()).toBe(true);
});
describe('when we emit close', () => { describe('when we emit close', () => {
let toggleBoardItem; let toggleBoardItem;
......
...@@ -225,7 +225,7 @@ export const mockIssues = [mockIssue, mockIssue2]; ...@@ -225,7 +225,7 @@ export const mockIssues = [mockIssue, mockIssue2];
export const mockEpic = { export const mockEpic = {
id: 'gid://gitlab/Epic/41', id: 'gid://gitlab/Epic/41',
iid: 1, iid: '1',
title: 'Epic title', title: 'Epic title',
state: 'opened', state: 'opened',
webUrl: '/groups/gitlab-org/-/epics/1', webUrl: '/groups/gitlab-org/-/epics/1',
......
...@@ -1413,3 +1413,30 @@ describe('setActiveEpicLabels', () => { ...@@ -1413,3 +1413,30 @@ describe('setActiveEpicLabels', () => {
await expect(actions.setActiveEpicLabels({ getters }, input)).rejects.toThrow(Error); await expect(actions.setActiveEpicLabels({ getters }, input)).rejects.toThrow(Error);
}); });
}); });
describe('setActiveEpicConfidential', () => {
const state = { boardItems: { [mockEpic.id]: mockEpic } };
const getters = { activeBoardItem: mockEpic };
it('set confidential value on epic', (done) => {
const payload = {
itemId: getters.activeBoardItem.id,
prop: 'confidential',
value: true,
};
testAction(
actions.setActiveEpicConfidential,
true,
{ ...state, ...getters },
[
{
type: typesCE.UPDATE_BOARD_ITEM_BY_ID,
payload,
},
],
[],
done,
);
});
});
...@@ -33,6 +33,9 @@ describe('EpicSidebarComponent', () => { ...@@ -33,6 +33,9 @@ describe('EpicSidebarComponent', () => {
return shallowMount(EpicSidebar, { return shallowMount(EpicSidebar, {
store, store,
provide: {
iid: '1',
},
}); });
}; };
......
...@@ -20,11 +20,9 @@ describe('Sidebar Confidentiality Form', () => { ...@@ -20,11 +20,9 @@ describe('Sidebar Confidentiality Form', () => {
mutate = jest.fn().mockResolvedValue('Success'), mutate = jest.fn().mockResolvedValue('Success'),
} = {}) => { } = {}) => {
wrapper = shallowMount(SidebarConfidentialityForm, { wrapper = shallowMount(SidebarConfidentialityForm, {
provide: { propsData: {
fullPath: 'group/project', fullPath: 'group/project',
iid: '1', iid: '1',
},
propsData: {
confidential: false, confidential: false,
issuableType: 'issue', issuableType: 'issue',
...props, ...props,
......
...@@ -35,11 +35,11 @@ describe('Sidebar Confidentiality Widget', () => { ...@@ -35,11 +35,11 @@ describe('Sidebar Confidentiality Widget', () => {
localVue, localVue,
apolloProvider: fakeApollo, apolloProvider: fakeApollo,
provide: { provide: {
fullPath: 'group/project',
iid: '1',
canUpdate: true, canUpdate: true,
}, },
propsData: { propsData: {
fullPath: 'group/project',
iid: '1',
issuableType: 'issue', issuableType: 'issue',
}, },
stubs: { stubs: {
......
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