1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 09:46:22 +00:00

redirect when create new note

This commit is contained in:
Dick Choi
2016-06-01 10:19:36 +09:00
parent c691af9712
commit 45212e7e14
2 changed files with 17 additions and 2 deletions

View File

@@ -89,7 +89,8 @@ class Main extends React.Component {
'dispatch', 'dispatch',
'repositories', 'repositories',
'config', 'config',
'params' 'params',
'location'
])} ])}
/> />
<div styleName={config.isSideNavFolded ? 'body--expanded' : 'body'} <div styleName={config.isSideNavFolded ? 'body--expanded' : 'body'}

View File

@@ -65,12 +65,20 @@ class TopBar extends React.Component {
return repo.addNote(newNote) return repo.addNote(newNote)
}) })
.then((note) => { .then((note) => {
let { dispatch } = this.props let { dispatch, location } = this.props
let { router } = this.context
dispatch({ dispatch({
type: 'ADD_NOTE', type: 'ADD_NOTE',
repository: repositoryKey, repository: repositoryKey,
note: note note: note
}) })
router.push({
pathname: location.pathname,
query: {
key: `${note._repository.key}-${note.key}`
}
})
}) })
.catch((err) => { .catch((err) => {
console.error(err) console.error(err)
@@ -139,6 +147,12 @@ class TopBar extends React.Component {
} }
} }
TopBar.contextTypes = {
router: PropTypes.shape({
push: PropTypes.func
})
}
TopBar.propTypes = { TopBar.propTypes = {
dispatch: PropTypes.func, dispatch: PropTypes.func,
config: PropTypes.shape({ config: PropTypes.shape({