React/Redux - publish component #323

Merged
bones7242 merged 80 commits from react-upload into master 2018-01-25 22:43:20 +01:00
5 changed files with 47 additions and 21 deletions
Showing only changes of commit 66e1496a73 - Show all commits

View file

@ -1,12 +1,13 @@
// export action types // export action types
export const FILE_SELECTED = 'FILE_SELECTED'; export const FILE_SELECTED = 'FILE_SELECTED';
export const FILE_CLEAR = 'FILE_CLEAR'; export const FILE_CLEAR = 'FILE_CLEAR';
export const METADATA_UPDATE = 'TITLE_UPDATE';
// export action creators // export action creators
export function selectFile (file) { export function selectFile (file) {
return { return {
type : FILE_SELECTED, type: FILE_SELECTED,
payload: file, file: file,
}; };
}; };
@ -15,3 +16,11 @@ export function clearFile () {
type: FILE_CLEAR, type: FILE_CLEAR,
}; };
}; };
export function updateMetadata (name, value) {
return {
type: METADATA_UPDATE,
name,
value,
};
};

View file

@ -28,10 +28,7 @@ class PublishForm extends React.Component {
<div className="row row--no-bottom"> <div className="row row--no-bottom">
<div className="column column--10"> <div className="column column--10">
<PublishTitleInput <PublishTitleInput />
title={this.props.title}
updateUploaderState={this.props.updateUploaderState}
/>
</div> </div>
<div className="column column--5 column--sml-10" > <div className="column column--5 column--sml-10" >
@ -103,7 +100,6 @@ const mapStateToProps = state => {
loggedInChannelShortId: state.loggedInChannelShortId, loggedInChannelShortId: state.loggedInChannelShortId,
publishToChannel : state.publishToChannel, publishToChannel : state.publishToChannel,
file : state.file, file : state.file,
title : state.title,
claim : state.claim, claim : state.claim,
thumbnail : state.thumbnail, thumbnail : state.thumbnail,
description : state.description, description : state.description,

View file

@ -1,4 +1,6 @@
import React from 'react'; import React from 'react';
import {updateMetadata} from '../actions';
import {connect} from 'react-redux';
class TitleInput extends React.Component { class TitleInput extends React.Component {
constructor (props) { constructor (props) {
@ -9,7 +11,7 @@ class TitleInput extends React.Component {
e.preventDefault(); e.preventDefault();
const name = e.target.name; const name = e.target.name;
const value = e.target.value; const value = e.target.value;
this.props.updateUploaderState(name, value); this.props.onMetadataChange(name, value);
} }
render () { render () {
return ( return (
@ -18,4 +20,18 @@ class TitleInput extends React.Component {
} }
} }
module.exports = TitleInput; const mapStateToProps = state => {
return {
title: state.metadata.title,
};
};
const mapDispatchToProps = dispatch => {
return {
onMetadataChange: (name, value) => {
dispatch(updateMetadata(name, value));
},
};
}
export default connect(mapStateToProps, mapDispatchToProps)(TitleInput);

View file

@ -97,7 +97,6 @@ class PublishTool extends React.Component {
{ this.props.file && { this.props.file &&
<PublishForm <PublishForm
updateUploaderState={this.updateUploaderState} updateUploaderState={this.updateUploaderState}
clearUploaderState={this.clearUploaderState}
makeGetRequest={this.makeGetRequest} makeGetRequest={this.makeGetRequest}
makePostRequest={this.makePostRequest} makePostRequest={this.makePostRequest}
cleanseInput={this.cleanseInput} cleanseInput={this.cleanseInput}

View file

@ -1,21 +1,20 @@
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
import {FILE_CLEAR, FILE_SELECTED} from '../actions'; import {FILE_CLEAR, FILE_SELECTED, METADATA_UPDATE} from '../actions';
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
const DROPZONE = 'DROPZONE';
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
const initialState = { const initialState = {
showComponent : DROPZONE,
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
loggedInChannelName : null, loggedInChannelName : null,
loggedInChannelShortId: null, loggedInChannelShortId: null,
publishToChannel : false, publishToChannel : false,
publishStatus : null, publishStatus : null,
error : null, error : null,
file : null, file : null,
title : '', metadata : {
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
claim : '', title : '',
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
thumbnail : '', claim : '',
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
description : '', thumbnail : '',
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
license : '', description: '',
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
nsfw : '', license : '',
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
nsfw : '',
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
},
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
}; };
/* /*
@ -26,10 +25,17 @@ export default function (state = initialState, action) {
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
switch (action.type) { switch (action.type) {
case FILE_SELECTED: case FILE_SELECTED:
return Object.assign({}, state, { return Object.assign({}, state, {
file: action.payload, file: action.file,
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
}); });
case FILE_CLEAR: case FILE_CLEAR:
return initialState; return initialState;
case METADATA_UPDATE:
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
console.log(`reducer for ${action.name} ${action.value}`);
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
return Object.assign({}, state, {
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
metadata: {
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
[action.name]: action.value,
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
},
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
})
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
default: default:
return state; return state;
} }

kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).
kauffj commented 2018-01-15 20:27:22 +01:00 (Migrated from github.com)
Review

import * as

`import * as`
kauffj commented 2018-01-15 20:28:40 +01:00 (Migrated from github.com)
Review

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).

Some of these should possibly be renamed or refactored into separate files (or possibly can wait until next refactor/revision).