Commit 496819de authored by Phil Hughes's avatar Phil Hughes

Merge branch '216792-cleanup-roadmap-rails-api-frontend' into 'master'

Roadmap: Remove Rails API related code

See merge request gitlab-org/gitlab!39801
parents 39db2b06 b5bc6b10
......@@ -141,7 +141,7 @@ export default {
},
getEpicItemProps(index) {
return {
key: index,
key: generateKey(this.displayedEpics[index]),
props: {
epic: this.displayedEpics[index],
presetType: this.presetType,
......
......@@ -15,7 +15,7 @@ import { visitUrl, mergeUrlParams } from '~/lib/utils/url_utility';
import { PRESET_TYPES, EPIC_DETAILS_CELL_WIDTH } from './constants';
import { getEpicsPathForPreset, getTimeframeForPreset } from './utils/roadmap_utils';
import { getTimeframeForPreset } from './utils/roadmap_utils';
import createStore from './store';
......@@ -57,9 +57,8 @@ export default () => {
supportedPresetTypes.indexOf(dataset.presetType) > -1
? dataset.presetType
: PRESET_TYPES.MONTHS;
const filterQueryString = window.location.search.substring(1);
const filterParams = Object.assign(
convertObjectPropsToCamelCase(urlParamsToObject(filterQueryString), {
convertObjectPropsToCamelCase(urlParamsToObject(window.location.search.substring(1)), {
dropKeys: ['scope', 'utf8', 'state', 'sort', 'layout'], // These keys are unsupported/unnecessary
}),
);
......@@ -67,13 +66,6 @@ export default () => {
presetType,
window.innerWidth - el.offsetLeft - EPIC_DETAILS_CELL_WIDTH,
);
const initialEpicsPath = getEpicsPathForPreset({
basePath: dataset.epicsPath,
epicsState: dataset.epicsState,
filterQueryString,
presetType,
timeframe,
});
return {
emptyStateIllustrationPath: dataset.emptyStateIllustration,
......@@ -90,8 +82,6 @@ export default () => {
groupMilestonesEndpoint: dataset.groupMilestonesEndpoint,
epicsState: dataset.epicsState,
sortedBy: dataset.sortedBy,
filterQueryString,
initialEpicsPath,
filterParams,
presetType,
timeframe,
......@@ -107,9 +97,7 @@ export default () => {
epicsState: this.epicsState,
timeframe: this.timeframe,
basePath: this.basePath,
filterQueryString: this.filterQueryString,
filterParams: this.filterParams,
initialEpicsPath: this.initialEpicsPath,
groupLabelsEndpoint: this.groupLabelsEndpoint,
groupMilestonesEndpoint: this.groupMilestonesEndpoint,
defaultInnerHeight: this.defaultInnerHeight,
......
......@@ -2,8 +2,6 @@ export default () => ({
// API Calls
basePath: '',
epicsState: '',
filterQueryString: '',
initialEpicsPath: '',
filterParams: null,
groupLabelsEndpoint: '',
groupMilestonesEndpoint: '',
......
......@@ -406,34 +406,6 @@ export const getEpicsTimeframeRange = ({ presetType = '', timeframe = [] }) => {
};
};
export const getEpicsPathForPreset = ({
basePath = '',
filterQueryString = '',
presetType = '',
timeframe = [],
epicsState = 'all',
}) => {
let epicsPath = basePath;
if (!basePath || !timeframe.length) {
return null;
}
const range = getEpicsTimeframeRange({
presetType,
timeframe,
});
epicsPath += epicsPath.indexOf('?') === -1 ? '?' : '&';
epicsPath += `state=${epicsState}&start_date=${range.startDate}&end_date=${range.dueDate}`;
if (filterQueryString) {
epicsPath += `&${filterQueryString}`;
}
return epicsPath;
};
/**
* This function takes two epics and return sortable dates depending on the '
* type of sorting order -- startDate or endDate.
......
......@@ -245,7 +245,7 @@ describe('EpicsListSectionComponent', () => {
it('returns an object containing props for EpicItem component', () => {
expect(wrapper.vm.getEpicItemProps(1)).toEqual(
expect.objectContaining({
key: 1,
key: `epic-${wrapper.vm.epics[1].id}`,
props: {
epic: wrapper.vm.epics[1],
presetType: wrapper.vm.presetType,
......
......@@ -7,7 +7,6 @@ import {
extendTimeframeForWeeksView,
extendTimeframeForAvailableWidth,
getEpicsTimeframeRange,
getEpicsPathForPreset,
assignDates,
sortEpics,
} from 'ee/roadmap/utils/roadmap_utils';
......@@ -345,71 +344,6 @@ describe('getEpicsTimeframeRange', () => {
});
});
describe('getEpicsPathForPreset', () => {
const basePath = '/groups/gitlab-org/-/epics.json';
const filterQueryString = 'scope=all&utf8=✓&state=opened&label_name[]=Bug';
it('returns epics path string based on provided basePath and timeframe for Quarters', () => {
const timeframeQuarters = getTimeframeForQuartersView(new Date(2018, 0, 1));
const epicsPath = getEpicsPathForPreset({
basePath,
timeframe: timeframeQuarters,
presetType: PRESET_TYPES.QUARTERS,
});
expect(epicsPath).toBe(`${basePath}?state=all&start_date=2017-7-1&end_date=2019-3-31`);
});
it('returns epics path string based on provided basePath and timeframe for Months', () => {
const timeframeMonths = getTimeframeForMonthsView(new Date(2018, 0, 1));
const epicsPath = getEpicsPathForPreset({
basePath,
timeframe: timeframeMonths,
presetType: PRESET_TYPES.MONTHS,
});
expect(epicsPath).toBe(`${basePath}?state=all&start_date=2017-11-1&end_date=2018-6-30`);
});
it('returns epics path string based on provided basePath and timeframe for Weeks', () => {
const timeframeWeeks = getTimeframeForWeeksView(new Date(2018, 0, 1));
const epicsPath = getEpicsPathForPreset({
basePath,
timeframe: timeframeWeeks,
presetType: PRESET_TYPES.WEEKS,
});
expect(epicsPath).toBe(`${basePath}?state=all&start_date=2017-12-17&end_date=2018-2-3`);
});
it('returns epics path string while preserving filterQueryString', () => {
const timeframeMonths = getTimeframeForMonthsView(new Date(2018, 0, 1));
const epicsPath = getEpicsPathForPreset({
basePath,
filterQueryString,
timeframe: timeframeMonths,
presetType: PRESET_TYPES.MONTHS,
});
expect(epicsPath).toBe(
`${basePath}?state=all&start_date=2017-11-1&end_date=2018-6-30&scope=all&utf8=✓&state=opened&label_name[]=Bug`,
);
});
it('returns epics path string containing epicsState', () => {
const epicsState = 'opened';
const timeframe = getTimeframeForMonthsView(new Date(2018, 0, 1));
const epicsPath = getEpicsPathForPreset({
presetType: PRESET_TYPES.MONTHS,
basePath,
timeframe,
epicsState,
});
expect(epicsPath).toContain(`state=${epicsState}`);
});
});
describe('sortEpics', () => {
it('sorts epics list by startDate in ascending order when `sortedBy` param is `start_date_asc`', () => {
const epics = mockUnsortedEpics.slice();
......
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