diff --git a/README.md b/README.md index bf5f7e1c..d4609cf2 100644 --- a/README.md +++ b/README.md @@ -31,10 +31,12 @@ Checklist - [x] Request invite code - [x] Request user object itself - [x] Load the metacodes - +- [x] move ImportDialog lightbox into main app - [x] create topic form + - [ ] create synapse form -- [ ] move ImportDialog lightbox into main app +- [ ] replace old loader with react loader +- [ ] ensure exports of maps work - [ ] Notifications: make sure notifications either look nice, or redirect - [ ] Notifications: pagination - [ ] Get actioncable working diff --git a/src/Metamaps/GlobalUI/ImportDialog.js b/src/Metamaps/GlobalUI/ImportDialog.js index c253512d..babe9862 100644 --- a/src/Metamaps/GlobalUI/ImportDialog.js +++ b/src/Metamaps/GlobalUI/ImportDialog.js @@ -1,36 +1,14 @@ /* global $ */ -import React from 'react' -import ReactDOM from 'react-dom' -import outdent from 'outdent' - -import ImportDialogBox from '../../routes/MapView/ImportDialogBox' - -import PasteInput from '../PasteInput' import Map from '../Map' const ImportDialog = { openLightbox: null, closeLightbox: null, - init: function(serverData, openLightbox, closeLightbox) { const self = ImportDialog self.openLightbox = openLightbox self.closeLightbox = closeLightbox - - $('#lightbox_content').append($(outdent` -
-
-
- `)) - ReactDOM.render(React.createElement(ImportDialogBox, { - onFileAdded: PasteInput.handleFile, - exampleImageUrl: serverData['import-example.png'], - downloadScreenshot: ImportDialog.downloadScreenshot, - onExport: format => () => { - window.open(`${window.location.pathname}/export.${format}`, '_blank') - } - }), $('.importDialogWrapper').get(0)) }, show: function() { ImportDialog.openLightbox('import-dialog') diff --git a/src/Metamaps/GlobalUI/ReactApp.js b/src/Metamaps/GlobalUI/ReactApp.js index 08752098..321c0383 100644 --- a/src/Metamaps/GlobalUI/ReactApp.js +++ b/src/Metamaps/GlobalUI/ReactApp.js @@ -16,6 +16,7 @@ import DataFetcher from '../DataFetcher' import { ExploreMaps, ChatView, TopicCard, ContextMenu } from '../Views' import Filter from '../Filter' import JIT from '../JIT' +import PasteInput from '../PasteInput' import Realtime from '../Realtime' import Map, { InfoBox } from '../Map' import Topic from '../Topic' @@ -143,7 +144,12 @@ const ReactApp = { onMapStar: Map.star, onMapUnstar: Map.unstar, initNewTopic: Create.newTopic.init, - initNewSynapse: Create.newSynapse.init + initNewSynapse: Create.newSynapse.init, + importHandleFile: PasteInput.handleFile, + downloadScreenshot: ImportDialog.downloadScreenshot, + onExport: format => () => { + window.open(`${window.location.pathname}/export.${format}`, '_blank') + } } }, getCommonProps: function() { diff --git a/src/Metamaps/Map/index.js b/src/Metamaps/Map/index.js index b509ed46..0bd657f6 100644 --- a/src/Metamaps/Map/index.js +++ b/src/Metamaps/Map/index.js @@ -381,5 +381,5 @@ const Map = { } } -export { CheatSheet, InfoBox } +export { InfoBox } export default Map diff --git a/src/components/LightBoxes/ImportDialogBox.js b/src/components/LightBoxes/ImportDialogBox.js new file mode 100644 index 00000000..e00f998b --- /dev/null +++ b/src/components/LightBoxes/ImportDialogBox.js @@ -0,0 +1,46 @@ +import React, { Component } from 'react' +import PropTypes from 'prop-types' +import Dropzone from 'react-dropzone' + +class ImportDialogBox extends Component { + handleFile = (files, e) => { + e.preventDefault() // prevent it from triggering the default drag-drop handler + this.props.onFileAdded(files[0]) + } + + render = () => { + return ( +
+
+
+

EXPORT

+
+ Export as CSV +
+
+ Export as JSON +
+
+ Download screenshot +
+

IMPORT

+

To upload a file, drop it here:

+ + Drop files here! + +

See docs.metamaps.cc for instructions.

+
+
+
+ ) + } +} + +ImportDialogBox.propTypes = { + onFileAdded: PropTypes.func, + downloadScreenshot: PropTypes.func, + onExport: PropTypes.func +} + +export default ImportDialogBox diff --git a/src/components/LightBoxes/index.js b/src/components/LightBoxes/index.js index f851108f..9ed26774 100644 --- a/src/components/LightBoxes/index.js +++ b/src/components/LightBoxes/index.js @@ -3,6 +3,7 @@ import React, { Component } from 'react' import About from './About' import CheatSheet from './CheatSheet' import ForkMap from './ForkMap' +import ImportDialogBox from './ImportDialogBox' import Invite from './Invite' import NoIE from './NoIE' import SwitchMetacodes from './SwitchMetacodes' @@ -10,6 +11,11 @@ import Tutorial from './Tutorial' class LightBoxes extends Component { render = () => { + const importProps = { + onFileAdded: this.props.importHandleFile, + downloadScreenshot: this.props.downloadScreenshot, + onExport: this.props.onExport + } return (