summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/reports/store/mutations.js
blob: 120ec177666524a0121da12582f9bf2c6a6608e6 (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
41
42
43
44
45
46
47
/* eslint-disable no-param-reassign */
import Vue from 'vue';
import * as types from './mutation_types';

export default {
  [types.SET_ENDPOINT](state, endpoint) {
    state.endpoint = endpoint;
  },
  [types.REQUEST_REPORTS](state) {
    state.isLoading = true;
  },
  [types.RECEIVE_REPORTS_SUCCESS](state, response) {

    state.isLoading = false;

    Vue.set(state.summary, 'total', response.summary.total);
    Vue.set(state.summary, 'resolved', response.summary.resolved);
    Vue.set(state.summary, 'failed', response.summary.failed);

    state.status = response.status;
    state.reports = response.suites;

  },
  [types.RECEIVE_REPORTS_ERROR](state) {
    state.isLoading = false;
    state.hasError = true;
  },
  [types.SET_ISSUE_MODAL_DATA](state, payload) {
    Vue.set(state.modal, 'title', payload.issue.name);
    Vue.set(state.modal, 'status', payload.status);

    Object.keys(payload.issue).forEach((key) => {
      if (Object.prototype.hasOwnProperty.call(state.modal.data, key)) {
        Vue.set(state.modal.data[key], 'value', payload.issue[key]);
      }
    });
  },
  [types.REQUEST_CREATE_ISSUE](state) {
    Vue.set(state.modal, 'isLoading', true);
  },
  [types.RECEIVE_CREATE_ISSUE_SUCCESS](state) {
    Vue.set(state.modal, 'isLoading', false);
  },
  [types.RECEIVE_CREATE_ISSUE_ERROR](state) {
    Vue.set(state.modal, 'isLoading', false);
  },
};