summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/error_tracking/store/actions.js
blob: 49fa5f3cec5ea60ab1b2d7b1a42c580aa18812c4 (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
import service from './../services';
import * as types from './mutation_types';
import createFlash from '~/flash';
import { visitUrl } from '~/lib/utils/url_utility';
import { __ } from '~/locale';

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

export const updateStatus = ({ commit }, { endpoint, redirectUrl, status }) =>
  service
    .updateErrorStatus(endpoint, status)
    .then(() => {
      if (redirectUrl) visitUrl(redirectUrl);
      commit(types.SET_ERROR_STATUS, status);
    })
    .catch(() => createFlash(__('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);
  });
};

export default () => {};