1
|
|
|
const React = require('react'); |
2
|
|
|
const ReactRedux = require('react-redux'); |
3
|
|
|
|
4
|
|
|
const StatusBox = require('../components/StatusBox.jsx'); |
5
|
|
|
const DeployDiff = require('../components/DeployDiff.jsx'); |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* This simple container is a locked down / readonly version of the first step |
9
|
|
|
* (git ref selector) that are shown when a deployment is waiting for approval |
10
|
|
|
* or deploy |
11
|
|
|
*/ |
12
|
|
|
const TargetReleaseRO = React.createClass({ |
13
|
|
|
|
14
|
|
|
getInitialState: function() { |
15
|
|
|
return { |
16
|
|
|
open: false |
17
|
|
|
}; |
18
|
|
|
}, |
19
|
|
|
|
20
|
|
|
toggleOpen: function() { |
21
|
|
|
this.setState({ |
22
|
|
|
open: !this.state.open |
23
|
|
|
}); |
24
|
|
|
}, |
25
|
|
|
|
26
|
|
|
render: function() { |
27
|
|
|
const props = this.props; |
28
|
|
|
|
29
|
|
|
if (props.length < 1) { |
30
|
|
|
return ( |
31
|
|
|
<div className="section"> |
32
|
|
|
<header id="0">Target release</header> |
33
|
|
|
</div> |
34
|
|
|
); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
let deployDiff = null; |
38
|
|
|
let linkName = 'View details'; |
39
|
|
|
let caret = 'up'; |
40
|
|
|
if (this.state.open) { |
41
|
|
|
deployDiff = <DeployDiff changes={props.deployment.changes} />; |
42
|
|
|
linkName = 'Hide details'; |
43
|
|
|
caret = 'down'; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
return ( |
47
|
|
|
<div className="section target-release"> |
48
|
|
|
<header id="0">Target release</header> |
49
|
|
|
<div>{props.ref_type_description}</div> |
50
|
|
|
|
51
|
|
|
<StatusBox type="default"> |
52
|
|
|
<span className="label label-default">{props.deployment.ref_name}</span> |
53
|
|
|
<a |
54
|
|
|
className="sha-detail" |
55
|
|
|
href={props.deployment.commit_url} |
56
|
|
|
title={props.deployment.sha} |
57
|
|
|
> |
58
|
|
|
{props.deployment.short_sha} |
59
|
|
|
</a> |
60
|
|
|
<span className="deployed-detail">{props.deployment.commit_subject}</span> |
61
|
|
|
<div style={{float: "right"}}> |
62
|
|
|
<span> |
63
|
|
|
<a href={"javascript:void(0);"} onClick={this.toggleOpen}>{linkName} <i className={"fa fa-caret-" + caret}></i></a> |
|
|
|
|
64
|
|
|
</span> |
65
|
|
|
</div><br /> |
66
|
|
|
|
67
|
|
|
{deployDiff} |
68
|
|
|
</StatusBox> |
69
|
|
|
|
70
|
|
|
<div className="row"> |
71
|
|
|
<div className="col-md-6"> |
72
|
|
|
<dl className="dl-horizontal"> |
73
|
|
|
<dt>Environment</dt> |
74
|
|
|
<dd>{props.environment}</dd> |
75
|
|
|
<dt>Deployment type</dt> |
76
|
|
|
<dd>{props.deployment.deployment_type}</dd> |
77
|
|
|
<dt>Deployment time</dt> |
78
|
|
|
<dd>{props.deployment.deployment_estimate} min</dd> |
79
|
|
|
<dt>Version</dt> |
80
|
|
|
<dd>{props.deployment.short_sha}</dd> |
81
|
|
|
</dl> |
82
|
|
|
</div> |
83
|
|
|
<div className="col-md-6"> |
84
|
|
|
<dl className="dl-horizontal"> |
85
|
|
|
<dt>Requested by</dt> |
86
|
|
|
<dd>{props.deployment.deployer.name}</dd> |
87
|
|
|
<dt>Date requested</dt> |
88
|
|
|
<dd>{props.date_requested}</dd> |
89
|
|
|
</dl> |
90
|
|
|
</div> |
91
|
|
|
</div> |
92
|
|
|
</div> |
93
|
|
|
); |
94
|
|
|
} |
95
|
|
|
}); |
96
|
|
|
|
97
|
|
|
const mapStateToProps = function(state) { |
98
|
|
|
if (typeof state.deployment.list[state.deployment.current_id] === 'undefined') { |
99
|
|
|
return {}; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
const current = state.deployment.list[state.deployment.current_id] || {}; |
103
|
|
|
|
104
|
|
|
let ref_type_description = ""; |
105
|
|
|
if (state.git.list[current.ref_type]) { |
106
|
|
|
ref_type_description = state.git.list[current.ref_type].description; |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
return { |
110
|
|
|
deployment: current, |
111
|
|
|
date_requested: current.date_requested_nice ? current.date_requested_nice : 'n/a', |
112
|
|
|
environment: state.environment.name, |
113
|
|
|
ref_type_description: ref_type_description |
114
|
|
|
}; |
115
|
|
|
}; |
116
|
|
|
|
117
|
|
|
const mapDispatchToProps = function() { |
118
|
|
|
return {}; |
119
|
|
|
}; |
120
|
|
|
|
121
|
|
|
module.exports = ReactRedux.connect(mapStateToProps, mapDispatchToProps)(TargetReleaseRO); |
122
|
|
|
|