summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/error_tracking/store/actions.js
blob: adbce7750fa6104c597a83ff7710764c21f0e4bd (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
29
30
31
32
33
34
35
36
37
38
39
40
import { createAlert } from '~/alert';
import { visitUrl } from '~/lib/utils/url_utility';
import { __ } from '~/locale';
import service from '../services';
import * as types from './mutation_types';

export const setStatus = ({ commit }, status) => {
  commit(types.SET_ERROR_STATUS, status.toLowerCase());
};

export const updateStatus = ({ commit }, { endpoint, redirectUrl, status }) =>
  service
    .updateErrorStatus(endpoint, status)
    .then((resp) => {
      commit(types.SET_ERROR_STATUS, status);
      if (redirectUrl) visitUrl(redirectUrl);

      return resp.data.result;
    })
    .catch(() =>
      createAlert({
        message: __('Failed to update issue status'),
      }),
    );

export const updateResolveStatus = ({ commit, dispatch }, params) => {
  commit(types.SET_UPDATING_RESOLVE_STATUS, true);

  return dispatch('updateStatus', params).finally(() => {
    commit(types.SET_UPDATING_RESOLVE_STATUS, false);
  });
};

export const updateIgnoreStatus = ({ commit, dispatch }, params) => {
  commit(types.SET_UPDATING_IGNORE_STATUS, true);

  return dispatch('updateStatus', params).finally(() => {
    commit(types.SET_UPDATING_IGNORE_STATUS, false);
  });
};