Commit 80b1aeb9 authored by Mark Florian's avatar Mark Florian

Merge branch 'kp-fix-roadmap-epics-list' into 'master'

Include Epics in Roadmap whose parents are not part of Roadmap

See merge request gitlab-org/gitlab!34243
parents 444a51c4 0ca73199
...@@ -54,7 +54,7 @@ export default { ...@@ -54,7 +54,7 @@ export default {
computed: { computed: {
...mapState(['bufferSize', 'epicIid', 'childrenEpics', 'childrenFlags', 'epicIds']), ...mapState(['bufferSize', 'epicIid', 'childrenEpics', 'childrenFlags', 'epicIds']),
emptyRowContainerVisible() { emptyRowContainerVisible() {
return this.epics.length < this.bufferSize; return this.displayedEpics.length < this.bufferSize;
}, },
sectionContainerStyles() { sectionContainerStyles() {
return { return {
...@@ -66,21 +66,10 @@ export default { ...@@ -66,21 +66,10 @@ export default {
left: `${this.offsetLeft}px`, left: `${this.offsetLeft}px`,
}; };
}, },
findEpicsMatchingFilter() { epicsWithAssociatedParents() {
return this.epics.reduce((acc, epic) => { return this.epics.filter(
if (!epic.hasParent || (epic.hasParent && this.epicIds.indexOf(epic.parent.id) < 0)) { epic => !epic.hasParent || (epic.hasParent && this.epicIds.indexOf(epic.parent.id) < 0),
acc.push(epic); );
}
return acc;
}, []);
},
findParentEpics() {
return this.epics.reduce((acc, epic) => {
if (!epic.hasParent) {
acc.push(epic);
}
return acc;
}, []);
}, },
displayedEpics() { displayedEpics() {
// If roadmap is accessed from epic, return all epics // If roadmap is accessed from epic, return all epics
...@@ -88,8 +77,8 @@ export default { ...@@ -88,8 +77,8 @@ export default {
return this.epics; return this.epics;
} }
// If a search is being performed, add child as parent if parent doesn't match the search // Return epics with correct parent associations.
return this.hasFiltersApplied ? this.findEpicsMatchingFilter : this.findParentEpics; return this.epicsWithAssociatedParents;
}, },
}, },
mounted() { mounted() {
......
...@@ -107,13 +107,13 @@ export const receiveEpicsSuccess = ( ...@@ -107,13 +107,13 @@ export const receiveEpicsSuccess = (
}, []); }, []);
commit(types.UPDATE_EPIC_IDS, epicIds); commit(types.UPDATE_EPIC_IDS, epicIds);
dispatch('initItemChildrenFlags', { epics });
if (timeframeExtended) { if (timeframeExtended) {
const updatedEpics = state.epics.concat(epics); const updatedEpics = state.epics.concat(epics);
sortEpics(updatedEpics, state.sortedBy); sortEpics(updatedEpics, state.sortedBy);
commit(types.RECEIVE_EPICS_FOR_TIMEFRAME_SUCCESS, updatedEpics); commit(types.RECEIVE_EPICS_FOR_TIMEFRAME_SUCCESS, updatedEpics);
} else { } else {
dispatch('initItemChildrenFlags', { epics });
commit(types.RECEIVE_EPICS_SUCCESS, epics); commit(types.RECEIVE_EPICS_SUCCESS, epics);
} }
}; };
......
---
title: Include Epics in Roadmap whose parents are not part of Roadmap
merge_request: 34243
author:
type: fixed
...@@ -15,6 +15,7 @@ import { ...@@ -15,6 +15,7 @@ import {
mockTimeframeInitialDate, mockTimeframeInitialDate,
mockGroupId, mockGroupId,
rawEpics, rawEpics,
mockEpicsWithParents,
mockSortedBy, mockSortedBy,
basePath, basePath,
epicsPath, epicsPath,
...@@ -119,20 +120,25 @@ describe('EpicsListSectionComponent', () => { ...@@ -119,20 +120,25 @@ describe('EpicsListSectionComponent', () => {
}); });
}); });
describe('epicsWithAssociatedParents', () => {
it('should return epics which contain parent associations', () => {
wrapper.setProps({
epics: mockEpicsWithParents,
});
return wrapper.vm.$nextTick(() => {
expect(wrapper.vm.epicsWithAssociatedParents).toEqual(mockEpicsWithParents);
});
});
});
describe('displayedEpics', () => { describe('displayedEpics', () => {
beforeAll(() => { beforeAll(() => {
store.state.epicIds = ['1', '2', '3']; store.state.epicIds = ['1', '2', '3'];
}); });
it('returns findParentEpics method by default', () => { it('returns epicsWithAssociatedParents computed prop by default', () => {
expect(wrapper.vm.displayedEpics).toEqual(wrapper.vm.findParentEpics); expect(wrapper.vm.displayedEpics).toEqual(wrapper.vm.epicsWithAssociatedParents);
});
it('returns findEpicsMatchingFilter method if filtered is applied', () => {
wrapper.setProps({
hasFiltersApplied: true,
});
expect(wrapper.vm.displayedEpics).toEqual(wrapper.vm.findEpicsMatchingFilter);
}); });
it('returns all epics if epicIid is specified', () => { it('returns all epics if epicIid is specified', () => {
......
...@@ -621,3 +621,34 @@ export const mockGroupMilestonesQueryResponse = { ...@@ -621,3 +621,34 @@ export const mockGroupMilestonesQueryResponse = {
}, },
}, },
}; };
export const mockEpicsWithParents = [
{
id: 'gid://gitlab-org/subgroup/Epic/1',
hasParent: true,
parent: {
id: 'gid://gitlab-org/Epic/1',
},
},
{
id: 'gid://gitlab-org/subgroup/Epic/2',
hasParent: true,
parent: {
id: 'gid://gitlab-org/subgroup/Epic/1',
},
},
{
id: 'gid://gitlab-org/subgroup/Epic/3',
hasParent: true,
parent: {
id: 'gid://gitlab-org/subgroup/Epic/1',
},
},
{
id: 'gid://gitlab-org/subgroup/Epic/4',
hasParent: true,
parent: {
id: 'gid://gitlab-org/subgroup/Epic/1',
},
},
];
...@@ -155,7 +155,21 @@ describe('Roadmap Vuex Actions', () => { ...@@ -155,7 +155,21 @@ describe('Roadmap Vuex Actions', () => {
payload: [{ ...mockFormattedEpic, newEpic: true }], payload: [{ ...mockFormattedEpic, newEpic: true }],
}, },
], ],
[], [
{
type: 'initItemChildrenFlags',
payload: {
epics: [
{
...mockFormattedEpic,
startDateOutOfRange: true,
endDateOutOfRange: false,
newEpic: 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