summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/modules/pipelines/mutations.js
blob: 382775de10adeaa7a1e429d06e47ccb046cf7a12 (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
/* eslint-disable no-param-reassign */
import * as types from './mutation_types';

export default {
  [types.REQUEST_LATEST_PIPELINE](state) {
    state.isLoadingPipeline = true;
  },
  [types.RECEIVE_LASTEST_PIPELINE_ERROR](state) {
    state.isLoadingPipeline = false;
  },
  [types.RECEIVE_LASTEST_PIPELINE_SUCCESS](state, pipeline) {
    state.isLoadingPipeline = false;

    if (pipeline) {
      state.latestPipeline = {
        id: pipeline.id,
        status: pipeline.status,
      };
    }
  },
  [types.REQUEST_JOBS](state) {
    state.isLoadingJobs = true;
  },
  [types.RECEIVE_JOBS_ERROR](state) {
    state.isLoadingJobs = false;
  },
  [types.RECEIVE_JOBS_SUCCESS](state, jobs) {
    state.isLoadingJobs = false;
    state.jobs = jobs.map(job => ({
      id: job.id,
      name: job.name,
      status: job.status,
      stage: job.stage,
      duration: job.duration,
    }));
  },
};