/** * Copyright 2017 Red Hat Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. You may obtain * a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations * under the License. */ import { connect } from 'react-redux'; import { defineMessages, FormattedMessage, injectIntl } from 'react-intl'; import ImmutablePropTypes from 'react-immutable-proptypes'; import { ModalHeader, ModalTitle, ModalFooter } from 'react-bootstrap'; import PropTypes from 'prop-types'; import React from 'react'; import { allPreDeploymentValidationsSuccessful } from '../../selectors/validations'; import DeploymentConfirmation from './DeploymentConfirmation'; import DeploymentProgress from './DeploymentProgress'; import DeploymentSuccess from './DeploymentSuccess'; import DeploymentFailure from './DeploymentFailure'; import { getCurrentPlan, getCurrentPlanName } from '../../selectors/plans'; import { getCurrentStack, getCurrentStackDeploymentProgress, getOvercloudInfo } from '../../selectors/stacks'; import { getEnvironmentConfigurationSummary } from '../../selectors/environmentConfiguration'; import { Loader } from '../ui/Loader'; import { CloseModalButton, CloseModalXButton, RoutedModalPanel } from '../ui/Modals'; import PlanActions from '../../actions/PlansActions'; import { stackStates } from '../../constants/StacksConstants'; import StacksActions from '../../actions/StacksActions'; import ValidationsActions from '../../actions/ValidationsActions'; const messages = defineMessages({ close: { id: 'DeploymentDetail.close', defaultMessage: 'Close' }, loadingStacksLoader: { id: 'DeploymentDetail.loadingStacksLoader', defaultMessage: 'Loading Stacks...' }, modalTitle: { id: 'DeploymentDetail.modalTitle', defaultMessage: 'Plan {planName} deployment' } }); class DeploymentDetail extends React.Component { renderStatus() { const { allPreDeploymentValidationsSuccessful, currentPlan, currentPlanName, currentStack, currentStackDeploymentProgress, currentStackResources, currentStackResourcesLoaded, deployPlan, environmentConfigurationSummary, fetchStackResources, runPreDeploymentValidations } = this.props; if ( !currentStack || currentStack.stack_status === stackStates.DELETE_COMPLETE ) { return ( ); } else if (currentStack.stack_status.match(/PROGRESS/)) { return ( ); } else if (currentStack.stack_status.match(/COMPLETE/)) { return ( ); } else { return ( ); } } render() { const { currentPlanName, intl: { formatMessage }, stacksLoaded } = this.props; return ( {this.renderStatus()} ); } } DeploymentDetail.propTypes = { allPreDeploymentValidationsSuccessful: PropTypes.bool.isRequired, currentPlan: ImmutablePropTypes.record.isRequired, currentPlanName: PropTypes.string.isRequired, currentStack: ImmutablePropTypes.record, currentStackDeploymentProgress: PropTypes.number.isRequired, currentStackResources: ImmutablePropTypes.map, currentStackResourcesLoaded: PropTypes.bool.isRequired, deployPlan: PropTypes.func.isRequired, environmentConfigurationSummary: PropTypes.string, fetchStackResources: PropTypes.func.isRequired, intl: PropTypes.object, overcloudInfo: ImmutablePropTypes.map.isRequired, runPreDeploymentValidations: PropTypes.func.isRequired, stacksLoaded: PropTypes.bool.isRequired }; const mapStateToProps = state => ({ allPreDeploymentValidationsSuccessful: allPreDeploymentValidationsSuccessful( state ), currentPlan: getCurrentPlan(state), currentPlanName: getCurrentPlanName(state), currentStack: getCurrentStack(state), currentStackDeploymentProgress: getCurrentStackDeploymentProgress(state), currentStackResources: state.stacks.resources, currentStackResourcesLoaded: state.stacks.resourcesLoaded, environmentConfigurationSummary: getEnvironmentConfigurationSummary(state), overcloudInfo: getOvercloudInfo(state), stacksLoaded: state.stacks.isLoaded }); const mapDispatchToProps = dispatch => ({ deployPlan: planName => dispatch(PlanActions.deployPlan(planName)), fetchStackResources: stack => dispatch(StacksActions.fetchResources(stack.stack_name, stack.id)), runPreDeploymentValidations: planName => dispatch( ValidationsActions.runValidationGroups(['pre-deployment'], planName) ) }); export default injectIntl( connect(mapStateToProps, mapDispatchToProps)(DeploymentDetail) );