From 9843e6f0e2f61c6e66eefa8e7fd588dd0e6b29c0 Mon Sep 17 00:00:00 2001 From: Jayasanka Date: Tue, 30 Apr 2019 21:55:39 +0530 Subject: [PATCH] loaded modal with redux --- .../react-app/src/components/apps/AppCard.js | 17 ++++++- .../react-app/src/components/apps/AppList.js | 1 + .../src/components/apps/ReleaseModal.js | 49 ++++++++++--------- .../react-app/src/js/actions/index.js | 5 +- .../react-app/src/js/reducers/index.js | 4 +- 5 files changed, 48 insertions(+), 28 deletions(-) diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppCard.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppCard.js index ac1f66f2da3..8fa60bffcc4 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppCard.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppCard.js @@ -3,14 +3,25 @@ import { } from 'antd'; import React from "react"; import config from "../../../public/conf/config.json"; +import {openReleasesModal} from "../../js/actions"; +import {connect} from "react-redux"; const { Meta } = Card; const { Text } = Typography; -class AppCard extends React.Component { +const mapDispatchToProps = dispatch => ({ + openReleasesModal: (app) => dispatch(openReleasesModal(app)) +}); + +class ConnectedAppCard extends React.Component { constructor(props){ super(props); + this.handleReleasesClick = this.handleReleasesClick.bind(this); + } + + handleReleasesClick(){ + this.props.openReleasesModal(this.props.app); } @@ -33,7 +44,7 @@ class AppCard extends React.Component { ); return ( - , , ]}> + , , ]}> } title={this.props.name} @@ -44,4 +55,6 @@ class AppCard extends React.Component { } } +const AppCard = connect(null,mapDispatchToProps)(ConnectedAppCard); + export default AppCard; \ No newline at end of file diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppList.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppList.js index 599e6be2d0c..00f715825f0 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppList.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/components/apps/AppList.js @@ -24,6 +24,7 @@ class ConnectedAppList extends React.Component { {this.props.apps.map(app => ( { return {releaseView: state.releaseView} }; +const Text = Typography; + class ConnectedReleaseModal extends React.Component { constructor(props) { super(props); this.state = { - visible: false + visible: false, + app: null }; } componentWillReceiveProps(nextProps) { if (nextProps !== this.props) { this.setState({ - visible: nextProps.releaseView.visible + visible: nextProps.releaseView.visible, + app: nextProps.releaseView.app }) } } @@ -29,37 +33,38 @@ class ConnectedReleaseModal extends React.Component { }; handleOk = (e) => { - console.log(e); this.setState({ visible: false, }); }; handleCancel = (e) => { - console.log(e); this.setState({ visible: false, }); }; render() { - return ( -
- - -

Some contents...

-

Some contents...

-

Some contents...

-
-
- ); + if(this.props.releaseView.app != null){ + const app = this.props.app; + + return ( +
+ +

Some contents...

+

Some contents...

+

Some contents...

+
+
+ ); + }else { + return null; + } } } diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js index cd9fc1adc61..ba225caf320 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/actions/index.js @@ -28,11 +28,12 @@ export const getApps = () => dispatch => { }; -export const openReleasesModal = () => dispatch => { +export const openReleasesModal = (app) => dispatch => { + console.log(app); dispatch({ type: ActionTypes.OPEN_RELEASES_MODAL, payload: { - title :"hi" + app:app } }); }; diff --git a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js index c2e5074064d..51db6d4e50a 100644 --- a/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js +++ b/components/application-mgt/org.wso2.carbon.device.application.mgt.publisher.ui/react-app/src/js/reducers/index.js @@ -4,7 +4,7 @@ const initialState = { apps: [], releaseView: { visible: false, - title: "hi" + app: null } }; @@ -17,7 +17,7 @@ function rootReducer(state = initialState, action) { return Object.assign({}, state, { releaseView: { visible: true, - title: action.title + app: action.payload.app } }); }