Commit ffa2b3a8 authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Applying patch from @pslaughter

parent 1ed0e173
...@@ -13,6 +13,7 @@ import StageDropdownFilter from './stage_dropdown_filter.vue'; ...@@ -13,6 +13,7 @@ import StageDropdownFilter from './stage_dropdown_filter.vue';
import SummaryTable from './summary_table.vue'; import SummaryTable from './summary_table.vue';
import StageTable from './stage_table.vue'; import StageTable from './stage_table.vue';
import TasksByTypeChart from './tasks_by_type_chart.vue'; import TasksByTypeChart from './tasks_by_type_chart.vue';
import UrlSync from './url_sync.vue';
export default { export default {
name: 'CycleAnalytics', name: 'CycleAnalytics',
...@@ -27,6 +28,7 @@ export default { ...@@ -27,6 +28,7 @@ export default {
StageDropdownFilter, StageDropdownFilter,
Scatterplot, Scatterplot,
TasksByTypeChart, TasksByTypeChart,
UrlSync,
}, },
mixins: [glFeatureFlagsMixin()], mixins: [glFeatureFlagsMixin()],
props: { props: {
...@@ -203,6 +205,7 @@ export default { ...@@ -203,6 +205,7 @@ export default {
<template> <template>
<div class="js-cycle-analytics"> <div class="js-cycle-analytics">
<url-sync />
<div class="page-title-holder d-flex align-items-center"> <div class="page-title-holder d-flex align-items-center">
<h3 class="page-title">{{ __('Value Stream Analytics') }}</h3> <h3 class="page-title">{{ __('Value Stream Analytics') }}</h3>
</div> </div>
......
<script>
import { mapState, mapGetters } from 'vuex';
import { historyPushState } from '~/lib/utils/common_utils';
import { setUrlParams } from '~/lib/utils/url_utility';
import { toYmd } from '../../shared/utils';
export default {
computed: {
...mapGetters(['currentGroupPath', 'selectedProjectIds']),
...mapState(['startDate', 'endDate']),
query() {
return {
group_id: this.currentGroupPath,
'project_ids[]': this.selectedProjectIds,
created_after: toYmd(this.startDate),
created_before: toYmd(this.endDate),
};
},
},
watch: {
query() {
historyPushState(setUrlParams(this.query, window.location.href, true));
},
},
render() {
return this.$slots.default;
},
};
</script>
import dateFormat from 'dateformat'; import dateFormat from 'dateformat';
import Api from 'ee/api'; import Api from 'ee/api';
import { getDayDifference, getDateInPast } from '~/lib/utils/datetime_utility'; import { getDayDifference, getDateInPast } from '~/lib/utils/datetime_utility';
import { historyPushState } from '~/lib/utils/common_utils'; import createFlash, { hideFlash } from '~/flash';
import { setUrlParams } from '~/lib/utils/url_utility';
import createFlash from '~/flash';
import { __, sprintf } from '~/locale'; import { __, sprintf } from '~/locale';
import httpStatus from '~/lib/utils/http_status'; import httpStatus from '~/lib/utils/http_status';
import * as types from './mutation_types'; import * as types from './mutation_types';
import { dateFormats } from '../../shared/constants'; import { dateFormats } from '../../shared/constants';
import { toYmd } from '../../shared/utils';
import { removeFlash } from '../utils'; const removeError = () => {
const flashEl = document.querySelector('.flash-alert');
if (flashEl) {
hideFlash(flashEl);
}
};
const handleErrorOrRethrow = ({ action, error }) => { const handleErrorOrRethrow = ({ action, error }) => {
if (error?.response?.status === httpStatus.FORBIDDEN) { if (error?.response?.status === httpStatus.FORBIDDEN) {
...@@ -26,50 +29,21 @@ const isStageNameExistsError = ({ status, errors }) => { ...@@ -26,50 +29,21 @@ const isStageNameExistsError = ({ status, errors }) => {
return false; return false;
}; };
const updateUrlParams = (
{ getters: { currentGroupPath, selectedProjectIds } },
additionalParams = {},
) => {
historyPushState(
setUrlParams(
{
group_id: currentGroupPath,
'project_ids[]': selectedProjectIds,
...additionalParams,
},
window.location.href,
true,
),
);
};
export const setFeatureFlags = ({ commit }, featureFlags) => export const setFeatureFlags = ({ commit }, featureFlags) =>
commit(types.SET_FEATURE_FLAGS, featureFlags); commit(types.SET_FEATURE_FLAGS, featureFlags);
export const setSelectedGroup = ({ commit, getters }, group) => { export const setSelectedGroup = ({ commit }, group) => {
commit(types.SET_SELECTED_GROUP, group); commit(types.SET_SELECTED_GROUP, group);
updateUrlParams({ getters });
}; };
export const setSelectedProjects = ({ commit, getters }, projects) => { export const setSelectedProjects = ({ commit }, projects) => {
commit(types.SET_SELECTED_PROJECTS, projects); commit(types.SET_SELECTED_PROJECTS, projects);
updateUrlParams({ getters });
}; };
export const setSelectedStage = ({ commit }, stage) => commit(types.SET_SELECTED_STAGE, stage); export const setSelectedStage = ({ commit }, stage) => commit(types.SET_SELECTED_STAGE, stage);
export const setDateRange = ( export const setDateRange = ({ commit, dispatch }, { skipFetch = false, startDate, endDate }) => {
{ commit, dispatch, getters },
{ skipFetch = false, startDate, endDate },
) => {
commit(types.SET_DATE_RANGE, { startDate, endDate }); commit(types.SET_DATE_RANGE, { startDate, endDate });
updateUrlParams(
{ getters },
{
created_after: toYmd(startDate),
created_before: toYmd(endDate),
},
);
if (skipFetch) return false; if (skipFetch) return false;
......
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