summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/modules/pipelines
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-05-30 13:31:15 +0100
committerPhil Hughes <me@iamphill.com>2018-05-30 13:31:15 +0100
commit3270e140772319f74ede743c61a94af84a850b97 (patch)
tree0aa6ba5c01c233a34b152a9ca8ac8841a1b7af7b /app/assets/javascripts/ide/stores/modules/pipelines
parentc9d676c1069e6e88b4eeeea2246cc5706b56f2ab (diff)
downloadgitlab-ce-3270e140772319f74ede743c61a94af84a850b97.tar.gz
changed mutation to return new array
this makes the component completly unaware of the store, instead it emits events to the parent which knows about the store
Diffstat (limited to 'app/assets/javascripts/ide/stores/modules/pipelines')
-rw-r--r--app/assets/javascripts/ide/stores/modules/pipelines/mutations.js26
1 files changed, 17 insertions, 9 deletions
diff --git a/app/assets/javascripts/ide/stores/modules/pipelines/mutations.js b/app/assets/javascripts/ide/stores/modules/pipelines/mutations.js
index 38459dfbe77..3c50279642b 100644
--- a/app/assets/javascripts/ide/stores/modules/pipelines/mutations.js
+++ b/app/assets/javascripts/ide/stores/modules/pipelines/mutations.js
@@ -39,20 +39,28 @@ export default {
}
},
[types.REQUEST_JOBS](state, id) {
- const stage = state.stages.find(s => s.id === id);
- stage.isLoading = true;
+ state.stages = state.stages.map(stage => ({
+ ...stage,
+ isLoading: stage.id === id ? true : stage.isLoading,
+ }));
},
[types.RECEIVE_JOBS_ERROR](state, id) {
- const stage = state.stages.find(s => s.id === id);
- stage.isLoading = false;
+ state.stages = state.stages.map(stage => ({
+ ...stage,
+ isLoading: stage.id === id ? false : stage.isLoading,
+ }));
},
[types.RECEIVE_JOBS_SUCCESS](state, { id, data }) {
- const stage = state.stages.find(s => s.id === id);
- stage.isLoading = false;
- stage.jobs = data.latest_statuses.map(normalizeJob);
+ state.stages = state.stages.map(stage => ({
+ ...stage,
+ isLoading: stage.id === id ? false : stage.isLoading,
+ jobs: data.latest_statuses.map(normalizeJob),
+ }));
},
[types.TOGGLE_STAGE_COLLAPSE](state, id) {
- const stage = state.stages.find(s => s.id === id);
- stage.isCollapsed = !stage.isCollapsed;
+ state.stages = state.stages.map(stage => ({
+ ...stage,
+ isCollapsed: stage.id === id ? !stage.isCollapsed : stage.isCollapsed,
+ }));
},
};