diff options
| author | Georgios Andreadis <info@gandreadis.com> | 2020-07-10 10:21:46 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:48:01 +0200 |
| commit | 8aa174e70c01631ae4e00a6d208966fcd77cf972 (patch) | |
| tree | 35ec6527e8d7a0b4093e18c8cb501c293a18b5eb /frontend/src/containers/app/sidebars/project/TopologyListContainer.js | |
| parent | 607e8c72d85bf79dcd9bf28df96b239e2764bc30 (diff) | |
Add implementation of portfolio and scenario UI structure
Diffstat (limited to 'frontend/src/containers/app/sidebars/project/TopologyListContainer.js')
| -rw-r--r-- | frontend/src/containers/app/sidebars/project/TopologyListContainer.js | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/frontend/src/containers/app/sidebars/project/TopologyListContainer.js b/frontend/src/containers/app/sidebars/project/TopologyListContainer.js index cab47c8d..6905c7c5 100644 --- a/frontend/src/containers/app/sidebars/project/TopologyListContainer.js +++ b/frontend/src/containers/app/sidebars/project/TopologyListContainer.js @@ -2,7 +2,9 @@ import { connect } from 'react-redux' import TopologyListComponent from '../../../../components/app/sidebars/project/TopologyListComponent' import { setCurrentTopology } from '../../../../actions/topology/building' import { openNewTopologyModal } from '../../../../actions/modals/topology' -import { deleteTopology } from '../../../../actions/topologies' +import { withRouter } from 'react-router-dom' +import { getState } from '../../../../util/state-utils' +import { deleteScenario } from '../../../../actions/scenarios' const mapStateToProps = state => { let topologies = state.objects.project[state.currentProjectId] ? state.objects.project[state.currentProjectId].topologyIds.map(t => ( @@ -13,34 +15,35 @@ const mapStateToProps = state => { } return { - show: state.modals.changeTopologyModalVisible, currentTopologyId: state.currentTopologyId, topologies, + } } -const mapDispatchToProps = dispatch => { +const mapDispatchToProps = (dispatch, ownProps) => { return { - onChooseTopology: (id) => { - dispatch( - setCurrentTopology(id), - ) + onChooseTopology: async (id) => { + dispatch(setCurrentTopology(id)) + const state = await getState(dispatch) + ownProps.history.push(`/projects/${state.currentProjectId}`) }, onNewTopology: () => { dispatch(openNewTopologyModal()) }, - onDeleteTopology: (id) => { + onDeleteTopology: async (id) => { if (id) { - dispatch( - deleteTopology(id), - ) + const state = await getState(dispatch) + dispatch(deleteScenario(id)) + dispatch(setCurrentTopology(state.objects.project[state.currentProjectId].topologyIds[0])) + ownProps.history.push(`/projects/${state.currentProjectId}`) } }, } } -const TopologyListContainer = connect(mapStateToProps, mapDispatchToProps)( +const TopologyListContainer = withRouter(connect(mapStateToProps, mapDispatchToProps)( TopologyListComponent, -) +)) export default TopologyListContainer |
