Commit 5ec0a9ee authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '332306-reuse-ancestors-widget-in-epic-sidebar' into 'master'

Migrate epic sidebar ancestors to widget

See merge request gitlab-org/gitlab!68428
parents 1ad294be 47302502
<script> <script>
import { mapState, mapGetters, mapActions } from 'vuex'; import { mapState, mapGetters, mapActions } from 'vuex';
import AncestorsTree from 'ee/sidebar/components/ancestors_tree/ancestors_tree.vue'; import SidebarAncestorsWidget from 'ee_component/sidebar/components/ancestors_tree/sidebar_ancestors_widget.vue';
import { TYPE_EPIC } from '~/graphql_shared/constants'; import { TYPE_EPIC } from '~/graphql_shared/constants';
import { convertToGraphQLId } from '~/graphql_shared/utils'; import { convertToGraphQLId } from '~/graphql_shared/utils';
...@@ -28,7 +28,7 @@ export default { ...@@ -28,7 +28,7 @@ export default {
SidebarDatePicker, SidebarDatePicker,
SidebarDatePickerCollapsed, SidebarDatePickerCollapsed,
SidebarLabels, SidebarLabels,
AncestorsTree, SidebarAncestorsWidget,
SidebarParticipants, SidebarParticipants,
SidebarConfidentialityWidget, SidebarConfidentialityWidget,
SidebarSubscriptionsWidget, SidebarSubscriptionsWidget,
...@@ -73,7 +73,6 @@ export default { ...@@ -73,7 +73,6 @@ export default {
'dueDateTimeFromMilestones', 'dueDateTimeFromMilestones',
'dueDateTime', 'dueDateTime',
'dueDateForCollapsedSidebar', 'dueDateForCollapsedSidebar',
'ancestors',
]), ]),
issuableType() { issuableType() {
return IssuableType.Epic; return IssuableType.Epic;
...@@ -246,9 +245,12 @@ export default { ...@@ -246,9 +245,12 @@ export default {
@expandSidebar="handleSidebarToggle" @expandSidebar="handleSidebarToggle"
@confidentialityUpdated="updateConfidentialityOnIssuable($event)" @confidentialityUpdated="updateConfidentialityOnIssuable($event)"
/> />
<div v-if="allowSubEpics" class="block ancestors"> <sidebar-ancestors-widget
<ancestors-tree :ancestors="ancestors" :is-fetching="false" data-testid="ancestors" /> v-if="allowSubEpics"
</div> :iid="String(iid)"
:full-path="fullPath"
:issuable-type="issuableType"
/>
<div class="block participants"> <div class="block participants">
<sidebar-participants <sidebar-participants
:participants="participants" :participants="participants"
......
...@@ -54,5 +54,3 @@ export const isDateInvalid = (state, getters) => { ...@@ -54,5 +54,3 @@ export const isDateInvalid = (state, getters) => {
getters.dueDateTimeFromMilestones, getters.dueDateTimeFromMilestones,
); );
}; };
export const ancestors = (state) => (state.ancestors ? [...state.ancestors].reverse() : []);
...@@ -55,7 +55,6 @@ export default () => ({ ...@@ -55,7 +55,6 @@ export default () => ({
dueDateFromMilestones: '', dueDateFromMilestones: '',
dueDate: '', dueDate: '',
labels: [], labels: [],
ancestors: [],
participants: [], participants: [],
subscribed: false, subscribed: false,
confidential: false, confidential: false,
......
...@@ -8,13 +8,15 @@ import { getStoreConfig } from 'ee/epic/store'; ...@@ -8,13 +8,15 @@ import { getStoreConfig } from 'ee/epic/store';
import epicUtils from 'ee/epic/utils/epic_utils'; import epicUtils from 'ee/epic/utils/epic_utils';
import SidebarAncestorsWidget from 'ee_component/sidebar/components/ancestors_tree/sidebar_ancestors_widget.vue';
import { parsePikadayDate } from '~/lib/utils/datetime_utility'; import { parsePikadayDate } from '~/lib/utils/datetime_utility';
import SidebarReferenceWidget from '~/sidebar/components/reference/sidebar_reference_widget.vue'; import SidebarReferenceWidget from '~/sidebar/components/reference/sidebar_reference_widget.vue';
import SidebarSubscriptionsWidget from '~/sidebar/components/subscriptions/sidebar_subscriptions_widget.vue'; import SidebarSubscriptionsWidget from '~/sidebar/components/subscriptions/sidebar_subscriptions_widget.vue';
import SidebarTodoWidget from '~/sidebar/components/todo_toggle/sidebar_todo_widget.vue'; import SidebarTodoWidget from '~/sidebar/components/todo_toggle/sidebar_todo_widget.vue';
import { mockEpicMeta, mockEpicData, mockAncestors } from '../mock_data'; import { mockEpicMeta, mockEpicData } from '../mock_data';
describe('EpicSidebarComponent', () => { describe('EpicSidebarComponent', () => {
const originalUserId = gon.current_user_id; const originalUserId = gon.current_user_id;
...@@ -29,7 +31,6 @@ describe('EpicSidebarComponent', () => { ...@@ -29,7 +31,6 @@ describe('EpicSidebarComponent', () => {
...state, ...state,
...mockEpicMeta, ...mockEpicMeta,
...mockEpicData, ...mockEpicData,
ancestors: mockAncestors,
}, },
actions: { ...actions, ...actionMocks }, actions: { ...actions, ...actionMocks },
...@@ -222,9 +223,8 @@ describe('EpicSidebarComponent', () => { ...@@ -222,9 +223,8 @@ describe('EpicSidebarComponent', () => {
expect(wrapper.find(SidebarReferenceWidget).exists()).toBe(true); expect(wrapper.find(SidebarReferenceWidget).exists()).toBe(true);
}); });
describe('when sub-epics feature is available', () => { describe('when sub-epics feature is not available', () => {
it('renders ancestors list', async () => { it('does not renders ancestors list', async () => {
store.dispatch('toggleSidebarFlag', false);
store.dispatch('setEpicMeta', { store.dispatch('setEpicMeta', {
...mockEpicMeta, ...mockEpicMeta,
allowSubEpics: false, allowSubEpics: false,
...@@ -232,20 +232,13 @@ describe('EpicSidebarComponent', () => { ...@@ -232,20 +232,13 @@ describe('EpicSidebarComponent', () => {
await nextTick(); await nextTick();
expect(wrapper.find('.block.ancestors').exists()).toBe(false); expect(wrapper.find(SidebarAncestorsWidget).exists()).toBe(false);
}); });
}); });
describe('when sub-epics feature is not available', () => { describe('when sub-epics feature is available', () => {
it('does not render ancestors list', async () => { it('renders ancestors list', () => {
wrapper.vm.$store.dispatch('toggleSidebarFlag', false); expect(wrapper.find(SidebarAncestorsWidget).exists()).toBe(true);
await nextTick();
const ancestorsEl = wrapper.find('[data-testid="ancestors"]');
expect(ancestorsEl.exists()).toBe(true);
expect(ancestorsEl.props('ancestors')).toEqual([...mockAncestors].reverse());
}); });
}); });
......
...@@ -259,21 +259,4 @@ describe('Epic Store Getters', () => { ...@@ -259,21 +259,4 @@ describe('Epic Store Getters', () => {
).toBe(false); ).toBe(false);
}); });
}); });
describe('ancestors', () => {
it('returns `ancestors` from state when ancestors is not null', () => {
const ancestors = getters.ancestors({
ancestors: [{ id: 1, title: 'Parent' }],
});
expect(ancestors).toHaveLength(1);
});
it('returns empty array when `ancestors` within state is null', () => {
const ancestors = getters.ancestors({});
expect(ancestors).not.toBeNull();
expect(ancestors).toHaveLength(0);
});
});
}); });
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