diff --git a/lib/manager/components/DeploymentPreviewButton.js b/lib/manager/components/DeploymentPreviewButton.js index 70a1825ff..76b684fba 100644 --- a/lib/manager/components/DeploymentPreviewButton.js +++ b/lib/manager/components/DeploymentPreviewButton.js @@ -8,9 +8,16 @@ export default class DeploymentPreviewButton extends Component { } render () { const { deployment } = this.props - const { id, projectBounds } = deployment - // TODO: add Try it button - const server = deployment.project.otpServers.find(server => server.name === deployment.deployedTo) + const { id, deployedTo, project, projectBounds } = deployment + if (!deployedTo) { + // Deployment has not been deployed to a server, do not render button. + return null + } + if (!deployment.project.otpServers) { + console.warn(`No otp servers defined for project`) + return null + } + const server = project.otpServers.find(server => server.name === deployedTo) let href = server && server.publicUrl if (!href || href.length === 0) { console.warn(`No public URL set for deployment id=${id}`)