Fix issue: Publisher

not opening modal for second time
4.x.x
Jayasanka 6 years ago
parent b39a52fd7c
commit c2018da2e8

@ -12,7 +12,8 @@ const mapDispatchToProps = dispatch => ({
const mapStateToProps = state => { const mapStateToProps = state => {
return { return {
lifecycle: state.lifecycle lifecycle: state.lifecycle,
currentStatus : state.release.currentStatus.toUpperCase()
}; };
}; };
@ -29,17 +30,15 @@ class ConnectedLifeCycle extends React.Component {
} }
openModal() { openModal() {
console.log(this.props);
this.props.openLifecycleModal("IN_REVIEW"); this.props.openLifecycleModal("IN_REVIEW");
} }
render() { render() {
console.log();
const lifecycle = this.props.lifecycle; const lifecycle = this.props.lifecycle;
if (lifecycle != null) { if (lifecycle != null) {
return ( return (
<div> <div>
<LifecycleModal/> <LifecycleModal currentStatus={this.props.currentStatus}/>
<Button onClick={this.openModal}>aaaa</Button> <Button onClick={this.openModal}>aaaa</Button>
<LifeCycleGraph currentStatus={this.props.currentStatus} lifecycle={this.props.lifecycle}/> <LifeCycleGraph currentStatus={this.props.currentStatus} lifecycle={this.props.lifecycle}/>
</div> </div>

@ -1,16 +1,23 @@
import React from "react"; import React from "react";
import {Modal, Typography,List, Avatar} from 'antd'; import {Modal, Typography,Icon,Input} from 'antd';
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import {closeLifecycleModal} from "../../../js/actions";
const { TextArea } = Input;
const { Title } = Typography;
// connecting state.releaseView with the component // connecting state.releaseView with the component
const mapStateToProps = state => { const mapStateToProps = state => {
console.log(state);
return { return {
nextState: state.lifecycleModal.nextState, nextState: state.lifecycleModal.nextState,
visible: state.lifecycleModal.visible visible: state.lifecycleModal.visible
} }
}; };
const mapDispatchToProps = dispatch => ({
closeLifecycleModal : () => dispatch(closeLifecycleModal())
});
const Text = Typography; const Text = Typography;
class ConnectedLifecycleModal extends React.Component { class ConnectedLifecycleModal extends React.Component {
@ -23,7 +30,6 @@ class ConnectedLifecycleModal extends React.Component {
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
if (nextProps !== this.props) { if (nextProps !== this.props) {
console.log(nextProps);
this.setState({ this.setState({
visible: nextProps.visible visible: nextProps.visible
}) })
@ -46,6 +52,7 @@ class ConnectedLifecycleModal extends React.Component {
this.setState({ this.setState({
visible: false, visible: false,
}); });
this.props.closeLifecycleModal();
}; };
render() { render() {
@ -59,7 +66,9 @@ class ConnectedLifecycleModal extends React.Component {
onOk={this.handleOk} onOk={this.handleOk}
onCancel={this.handleCancel} onCancel={this.handleCancel}
> >
<p>Some contents...</p> <Title level={4}>{this.props.currentStatus} <Icon type="arrow-right" /> {nextState}</Title>
<p>Reason:</p>
<TextArea placeholder="Please enter the reason..." autosize />
</Modal> </Modal>
</div> </div>
); );
@ -69,6 +78,6 @@ class ConnectedLifecycleModal extends React.Component {
} }
} }
const LifecycleModal = connect(mapStateToProps, null)(ConnectedLifecycleModal); const LifecycleModal = connect(mapStateToProps, mapDispatchToProps)(ConnectedLifecycleModal);
export default LifecycleModal; export default LifecycleModal;

@ -57,7 +57,6 @@ export const openReleasesModal = (app) => dispatch => {
export const openLifecycleModal = (nextState) => dispatch => { export const openLifecycleModal = (nextState) => dispatch => {
console.log(nextState);
dispatch({ dispatch({
type: ActionTypes.OPEN_LIFECYCLE_MODAL, type: ActionTypes.OPEN_LIFECYCLE_MODAL,
payload: { payload: {
@ -66,6 +65,12 @@ export const openLifecycleModal = (nextState) => dispatch => {
}); });
}; };
export const closeLifecycleModal = () => dispatch => {
dispatch({
type: ActionTypes.CLOSE_LIFECYCLE_MODAL
});
};
export const getLifecycle = ()=> dispatch =>{ export const getLifecycle = ()=> dispatch =>{
const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/lifecycle-config"; const request = "method=get&content-type=application/json&payload={}&api-endpoint=/application-mgt-publisher/v1.0/applications/lifecycle-config";

@ -7,7 +7,8 @@ const ActionTypes = keyMirror({
CLOSE_RELEASES_MODAL: null, CLOSE_RELEASES_MODAL: null,
GET_RELEASE: null, GET_RELEASE: null,
GET_LIFECYCLE: null, GET_LIFECYCLE: null,
OPEN_LIFECYCLE_MODAL: null OPEN_LIFECYCLE_MODAL: null,
CLOSE_LIFECYCLE_MODAL: null
}); });
export default ActionTypes; export default ActionTypes;

@ -41,6 +41,13 @@ function rootReducer(state = initialState, action) {
nextState: action.payload.nextState nextState: action.payload.nextState
} }
}); });
}else if (action.type === ActionTypes.CLOSE_LIFECYCLE_MODAL) {
return Object.assign({}, state, {
lifecycleModal: {
visible: false,
nextState: null
}
});
} }
return state; return state;
} }

Loading…
Cancel
Save