summaryrefslogtreecommitdiff
path: root/frontend/views/graph/components
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/views/graph/components')
-rw-r--r--frontend/views/graph/components/page.edit.js22
1 files changed, 16 insertions, 6 deletions
diff --git a/frontend/views/graph/components/page.edit.js b/frontend/views/graph/components/page.edit.js
index 1e59647..5bc64d6 100644
--- a/frontend/views/graph/components/page.edit.js
+++ b/frontend/views/graph/components/page.edit.js
@@ -1,9 +1,12 @@
import React, { Component } from 'react'
import { Link } from 'react-router-dom'
import { connect } from 'react-redux'
+import { bindActionCreators } from 'redux'
import { history } from '../../../store'
import actions from '../../../actions'
+import * as siteActions from '../../site/site.actions'
+import * as graphActions from '../../graph/graph.actions'
import { Loader } from '../../../common'
@@ -11,16 +14,22 @@ import PageForm from '../components/page.form'
class PageEdit extends Component {
componentDidMount() {
- console.log(this.props.match.params.id)
- actions.page.show(this.props.match.params.id)
+ // actions.page.show(this.props.match.params.id)
}
handleSubmit(data) {
+ const { path: graphPath } = this.props.graph.show.res
+ const { path: oldPagePath } = this.props.page.show.res
+ const { path: newPagePath } = data
actions.page.update(data)
.then(response => {
- // response
- console.log(response)
- // history.push('/' + data.path)
+ // console.log(response)
+ actions.site.setSiteTitle(response.res.title)
+ this.props.graphActions.hideEditPageForm()
+ if (oldPagePath !== newPagePath) {
+ const newPath = '/' + graphPath + '/' + newPagePath
+ history.push(newPath)
+ }
})
}
@@ -49,7 +58,8 @@ const mapStateToProps = state => ({
})
const mapDispatchToProps = dispatch => ({
- // searchActions: bindActionCreators({ ...searchActions }, dispatch),
+ siteActions: bindActionCreators({ ...siteActions }, dispatch),
+ graphActions: bindActionCreators({ ...graphActions }, dispatch),
})
export default connect(mapStateToProps, mapDispatchToProps)(PageEdit)