@@ -15,13 +15,21 @@ import { getActiveInstanceCount, getServerForId } from '../util/deployment'
15
15
import DeploymentPreviewButton from './DeploymentPreviewButton'
16
16
import EC2InstanceCard from '../../common/components/EC2InstanceCard'
17
17
18
- import type { Deployment , DeploySummary , EC2InstanceSummary , OtpServer , ServerJob } from '../../types'
18
+ import type {
19
+ Deployment ,
20
+ DeploySummary ,
21
+ EC2InstanceSummary ,
22
+ OtpServer ,
23
+ Project ,
24
+ ServerJob
25
+ } from '../../types'
19
26
20
27
type Props = {
21
28
deployJobs : Array < ServerJob > ,
22
29
deployment : Deployment ,
23
30
downloadBuildArtifact : typeof deploymentActions . downloadBuildArtifact ,
24
31
fetchDeployment : typeof deploymentActions . fetchDeployment ,
32
+ project : Project ,
25
33
server : ?OtpServer ,
26
34
terminateEC2InstanceForDeployment : typeof deploymentActions . terminateEC2InstanceForDeployment
27
35
}
@@ -35,6 +43,12 @@ export default class CurrentDeploymentPanel extends Component<Props, State> {
35
43
activeSummaryIndex : 0
36
44
}
37
45
46
+ componentDidMount ( ) {
47
+ // Fetch single deployment. This JSON response will contain the #ec2Instances
48
+ // field, which does not come with this field (to prevent a very slow response).
49
+ this. props . fetchDeployment ( this . props . deployment . id )
50
+ }
51
+
38
52
componentWillReceiveProps ( nextProps : Props ) {
39
53
// If status message changes while deployment job is in progress, re-fetch
40
54
// deployment to update EC2 instance status.
@@ -55,7 +69,7 @@ export default class CurrentDeploymentPanel extends Component<Props, State> {
55
69
if ( this . props . server ) return this . props . server
56
70
const deployJob = this . _getDeployJob ( )
57
71
const serverId = deployJob && deployJob . serverId
58
- return getServerForId ( serverId , this . props . deployment . project )
72
+ return getServerForId ( serverId , this . props . project )
59
73
}
60
74
61
75
handleDecrementSummary = ( ) => {
@@ -84,11 +98,12 @@ export default class CurrentDeploymentPanel extends Component<Props, State> {
84
98
}
85
99
86
100
render ( ) {
87
- const { deployJobs , deployment } = this . props
101
+ const { deployJobs, deployment, project } = this . props
88
102
const { activeSummaryIndex } = this . state
89
103
const deployJob = this . _getDeployJob ( )
90
104
const server = this . _getServer ( )
91
105
const ec2Info = server && server . ec2Info
106
+ console . log ( server , ec2Info , deployment )
92
107
const hasPreviouslyDeployed = deployment . deployJobSummaries . length > 0
93
108
return (
94
109
< Panel header = { < h3 > < Icon type = 'server' /> Deployment Summary</ h3 > } >
@@ -137,13 +152,14 @@ export default class CurrentDeploymentPanel extends Component<Props, State> {
137
152
}
138
153
{ hasPreviouslyDeployed
139
154
? < DeployJobSummary
140
- summary = { deployment . deployJobSummaries [ activeSummaryIndex ] }
155
+ deployment = { deployment }
141
156
downloadBuildArtifact = { this . props . downloadBuildArtifact }
157
+ project = { project }
142
158
server = { server }
143
- deployment = { deployment } />
159
+ summary = { deployment . deployJobSummaries [ activeSummaryIndex ] } />
144
160
: 'No current deployment found'
145
161
}
146
- { ec2Info || deployment . ec2Instances . length > 0
162
+ { ec2Info // If has EC2 info, show EC2 instances box.
147
163
? < div >
148
164
< h4 >
149
165
EC2 instances ({ getActiveInstanceCount ( deployment . ec2Instances ) } active)
@@ -154,7 +170,7 @@ export default class CurrentDeploymentPanel extends Component<Props, State> {
154
170
< Icon type = 'refresh' />
155
171
</ Button >
156
172
</ h4 >
157
- { deployment . ec2Instances . length > 0
173
+ { deployment . ec2Instances
158
174
? < div style = { { height : '200px' , overflow : 'scroll' , paddingRight : '10px' } } >
159
175
{ deployment . ec2Instances . map ( instance => {
160
176
return (
@@ -180,6 +196,7 @@ export default class CurrentDeploymentPanel extends Component<Props, State> {
180
196
class DeployJobSummary extends Component < {
181
197
deployment : Deployment ,
182
198
downloadBuildArtifact : typeof deploymentActions . downloadBuildArtifact ,
199
+ project : Project ,
183
200
server : ?OtpServer ,
184
201
summary : ?DeploySummary
185
202
} > {
@@ -213,7 +230,7 @@ class DeployJobSummary extends Component<{
213
230
}
214
231
215
232
render ( ) {
216
- const { deployment , server, summary} = this . props
233
+ const { deployment , project , server, summary} = this . props
217
234
const serverLabel = this . _getLabelForServer ( server , deployment )
218
235
let deploymentType = 'unknown'
219
236
if ( server ) {
@@ -265,7 +282,10 @@ class DeployJobSummary extends Component<{
265
282
</ Button >
266
283
</ ButtonToolbar >
267
284
< div style = { { margin : '20px 0' } } >
268
- < DeploymentPreviewButton block deployment = { deployment } />
285
+ < DeploymentPreviewButton
286
+ block
287
+ deployment = { deployment }
288
+ project = { project } />
269
289
</ div >
270
290
</ div >
271
291
)
0 commit comments