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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/* 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_STAGES](state) {
state.isLoadingJobs = true;
},
[types.RECEIVE_STAGES_ERROR](state) {
state.isLoadingJobs = false;
},
[types.RECEIVE_STAGES_SUCCESS](state, stages) {
state.isLoadingJobs = false;
state.stages = stages.map((stage, i) => {
const foundStage = state.stages.find(s => s.id === i);
return {
...stage,
id: i,
isCollapsed: foundStage ? foundStage.isCollapsed : false,
isLoading: foundStage ? foundStage.isLoading : false,
jobs: foundStage ? foundStage.jobs : [],
};
});
},
[types.REQUEST_JOBS](state, id) {
state.stages = state.stages.reduce(
(acc, stage) =>
acc.concat({
...stage,
isLoading: id === stage.id ? true : stage.isLoading,
}),
[],
);
},
[types.RECEIVE_JOBS_ERROR](state, id) {
state.stages = state.stages.reduce(
(acc, stage) =>
acc.concat({
...stage,
isLoading: id === stage.id ? false : stage.isLoading,
}),
[],
);
},
[types.RECEIVE_JOBS_SUCCESS](state, { id, data }) {
state.stages = state.stages.reduce(
(acc, stage) =>
acc.concat({
...stage,
isLoading: id === stage.id ? false : stage.isLoading,
jobs: id === stage.id ? data.latest_statuses : stage.jobs,
}),
[],
);
},
};
|