This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | const _ = require('underscore'); |
||
2 | |||
3 | const actions = require('../_actions.js'); |
||
4 | |||
5 | const initialState = { |
||
6 | // this is the time of the last update we got from the server |
||
7 | // it is used for syncronising with the backend |
||
8 | server_time: 0, |
||
9 | is_creating: false, |
||
10 | is_loading: false, |
||
11 | is_queuing: false, |
||
12 | // this is the "list" (actually an object) of all deployments that we fetched, updated etc keyed by deployment id |
||
13 | list: {}, |
||
14 | // point to a deployment in the list above and is used to for the modal |
||
15 | current_id: "", |
||
16 | // this is a "list" (actually an object) of deployment logs keyed by the deployment id |
||
17 | logs: {}, |
||
18 | history_error: null, |
||
19 | error: null, |
||
20 | current_page: 1, |
||
21 | history_is_loading: false, |
||
22 | abort_is_loading: false |
||
23 | }; |
||
24 | |||
25 | module.exports = function deployment(state, action) { |
||
26 | if (typeof state === 'undefined') { |
||
27 | return initialState; |
||
28 | } |
||
29 | |||
30 | switch (action.type) { |
||
31 | case actions.SET_DEPLOY_HISTORY_PAGE: { |
||
32 | return _.assign({}, state, { |
||
33 | current_page: action.page |
||
34 | }); |
||
35 | } |
||
36 | case actions.START_DEPLOY_HISTORY_GET: |
||
37 | return _.assign({}, state, { |
||
38 | history_is_loading: true |
||
39 | }); |
||
40 | case actions.FAIL_DEPLOY_HISTORY_GET: |
||
41 | return _.assign({}, state, { |
||
42 | history_is_loading: false, |
||
43 | history_error: action.error.toString() |
||
44 | }); |
||
45 | case actions.SUCCEED_DEPLOY_HISTORY_GET: { |
||
46 | // get current list |
||
47 | const newList = _.assign({}, state.list); |
||
48 | let new_current_build_id = null; |
||
49 | |||
50 | // add or update the entries in the current list |
||
51 | for (let i = 0; i < action.data.list.length; i++) { |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
52 | // if one of the new entries is the current_build, |
||
53 | // we'll be invalidating the current one for the new one |
||
54 | if (action.data.list[i].is_current_build === true) { |
||
55 | new_current_build_id = action.data.list[i].id; |
||
56 | } |
||
57 | newList[action.data.list[i].id] = action.data.list[i]; |
||
58 | } |
||
59 | |||
60 | if (new_current_build_id !== null) { |
||
61 | // first of all, set everything to not be the current build |
||
62 | Object.keys(newList).forEach(function(key) { |
||
63 | newList[key].is_current_build = false; |
||
64 | }); |
||
65 | // now set the item we need to current |
||
66 | newList[new_current_build_id].is_current_build = true; |
||
67 | } |
||
68 | |||
69 | return _.assign({}, state, { |
||
70 | server_time: action.data.server_time, |
||
71 | list: newList, |
||
72 | history_is_loading: false |
||
73 | }); |
||
74 | } |
||
75 | case actions.NEW_DEPLOYMENT: |
||
76 | return _.assign({}, state, { |
||
77 | current_id: "", |
||
78 | error: null, |
||
79 | }); |
||
80 | |||
81 | case actions.START_DEPLOYMENT_CREATE: |
||
82 | return _.assign({}, state, { |
||
83 | is_creating: true, |
||
84 | }); |
||
85 | |||
86 | case actions.SUCCEED_DEPLOYMENT_CREATE: { |
||
87 | const newList = _.assign({}, state.list); |
||
88 | newList[action.data.deployment.id] = action.data.deployment; |
||
89 | return _.assign({}, state, { |
||
90 | is_creating: false, |
||
91 | current_id: action.data.deployment.id, |
||
92 | list: newList |
||
93 | }); |
||
94 | } |
||
95 | |||
96 | case actions.FAIL_DEPLOYMENT_CREATE: |
||
97 | return _.assign({}, state, { |
||
98 | is_creating: false, |
||
99 | error: action.error.toString() |
||
100 | }); |
||
101 | |||
102 | case actions.START_DEPLOYMENT_GET: |
||
103 | return _.assign({}, state, { |
||
104 | is_loading: true, |
||
105 | error: null |
||
106 | }); |
||
107 | |||
108 | case actions.SET_APPROVER: { |
||
109 | if (!state.list[state.current_id]) { |
||
110 | return state; |
||
111 | } |
||
112 | const newList = _.assign({}, state.list); |
||
113 | newList[state.current_id].approver_id = action.id; |
||
114 | return _.assign({}, state, { |
||
115 | list: newList |
||
116 | }); |
||
117 | } |
||
118 | |||
119 | case actions.SET_REJECT_REASON: { |
||
120 | if (!state.list[state.current_id]) { |
||
121 | return state; |
||
122 | } |
||
123 | const newList = _.assign({}, state.list); |
||
124 | newList[state.current_id].rejected_reason = action.value; |
||
125 | |||
126 | return _.assign({}, state, { |
||
127 | list: newList |
||
128 | }); |
||
129 | } |
||
130 | |||
131 | case actions.START_DEPLOYMENT_QUEUE: |
||
132 | return _.assign({}, state, { |
||
133 | is_queuing: true |
||
134 | }); |
||
135 | |||
136 | case actions.SUCCEED_APPROVAL_SUBMIT: |
||
137 | case actions.SUCCEED_APPROVAL_CANCEL: |
||
138 | case actions.SUCCEED_APPROVAL_APPROVE: |
||
139 | case actions.SUCCEED_APPROVAL_REJECT: |
||
140 | case actions.SUCCEED_DEPLOYMENT_QUEUE: |
||
141 | case actions.SUCCEED_DEPLOYMENT_GET: { |
||
142 | // get current list |
||
143 | const newList = _.assign({}, state.list); |
||
144 | newList[action.data.deployment.id] = action.data.deployment; |
||
145 | |||
146 | return _.assign({}, state, { |
||
147 | is_loading: false, |
||
148 | is_queuing: false, |
||
149 | error: null, |
||
150 | current_id: action.data.deployment.id, |
||
151 | list: newList |
||
152 | }); |
||
153 | } |
||
154 | |||
155 | case actions.FAIL_DEPLOYMENT_QUEUE: |
||
156 | case actions.FAIL_DEPLOY_LOG_UPDATE: |
||
157 | case actions.FAIL_DEPLOYMENT_GET: |
||
158 | return _.assign({}, state, { |
||
159 | is_loading: false, |
||
160 | error: action.error.toString() |
||
161 | }); |
||
162 | |||
163 | case actions.SUCCEED_DEPLOY_LOG_UPDATE: { |
||
164 | const newList = _.assign({}, state.list); |
||
165 | newList[action.data.deployment.id] = action.data.deployment; |
||
166 | |||
167 | const newLogList = _.assign({}, state.logs); |
||
168 | newLogList[action.data.deployment.id] = action.data.message; |
||
169 | |||
170 | return _.assign({}, state, { |
||
171 | logs: newLogList, |
||
172 | error: null, |
||
173 | list: newList |
||
174 | }); |
||
175 | } |
||
176 | case actions.SUCCEED_DEPLOYMENT_DELETE: { |
||
177 | // get current list |
||
178 | const newList = _.assign({}, state.list); |
||
179 | newList[action.data.deployment.id] = action.data.deployment; |
||
180 | |||
181 | return _.assign({}, state, { |
||
182 | error: null, |
||
183 | list: newList |
||
184 | }); |
||
185 | } |
||
186 | |||
187 | case actions.SET_TITLE: |
||
188 | case actions.SET_SUMMARY: |
||
189 | case actions.SET_REVISION: |
||
190 | case actions.TOGGLE_OPTION: { |
||
191 | if (!state.list[state.current_id]) { |
||
192 | return state; |
||
193 | } |
||
194 | const newList = _.assign({}, state.list); |
||
195 | newList[state.current_id].dirty = true; |
||
196 | return _.assign({}, state, { |
||
197 | list: newList |
||
198 | }); |
||
199 | } |
||
200 | |||
201 | case actions.START_ABORT_DEPLOYMENT: |
||
202 | return _.assign({}, state, { |
||
203 | abort_is_loading: true |
||
204 | }); |
||
205 | case actions.FAIL_ABORT_DEPLOYMENT: |
||
206 | return _.assign({}, state, { |
||
207 | abort_is_loading: false |
||
208 | }); |
||
209 | case actions.SUCCEED_ABORT_DEPLOYMENT: { |
||
210 | const newList = _.assign({}, state.list); |
||
211 | newList[action.data.deployment.id] = action.data.deployment; |
||
212 | |||
213 | return _.assign({}, state, { |
||
214 | list: newList, |
||
215 | abort_is_loading: false |
||
216 | }); |
||
217 | } |
||
218 | |||
219 | default: |
||
220 | return state; |
||
221 | } |
||
222 | }; |
||
223 |