summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/ide/stores/modules
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-05-23 15:29:34 +0100
committerPhil Hughes <me@iamphill.com>2018-05-24 10:38:02 +0100
commit76ffde63189efd81249857a6a9bf612f328322c6 (patch)
treed91da91f755eabb6366e953d3a3b99090c539fe4 /app/assets/javascripts/ide/stores/modules
parent5e79276b53f61cbd727411ed33e71d5b6fa5ca54 (diff)
downloadgitlab-ce-76ffde63189efd81249857a6a9bf612f328322c6.tar.gz
style improvements
fixed multiple requests causing state to be emptied at wrong time
Diffstat (limited to 'app/assets/javascripts/ide/stores/modules')
-rw-r--r--app/assets/javascripts/ide/stores/modules/pipelines/actions.js1
-rw-r--r--app/assets/javascripts/ide/stores/modules/pipelines/getters.js2
-rw-r--r--app/assets/javascripts/ide/stores/modules/pipelines/mutations.js17
3 files changed, 12 insertions, 8 deletions
diff --git a/app/assets/javascripts/ide/stores/modules/pipelines/actions.js b/app/assets/javascripts/ide/stores/modules/pipelines/actions.js
index 994edd74aef..b5d78b381ea 100644
--- a/app/assets/javascripts/ide/stores/modules/pipelines/actions.js
+++ b/app/assets/javascripts/ide/stores/modules/pipelines/actions.js
@@ -35,7 +35,6 @@ export const fetchStages = ({ dispatch, state, rootState }) => {
Api.pipelineJobs(rootState.currentProjectId, state.latestPipeline.id)
.then(({ data }) => dispatch('receiveStagesSuccess', data))
- .then(() => state.stages.forEach(stage => dispatch('fetchJobs', stage)))
.catch(() => dispatch('receiveStagesError'));
};
diff --git a/app/assets/javascripts/ide/stores/modules/pipelines/getters.js b/app/assets/javascripts/ide/stores/modules/pipelines/getters.js
index 99b4554a96e..e4570717791 100644
--- a/app/assets/javascripts/ide/stores/modules/pipelines/getters.js
+++ b/app/assets/javascripts/ide/stores/modules/pipelines/getters.js
@@ -1,5 +1,7 @@
export const hasLatestPipeline = state => !state.isLoadingPipeline && !!state.latestPipeline;
+export const failedStages = state => state.stages.filter(stage => stage.status.label === 'failed');
+
export const failedJobsCount = state =>
state.stages.reduce(
(acc, stage) => acc + stage.jobs.filter(j => j.status.label === 'failed').length,
diff --git a/app/assets/javascripts/ide/stores/modules/pipelines/mutations.js b/app/assets/javascripts/ide/stores/modules/pipelines/mutations.js
index 7115f5e5386..0713aa4a3f5 100644
--- a/app/assets/javascripts/ide/stores/modules/pipelines/mutations.js
+++ b/app/assets/javascripts/ide/stores/modules/pipelines/mutations.js
@@ -27,13 +27,16 @@ export default {
[types.RECEIVE_STAGES_SUCCESS](state, stages) {
state.isLoadingJobs = false;
- state.stages = stages.map((stage, i) => ({
- ...stage,
- id: i,
- isCollapsed: false,
- isLoading: false,
- jobs: [],
- }));
+ 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(