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 | // polyfills |
||
2 | require('babel-polyfill'); |
||
3 | const api = require('./_api.js'); |
||
4 | const constants = require('./constants/deployment.js'); |
||
5 | |||
6 | const gitAPI = api.create('git'); |
||
7 | const deployAPI = api.create('deploys'); |
||
8 | const approvalsAPI = api.create('approvals'); |
||
9 | |||
10 | // allows history to be accessed throughout the project, this will be set |
||
11 | // when the store is configured in EnvironmentOverview.jsx |
||
12 | export const history = null; |
||
13 | |||
14 | export const SET_ENVIRONMENT = 'SET_ENVIRONMENT'; |
||
15 | export function setEnvironment(data) { |
||
16 | return { |
||
17 | type: SET_ENVIRONMENT, |
||
18 | data: data |
||
19 | }; |
||
20 | } |
||
21 | |||
22 | export const SET_USER = 'SET_USER'; |
||
23 | export function setUser(data) { |
||
24 | return { |
||
25 | type: SET_USER, |
||
26 | data: data |
||
27 | }; |
||
28 | } |
||
29 | |||
30 | export const NEW_DEPLOYMENT = "NEW_DEPLOYMENT"; |
||
31 | export function newDeployment() { |
||
32 | return {type: NEW_DEPLOYMENT}; |
||
33 | } |
||
34 | |||
35 | export const START_REPO_UPDATE = 'START_REPO_UPDATE'; |
||
36 | export function startRepoUpdate() { |
||
37 | return { |
||
38 | type: START_REPO_UPDATE |
||
39 | }; |
||
40 | } |
||
41 | |||
42 | export const SUCCEED_REPO_UPDATE = 'SUCCEED_REPO_UPDATE'; |
||
43 | export function succeedRepoUpdate() { |
||
44 | return { |
||
45 | type: SUCCEED_REPO_UPDATE, |
||
46 | received_at: Date.now() |
||
47 | }; |
||
48 | } |
||
49 | |||
50 | export const FAIL_REPO_UPDATE = 'FAIL_REPO_UPDATE'; |
||
51 | export function failRepoUpdate(err) { |
||
52 | return { |
||
53 | type: FAIL_REPO_UPDATE, |
||
54 | error: err |
||
55 | }; |
||
56 | } |
||
57 | |||
58 | export const START_REVISIONS_GET = 'START_REVISIONS_GET'; |
||
59 | export function startRevisionGet() { |
||
60 | return { |
||
61 | type: START_REVISIONS_GET |
||
62 | }; |
||
63 | } |
||
64 | |||
65 | export const SUCCEED_REVISIONS_GET = 'SUCCEED_REVISIONS_GET'; |
||
66 | export function succeedRevisionsGet(data) { |
||
67 | return { |
||
68 | type: SUCCEED_REVISIONS_GET, |
||
69 | data: data |
||
70 | }; |
||
71 | } |
||
72 | |||
73 | export const FAIL_REVISIONS_GET = 'FAIL_REVISIONS_GET'; |
||
74 | export function failRevisionsGet(err) { |
||
75 | return { |
||
76 | type: FAIL_REVISIONS_GET, |
||
77 | error: err |
||
78 | }; |
||
79 | } |
||
80 | |||
81 | export const START_DEPLOY_HISTORY_GET = 'START_DEPLOY_HISTORY_GET'; |
||
82 | export function startDeployHistoryGet() { |
||
83 | return { |
||
84 | type: START_DEPLOY_HISTORY_GET |
||
85 | }; |
||
86 | } |
||
87 | |||
88 | export const SUCCEED_DEPLOY_HISTORY_GET = 'SUCCEED_DEPLOY_HISTORY_GET'; |
||
89 | export function succeedDeployHistoryGet(data) { |
||
90 | return { |
||
91 | type: SUCCEED_DEPLOY_HISTORY_GET, |
||
92 | data: data |
||
93 | }; |
||
94 | } |
||
95 | |||
96 | export const FAIL_DEPLOY_HISTORY_GET = 'FAIL_DEPLOY_HISTORY_GET'; |
||
97 | export function failDeployHistoryGet(err) { |
||
98 | return { |
||
99 | type: FAIL_DEPLOY_HISTORY_GET, |
||
100 | error: err |
||
101 | }; |
||
102 | } |
||
103 | |||
104 | export const SET_DEPLOY_HISTORY_PAGE = 'SET_DEPLOY_HISTORY_PAGE'; |
||
105 | export function setDeployHistoryPage(page) { |
||
106 | let selected_page = 1; |
||
107 | if (typeof page !== 'undefined') { |
||
108 | selected_page = page; |
||
109 | } |
||
110 | |||
111 | return { |
||
112 | type: SET_DEPLOY_HISTORY_PAGE, |
||
113 | page: selected_page |
||
114 | }; |
||
115 | } |
||
116 | |||
117 | export function getRevisions() { |
||
118 | return (dispatch, getState) => { |
||
119 | dispatch(startRevisionGet()); |
||
120 | return gitAPI.call(getState, `/show?environmentId=${getState().environment.id}`, 'get') |
||
121 | .then(json => dispatch(succeedRevisionsGet(json))) |
||
122 | .catch(err => dispatch(failRevisionsGet(err))); |
||
123 | }; |
||
124 | } |
||
125 | |||
126 | export function getDeployHistory() { |
||
127 | return (dispatch, getState) => { |
||
128 | if (getState().deployment.history_is_loading) { |
||
129 | return; |
||
130 | } |
||
131 | dispatch(startDeployHistoryGet()); |
||
132 | return deployAPI.call(getState, `/history?from=${getState().deployment.server_time}`, 'get') |
||
0 ignored issues
–
show
introduced
by
![]() |
|||
133 | .then(json => dispatch(succeedDeployHistoryGet(json))) |
||
134 | .catch(err => dispatch(failDeployHistoryGet(err))); |
||
135 | }; |
||
136 | } |
||
137 | |||
138 | export function getRevisionsIfNeeded() { |
||
139 | return (dispatch, getState) => { |
||
140 | if (!getState().git.length) { |
||
141 | dispatch(getRevisions()); |
||
142 | } |
||
143 | }; |
||
144 | } |
||
145 | |||
146 | // combines the updateRepo and revisionGet actions in one call |
||
147 | export function updateRepoAndGetRevisions() { |
||
148 | return (dispatch, getState) => { |
||
149 | dispatch(startRepoUpdate()); |
||
150 | return gitAPI.call(getState, '/update', 'post') |
||
151 | .then(data => gitAPI.waitForSuccess(getState, `/update/${data.id}`)) |
||
152 | .then(() => dispatch(succeedRepoUpdate())) |
||
153 | .catch(err => dispatch(failRepoUpdate(err))) |
||
154 | .then(() => dispatch(startRevisionGet())) |
||
155 | .then(() => gitAPI.call(getState, `/show?environmentId=${getState().environment.id}`, 'get')) |
||
156 | .then(json => dispatch(succeedRevisionsGet(json))) |
||
157 | .catch(err => dispatch(failRevisionsGet(err))); |
||
158 | }; |
||
159 | } |
||
160 | |||
161 | export const TOGGLE_OPTION = 'TOGGLE_OPTION'; |
||
162 | export function toggleOption(name) { |
||
163 | return { |
||
164 | type: TOGGLE_OPTION, |
||
165 | name: name |
||
166 | }; |
||
167 | } |
||
168 | |||
169 | export const SET_REVISION_TYPE = "SET_REVISION_TYPE"; |
||
170 | export function setGitRefType(id) { |
||
171 | return {type: SET_REVISION_TYPE, id}; |
||
172 | } |
||
173 | |||
174 | export const SET_REVISION = "SET_REVISION"; |
||
175 | export function setGitRef(id) { |
||
176 | return {type: SET_REVISION, id}; |
||
177 | } |
||
178 | |||
179 | export const SET_REJECT_REASON = 'SET_REJECT_REASON'; |
||
180 | export function setRejectReason(value) { |
||
181 | return { |
||
182 | type: SET_REJECT_REASON, |
||
183 | value: value |
||
184 | }; |
||
185 | } |
||
186 | |||
187 | export const START_SUMMARY_GET = 'START_SUMMARY_GET'; |
||
188 | export function startSummaryGet() { |
||
189 | return { |
||
190 | type: START_SUMMARY_GET |
||
191 | }; |
||
192 | } |
||
193 | |||
194 | export const SUCCEED_SUMMARY_GET = 'SUCCEED_SUMMARY_GET'; |
||
195 | export function succeedSummaryGet(json) { |
||
196 | return { |
||
197 | type: SUCCEED_SUMMARY_GET, |
||
198 | summary: json, |
||
199 | received_at: Date.now() |
||
200 | }; |
||
201 | } |
||
202 | |||
203 | export const FAIL_SUMMARY_GET = 'FAIL_SUMMARY_GET'; |
||
204 | export function failSummaryGet(err) { |
||
205 | return { |
||
206 | type: FAIL_SUMMARY_GET, |
||
207 | error: err |
||
208 | }; |
||
209 | } |
||
210 | |||
211 | export function getDeploySummary() { |
||
212 | return (dispatch, getState) => { |
||
213 | if (!getState().git.selected_ref) { |
||
214 | return; |
||
215 | } |
||
216 | |||
217 | const options = []; |
||
218 | Object.keys(getState().git.selected_options).forEach(function(option) { |
||
219 | if (getState().git.selected_options[option] === true) { |
||
220 | options.push(option); |
||
221 | } |
||
222 | }); |
||
223 | |||
224 | dispatch(startSummaryGet()); |
||
225 | return deployAPI.call(getState, '/summary', 'post', { |
||
0 ignored issues
–
show
|
|||
226 | ref: getState().git.selected_ref, |
||
227 | options: options |
||
228 | }) |
||
229 | .then(data => dispatch(succeedSummaryGet(data))) |
||
230 | .catch(err => dispatch(failSummaryGet(err))); |
||
231 | }; |
||
232 | } |
||
233 | |||
234 | export const SET_TITLE = "SET_TITLE"; |
||
235 | export function setTitle(text) { |
||
236 | return {type: SET_TITLE, text}; |
||
237 | } |
||
238 | |||
239 | export const SET_SUMMARY = "SET_SUMMARY"; |
||
240 | export function setSummary(text) { |
||
241 | return {type: SET_SUMMARY, text}; |
||
242 | } |
||
243 | |||
244 | export const SET_APPROVER = "SET_APPROVER"; |
||
245 | export function setApprover(id) { |
||
246 | return {type: SET_APPROVER, id}; |
||
247 | } |
||
248 | |||
249 | export const START_APPROVAL_SUBMIT = "START_APPROVAL_SUBMIT"; |
||
250 | export function startApprovalSubmit() { |
||
251 | return {type: START_APPROVAL_SUBMIT}; |
||
252 | } |
||
253 | |||
254 | export const SUCCEED_APPROVAL_SUBMIT = "SUCCEED_APPROVAL_SUBMIT"; |
||
255 | export function succeedApprovalSubmit(data) { |
||
256 | return { |
||
257 | type: SUCCEED_APPROVAL_SUBMIT, |
||
258 | data: data |
||
259 | }; |
||
260 | } |
||
261 | |||
262 | export const FAIL_APPROVAL_SUBMIT = "FAIL_APPROVAL_SUBMIT"; |
||
263 | export function failApprovalSubmit(err) { |
||
264 | return { |
||
265 | type: FAIL_APPROVAL_SUBMIT, |
||
266 | error: err |
||
267 | }; |
||
268 | } |
||
269 | |||
270 | export function submitForApproval() { |
||
271 | return (dispatch, getState) => { |
||
272 | dispatch(startApprovalSubmit()); |
||
273 | const current = getState().deployment.list[getState().deployment.current_id] || {}; |
||
274 | return approvalsAPI.call(getState, '/submit', 'post', { |
||
275 | id: getState().deployment.current_id, |
||
276 | approver_id: current.approver_id, |
||
277 | title: getState().plan.title, |
||
278 | summary: getState().plan.summary_of_changes |
||
279 | }) |
||
280 | .then(function(data) { |
||
281 | dispatch(succeedApprovalSubmit(data)); |
||
282 | }) |
||
283 | .catch((error) => dispatch(failApprovalSubmit(error))); |
||
0 ignored issues
–
show
|
|||
284 | }; |
||
285 | } |
||
286 | |||
287 | export const START_APPROVAL_CANCEL = "START_APPROVAL_CANCEL"; |
||
288 | export function startApprovalCancel() { |
||
289 | return {type: START_APPROVAL_CANCEL}; |
||
290 | } |
||
291 | |||
292 | export const SUCCEED_APPROVAL_CANCEL = "SUCCEED_APPROVAL_CANCEL"; |
||
293 | export function succeedApprovalCancel(data) { |
||
294 | return { |
||
295 | type: SUCCEED_APPROVAL_CANCEL, |
||
296 | data: data |
||
297 | }; |
||
298 | } |
||
299 | |||
300 | export const FAIL_APPROVAL_CANCEL = "FAIL_APPROVAL_CANCEL"; |
||
301 | export function failApprovalCancel(err) { |
||
302 | return { |
||
303 | type: FAIL_APPROVAL_CANCEL, |
||
304 | error: err |
||
305 | }; |
||
306 | } |
||
307 | |||
308 | export function cancelApprovalRequest() { |
||
309 | return (dispatch, getState) => { |
||
310 | dispatch(startApprovalCancel()); |
||
311 | return approvalsAPI.call(getState, '/cancel', 'post', { |
||
312 | id: getState().deployment.current_id |
||
313 | }) |
||
314 | .then(function(data) { |
||
315 | dispatch(succeedApprovalCancel(data)); |
||
316 | }) |
||
317 | .catch((error) => dispatch(failApprovalCancel(error))); |
||
0 ignored issues
–
show
|
|||
318 | }; |
||
319 | } |
||
320 | |||
321 | export const START_APPROVAL_APPROVE = "START_APPROVAL_APPROVE"; |
||
322 | export function startApprovalApprove() { |
||
323 | return {type: START_APPROVAL_APPROVE}; |
||
324 | } |
||
325 | |||
326 | export const SUCCEED_APPROVAL_APPROVE = "SUCCEED_APPROVAL_APPROVE"; |
||
327 | export function succeedApprovalApprove(data) { |
||
328 | return { |
||
329 | type: SUCCEED_APPROVAL_APPROVE, |
||
330 | data: data |
||
331 | }; |
||
332 | } |
||
333 | |||
334 | export const FAIL_APPROVAL_APPROVE = "FAIL_APPROVAL_APPROVE"; |
||
335 | export function failApprovalApprove(err) { |
||
336 | return { |
||
337 | type: FAIL_APPROVAL_APPROVE, |
||
338 | error: err |
||
339 | }; |
||
340 | } |
||
341 | |||
342 | export function approveDeployment() { |
||
343 | return (dispatch, getState) => { |
||
344 | dispatch(startApprovalApprove()); |
||
345 | return approvalsAPI.call(getState, '/approve', 'post', { |
||
346 | id: getState().deployment.current_id, |
||
347 | title: getState().plan.title, |
||
348 | summary: getState().plan.summary_of_changes |
||
349 | }) |
||
350 | .then(function(data) { |
||
351 | dispatch(succeedApprovalApprove(data)); |
||
352 | }) |
||
353 | .catch((error) => dispatch(failApprovalApprove(error))); |
||
0 ignored issues
–
show
|
|||
354 | }; |
||
355 | } |
||
356 | |||
357 | export const START_APPROVAL_REJECT = "START_APPROVAL_REJECT"; |
||
358 | export function startApprovalReject() { |
||
359 | return {type: START_APPROVAL_REJECT}; |
||
360 | } |
||
361 | |||
362 | export const SUCCEED_APPROVAL_REJECT = "SUCCEED_APPROVAL_REJECT"; |
||
363 | export function succeedApprovalReject(data) { |
||
364 | return { |
||
365 | type: SUCCEED_APPROVAL_REJECT, |
||
366 | data: data |
||
367 | }; |
||
368 | } |
||
369 | |||
370 | export const FAIL_APPROVAL_REJECT = "FAIL_APPROVAL_REJECT"; |
||
371 | export function failApprovalReject(err) { |
||
372 | return { |
||
373 | type: FAIL_APPROVAL_REJECT, |
||
374 | error: err |
||
375 | }; |
||
376 | } |
||
377 | |||
378 | export function rejectDeployment() { |
||
379 | return (dispatch, getState) => { |
||
380 | dispatch(startApprovalReject()); |
||
381 | const current = getState().deployment.list[getState().deployment.current_id] || {}; |
||
382 | return approvalsAPI.call(getState, '/reject', 'post', { |
||
383 | id: getState().deployment.current_id, |
||
384 | rejected_reason: current.rejected_reason |
||
385 | }) |
||
386 | .then(function(data) { |
||
387 | dispatch(succeedApprovalReject(data)); |
||
388 | }) |
||
389 | .catch((error) => dispatch(failApprovalReject(error))); |
||
0 ignored issues
–
show
|
|||
390 | }; |
||
391 | } |
||
392 | |||
393 | export const START_DEPLOYMENT_CREATE = "START_DEPLOYMENT_CREATE"; |
||
394 | export function startDeploymentCreate() { |
||
395 | return {type: START_DEPLOYMENT_CREATE}; |
||
396 | } |
||
397 | |||
398 | export const SUCCEED_DEPLOYMENT_CREATE = "SUCCEED_DEPLOYMENT_CREATE"; |
||
399 | export function succeedDeploymentCreate(data) { |
||
400 | return { |
||
401 | type: SUCCEED_DEPLOYMENT_CREATE, |
||
402 | data: data |
||
403 | }; |
||
404 | } |
||
405 | |||
406 | export const FAIL_DEPLOYMENT_CREATE = "FAIL_DEPLOYMENT_CREATE"; |
||
407 | export function failDeploymentCreate(err) { |
||
408 | return { |
||
409 | type: FAIL_DEPLOYMENT_CREATE, |
||
410 | error: err |
||
411 | }; |
||
412 | } |
||
413 | |||
414 | export function createDeployment() { |
||
415 | return (dispatch, getState) => { |
||
416 | |||
417 | const options = []; |
||
418 | Object.keys(getState().git.selected_options).forEach(function(option) { |
||
419 | if (getState().git.selected_options[option] === true) { |
||
420 | options.push(option); |
||
421 | } |
||
422 | }); |
||
423 | |||
424 | dispatch(startDeploymentCreate()); |
||
425 | const current = getState().deployment.list[getState().deployment.current_id] || {}; |
||
426 | return deployAPI.call(getState, '/createdeployment', 'post', { |
||
427 | id: current.id || 0, |
||
428 | ref: getState().git.selected_ref, |
||
429 | ref_type: getState().git.selected_type, |
||
430 | ref_name: getState().git.selected_name, |
||
431 | options: options, |
||
432 | title: getState().plan.title, |
||
433 | summary: getState().plan.summary_of_changes, |
||
434 | approver_id: current.approver_id |
||
435 | }) |
||
436 | .then(function(data) { |
||
437 | window.history.pushState("", "", data.location); |
||
438 | return dispatch(succeedDeploymentCreate(data)); |
||
439 | }) |
||
440 | .catch((error) => dispatch(failDeploymentCreate(error))); |
||
0 ignored issues
–
show
|
|||
441 | }; |
||
442 | } |
||
443 | |||
444 | export const START_DEPLOYMENT_QUEUE = "START_DEPLOYMENT_QUEUE"; |
||
445 | export function startDeploymentEnqueue() { |
||
446 | return {type: START_DEPLOYMENT_QUEUE}; |
||
447 | } |
||
448 | |||
449 | export const SUCCEED_DEPLOYMENT_QUEUE = "SUCCEED_DEPLOYMENT_QUEUE"; |
||
450 | export function succeedDeploymentEnqueue(data) { |
||
451 | return { |
||
452 | type: SUCCEED_DEPLOYMENT_QUEUE, |
||
453 | data: data |
||
454 | }; |
||
455 | } |
||
456 | |||
457 | export const FAIL_DEPLOYMENT_QUEUE = "FAIL_DEPLOYMENT_QUEUE"; |
||
458 | export function failDeploymentEnqueue(err) { |
||
459 | return { |
||
460 | type: FAIL_DEPLOYMENT_QUEUE, |
||
461 | error: err |
||
462 | }; |
||
463 | } |
||
464 | |||
465 | export const SUCCEED_DEPLOY_LOG_UPDATE = 'SUCCEED_DEPLOY_LOG_UPDATE'; |
||
466 | export function succeedDeployLogUpdate(data) { |
||
467 | return { |
||
468 | type: SUCCEED_DEPLOY_LOG_UPDATE, |
||
469 | data: data |
||
470 | }; |
||
471 | } |
||
472 | |||
473 | export const FAIL_DEPLOY_LOG_UPDATE = 'FAIL_DEPLOY_LOG_UPDATE'; |
||
474 | export function failDeployLogUpdate(err) { |
||
475 | return { |
||
476 | type: FAIL_DEPLOY_LOG_UPDATE, |
||
477 | error: err |
||
478 | }; |
||
479 | } |
||
480 | |||
481 | export function getDeployLog() { |
||
482 | return (dispatch, getState) => { |
||
483 | const current = getState().deployment.list[getState().deployment.current_id] || {}; |
||
484 | if (!constants.hasLogs(current.state)) { |
||
485 | return; |
||
486 | } |
||
487 | return deployAPI.call(getState, `/log/${getState().deployment.current_id}`, 'get') |
||
0 ignored issues
–
show
|
|||
488 | .then(function(data) { |
||
489 | dispatch(succeedDeployLogUpdate(data)); |
||
490 | }) |
||
491 | .catch((error) => dispatch(failDeployLogUpdate(error))); |
||
0 ignored issues
–
show
|
|||
492 | }; |
||
493 | } |
||
494 | |||
495 | export function startDeploy() { |
||
496 | return (dispatch, getState) => { |
||
497 | dispatch(startDeploymentEnqueue()); |
||
498 | return deployAPI.call(getState, '/start', 'post', { |
||
499 | id: getState().deployment.current_id |
||
500 | }) |
||
501 | .then(function(data) { |
||
502 | return dispatch(succeedDeploymentEnqueue(data)); |
||
503 | }) |
||
504 | .catch((error) => dispatch(failDeploymentEnqueue(error))); |
||
0 ignored issues
–
show
|
|||
505 | }; |
||
506 | } |
||
507 | |||
508 | export const START_ABORT_DEPLOYMENT = 'START_ABORT_DEPLOYMENT'; |
||
509 | export function startAbortDeployment() { |
||
510 | return { |
||
511 | type: START_ABORT_DEPLOYMENT |
||
512 | }; |
||
513 | } |
||
514 | |||
515 | export const SUCCEED_ABORT_DEPLOYMENT = 'SUCCEED_ABORT_DEPLOYMENT'; |
||
516 | export function succeedAbortDeployment(data) { |
||
517 | return { |
||
518 | type: SUCCEED_ABORT_DEPLOYMENT, |
||
519 | data: data |
||
520 | } |
||
521 | } |
||
522 | |||
523 | export const FAIL_ABORT_DEPLOYMENT = 'FAIL_ABORT_DEPLOYMENT'; |
||
524 | export function failAbortDeployment(err) { |
||
525 | return { |
||
526 | type: FAIL_ABORT_DEPLOYMENT, |
||
527 | error: err |
||
528 | }; |
||
529 | } |
||
530 | |||
531 | export function abortDeployment() { |
||
532 | return (dispatch, getState) => { |
||
533 | dispatch(startAbortDeployment()); |
||
534 | return deployAPI.call(getState, '/abort', 'post', { |
||
535 | id: getState().deployment.current_id |
||
536 | }) |
||
537 | .then(function(data) { |
||
538 | return dispatch(succeedAbortDeployment(data)); |
||
539 | }) |
||
540 | .catch((error) => dispatch(failAbortDeployment(error))); |
||
0 ignored issues
–
show
|
|||
541 | }; |
||
542 | } |
||
543 | |||
544 | export const START_DEPLOYMENT_GET = "START_DEPLOYMENT_GET"; |
||
545 | export function startGetDeployment() { |
||
546 | return {type: START_DEPLOYMENT_GET}; |
||
547 | } |
||
548 | |||
549 | export const SUCCEED_DEPLOYMENT_GET = "SUCCEED_DEPLOYMENT_GET"; |
||
550 | export function succeedGetDeployment(data) { |
||
551 | return { |
||
552 | type: SUCCEED_DEPLOYMENT_GET, |
||
553 | data: data |
||
554 | }; |
||
555 | } |
||
556 | |||
557 | export const FAIL_DEPLOYMENT_GET = "FAIL_DEPLOYMENT_GET"; |
||
558 | export function failGetDeployment(err) { |
||
559 | return { |
||
560 | type: FAIL_DEPLOYMENT_QUEUE, |
||
561 | error: err |
||
562 | }; |
||
563 | } |
||
564 | |||
565 | export function getDeployment(id) { |
||
566 | return (dispatch, getState) => { |
||
567 | dispatch(startGetDeployment()); |
||
568 | |||
569 | let getDeployPromise = null; |
||
570 | if (getState().deployment.list[id]) { |
||
571 | // we can use the cached value |
||
572 | getDeployPromise = new Promise(function(resolve) { |
||
573 | resolve({deployment: getState().deployment.list[id]}); |
||
574 | }); |
||
575 | } else { |
||
576 | // we need to fetch the deployment from the backend |
||
577 | getDeployPromise = deployAPI.call(getState, `/show/${id}`, 'get'); |
||
578 | } |
||
579 | |||
580 | return getDeployPromise |
||
581 | .then(data => { |
||
0 ignored issues
–
show
|
|||
582 | dispatch(succeedGetDeployment(data)); |
||
583 | }) |
||
584 | .catch(err => dispatch(failGetDeployment(err))); |
||
585 | }; |
||
586 | } |
||
587 | |||
588 | export const START_DEPLOYMENT_DELETE = 'START_DEPLOYMENT_DELETE'; |
||
589 | export function startDeploymentDelete() { |
||
590 | return { |
||
591 | type: START_DEPLOYMENT_DELETE |
||
592 | }; |
||
593 | } |
||
594 | |||
595 | export const SUCCEED_DEPLOYMENT_DELETE = 'SUCCEED_DEPLOYMENT_DELETE'; |
||
596 | export function succeedDeploymentDelete(data) { |
||
597 | return { |
||
598 | type: SUCCEED_DEPLOYMENT_DELETE, |
||
599 | data: data |
||
600 | }; |
||
601 | } |
||
602 | |||
603 | export const FAIL_DEPLOYMENT_DELETE = 'FAIL_DEPLOYMENT_DELETE'; |
||
604 | export function failDeploymentDelete(err) { |
||
605 | return { |
||
606 | type: FAIL_DEPLOYMENT_DELETE, |
||
607 | error: err |
||
608 | }; |
||
609 | } |
||
610 | |||
611 | export function deleteDeployment() { |
||
612 | return (dispatch, getState) => { |
||
613 | dispatch(startDeploymentDelete()); |
||
614 | return deployAPI.call(getState, '/delete', 'post', { |
||
615 | id: getState().deployment.current_id |
||
616 | }) |
||
617 | .then(function(data) { |
||
618 | return dispatch(succeedDeploymentDelete(data)); |
||
619 | }) |
||
620 | .catch((error) => dispatch(failDeploymentDelete(error))); |
||
0 ignored issues
–
show
|
|||
621 | }; |
||
622 | } |
||
623 |