@@ -15,13 +15,21 @@ import { getActiveInstanceCount, getServerForId } from '../util/deployment'
1515import DeploymentPreviewButton from './DeploymentPreviewButton'
1616import EC2InstanceCard from '../../common/components/EC2InstanceCard'
1717
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'
1926
2027type Props = {
2128 deployJobs : Array < ServerJob > ,
2229 deployment : Deployment ,
2330 downloadBuildArtifact : typeof deploymentActions . downloadBuildArtifact ,
2431 fetchDeployment : typeof deploymentActions . fetchDeployment ,
32+ project : Project ,
2533 server : ?OtpServer ,
2634 terminateEC2InstanceForDeployment : typeof deploymentActions . terminateEC2InstanceForDeployment
2735}
@@ -35,6 +43,12 @@ export default class CurrentDeploymentPanel extends Component<Props, State> {
3543 activeSummaryIndex : 0
3644 }
3745
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+
3852 componentWillReceiveProps ( nextProps : Props ) {
3953 // If status message changes while deployment job is in progress, re-fetch
4054 // deployment to update EC2 instance status.
@@ -55,7 +69,7 @@ export default class CurrentDeploymentPanel extends Component<Props, State> {
5569 if ( this . props . server ) return this . props . server
5670 const deployJob = this . _getDeployJob ( )
5771 const serverId = deployJob && deployJob . serverId
58- return getServerForId ( serverId , this . props . deployment . project )
72+ return getServerForId ( serverId , this . props . project )
5973 }
6074
6175 handleDecrementSummary = ( ) => {
@@ -84,11 +98,12 @@ export default class CurrentDeploymentPanel extends Component<Props, State> {
8498 }
8599
86100 render ( ) {
87- const { deployJobs , deployment } = this . props
101+ const { deployJobs, deployment, project } = this . props
88102 const { activeSummaryIndex } = this . state
89103 const deployJob = this . _getDeployJob ( )
90104 const server = this . _getServer ( )
91105 const ec2Info = server && server . ec2Info
106+ console . log ( server , ec2Info , deployment )
92107 const hasPreviouslyDeployed = deployment . deployJobSummaries . length > 0
93108 return (
94109 < Panel header = { < h3 > < Icon type = 'server' /> Deployment Summary</ h3 > } >
@@ -137,13 +152,14 @@ export default class CurrentDeploymentPanel extends Component<Props, State> {
137152 }
138153 { hasPreviouslyDeployed
139154 ? < DeployJobSummary
140- summary = { deployment . deployJobSummaries [ activeSummaryIndex ] }
155+ deployment = { deployment }
141156 downloadBuildArtifact = { this . props . downloadBuildArtifact }
157+ project = { project }
142158 server = { server }
143- deployment = { deployment } />
159+ summary = { deployment . deployJobSummaries [ activeSummaryIndex ] } />
144160 : 'No current deployment found'
145161 }
146- { ec2Info || deployment . ec2Instances . length > 0
162+ { ec2Info // If has EC2 info, show EC2 instances box.
147163 ? < div >
148164 < h4 >
149165 EC2 instances ({ getActiveInstanceCount ( deployment . ec2Instances ) } active)
@@ -154,7 +170,7 @@ export default class CurrentDeploymentPanel extends Component<Props, State> {
154170 < Icon type = 'refresh' />
155171 </ Button >
156172 </ h4 >
157- { deployment . ec2Instances . length > 0
173+ { deployment . ec2Instances
158174 ? < div style = { { height : '200px' , overflow : 'scroll' , paddingRight : '10px' } } >
159175 { deployment . ec2Instances . map ( instance => {
160176 return (
@@ -180,6 +196,7 @@ export default class CurrentDeploymentPanel extends Component<Props, State> {
180196class DeployJobSummary extends Component < {
181197 deployment : Deployment ,
182198 downloadBuildArtifact : typeof deploymentActions . downloadBuildArtifact ,
199+ project : Project ,
183200 server : ?OtpServer ,
184201 summary : ?DeploySummary
185202} > {
@@ -213,7 +230,7 @@ class DeployJobSummary extends Component<{
213230 }
214231
215232 render ( ) {
216- const { deployment , server, summary} = this . props
233+ const { deployment , project , server, summary} = this . props
217234 const serverLabel = this . _getLabelForServer ( server , deployment )
218235 let deploymentType = 'unknown'
219236 if ( server ) {
@@ -265,7 +282,10 @@ class DeployJobSummary extends Component<{
265282 </ Button >
266283 </ ButtonToolbar >
267284 < div style = { { margin : '20px 0' } } >
268- < DeploymentPreviewButton block deployment = { deployment } />
285+ < DeploymentPreviewButton
286+ block
287+ deployment = { deployment }
288+ project = { project } />
269289 </ div >
270290 </ div >
271291 )
0 commit comments