debian-mirror-gitlab/app/assets/javascripts/cycle_analytics/store/getters.js

64 lines
1.9 KiB
JavaScript
Raw Normal View History

2021-09-30 23:02:18 +05:30
import dateFormat from 'dateformat';
import { dateFormats } from '~/analytics/shared/constants';
2021-11-11 11:23:49 +05:30
import { filterToQueryObject } from '~/vue_shared/components/filtered_search_bar/filtered_search_utils';
2021-11-18 22:05:49 +05:30
import { PAGINATION_TYPE } from '../constants';
2021-09-04 01:27:46 +05:30
import { transformStagesForPathNavigation, filterStagesByHiddenStatus } from '../utils';
export const pathNavigationData = ({ stages, medians, stageCounts, selectedStage }) => {
return transformStagesForPathNavigation({
stages: filterStagesByHiddenStatus(stages, false),
medians,
stageCounts,
selectedStage,
});
};
2021-09-30 23:02:18 +05:30
export const requestParams = (state) => {
const {
2021-10-27 15:23:28 +05:30
endpoints: { fullPath },
2021-09-30 23:02:18 +05:30
selectedValueStream: { id: valueStreamId },
2021-10-27 15:23:28 +05:30
selectedStage: { id: stageId = null },
2021-09-30 23:02:18 +05:30
} = state;
2021-10-27 15:23:28 +05:30
return { requestPath: fullPath, valueStreamId, stageId };
2021-09-30 23:02:18 +05:30
};
2021-11-18 22:05:49 +05:30
export const paginationParams = ({ pagination: { page, sort, direction } }) => ({
pagination: PAGINATION_TYPE,
sort,
direction,
page,
});
2021-11-11 11:23:49 +05:30
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-09-30 23:02:18 +05:30
const dateRangeParams = ({ createdAfter, createdBefore }) => ({
created_after: createdAfter ? dateFormat(createdAfter, dateFormats.isoDate) : null,
created_before: createdBefore ? dateFormat(createdBefore, dateFormats.isoDate) : null,
});
2021-10-27 15:23:28 +05:30
export const legacyFilterParams = ({ daysInPast }) => {
2021-09-30 23:02:18 +05:30
return {
2021-10-27 15:23:28 +05:30
'cycle_analytics[start_date]': daysInPast,
2021-09-30 23:02:18 +05:30
};
};
2021-10-27 15:23:28 +05:30
export const filterParams = (state) => {
2021-09-30 23:02:18 +05:30
return {
2021-11-11 11:23:49 +05:30
...filterBarParams(state),
2021-10-27 15:23:28 +05:30
...dateRangeParams(state),
2021-09-30 23:02:18 +05:30
};
};