1
|
|
|
const React = require('react'); |
2
|
|
|
const ReactRedux = require('react-redux'); |
3
|
|
|
|
4
|
|
|
const actions = require('../_actions.js'); |
5
|
|
|
const constants = require('../constants/deployment.js'); |
6
|
|
|
const AbortButton = require('../containers/buttons/AbortDeployment.jsx'); |
7
|
|
|
|
8
|
|
|
function getHeaderText(deployState) { |
9
|
|
|
switch (deployState) { |
10
|
|
|
case constants.STATE_COMPLETED: |
11
|
|
|
return 'Successfully deployed'; |
12
|
|
|
case constants.STATE_FAILED: |
13
|
|
|
return 'Failed deployment'; |
14
|
|
|
case constants.STATE_ABORTING: |
15
|
|
|
return 'Aborting deployment'; |
16
|
|
|
default: |
17
|
|
|
return 'Deploying'; |
18
|
|
|
} |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
function getDescriptionText(deployState) { |
22
|
|
|
switch (deployState) { |
23
|
|
|
case constants.STATE_DEPLOYING: |
24
|
|
|
case constants.STATE_QUEUED: |
25
|
|
|
return 'and come back at any time to check its progress.'; |
26
|
|
|
default: |
27
|
|
|
return 'and come back to access this information at any time.'; |
28
|
|
|
} |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
function getHeaderIcon(deployState) { |
32
|
|
|
switch (deployState) { |
33
|
|
|
case constants.STATE_DEPLOYING: |
34
|
|
|
case constants.STATE_QUEUED: |
35
|
|
|
case constants.STATE_APPROVED: |
36
|
|
|
return 'fa-cogs'; |
37
|
|
|
case constants.STATE_FAILED: |
38
|
|
|
return 'fa-exclamation-triangle'; |
39
|
|
|
default: |
40
|
|
|
return 'fa-rocket'; |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
function getTimeInformation(deployState, props) { |
45
|
|
|
switch (deployState) { |
46
|
|
|
case constants.STATE_DEPLOYING: |
47
|
|
|
case constants.STATE_QUEUED: |
48
|
|
|
return "Approximately " + props.deployment_estimate + " minutes"; |
49
|
|
|
default: |
50
|
|
|
return props.date_started_nice; |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
function DeploymentStatusBar(props) { |
55
|
|
|
const deployState = props.state; |
56
|
|
|
|
57
|
|
|
const headerText = getHeaderText(deployState); |
58
|
|
|
const descriptionText = getDescriptionText(deployState); |
59
|
|
|
const headerIcon = getHeaderIcon(deployState); |
60
|
|
|
const timeInformation = getTimeInformation(deployState, props); |
61
|
|
|
|
62
|
|
|
return ( |
63
|
|
|
<div className="deployment-status-bar fade-in clearfix"> |
64
|
|
|
<div className={"deployment-status-icon " + deployState}> |
65
|
|
|
<i className={"fa " + headerIcon} aria-hidden="true" /> |
66
|
|
|
</div> |
67
|
|
|
<div className="deployment-status-text-parent"> |
68
|
|
|
<div className="deployment-status-text-child"> |
69
|
|
|
<div className="deployment-status-header"> |
70
|
|
|
{headerText} to |
71
|
|
|
<strong> {props.project_name} / {props.environment_name}</strong> <small>{timeInformation}</small> |
|
|
|
|
72
|
|
|
</div> |
73
|
|
|
<div className="deployment-status-close-notice"> |
74
|
|
|
You may <a |
75
|
|
|
href={"javascript:void(0);"} |
|
|
|
|
76
|
|
|
onClick={props.onClose} |
77
|
|
|
>close this screen</a> {descriptionText} |
78
|
|
|
</div> |
79
|
|
|
</div> |
80
|
|
|
</div> |
81
|
|
|
<div className="abort-action pull-right"> |
82
|
|
|
<AbortButton /> |
83
|
|
|
</div> |
84
|
|
|
</div> |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
const mapStateToProps = function(state) { |
89
|
|
|
const current = state.deployment.list[state.deployment.current_id] || {}; |
90
|
|
|
return { |
91
|
|
|
state: current.state, |
92
|
|
|
environment_name: state.environment.name, |
93
|
|
|
project_name: state.environment.project_name, |
94
|
|
|
deployment_estimate: current.deployment_estimate, |
95
|
|
|
date_started_nice: current.date_started_nice, |
96
|
|
|
}; |
97
|
|
|
}; |
98
|
|
|
|
99
|
|
|
const mapDispatchToProps = function() { |
100
|
|
|
return { |
101
|
|
|
onClose: function() { |
102
|
|
|
actions.history.push('/'); |
103
|
|
|
}, |
104
|
|
|
}; |
105
|
|
|
}; |
106
|
|
|
|
107
|
|
|
module.exports = ReactRedux.connect(mapStateToProps, mapDispatchToProps)(DeploymentStatusBar); |
108
|
|
|
|