diff --git a/react/components/PublishForm.jsx b/react/components/PublishForm.jsx
index da502a22..5a87b66e 100644
--- a/react/components/PublishForm.jsx
+++ b/react/components/PublishForm.jsx
@@ -63,9 +63,9 @@ class PublishForm extends React.Component {
-
+
{this.state.error}
@@ -89,12 +89,9 @@ class PublishForm extends React.Component {
const mapStateToProps = state => {
return {
- fileType : state.file.type,
- claim : state.claim,
- thumbnail : state.thumbnail,
- description: state.description,
- license : state.license,
- nsfw : state.nsfw,
+ fileType : state.file.type,
+ claim : state.claim,
+ thumbnail: state.thumbnail,
};
};
diff --git a/react/components/PublishMetadataInputs.jsx b/react/components/PublishMetadataInputs.jsx
index 4cb28b48..7cf51502 100644
--- a/react/components/PublishMetadataInputs.jsx
+++ b/react/components/PublishMetadataInputs.jsx
@@ -1,41 +1,45 @@
import React from 'react';
+import { connect } from 'react-redux';
+import { updateMetadata } from '../actions';
class MetadataInputs extends React.Component {
constructor (props) {
super(props);
this.state = {
- showInputs : false,
+ showInputs: false,
};
this.toggleShowInputs = this.toggleShowInputs.bind(this);
this.handleInput = this.handleInput.bind(this);
+ this.handleCheck = this.handleCheck.bind(this);
this.handleSelection = this.handleSelection.bind(this);
}
toggleShowInputs () {
- if (this.state.showInputs) {
- this.setState({'showInputs': false});
- } else {
- this.setState({'showInputs': true});
- }
+ this.setState({'showInputs': !this.state.showInputs});
}
handleInput (event) {
event.preventDefault();
- const target = event.target;
- const name = target.name;
- const value = target.type === 'checkbox' ? target.checked : target.value;
- this.props.updateUploaderState(name, value);
+ const name = event.target.name;
+ const value = event.target.value;
+ this.props.onMetadataChange(name, value);
+ }
+ handleCheck (event) {
+ console.log('handle input', event);
+ event.preventDefault();
+ const name = event.target.name;
+ const value = event.target.checked;
+ this.props.onMetadataChange(name, value);
}
handleSelection (event) {
+ const name = event.target.name;
const selectedOption = event.target.selectedOptions[0].value;
- this.props.updateUploaderState('', value);
+ this.props.onMetadataChange(name, selectedOption);
}
-
render () {
return (
-
-
+
{this.state.showInputs && (
@@ -51,7 +55,7 @@ class MetadataInputs extends React.Component {
-
)}
-
);
}
}
-module.exports = MetadataInputs;
+const mapStateToProps = state => {
+ return {
+ description: state.metadata.description,
+ license : state.metadata.license,
+ nsfw : state.metadata.nsfw,
+ };
+};
+
+const mapDispatchToProps = dispatch => {
+ return {
+ onMetadataChange: (name, value) => {
+ dispatch(updateMetadata(name, value));
+ },
+ };
+};
+
+export default connect(mapStateToProps, mapDispatchToProps)(MetadataInputs);
diff --git a/react/index.js b/react/index.js
index 31084e33..5f5c1d2b 100644
--- a/react/index.js
+++ b/react/index.js
@@ -5,7 +5,10 @@ import { createStore } from 'redux';
import Reducers from './reducers/index.js';
import PublishTool from './components/PublishTool.jsx';
-let store = createStore(Reducers)
+let store = createStore(
+ Reducers,
+ window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
+);
ReactDOM.render(
diff --git a/react/reducers/index.js b/react/reducers/index.js
index 53e08abf..b6e4adff 100644
--- a/react/reducers/index.js
+++ b/react/reducers/index.js
@@ -19,7 +19,7 @@ const initialState = {
thumbnail : '',
description: '',
license : '',
- nsfw : '',
+ nsfw : false,
},
};
@@ -38,9 +38,9 @@ export default function (state = initialState, action) {
case METADATA_UPDATE:
console.log(`reducer for ${action.name} ${action.value}`);
return Object.assign({}, state, {
- metadata: {
+ metadata: Object.assign({}, state.metadata, {
[action.name]: action.value,
- },
+ }),
});
case CLAIM_UPDATE:
return Object.assign({}, state, {