All files / ee/app/assets/javascripts/analytics/productivity_analytics/store/modules/filters actions.js

100% Statements 32/32
100% Branches 3/3
100% Functions 10/10
100% Lines 31/31

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83      4x 55x   55x   2x 2x   2x       4x 44x       44x       44x 44x   44x       4x 2x   2x   2x 2x   2x       4x               7x   7x                 7x   7x 7x   7x       4x 1x   1x   1x 1x   1x      
import { chartKeys } from '../../../constants';
import * as types from './mutation_types';
 
export const setInitialData = ({ commit, dispatch }, { skipFetch = false, data }) => {
  commit(types.SET_INITIAL_DATA, data);
 
  if (skipFetch) return Promise.resolve();
 
  return dispatch('charts/fetchChartData', chartKeys.main, { root: true }).then(() => {
    dispatch('charts/fetchSecondaryChartData', null, { root: true });
    // let's reset the page on the MR table and fetch data
    dispatch('table/setPage', 0, { root: true });
  });
};
 
export const setGroupNamespace = ({ commit, dispatch }, groupNamespace) => {
  commit(types.SET_GROUP_NAMESPACE, groupNamespace);
 
  // let's reset the current selection first
  // with skipReload=true we avoid data from being fetched here
  dispatch('charts/resetMainChartSelection', true, { root: true });
 
  // let's fetch the main chart data first to see if the user has access to the selected group
  // if there's no 403, then we fetch all remaining chart data and table data
  return dispatch('charts/fetchChartData', chartKeys.main, { root: true }).then(() => {
    dispatch('charts/fetchSecondaryChartData', null, { root: true });
    // let's reset the page on the MR table and fetch data
    dispatch('table/setPage', 0, { root: true });
  });
};
 
export const setProjectPath = ({ commit, dispatch }, projectPath) => {
  commit(types.SET_PROJECT_PATH, projectPath);
 
  dispatch('charts/resetMainChartSelection', true, { root: true });
 
  return dispatch('charts/fetchChartData', chartKeys.main, { root: true }).then(() => {
    dispatch('charts/fetchSecondaryChartData', null, { root: true });
    // let's reset the page on the MR table and fetch data
    dispatch('table/setPage', 0, { root: true });
  });
};
 
export const setFilters = ({ commit, dispatch }, data) => {
  const {
    author_username: authorUsername,
    label_name: labelName,
    milestone_title: milestoneTitle,
    'not[author_username]': notAuthorUsername,
    'not[milestone_title]': notMilestoneTitle,
    'not[label_name]': notLabelName,
  } = data;
 
  commit(types.SET_FILTERS, {
    authorUsername,
    labelName,
    milestoneTitle,
    notAuthorUsername,
    notMilestoneTitle,
    notLabelName,
  });
 
  dispatch('charts/resetMainChartSelection', true, { root: true });
 
  return dispatch('charts/fetchChartData', chartKeys.main, { root: true }).then(() => {
    dispatch('charts/fetchSecondaryChartData', null, { root: true });
    // let's reset the page on the MR table and fetch data
    dispatch('table/setPage', 0, { root: true });
  });
};
 
export const setDateRange = ({ commit, dispatch }, { startDate, endDate }) => {
  commit(types.SET_DATE_RANGE, { startDate, endDate });
 
  dispatch('charts/resetMainChartSelection', true, { root: true });
 
  return dispatch('charts/fetchChartData', chartKeys.main, { root: true }).then(() => {
    dispatch('charts/fetchSecondaryChartData', null, { root: true });
    // let's reset the page on the MR table and fetch data
    dispatch('table/setPage', 0, { root: true });
  });
};