2021-07-15 18:09:37 +00:00
|
|
|
import { dateFormats } from '~/analytics/shared/constants';
|
2022-08-23 18:11:55 +00:00
|
|
|
import dateFormat from '~/lib/dateformat';
|
2021-09-07 15:11:06 +00:00
|
|
|
import { filterToQueryObject } from '~/vue_shared/components/filtered_search_bar/filtered_search_utils';
|
2021-10-12 15:12:08 +00:00
|
|
|
import { PAGINATION_TYPE } from '../constants';
|
2021-06-02 09:09:46 +00:00
|
|
|
import { transformStagesForPathNavigation, filterStagesByHiddenStatus } from '../utils';
|
|
|
|
|
|
|
|
export const pathNavigationData = ({ stages, medians, stageCounts, selectedStage }) => {
|
|
|
|
return transformStagesForPathNavigation({
|
|
|
|
stages: filterStagesByHiddenStatus(stages, false),
|
|
|
|
medians,
|
|
|
|
stageCounts,
|
|
|
|
selectedStage,
|
|
|
|
});
|
|
|
|
};
|
2021-07-15 18:09:37 +00:00
|
|
|
|
|
|
|
export const requestParams = (state) => {
|
|
|
|
const {
|
2021-08-04 18:09:57 +00:00
|
|
|
endpoints: { fullPath },
|
2021-07-15 18:09:37 +00:00
|
|
|
selectedValueStream: { id: valueStreamId },
|
2021-08-04 18:09:57 +00:00
|
|
|
selectedStage: { id: stageId = null },
|
2021-07-15 18:09:37 +00:00
|
|
|
} = state;
|
2021-08-04 18:09:57 +00:00
|
|
|
return { requestPath: fullPath, valueStreamId, stageId };
|
2021-07-15 18:09:37 +00:00
|
|
|
};
|
|
|
|
|
2021-10-12 15:12:08 +00:00
|
|
|
export const paginationParams = ({ pagination: { page, sort, direction } }) => ({
|
|
|
|
pagination: PAGINATION_TYPE,
|
|
|
|
sort,
|
|
|
|
direction,
|
|
|
|
page,
|
|
|
|
});
|
|
|
|
|
2021-09-07 15:11:06 +00:00
|
|
|
const filterBarParams = ({ filters }) => {
|
|
|
|
const {
|
|
|
|
authors: { selected: selectedAuthor },
|
|
|
|
milestones: { selected: selectedMilestone },
|
|
|
|
assignees: { selectedList: selectedAssigneeList },
|
|
|
|
labels: { selectedList: selectedLabelList },
|
|
|
|
} = filters;
|
|
|
|
return filterToQueryObject({
|
|
|
|
milestone_title: selectedMilestone,
|
|
|
|
author_username: selectedAuthor,
|
|
|
|
label_name: selectedLabelList,
|
|
|
|
assignee_username: selectedAssigneeList,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2021-07-15 18:09:37 +00:00
|
|
|
const dateRangeParams = ({ createdAfter, createdBefore }) => ({
|
|
|
|
created_after: createdAfter ? dateFormat(createdAfter, dateFormats.isoDate) : null,
|
|
|
|
created_before: createdBefore ? dateFormat(createdBefore, dateFormats.isoDate) : null,
|
|
|
|
});
|
|
|
|
|
2021-08-04 18:09:57 +00:00
|
|
|
export const filterParams = (state) => {
|
2021-07-15 18:09:37 +00:00
|
|
|
return {
|
2021-09-07 15:11:06 +00:00
|
|
|
...filterBarParams(state),
|
2021-08-04 18:09:57 +00:00
|
|
|
...dateRangeParams(state),
|
2021-07-15 18:09:37 +00:00
|
|
|
};
|
|
|
|
};
|