summaryrefslogtreecommitdiff
path: root/animism-align/frontend/views/media/components/media.menu.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-07-08 15:01:29 +0200
committerJules Laplace <julescarbon@gmail.com>2020-07-08 15:01:29 +0200
commitbbcf48825bec60dab7a4de955bc4831eadb37792 (patch)
tree79895748a2712e38ecfc96ad2d2630f392c4e851 /animism-align/frontend/views/media/components/media.menu.js
parent084d11a05fe1220c5104ea59f4fab4860e70b434 (diff)
media form and anuvva migration
Diffstat (limited to 'animism-align/frontend/views/media/components/media.menu.js')
-rw-r--r--animism-align/frontend/views/media/components/media.menu.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/animism-align/frontend/views/media/components/media.menu.js b/animism-align/frontend/views/media/components/media.menu.js
new file mode 100644
index 0000000..3d7e86a
--- /dev/null
+++ b/animism-align/frontend/views/media/components/media.menu.js
@@ -0,0 +1,49 @@
+import React, { Component } from 'react'
+import { Route, Link } from 'react-router-dom'
+import { connect } from 'react-redux'
+
+import { history } from '../../../store'
+import actions from '../../../actions'
+import { MenuButton, FileInput } from '../../../common'
+
+const mapStateToProps = state => ({
+ media: state.media,
+})
+
+export default class MediaMenu extends Component {
+ render() {
+ return (
+ <div className='menuButtons'>
+ <Route exact path='/media/:id/show/' component={MediaShowMenu} />
+ <Route exact path='/media/:id/edit/' component={MediaEditMenu} />
+ <Route exact path='/media/new/' component={MediaNewMenu} />
+ <Route exact path='/media/' component={MediaIndexMenu} />
+ </div>
+ )
+ }
+}
+
+const MediaIndexMenu = () => ([
+ <MenuButton key='new' name="new" href="/media/new/" />,
+])
+
+const MediaShowMenu = connect(mapStateToProps)((props) => ([
+ <MenuButton key='back' name="back" />,
+ <MenuButton key='edit' name="edit" href={"/media/" + props.match.params.id + "/edit/"} />,
+ <MenuButton key='delete' name="delete" onClick={() => {
+ const { res: media } = props.media.show
+ if (confirm("Really delete this media?")) {
+ actions.media.destroy(media).then(() => {
+ history.push('/media/')
+ })
+ }
+ }} />,
+]))
+
+const MediaNewMenu = (props) => ([
+ <MenuButton key='back' name="back" />,
+])
+
+const MediaEditMenu = (props) => ([
+ <MenuButton key='back' name="back" />,
+])