Welcome to mirror list, hosted at ThFree Co, Russian Federation.

actions.js « store « statistics_panel « admin « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 537025f524cb27158214e7869e7089beff6e156e (plain)
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
import Api from '~/api';
import { s__ } from '~/locale';
import createFlash from '~/flash';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import * as types from './mutation_types';

export const requestStatistics = ({ commit }) => commit(types.REQUEST_STATISTICS);

export const fetchStatistics = ({ dispatch }) => {
  dispatch('requestStatistics');

  Api.adminStatistics()
    .then(({ data }) => {
      dispatch('receiveStatisticsSuccess', convertObjectPropsToCamelCase(data, { deep: true }));
    })
    .catch(error => dispatch('receiveStatisticsError', error));
};

export const receiveStatisticsSuccess = ({ commit }, statistics) =>
  commit(types.RECEIVE_STATISTICS_SUCCESS, statistics);

export const receiveStatisticsError = ({ commit }, error) => {
  commit(types.RECEIVE_STATISTICS_ERROR, error);
  createFlash(s__('AdminDashboard|Error loading the statistics. Please try again'));
};

// prevent babel-plugin-rewire from generating an invalid default during karma tests
export default () => {};