Commit 6b983bcb authored by Natalia Tepluhina's avatar Natalia Tepluhina

Merge branch '220138-separate-milestone-and-epic-queries-when-loading-roadmap' into 'master'

Separate milestone and epic queries when loading roadmap

See merge request gitlab-org/gitlab!80878
parents 2c1a770a 270c1d33
...@@ -34,7 +34,6 @@ export default { ...@@ -34,7 +34,6 @@ export default {
'currentGroupId', 'currentGroupId',
'epicIid', 'epicIid',
'epics', 'epics',
'milestones',
'timeframe', 'timeframe',
'epicsFetchInProgress', 'epicsFetchInProgress',
'epicsFetchResultEmpty', 'epicsFetchResultEmpty',
...@@ -62,12 +61,11 @@ export default { ...@@ -62,12 +61,11 @@ export default {
return !this.isWarningDismissed && this.epics.length > gon?.roadmap_epics_limit; return !this.isWarningDismissed && this.epics.length > gon?.roadmap_epics_limit;
}, },
}, },
mounted() { created() {
this.fetchEpics(); this.fetchEpics();
this.fetchMilestones();
}, },
methods: { methods: {
...mapActions(['fetchEpics', 'fetchMilestones']), ...mapActions(['fetchEpics']),
toggleSettings() { toggleSettings() {
this.isSettingsSidebarOpen = !this.isSettingsSidebarOpen; this.isSettingsSidebarOpen = !this.isSettingsSidebarOpen;
}, },
...@@ -98,7 +96,6 @@ export default { ...@@ -98,7 +96,6 @@ export default {
v-else-if="!epicsFetchFailure" v-else-if="!epicsFetchFailure"
:preset-type="presetType" :preset-type="presetType"
:epics="epics" :epics="epics"
:milestones="milestones"
:timeframe="timeframe" :timeframe="timeframe"
:current-group-id="currentGroupId" :current-group-id="currentGroupId"
:has-filters-applied="hasFiltersApplied" :has-filters-applied="hasFiltersApplied"
......
...@@ -12,15 +12,21 @@ export default { ...@@ -12,15 +12,21 @@ export default {
GlToggle, GlToggle,
}, },
computed: { computed: {
...mapState(['milestonesType', 'isShowingMilestones']), ...mapState(['milestonesType', 'isShowingMilestones', 'milestones']),
}, },
methods: { methods: {
...mapActions(['setMilestonesType', 'toggleMilestones']), ...mapActions(['setMilestonesType', 'toggleMilestones', 'fetchMilestones']),
handleMilestonesChange(option) { handleMilestonesChange(option) {
if (option !== this.milestonesType) { if (option !== this.milestonesType) {
this.setMilestonesType(option); this.setMilestonesType(option);
} }
}, },
toggle(value) {
if (value && this.milestones.length === 0) {
this.fetchMilestones();
}
this.toggleMilestones();
},
}, },
i18n: { i18n: {
header: __('Milestones'), header: __('Milestones'),
...@@ -48,7 +54,7 @@ export default { ...@@ -48,7 +54,7 @@ export default {
data-track-action="click_toggle" data-track-action="click_toggle"
:data-track-label="$options.tracking.label" :data-track-label="$options.tracking.label"
:data-track-property="$options.tracking.property" :data-track-property="$options.tracking.property"
@change="toggleMilestones" @change="toggle"
/> />
<gl-form-radio-group <gl-form-radio-group
v-if="isShowingMilestones" v-if="isShowingMilestones"
......
<script> <script>
import { mapState } from 'vuex'; import { mapActions, mapState } from 'vuex';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
import { MILESTONES_GROUP, MILESTONES_SUBGROUP, MILESTONES_PROJECT } from '../constants'; import { MILESTONES_GROUP, MILESTONES_SUBGROUP, MILESTONES_PROJECT } from '../constants';
...@@ -23,10 +23,6 @@ export default { ...@@ -23,10 +23,6 @@ export default {
type: Array, type: Array,
required: true, required: true,
}, },
milestones: {
type: Array,
required: true,
},
timeframe: { timeframe: {
type: Array, type: Array,
required: true, required: true,
...@@ -41,7 +37,7 @@ export default { ...@@ -41,7 +37,7 @@ export default {
}, },
}, },
computed: { computed: {
...mapState(['defaultInnerHeight', 'isShowingMilestones', 'milestonesType']), ...mapState(['defaultInnerHeight', 'isShowingMilestones', 'milestonesType', 'milestones']),
displayMilestones() { displayMilestones() {
return Boolean(this.milestones.length) && this.isShowingMilestones; return Boolean(this.milestones.length) && this.isShowingMilestones;
}, },
...@@ -58,7 +54,13 @@ export default { ...@@ -58,7 +54,13 @@ export default {
} }
}, },
}, },
mounted() {
if (this.isShowingMilestones) {
this.fetchMilestones();
}
},
methods: { methods: {
...mapActions(['fetchMilestones']),
handleScroll() { handleScroll() {
const { scrollTop, scrollLeft, clientHeight, scrollHeight } = this.$el; const { scrollTop, scrollLeft, clientHeight, scrollHeight } = this.$el;
......
...@@ -151,7 +151,6 @@ describe('RoadmapApp', () => { ...@@ -151,7 +151,6 @@ describe('RoadmapApp', () => {
hasFiltersApplied, hasFiltersApplied,
presetType, presetType,
timeframe, timeframe,
milestones: [],
}); });
}); });
......
...@@ -13,18 +13,15 @@ import eventHub from 'ee/roadmap/event_hub'; ...@@ -13,18 +13,15 @@ import eventHub from 'ee/roadmap/event_hub';
import createStore from 'ee/roadmap/store'; import createStore from 'ee/roadmap/store';
import { getTimeframeForRangeType } from 'ee/roadmap/utils/roadmap_utils'; import { getTimeframeForRangeType } from 'ee/roadmap/utils/roadmap_utils';
import { import { mockEpic, mockTimeframeInitialDate, mockGroupId } from 'ee_jest/roadmap/mock_data';
mockEpic,
mockTimeframeInitialDate,
mockGroupId,
mockMilestone,
} from 'ee_jest/roadmap/mock_data';
const mockTimeframeMonths = getTimeframeForRangeType({ const mockTimeframeMonths = getTimeframeForRangeType({
timeframeRangeType: DATE_RANGES.CURRENT_YEAR, timeframeRangeType: DATE_RANGES.CURRENT_YEAR,
presetType: PRESET_TYPES.MONTHS, presetType: PRESET_TYPES.MONTHS,
initialDate: mockTimeframeInitialDate, initialDate: mockTimeframeInitialDate,
}); });
const presetType = PRESET_TYPES.MONTHS;
const timeframeRangeType = DATE_RANGES.CURRENT_YEAR;
describe('RoadmapShell', () => { describe('RoadmapShell', () => {
Vue.use(Vuex); Vue.use(Vuex);
...@@ -37,13 +34,15 @@ describe('RoadmapShell', () => { ...@@ -37,13 +34,15 @@ describe('RoadmapShell', () => {
store.dispatch('setInitialData', { store.dispatch('setInitialData', {
defaultInnerHeight, defaultInnerHeight,
childrenFlags: { 1: { itemExpanded: false } }, childrenFlags: { 1: { itemExpanded: false } },
timeframe: mockTimeframeMonths,
presetType,
timeframeRangeType,
}); });
}; };
const createComponent = ( const createComponent = (
{ {
epics = [mockEpic], epics = [mockEpic],
milestones = [mockMilestone],
timeframe = mockTimeframeMonths, timeframe = mockTimeframeMonths,
currentGroupId = mockGroupId, currentGroupId = mockGroupId,
hasFiltersApplied = false, hasFiltersApplied = false,
...@@ -56,7 +55,6 @@ describe('RoadmapShell', () => { ...@@ -56,7 +55,6 @@ describe('RoadmapShell', () => {
propsData: { propsData: {
presetType: PRESET_TYPES.MONTHS, presetType: PRESET_TYPES.MONTHS,
epics, epics,
milestones,
timeframe, timeframe,
currentGroupId, currentGroupId,
hasFiltersApplied, hasFiltersApplied,
......
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