diff --git a/react/components/ChannelSelector.jsx b/react/components/ChannelSelector.jsx index 08e78274..068af619 100644 --- a/react/components/ChannelSelector.jsx +++ b/react/components/ChannelSelector.jsx @@ -1,6 +1,6 @@ import React from 'react'; -import ChannelLoginForm from './ChannelLoginForm.jsx'; -import ChannelCreateForm from './ChannelCreateForm.jsx'; +import ChannelLoginForm from '../containers/ChannelLoginForm.jsx'; +import ChannelCreateForm from '../containers/ChannelCreateForm.jsx'; import { connect } from 'react-redux'; const LOGIN = 'login'; @@ -16,7 +16,7 @@ class ChannelSelector extends React.Component { this.selectOption = this.selectOption.bind(this); } componentWillMount () { - console.log('ChannelSelector will mount.'); + console.log('ChannelSelector will mount'); if (this.props.loggedInChannelName) { this.selectOption(this.props.loggedInChannelName); } diff --git a/react/components/Preview.jsx b/react/components/Preview.jsx index 8b246fdd..e6a8248f 100644 --- a/react/components/Preview.jsx +++ b/react/components/Preview.jsx @@ -11,9 +11,7 @@ class Preview extends React.Component { } componentWillMount () { console.log('Preview will mount'); - if (this.props.file) { - this.previewFile(this.props.file); - } + this.previewFile(this.props.file); } componentWillReceiveProps (newProps) { console.log('Preview will receive props', newProps); @@ -44,11 +42,4 @@ class Preview extends React.Component { } }; -const mapStateToProps = state => { - return { - file : state.file, - thumbnail: state.metadata.thumbnail, - }; -}; - -export default connect(mapStateToProps, null)(Preview); +export default Preview; diff --git a/react/components/UrlMiddle.jsx b/react/components/PublishUrlMiddle.jsx similarity index 100% rename from react/components/UrlMiddle.jsx rename to react/components/PublishUrlMiddle.jsx diff --git a/react/components/AnonymousOrChannelSelect.jsx b/react/containers/AnonymousOrChannelSelect.jsx similarity index 96% rename from react/components/AnonymousOrChannelSelect.jsx rename to react/containers/AnonymousOrChannelSelect.jsx index da93a88d..ab2c2efd 100644 --- a/react/components/AnonymousOrChannelSelect.jsx +++ b/react/containers/AnonymousOrChannelSelect.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import { setPublishInChannel } from '../actions'; +import { setPublishInChannel } from '../actions/index'; import { connect } from 'react-redux'; class AnonymousOrChannelSelect extends React.Component { diff --git a/react/components/ChannelCreateForm.jsx b/react/containers/ChannelCreateForm.jsx similarity index 98% rename from react/components/ChannelCreateForm.jsx rename to react/containers/ChannelCreateForm.jsx index f289ec5a..008f2d0b 100644 --- a/react/components/ChannelCreateForm.jsx +++ b/react/containers/ChannelCreateForm.jsx @@ -1,6 +1,6 @@ import React from 'react'; import {connect} from 'react-redux'; -import {updateLoggedInChannel} from '../actions'; +import {updateLoggedInChannel} from '../actions/index'; import { makeGetRequest, makePostRequest } from '../utils/xhr.js'; import { setUserCookies } from '../utils/cookies.js'; import { replaceChannelSelectionInNavBar } from '../utils/pageUpdate.js'; @@ -10,8 +10,8 @@ class ChannelCreateForm extends React.Component { super(props); this.state = { error : null, - channel : null, - password: null, + channel : '', + password: '', status : null, }; this.cleanseChannelInput = this.cleanseChannelInput.bind(this); diff --git a/react/components/ChannelLoginForm.jsx b/react/containers/ChannelLoginForm.jsx similarity index 97% rename from react/components/ChannelLoginForm.jsx rename to react/containers/ChannelLoginForm.jsx index b23ea0f8..47beaf34 100644 --- a/react/components/ChannelLoginForm.jsx +++ b/react/containers/ChannelLoginForm.jsx @@ -1,7 +1,7 @@ import React from 'react'; import { makePostRequest } from '../utils/xhr.js'; import { connect } from 'react-redux'; -import { updateLoggedInChannel } from '../actions'; +import { updateLoggedInChannel } from '../actions/index'; import { setUserCookies } from '../utils/cookies.js'; import { replaceChannelSelectionInNavBar } from '../utils/pageUpdate.js'; @@ -10,8 +10,8 @@ class ChannelLoginForm extends React.Component { super(props); this.state = { error : null, - name : null, - password: null, + name : '', + password: '', }; this.handleInput = this.handleInput.bind(this); this.loginToChannel = this.loginToChannel.bind(this); diff --git a/react/components/PreviewDropzone.jsx b/react/containers/Dropzone.jsx similarity index 91% rename from react/components/PreviewDropzone.jsx rename to react/containers/Dropzone.jsx index 49432db1..16dbeb53 100644 --- a/react/components/PreviewDropzone.jsx +++ b/react/containers/Dropzone.jsx @@ -1,12 +1,12 @@ import React from 'react'; // import PropTypes from 'prop-types'; -import { selectFile } from '../actions'; +import { selectFile } from '../actions/index'; import { connect } from 'react-redux'; -import Preview from './Preview.jsx'; +import Preview from '../components/Preview.jsx'; import { validateFile } from '../utils/file.js'; -class PreviewDropzone extends React.Component { +class Dropzone extends React.Component { constructor (props) { super(props); this.state = { @@ -95,7 +95,11 @@ class PreviewDropzone extends React.Component {
{this.props.file ? (
- +
{ this.state.dragOver ? (
@@ -140,7 +144,8 @@ class PreviewDropzone extends React.Component { const mapStateToProps = state => { return { - file: state.file, + file : state.file, + thumbnail: state.metadata.thumbnail, }; }; @@ -152,4 +157,4 @@ const mapDispatchToProps = dispatch => { }; } -export default connect(mapStateToProps, mapDispatchToProps)(PreviewDropzone); +export default connect(mapStateToProps, mapDispatchToProps)(Dropzone); diff --git a/react/components/PublishForm.jsx b/react/containers/PublishForm.jsx similarity index 95% rename from react/components/PublishForm.jsx rename to react/containers/PublishForm.jsx index 8f3a5884..8c211313 100644 --- a/react/components/PublishForm.jsx +++ b/react/containers/PublishForm.jsx @@ -1,13 +1,13 @@ import React from 'react'; -import PreviewDropzone from './PreviewDropzone.jsx'; +import PreviewDropzone from './Dropzone.jsx'; import PublishTitleInput from './PublishTitleInput.jsx'; -import ChannelSelector from './ChannelSelector.jsx'; +import ChannelSelector from '../components/ChannelSelector.jsx'; import PublishUrlInput from './PublishUrlInput.jsx'; import PublishThumbnailInput from './PublishThumbnailInput.jsx'; import PublishMetadataInputs from './PublishMetadataInputs.jsx'; import AnonymousOrChannelSelect from './AnonymousOrChannelSelect.jsx'; -import { selectFile, clearFile, updateLoggedInChannel } from '../actions'; +import { selectFile, clearFile, updateLoggedInChannel } from '../actions/index'; import { connect } from 'react-redux'; import { getCookie } from '../utils/cookies.js'; @@ -16,8 +16,7 @@ class PublishForm extends React.Component { super(props); // set defaults this.state = { - error : null, - showMetadataInputs: false, + error: null, }; this.publish = this.publish.bind(this); } diff --git a/react/components/PublishMetadataInputs.jsx b/react/containers/PublishMetadataInputs.jsx similarity index 98% rename from react/components/PublishMetadataInputs.jsx rename to react/containers/PublishMetadataInputs.jsx index d8b405dc..238e3d3d 100644 --- a/react/components/PublishMetadataInputs.jsx +++ b/react/containers/PublishMetadataInputs.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { connect } from 'react-redux'; -import { updateMetadata } from '../actions'; +import { updateMetadata } from '../actions/index'; /* const textarea = document.getElementById('publish-description'); diff --git a/react/components/PublishThumbnailInput.jsx b/react/containers/PublishThumbnailInput.jsx similarity index 98% rename from react/components/PublishThumbnailInput.jsx rename to react/containers/PublishThumbnailInput.jsx index 77c11042..410385ff 100644 --- a/react/components/PublishThumbnailInput.jsx +++ b/react/containers/PublishThumbnailInput.jsx @@ -1,6 +1,6 @@ import React from 'react'; import { connect } from 'react-redux'; -import { updateMetadata } from '../actions'; +import { updateMetadata } from '../actions/index'; class ThumbnailInput extends React.Component { constructor (props) { diff --git a/react/components/PublishTitleInput.jsx b/react/containers/PublishTitleInput.jsx similarity index 95% rename from react/components/PublishTitleInput.jsx rename to react/containers/PublishTitleInput.jsx index 8a806472..9a259064 100644 --- a/react/components/PublishTitleInput.jsx +++ b/react/containers/PublishTitleInput.jsx @@ -1,5 +1,5 @@ import React from 'react'; -import {updateMetadata} from '../actions'; +import {updateMetadata} from '../actions/index'; import {connect} from 'react-redux'; class TitleInput extends React.Component { diff --git a/react/components/PublishTool.jsx b/react/containers/PublishTool.jsx similarity index 86% rename from react/components/PublishTool.jsx rename to react/containers/PublishTool.jsx index 9e7f0687..2c885b1e 100644 --- a/react/components/PublishTool.jsx +++ b/react/containers/PublishTool.jsx @@ -1,7 +1,7 @@ import React from 'react'; -import PreviewDropzone from './PreviewDropzone.jsx'; +import PreviewDropzone from './Dropzone.jsx'; import PublishForm from './PublishForm.jsx'; -import PublishStatus from './PublishStatus.jsx'; +import PublishStatus from '../components/PublishStatus.jsx'; import {connect} from 'react-redux'; class PublishTool extends React.Component { diff --git a/react/components/PublishUrlInput.jsx b/react/containers/PublishUrlInput.jsx similarity index 96% rename from react/components/PublishUrlInput.jsx rename to react/containers/PublishUrlInput.jsx index 3147287e..c0a59d54 100644 --- a/react/components/PublishUrlInput.jsx +++ b/react/containers/PublishUrlInput.jsx @@ -1,8 +1,8 @@ import React from 'react'; -import { updateClaim } from '../actions'; +import { updateClaim } from '../actions/index'; import { connect } from 'react-redux'; import { makeGetRequest } from '../utils/xhr.js'; -import UrlMiddle from './UrlMiddle.jsx'; +import UrlMiddle from '../components/PublishUrlMiddle.jsx'; class UrlChooser extends React.Component { constructor (props) { diff --git a/react/index.js b/react/index.js index 5f5c1d2b..1cdd0e56 100644 --- a/react/index.js +++ b/react/index.js @@ -3,7 +3,7 @@ import ReactDOM from 'react-dom'; import { Provider } from 'react-redux'; import { createStore } from 'redux'; import Reducers from './reducers/index.js'; -import PublishTool from './components/PublishTool.jsx'; +import PublishTool from './containers/PublishTool.jsx'; let store = createStore( Reducers, diff --git a/react/reducers/index.js b/react/reducers/index.js index b6e4adff..5a5ecf01 100644 --- a/react/reducers/index.js +++ b/react/reducers/index.js @@ -36,7 +36,6 @@ export default function (state = initialState, action) { case FILE_CLEAR: return initialState; case METADATA_UPDATE: - console.log(`reducer for ${action.name} ${action.value}`); return Object.assign({}, state, { metadata: Object.assign({}, state.metadata, { [action.name]: action.value,