From 621eda30b9c2995ce934202bc92f9b553b98136d Mon Sep 17 00:00:00 2001 From: artpi Date: Mon, 8 Feb 2016 13:00:12 -0500 Subject: [PATCH 01/22] CP flux redux /preview-container.jsx --- .../editor-featured-image/preview-container.jsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/client/post-editor/editor-featured-image/preview-container.jsx b/client/post-editor/editor-featured-image/preview-container.jsx index b3c7b8fa1bd6e2..70b18a1e4a3cdf 100644 --- a/client/post-editor/editor-featured-image/preview-container.jsx +++ b/client/post-editor/editor-featured-image/preview-container.jsx @@ -3,7 +3,8 @@ */ import React, { PropTypes } from 'react'; import defer from 'lodash/function/defer'; - +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal dependencies */ @@ -11,8 +12,9 @@ import MediaActions from 'lib/media/actions'; import MediaStore from 'lib/media/store'; import PostActions from 'lib/posts/actions'; import EditorFeaturedImagePreview from './preview'; +import { setFeaturedImage } from 'state/ui/editor/post/actions'; -export default React.createClass( { +const EditorFeaturedImagePreviewContainer = React.createClass( { displayName: 'EditorFeaturedImagePreviewContainer', propTypes: { @@ -70,9 +72,12 @@ export default React.createClass( { defer( () => { if ( image && image.ID !== this.props.itemId ) { + // TODO: REDUX - remove flux actions when whole post-editor is reduxified PostActions.edit( { featured_image: image.ID } ); + + this.props.setFeaturedImage( image.ID ); } } ); }, @@ -85,3 +90,8 @@ export default React.createClass( { ); } } ); + +export default connect( + null, + dispatch => bindActionCreators( { setFeaturedImage }, dispatch ) +)( EditorFeaturedImagePreviewContainer ); From 391e441104514605cb99223045752bd3751c9873 Mon Sep 17 00:00:00 2001 From: artpi Date: Mon, 8 Feb 2016 15:18:23 -0500 Subject: [PATCH 02/22] CP flux redux editor-ground-control --- .../post-editor/editor-ground-control/index.jsx | 17 ++++++++++++++--- client/state/ui/editor/post/actions.js | 5 +++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/client/post-editor/editor-ground-control/index.jsx b/client/post-editor/editor-ground-control/index.jsx index 08f22699185f51..5fc5eb5d708a81 100644 --- a/client/post-editor/editor-ground-control/index.jsx +++ b/client/post-editor/editor-ground-control/index.jsx @@ -1,14 +1,16 @@ /** * External dependencies */ -var noop = require( 'lodash/utility/noop' ), +const noop = require( 'lodash/utility/noop' ), React = require( 'react' ), PureRenderMixin = require( 'react-pure-render/mixin' ); +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal dependencies */ -var Card = require( 'components/card' ), +const Card = require( 'components/card' ), EditPostStatus = require( 'post-editor/edit-post-status' ), Gridicon = require( 'components/gridicon' ), Popover = require( 'components/popover' ), @@ -22,12 +24,13 @@ var Card = require( 'components/card' ), Tooltip = require( 'components/tooltip' ), PostListFetcher = require( 'components/post-list-fetcher' ), stats = require( 'lib/posts/stats' ); +import { setDate } from 'state/ui/editor/post/actions'; function isPostEmpty( props ) { return ( props.isNew && ! props.isDirty ) || ! props.hasContent; } -module.exports = React.createClass( { +const EditorGroundControl = React.createClass( { displayName: 'EditorGroundControl', propTypes: { hasContent: React.PropTypes.bool, @@ -40,6 +43,7 @@ module.exports = React.createClass( { onPublish: React.PropTypes.func, onSaveDraft: React.PropTypes.func, post: React.PropTypes.object, + setDate: React.PropTypes.func, savedPost: React.PropTypes.object, site: React.PropTypes.object, type: React.PropTypes.string @@ -59,6 +63,7 @@ module.exports = React.createClass( { onSaveDraft: noop, post: null, savedPost: null, + setDate: () => {}, site: {} }; }, @@ -74,7 +79,9 @@ module.exports = React.createClass( { }, setPostDate: function( date ) { + // TODO: REDUX - remove flux actions when whole post-editor is reduxified postActions.edit( { date: date ? date.format() : null } ); + this.props.setDate( date ); }, setCurrentMonth: function( date ) { @@ -402,3 +409,7 @@ module.exports = React.createClass( { } } ); +export default connect( + null, + dispatch => bindActionCreators( { setDate }, dispatch ) +)( EditorGroundControl ); diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index 358b55d7dcb309..bb6596a09638c0 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -65,6 +65,11 @@ export function removeFeaturedImage() { return { type: 'TODO' }; } +export function setDate( postDate ) { + debug( 'setDate', postDate ); + return { type: 'TODO' }; +} + export const EDITING_MODES = { EXISTING: 'EDITING_MODE_EXISTING', NEW: 'EDITING_MODE_NEW' From 245bb1e7a3080bd950f378713e2043f6749df6a0 Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 18:19:03 -0500 Subject: [PATCH 03/22] Fix editor ground control tests and component call --- client/post-editor/editor-ground-control/index.jsx | 1 - client/post-editor/editor-ground-control/test/index.jsx | 6 +++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/post-editor/editor-ground-control/index.jsx b/client/post-editor/editor-ground-control/index.jsx index 5fc5eb5d708a81..2ead4dfae50983 100644 --- a/client/post-editor/editor-ground-control/index.jsx +++ b/client/post-editor/editor-ground-control/index.jsx @@ -18,7 +18,6 @@ const Card = require( 'components/card' ), StatusLabel = require( 'post-editor/status-label' ), postUtils = require( 'lib/posts/utils' ), siteUtils = require( 'lib/site/utils' ), - Popover = require( 'components/popover' ), PostSchedule = require( 'components/post-schedule' ), postActions = require( 'lib/posts/actions' ), Tooltip = require( 'components/tooltip' ), diff --git a/client/post-editor/editor-ground-control/test/index.jsx b/client/post-editor/editor-ground-control/test/index.jsx index 3d5f1b686a9bb7..a18479a2b9b63c 100644 --- a/client/post-editor/editor-ground-control/test/index.jsx +++ b/client/post-editor/editor-ground-control/test/index.jsx @@ -50,9 +50,13 @@ describe( 'EditorGroundControl', function() { mockery.registerMock( 'post-editor/status-label', MOCK_COMPONENT ); mockery.registerMock( 'components/sticky-panel', MOCK_COMPONENT ); mockery.registerMock( 'components/post-schedule', MOCK_COMPONENT ); - EditorGroundControl = require( '../' ); + EditorGroundControl = require( '../' ).WrappedComponent; EditorGroundControl.prototype.__reactAutoBindMap.translate = sinon.stub().returnsArg( 0 ); EditorGroundControl.prototype.__reactAutoBindMap.moment = moment; + // TODO: REDUX - add proper tests when whole post-editor is reduxified + mockery.registerMock( 'react-redux', { + connect: () => component => component + } ); } ); beforeEach( function() { From fed27f4df611a7de5e0853aaa4332fe721926c6a Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 18:31:45 -0500 Subject: [PATCH 04/22] editor-location --- client/post-editor/editor-location/index.jsx | 32 +++++++++++++++++--- client/state/ui/editor/post/actions.js | 10 ++++++ 2 files changed, 38 insertions(+), 4 deletions(-) diff --git a/client/post-editor/editor-location/index.jsx b/client/post-editor/editor-location/index.jsx index 3187c41bdeda6f..d3f214fb282d27 100644 --- a/client/post-editor/editor-location/index.jsx +++ b/client/post-editor/editor-location/index.jsx @@ -1,27 +1,34 @@ /** * External dependencies */ -var React = require( 'react' ), +const React = require( 'react' ), qs = require( 'querystring' ); +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; + /** * Internal dependencies */ -var PostActions = require( 'lib/posts/actions' ), +const PostActions = require( 'lib/posts/actions' ), EditorDrawerWell = require( 'post-editor/editor-drawer-well' ), Notice = require( 'components/notice' ), stats = require( 'lib/posts/stats' ), EditorLocationSearch = require( './search' ); +import { setLocation, removeLocation } from 'state/ui/editor/post/actions'; + /** * Module variables */ -var GOOGLE_MAPS_BASE_URL = 'http://maps.google.com/maps/api/staticmap?'; +const GOOGLE_MAPS_BASE_URL = 'http://maps.google.com/maps/api/staticmap?'; -module.exports = React.createClass( { +const EditorLocation = React.createClass( { displayName: 'EditorLocation', propTypes: { + setLocation: React.PropTypes.func, + removeLocation: React.PropTypes.func, label: React.PropTypes.string, coordinates: function( props, propName ) { var prop = props[ propName ]; @@ -31,6 +38,13 @@ module.exports = React.createClass( { } }, + getDefaultProps: function() { + return { + setLocation: () => {}, + removeLocation: () => {} + }; + }, + getInitialState: function() { return { error: null @@ -42,12 +56,14 @@ module.exports = React.createClass( { locating: false } ); + // TODO: REDUX - remove flux actions when whole post-editor is reduxified PostActions.updateMetadata( { geo_latitude: position.coords.latitude, geo_longitude: position.coords.longitude } ); stats.recordStat( 'location_geolocate_success' ); + this.props.setLocation( position.coords.latitude, position.coords.longitude ); }, onGeolocateFailure: function( error ) { @@ -82,7 +98,10 @@ module.exports = React.createClass( { }, clear: function() { + // TODO: REDUX - remove flux actions when whole post-editor is reduxified PostActions.deleteMetadata( [ 'geo_latitude', 'geo_longitude' ] ); + + this.props.removeLocation(); }, onSearchSelect: function( result ) { @@ -143,3 +162,8 @@ module.exports = React.createClass( { ); } } ); + +export default connect( + null, + dispatch => bindActionCreators( { setLocation, removeLocation }, dispatch ) +)( EditorLocation ); diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index bb6596a09638c0..14671e25ce4c2a 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -70,6 +70,16 @@ export function setDate( postDate ) { return { type: 'TODO' }; } +export function setLocation( latitude, longitude ) { + debug( 'setLocation', latitude, longitude ); + return { type: 'TODO' }; +} + +export function removeLocation() { + debug( 'removeLocation' ); + return { type: 'TODO' }; +} + export const EDITING_MODES = { EXISTING: 'EDITING_MODE_EXISTING', NEW: 'EDITING_MODE_NEW' From c6f4759ec43e32fc90a0ddf8f0e741e5133d90d7 Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 18:37:41 -0500 Subject: [PATCH 05/22] editor-menu-order --- client/post-editor/editor-page-order/index.jsx | 14 +++++++++++++- client/state/ui/editor/post/actions.js | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/client/post-editor/editor-page-order/index.jsx b/client/post-editor/editor-page-order/index.jsx index fef47e1cc7f48d..097e0d4f5e46ee 100644 --- a/client/post-editor/editor-page-order/index.jsx +++ b/client/post-editor/editor-page-order/index.jsx @@ -4,6 +4,8 @@ import React, { PropTypes } from 'react'; import PureRenderMixin from 'react-pure-render/mixin'; import isNaN from 'lodash/lang/isNaN'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal dependencies @@ -11,13 +13,15 @@ import isNaN from 'lodash/lang/isNaN'; import TextInput from 'components/forms/form-text-input'; import postActions from 'lib/posts/actions'; import { recordEvent, recordStat } from 'lib/posts/stats'; +import { setMenuOrder } from 'state/ui/editor/post/actions'; -export default React.createClass( { +const EditorPageOrder = React.createClass( { displayName: 'EditorPageOrder', mixins: [ PureRenderMixin ], propTypes: { + setMenuOrder: PropTypes.func, menuOrder: PropTypes.oneOfType( [ PropTypes.number, PropTypes.string @@ -26,6 +30,7 @@ export default React.createClass( { getDefaultProps() { return { + setMenuOrder: () => {}, menuOrder: 0 }; }, @@ -55,9 +60,11 @@ export default React.createClass( { recordStat( 'advanced_menu_order_changed' ); recordEvent( 'Changed page menu order' ); + // TODO: REDUX - remove flux actions when whole post-editor is reduxified postActions.edit( { menu_order: newOrder } ); + this.props.setMenuOrder( newOrder ); } }, @@ -72,3 +79,8 @@ export default React.createClass( { ); } } ); + +export default connect( + null, + dispatch => bindActionCreators( { setMenuOrder }, dispatch ) +)( EditorPageOrder ); diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index 14671e25ce4c2a..7575132a1bf5c4 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -80,6 +80,11 @@ export function removeLocation() { return { type: 'TODO' }; } +export function setMenuOrder( newOrder ) { + debug( 'setMenuOrder', newOrder ); + return { type: 'TODO' }; +} + export const EDITING_MODES = { EXISTING: 'EDITING_MODE_EXISTING', NEW: 'EDITING_MODE_NEW' From 820427e410dab84c63176a5b7f16cd4adc2ee943 Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 18:42:11 -0500 Subject: [PATCH 06/22] page-parent --- .../post-editor/editor-page-parent/index.jsx | 21 +++++++++++++++++-- client/state/ui/editor/post/actions.js | 6 ++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/client/post-editor/editor-page-parent/index.jsx b/client/post-editor/editor-page-parent/index.jsx index bfc6bd0dd4b145..ba0957be9a39da 100644 --- a/client/post-editor/editor-page-parent/index.jsx +++ b/client/post-editor/editor-page-parent/index.jsx @@ -4,7 +4,8 @@ import React, { PropTypes } from 'react'; import PureRenderMixin from 'react-pure-render/mixin'; import AccordionSection from 'components/accordion/section'; - +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal dependencies */ @@ -12,23 +13,34 @@ import PostSelector from 'my-sites/post-selector'; import postActions from 'lib/posts/actions'; import FormLabel from 'components/forms/form-label'; import FormToggle from 'components/forms/form-toggle/compact'; +import { setPageParent } from 'state/ui/editor/post/actions'; -export default React.createClass( { +const EditorPageParent = React.createClass( { displayName: 'EditorPageParent', mixins: [ PureRenderMixin ], propTypes: { + setPageParent: PropTypes.func, siteId: PropTypes.number, parent: PropTypes.number, postId: PropTypes.number }, + getDefaultProps: function() { + return { + setPageParent: () => {}, + }; + }, + updatePageParent( item ) { const parentId = item && item.ID ? item.ID : null; + // TODO: REDUX - remove flux actions when whole post-editor is reduxified postActions.edit( { parent: parentId } ); + + this.props.setPageParent( parentId ); }, getEmptyMessage() { @@ -67,3 +79,8 @@ export default React.createClass( { ); } } ); + +export default connect( + null, + dispatch => bindActionCreators( { setPageParent }, dispatch ) +)( EditorPageParent ); diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index 7575132a1bf5c4..92ee86b8c633a0 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -85,6 +85,12 @@ export function setMenuOrder( newOrder ) { return { type: 'TODO' }; } +export function setPageParent( newParentId ) { + debug( 'setPageParent', newParentId ); + return { type: 'TODO' }; +} + + export const EDITING_MODES = { EXISTING: 'EDITING_MODE_EXISTING', NEW: 'EDITING_MODE_NEW' From fec8980d0837d62c8426536322e3e32e3d6bc967 Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 18:49:54 -0500 Subject: [PATCH 07/22] editor-page-template --- client/post-editor/editor-page-templates/index.jsx | 14 +++++++++++++- client/state/ui/editor/post/actions.js | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/client/post-editor/editor-page-templates/index.jsx b/client/post-editor/editor-page-templates/index.jsx index 45324914664ce7..0dca9edf5ea3e1 100644 --- a/client/post-editor/editor-page-templates/index.jsx +++ b/client/post-editor/editor-page-templates/index.jsx @@ -3,6 +3,8 @@ */ import React, { PropTypes } from 'react'; import find from 'lodash/collection/find'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal dependencies @@ -11,17 +13,20 @@ import PostActions from 'lib/posts/actions'; import AccordionSection from 'components/accordion/section'; import SelectDropdown from 'components/select-dropdown'; import DropdownItem from 'components/select-dropdown/item'; +import { setPageTemplate } from 'state/ui/editor/post/actions'; -export default React.createClass( { +const EditorPageTemplates = React.createClass( { displayName: 'EditorPageTemplates', propTypes: { post: PropTypes.object, + setPageTemplate: PropTypes.func, pageTemplates: PropTypes.array.isRequired }, getDefaultProps() { return { + setPageTemplate: () => {}, pageTemplates: [] }; }, @@ -70,7 +75,9 @@ export default React.createClass( { }, _selectTemplate( template ) { + // TODO: REDUX - remove flux actions when whole post-editor is reduxified PostActions.edit( { page_template: template.file } ); + this.props.setPageTemplate( template ); }, _getSelectedTemplateText() { @@ -83,3 +90,8 @@ export default React.createClass( { } } ); + +export default connect( + null, + dispatch => bindActionCreators( { setPageTemplate }, dispatch ) +)( EditorPageTemplates ); diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index 92ee86b8c633a0..2971d50424b650 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -90,6 +90,11 @@ export function setPageParent( newParentId ) { return { type: 'TODO' }; } +export function setPageTemplate( newTemplate ) { + debug( 'setPageTemplate', newTemplate ); + return { type: 'TODO' }; +} + export const EDITING_MODES = { EXISTING: 'EDITING_MODE_EXISTING', From 5cb190dc2594511b5b537ba2f1dedc153f480348 Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 18:57:55 -0500 Subject: [PATCH 08/22] editor-post-format --- .../post-editor/editor-post-formats/index.jsx | 19 ++++++++++++++++--- client/state/ui/editor/post/actions.js | 6 +++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/client/post-editor/editor-post-formats/index.jsx b/client/post-editor/editor-post-formats/index.jsx index fb26739414b482..ce3223b835aef6 100644 --- a/client/post-editor/editor-post-formats/index.jsx +++ b/client/post-editor/editor-post-formats/index.jsx @@ -1,21 +1,25 @@ /** * External dependencies */ -var React = require( 'react' ); +const React = require( 'react' ); +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal dependencies */ -var FormRadio = require( 'components/forms/form-radio' ), +const FormRadio = require( 'components/forms/form-radio' ), Gridicon = require( 'components/gridicon' ), PostActions = require( 'lib/posts/actions' ), stats = require( 'lib/posts/stats' ), AccordionSection = require( 'components/accordion/section' ); +import { setPostFormat } from 'state/ui/editor/post/actions'; -module.exports = React.createClass( { +const EditorPostFormats = React.createClass( { displayName: 'EditorPostFormats', propTypes: { + setPostFormat: React.PropTypes.func, post: React.PropTypes.object, value: React.PropTypes.string, postFormats: React.PropTypes.arrayOf( React.PropTypes.shape( { @@ -26,6 +30,7 @@ module.exports = React.createClass( { getDefaultProps: function() { return { + setPostFormat: () => {}, value: 'standard' }; }, @@ -60,10 +65,13 @@ module.exports = React.createClass( { }, onChange: function( event ) { + // TODO: REDUX - remove flux actions when whole post-editor is reduxified PostActions.edit( { format: event.target.value } ); + this.props.setPostFormat( event.target.value ); + stats.recordStat( 'post_format_changed' ); stats.recordEvent( 'Changed Post Format', event.target.value ); }, @@ -100,3 +108,8 @@ module.exports = React.createClass( { ); } } ); + +export default connect( + null, + dispatch => bindActionCreators( { setPostFormat }, dispatch ) +)( EditorPostFormats ); diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index 2971d50424b650..88d8b23dd2e4de 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -94,7 +94,11 @@ export function setPageTemplate( newTemplate ) { debug( 'setPageTemplate', newTemplate ); return { type: 'TODO' }; } - + +export function setPostFormat( newFormat ) { + debug( 'setPostFormat', newFormat ); + return { type: 'TODO' }; +} export const EDITING_MODES = { EXISTING: 'EDITING_MODE_EXISTING', From 7a60820d8158e1fe69d1a93c30f938ebaac516af Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 19:11:08 -0500 Subject: [PATCH 09/22] publicize-connection --- .../editor-sharing/publicize-connection.jsx | 20 ++++++++++++++++++- client/state/ui/editor/post/actions.js | 11 ++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/client/post-editor/editor-sharing/publicize-connection.jsx b/client/post-editor/editor-sharing/publicize-connection.jsx index 021f7397ce4b95..043f126bef9e1a 100644 --- a/client/post-editor/editor-sharing/publicize-connection.jsx +++ b/client/post-editor/editor-sharing/publicize-connection.jsx @@ -3,6 +3,8 @@ */ import React, { PropTypes } from 'react'; import includes from 'lodash/collection/includes'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal dependencies @@ -13,11 +15,14 @@ import PostActions from 'lib/posts/actions'; import * as PostStats from 'lib/posts/stats'; import Notice from 'components/notice'; import Gridicon from 'components/gridicon'; +import { addPublicizeConnectionKey, removePublicizeConnectionKey } from 'state/ui/editor/post/actions'; -export default React.createClass( { +const EditorSharingPublicizeConnection = React.createClass( { displayName: 'EditorSharingPublicizeConnection', propTypes: { + addPublicizeConnectionKey: PropTypes.func, + removePublicizeConnectionKey: PropTypes.func, post: PropTypes.object, connection: PropTypes.object, onRefresh: PropTypes.func @@ -25,6 +30,8 @@ export default React.createClass( { getDefaultProps() { return { + addPublicizeConnectionKey: () => {}, + removePublicizeConnectionKey: () => {}, onRefresh: () => {} }; }, @@ -51,13 +58,19 @@ export default React.createClass( { } if ( event.target.checked ) { + // TODO: REDUX - remove flux actions when whole post-editor is reduxified PostActions.deleteMetadata( '_wpas_skip_' + connection.keyring_connection_ID ); PostStats.recordStat( 'sharing_enabled_' + connection.service ); PostStats.recordEvent( 'Publicize Service', connection.service, 'enabled' ); + + this.props.removePublicizeConnectionKey(); } else { + // TODO: REDUX - remove flux actions when whole post-editor is reduxified PostActions.updateMetadata( '_wpas_skip_' + connection.keyring_connection_ID, 1 ); PostStats.recordStat( 'sharing_disabled_' + connection.service ); PostStats.recordEvent( 'Publicize Service', connection.service, 'disabled' ); + + this.props.addPublicizeConnectionKey( connection.keyring_connection_ID ); } }, @@ -104,3 +117,8 @@ export default React.createClass( { ); } } ); + +export default connect( + null, + dispatch => bindActionCreators( { addPublicizeConnectionKey, removePublicizeConnectionKey }, dispatch ) +)( EditorSharingPublicizeConnection ); diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index 88d8b23dd2e4de..dd78b316d628b9 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -100,6 +100,17 @@ export function setPostFormat( newFormat ) { return { type: 'TODO' }; } +export function addPublicizeConnectionKey( newKeyID ) { + debug( 'addPublicizeConnectionKey', newKeyID ); + return { type: 'TODO' }; +} + +export function removePublicizeConnectionKey() { + debug( 'removePublicizeConnectionKey' ); + return { type: 'TODO' }; +} + + export const EDITING_MODES = { EXISTING: 'EDITING_MODE_EXISTING', NEW: 'EDITING_MODE_NEW' From 6791d681ada6bcb2fb6dceca4a96a6bc4adecfc3 Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 19:15:01 -0500 Subject: [PATCH 10/22] publicize-message --- .../editor-sharing/publicize-message.jsx | 19 ++++++++++++++++--- client/state/ui/editor/post/actions.js | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/client/post-editor/editor-sharing/publicize-message.jsx b/client/post-editor/editor-sharing/publicize-message.jsx index 50177ccdb9bbeb..3a9f0782f40a94 100644 --- a/client/post-editor/editor-sharing/publicize-message.jsx +++ b/client/post-editor/editor-sharing/publicize-message.jsx @@ -1,22 +1,26 @@ /** * External dependencies */ -var React = require( 'react' ); +const React = require( 'react' ); +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal dependencies */ -var CountedTextarea = require( 'components/forms/counted-textarea' ), +const CountedTextarea = require( 'components/forms/counted-textarea' ), FormTextarea = require( 'components/forms/form-textarea' ), PostActions = require( 'lib/posts/actions' ), stats = require( 'lib/posts/stats' ), TrackInputChanges = require( 'components/track-input-changes' ), InfoPopover = require( 'components/info-popover' ); +import { setPublicizeMessage } from 'state/ui/editor/post/actions'; -module.exports = React.createClass( { +const PublicizeMessage = React.createClass( { displayName: 'PublicizeMessage', propTypes: { + setPublicizeMessage: React.PropTypes.func, message: React.PropTypes.string, preview: React.PropTypes.string, acceptableLength: React.PropTypes.number, @@ -25,6 +29,7 @@ module.exports = React.createClass( { getDefaultProps: function() { return { + setPublicizeMessage: () => {}, message: '', acceptableLength: 140, requireCount: false, @@ -32,7 +37,10 @@ module.exports = React.createClass( { }, onChange: function( event ) { + // TODO: REDUX - remove flux actions when whole post-editor is reduxified PostActions.updateMetadata( '_wpas_mess', event.target.value ); + + this.props.setPublicizeMessage( event.target.value ); }, recordStats: function() { @@ -95,3 +103,8 @@ module.exports = React.createClass( { ); } } ); + +export default connect( + null, + dispatch => bindActionCreators( { setPublicizeMessage }, dispatch ) +)( PublicizeMessage ); diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index dd78b316d628b9..a54b0a52ac518c 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -110,6 +110,10 @@ export function removePublicizeConnectionKey() { return { type: 'TODO' }; } +export function setPublicizeMessage( newMessage ) { + debug( 'setPublicizeMessage', newMessage ); + return { type: 'TODO' }; +} export const EDITING_MODES = { EXISTING: 'EDITING_MODE_EXISTING', From f8886abf94da5c52c8235049ba002f2511e8820d Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 19:23:28 -0500 Subject: [PATCH 11/22] sharing-like-options --- .../editor-sharing/sharing-like-options.jsx | 24 ++++++++++++++++--- client/state/ui/editor/post/actions.js | 7 +++++- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/client/post-editor/editor-sharing/sharing-like-options.jsx b/client/post-editor/editor-sharing/sharing-like-options.jsx index 70470f2a3fd342..955cfc8b86b4f7 100644 --- a/client/post-editor/editor-sharing/sharing-like-options.jsx +++ b/client/post-editor/editor-sharing/sharing-like-options.jsx @@ -1,20 +1,24 @@ /** * External dependencies */ -var React = require( 'react' ); +const React = require( 'react' ); +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal dependencies */ -var EditorFieldset = require( 'post-editor/editor-fieldset' ), +const EditorFieldset = require( 'post-editor/editor-fieldset' ), FormCheckbox = require( 'components/forms/form-checkbox' ), PostActions = require( 'lib/posts/actions' ), stats = require( 'lib/posts/stats' ); +import { setSharingLikeOption } from 'state/ui/editor/post/actions'; -module.exports = React.createClass( { +const SharingLikeOptions = React.createClass( { displayName: 'SharingLikeOptions', propTypes: { + setSharingLikeOption: React.PropTypes.func, site: React.PropTypes.object, post: React.PropTypes.object, isSharingButtonsEnabled: React.PropTypes.bool, @@ -22,6 +26,12 @@ module.exports = React.createClass( { isNew: React.PropTypes.bool }, + getDefaultProps: function() { + return { + setSharingLikeOption: () => {} + }; + }, + isShowingSharingButtons: function() { if ( this.props.post && 'sharing_enabled' in this.props.post ) { return this.props.post.sharing_enabled; @@ -79,11 +89,14 @@ module.exports = React.createClass( { }, onChange: function( event ) { + // TODO: REDUX - remove flux actions when whole post-editor is reduxified PostActions.edit( { [ event.target.name ]: event.target.checked } ); this.recordStats( event ); + + this.props.setSharingLikeOption( event.target.name, event.target.checked ); }, recordStats: function( event ) { @@ -109,3 +122,8 @@ module.exports = React.createClass( { ); } } ); + +export default connect( + null, + dispatch => bindActionCreators( { setSharingLikeOption }, dispatch ) +)( SharingLikeOptions ); \ No newline at end of file diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index a54b0a52ac518c..9b1c91996e024d 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -115,7 +115,12 @@ export function setPublicizeMessage( newMessage ) { return { type: 'TODO' }; } -export const EDITING_MODES = { +export function setSharingLikeOption( optionKey, optionValue ) { + debug( 'setSharingLikeOption', optionKey, optionValue ); + return { type: 'TODO' }; +} + +export const EDITING_MODES = EXISTING: 'EDITING_MODE_EXISTING', NEW: 'EDITING_MODE_NEW' }; From d723f398f53cb939d189ce4d50317d9da73d8c3d Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 19:55:39 -0500 Subject: [PATCH 12/22] editor-slug --- client/post-editor/editor-slug/index.jsx | 15 ++++++++++++++- client/state/ui/editor/post/actions.js | 5 +++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/client/post-editor/editor-slug/index.jsx b/client/post-editor/editor-slug/index.jsx index 152866264404a0..7a4388b09b2655 100644 --- a/client/post-editor/editor-slug/index.jsx +++ b/client/post-editor/editor-slug/index.jsx @@ -6,6 +6,8 @@ import React, { PropTypes } from 'react'; import PureRenderMixin from 'react-pure-render/mixin'; import classNames from 'classnames'; import noop from 'lodash/utility/noop'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal Dependencies @@ -14,13 +16,15 @@ import actions from 'lib/posts/actions'; import TrackInputChanges from 'components/track-input-changes'; import FormTextInput from 'components/forms/form-text-input'; import { recordStat, recordEvent } from 'lib/posts/stats'; +import { setSlug } from 'state/ui/editor/post/actions'; -export default React.createClass( { +const PostEditorSlug = React.createClass( { displayName: 'PostEditorSlug', mixins: [ PureRenderMixin ], propTypes: { + setSlug: PropTypes.func, path: PropTypes.string, slug: PropTypes.string, onEscEnter: PropTypes.func, @@ -32,6 +36,7 @@ export default React.createClass( { getDefaultProps() { return { + setSlug: () => {}, onEscEnter: noop, isEditable: true }; @@ -44,7 +49,10 @@ export default React.createClass( { }, onSlugChange( event ) { + // TODO: REDUX - remove flux actions when whole post-editor is reduxified actions.edit( { slug: event.target.value } ); + + this.props.setSlug( event.target.value ); }, onSlugKeyDown( event ) { @@ -127,3 +135,8 @@ export default React.createClass( { ); } } ); + +export default connect( + null, + dispatch => bindActionCreators( { setSlug }, dispatch ) +)( PostEditorSlug ); diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index 9b1c91996e024d..a55f685cd34798 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -120,6 +120,11 @@ export function setSharingLikeOption( optionKey, optionValue ) { return { type: 'TODO' }; } +export function setSlug( newSlug ) { + debug( 'setSlug', newSlug ); + return { type: 'TODO' }; +} + export const EDITING_MODES = EXISTING: 'EDITING_MODE_EXISTING', NEW: 'EDITING_MODE_NEW' From fa0d43eeac071c5338efc8bccecbb5a0cf7a8a81 Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 19:59:47 -0500 Subject: [PATCH 13/22] editor-tags --- client/post-editor/editor-tags/index.jsx | 20 +++++++++++++++++++- client/state/ui/editor/post/actions.js | 5 +++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/client/post-editor/editor-tags/index.jsx b/client/post-editor/editor-tags/index.jsx index 1b463e49145426..21aeb2c9709fc3 100644 --- a/client/post-editor/editor-tags/index.jsx +++ b/client/post-editor/editor-tags/index.jsx @@ -4,6 +4,8 @@ import React from 'react'; import unescapeString from 'lodash/string/unescape'; import _debug from 'debug'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal dependencies @@ -14,19 +16,27 @@ import PostActions from 'lib/posts/actions'; import { recordStat, recordEvent } from 'lib/posts/stats'; import { isPage } from 'lib/posts/utils'; import InfoPopover from 'components/info-popover'; +import { setTags } from 'state/ui/editor/post/actions'; const debug = _debug( 'calypso:post-editor:editor-tags' ); -module.exports = React.createClass( { +const EditorTags = React.createClass( { displayName: 'EditorTags', propTypes: { + setTags: React.PropTypes.func, post: React.PropTypes.object, tags: React.PropTypes.arrayOf( React.PropTypes.object ), tagsHasNextPage: React.PropTypes.bool, tagsFetchingNextPage: React.PropTypes.bool }, + getDefaultProps: function() { + return { + setTags: () => {}, + }; + }, + onTagsChange: function( selectedTags ) { var tagStat, tagEventLabel; @@ -44,9 +54,12 @@ module.exports = React.createClass( { recordEvent( 'Changed Tags', tagEventLabel ); selectedTags = selectedTags.length ? selectedTags : null; + // TODO: REDUX - remove flux actions when whole post-editor is reduxified PostActions.edit( { tags: selectedTags } ); + + this.props.setTags( selectedTags ); }, getPostTags: function() { @@ -87,3 +100,8 @@ module.exports = React.createClass( { ); } } ); + +export default connect( + null, + dispatch => bindActionCreators( { setTags }, dispatch ) +)( EditorTags ); diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index a55f685cd34798..d1558d3a697a97 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -125,6 +125,11 @@ export function setSlug( newSlug ) { return { type: 'TODO' }; } +export function setTags( newTags ) { + debug( 'setTags', newTags ); + return { type: 'TODO' }; +} + export const EDITING_MODES = EXISTING: 'EDITING_MODE_EXISTING', NEW: 'EDITING_MODE_NEW' From bb89a902ee1cbcaeac954df42dce34144de389b0 Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 20:00:40 -0500 Subject: [PATCH 14/22] Add proper closing bracelet in editor actions --- .../post-editor/editor-sharing/npm-debug.log | 27 +++++++++++++++++++ client/state/ui/editor/post/actions.js | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 client/post-editor/editor-sharing/npm-debug.log diff --git a/client/post-editor/editor-sharing/npm-debug.log b/client/post-editor/editor-sharing/npm-debug.log new file mode 100644 index 00000000000000..fbe96db7cd6d47 --- /dev/null +++ b/client/post-editor/editor-sharing/npm-debug.log @@ -0,0 +1,27 @@ +0 info it worked if it ends with ok +1 verbose cli [ '/usr/local/Cellar/node/5.1.0/bin/node', +1 verbose cli '/usr/local/bin/npm', +1 verbose cli 'run', +1 verbose cli 'build' ] +2 info using npm@3.5.2 +3 info using node@v5.1.0 +4 verbose stack Error: missing script: build +4 verbose stack at run (/usr/local/lib/node_modules/npm/lib/run-script.js:147:19) +4 verbose stack at /usr/local/lib/node_modules/npm/lib/run-script.js:57:5 +4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:345:5 +4 verbose stack at checkBinReferences_ (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:309:45) +4 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:343:3) +4 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:113:5) +4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:232:12 +4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:76:16 +4 verbose stack at tryToString (fs.js:414:3) +4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:401:12) +5 verbose cwd /Users/Artpi/GIT/calypso/client/post-editor/editor-sharing +6 error Darwin 15.2.0 +7 error argv "/usr/local/Cellar/node/5.1.0/bin/node" "/usr/local/bin/npm" "run" "build" +8 error node v5.1.0 +9 error npm v3.5.2 +10 error missing script: build +11 error If you need help, you may report this error at: +11 error +12 verbose exit [ 1, true ] diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index d1558d3a697a97..3159dced0c4d12 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -130,7 +130,7 @@ export function setTags( newTags ) { return { type: 'TODO' }; } -export const EDITING_MODES = +export const EDITING_MODES = { EXISTING: 'EDITING_MODE_EXISTING', NEW: 'EDITING_MODE_NEW' }; From b1010bc45aa6842aab163ee780cd5a242e2dba51 Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 20:07:36 -0500 Subject: [PATCH 15/22] editor-title --- client/post-editor/editor-title/index.jsx | 16 ++++++++++++++-- client/state/ui/editor/post/actions.js | 5 +++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/client/post-editor/editor-title/index.jsx b/client/post-editor/editor-title/index.jsx index bde51554bc12e8..5a0b64d5eb86fa 100644 --- a/client/post-editor/editor-title/index.jsx +++ b/client/post-editor/editor-title/index.jsx @@ -4,6 +4,8 @@ import React, { PropTypes } from 'react'; import classNames from 'classnames'; import omit from 'lodash/object/omit'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal dependencies @@ -16,11 +18,13 @@ import TrackInputChanges from 'components/track-input-changes'; import FormTextInput from 'components/forms/form-text-input'; import { isMobile } from 'lib/viewport'; import * as stats from 'lib/posts/stats'; +import { setTitle } from 'state/ui/editor/post/actions'; -export default React.createClass( { +const EditorTitle = React.createClass( { displayName: 'EditorTitle', propTypes: { + setTitle: PropTypes.func, post: PropTypes.object, site: PropTypes.object, isNew: PropTypes.bool, @@ -36,7 +40,8 @@ export default React.createClass( { getDefaultProps() { return { isNew: true, - onChange: () => {} + onChange: () => {}, + setTitle: () => {}, }; }, @@ -64,10 +69,12 @@ export default React.createClass( { return; } + // TODO: REDUX - remove flux actions when whole post-editor is reduxified PostActions.edit( { title: event.target.value } ); + this.props.setTitle( event.target.value ); onChange( event ); }, @@ -127,3 +134,8 @@ export default React.createClass( { ); } } ); + +export default connect( + null, + dispatch => bindActionCreators( { setTitle }, dispatch ) +)( EditorTitle ); diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index 3159dced0c4d12..906f63e1ef8bec 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -130,6 +130,11 @@ export function setTags( newTags ) { return { type: 'TODO' }; } +export function setTitle( newTitle ) { + debug( 'setTitle', newTitle ); + return { type: 'TODO' }; +} + export const EDITING_MODES = { EXISTING: 'EDITING_MODE_EXISTING', NEW: 'EDITING_MODE_NEW' From 59d65f0ca3ef72838efef8801d6b1bd3c59bc6c8 Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 9 Feb 2016 21:00:51 -0500 Subject: [PATCH 16/22] editor-visibility --- .../post-editor/editor-visibility/index.jsx | 39 ++++++++++++++++++- client/state/ui/editor/post/actions.js | 20 ++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/client/post-editor/editor-visibility/index.jsx b/client/post-editor/editor-visibility/index.jsx index 311014d5c75d14..374d84640df881 100644 --- a/client/post-editor/editor-visibility/index.jsx +++ b/client/post-editor/editor-visibility/index.jsx @@ -5,6 +5,8 @@ import ReactDom from 'react-dom'; import React from 'react'; import includes from 'lodash/collection/includes'; import classNames from 'classnames'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal dependencies @@ -23,19 +25,33 @@ import Tooltip from 'components/tooltip'; import postActions from 'lib/posts/actions'; import { recordEvent, recordStat } from 'lib/posts/stats'; import accept from 'lib/accept'; +import { + setPostPassword, + setPostPasswordProtected, + setPostPrivate, + setPostPublic +} from 'state/ui/editor/post/actions'; -module.exports = React.createClass( { +const EditorVisibility = React.createClass( { displayName: 'EditorVisibility', showingAcceptDialog: false, getDefaultProps() { return { - isPrivateSite: false + isPrivateSite: false, + setPostPassword: () => {}, + setPostPasswordProtected: () => {}, + setPostPrivate: () => {}, + setPostPublic: () => {}, }; }, propTypes: { + setPostPassword: React.PropTypes.func, + setPostPasswordProtected: React.PropTypes.func, + setPostPrivate: React.PropTypes.func, + setPostPublic: React.PropTypes.func, visibility: React.PropTypes.string, onPrivatePublish: React.PropTypes.func, isPrivateSite: React.PropTypes.bool, @@ -160,10 +176,12 @@ module.exports = React.createClass( { switch ( newVisibility ) { case 'public': postEdits.password = ''; + this.props.setPostPublic(); break; case 'password': postEdits.password = this.props.savedPassword || ' '; + this.props.setPostPasswordProtected( postEdits.password ); break; } @@ -172,6 +190,7 @@ module.exports = React.createClass( { recordStat( 'visibility-set-' + newVisibility ); recordEvent( 'Changed visibility', newVisibility ); + // TODO: REDUX - remove flux actions when whole post-editor is reduxified postActions.edit( postEdits ); }, @@ -191,6 +210,7 @@ module.exports = React.createClass( { }, setPostToPrivate() { + // TODO: REDUX - remove flux actions when whole post-editor is reduxified postActions.edit( { password: '', status: 'private' @@ -200,6 +220,8 @@ module.exports = React.createClass( { recordStat( 'visibility-set-private' ); recordEvent( 'Changed visibility', 'private' ); + + this.props.setPostPrivate(); }, onPrivatePublish() { @@ -237,9 +259,12 @@ module.exports = React.createClass( { onPasswordChange( event ) { var newPassword = event.target.value.trim(); + // TODO: REDUX - remove flux actions when whole post-editor is reduxified postActions.edit( { password: newPassword } ); this.setState( { passwordIsValid: newPassword.length > 0 } ); + + this.props.setPostPassword( newPassword ); }, renderPasswordInput() { @@ -390,3 +415,13 @@ module.exports = React.createClass( { } } ); + +export default connect( + null, + dispatch => bindActionCreators( { + setPostPassword, + setPostPasswordProtected, + setPostPrivate, + setPostPublic + }, dispatch ) +)( EditorVisibility ); diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index 906f63e1ef8bec..fcef53d9ceba62 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -135,6 +135,26 @@ export function setTitle( newTitle ) { return { type: 'TODO' }; } +export function setPostPublic() { + debug( 'setPostPublic' ); + return { type: 'TODO' }; +} + +export function setPostPrivate() { + debug( 'setPostPrivate' ); + return { type: 'TODO' }; +} + +export function setPostPassword( newPassword ) { + debug( 'setPostPassword', newPassword ); + return { type: 'TODO' }; +} + +export function setPostPasswordProtected( newPassword ) { + debug( 'setPostPasswordProtected', newPassword ); + return { type: 'TODO' }; +} + export const EDITING_MODES = { EXISTING: 'EDITING_MODE_EXISTING', NEW: 'EDITING_MODE_NEW' From 37fd9f0db6c3dd17186efb27e46e6681e663da09 Mon Sep 17 00:00:00 2001 From: artpi Date: Wed, 10 Feb 2016 02:46:17 -0500 Subject: [PATCH 17/22] publicize-connection tests --- .../editor-sharing/test/specs/publicize-connection.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/post-editor/editor-sharing/test/specs/publicize-connection.jsx b/client/post-editor/editor-sharing/test/specs/publicize-connection.jsx index 4ee087904d84b4..d6b7b67ea05124 100644 --- a/client/post-editor/editor-sharing/test/specs/publicize-connection.jsx +++ b/client/post-editor/editor-sharing/test/specs/publicize-connection.jsx @@ -11,7 +11,7 @@ var ReactDom = require( 'react-dom' ), /** * Internal dependencies */ -var PublicizeConnection = require( '../../publicize-connection' ); +var PublicizeConnection = require( '../../publicize-connection' ).WrappedComponent; /** * Module variables From af83ce0762c333a04c80409242d4326233ac0fd3 Mon Sep 17 00:00:00 2001 From: artpi Date: Wed, 10 Feb 2016 05:57:28 -0500 Subject: [PATCH 18/22] post-editor.jsx --- client/post-editor/post-editor.jsx | 102 +++++++++++++++++++++++-- client/state/ui/editor/post/actions.js | 30 ++++++++ 2 files changed, 125 insertions(+), 7 deletions(-) diff --git a/client/post-editor/post-editor.jsx b/client/post-editor/post-editor.jsx index 465efc270b06e8..b36b896401ac39 100644 --- a/client/post-editor/post-editor.jsx +++ b/client/post-editor/post-editor.jsx @@ -1,7 +1,7 @@ /** * External dependencies */ -var ReactDom = require( 'react-dom' ), +const ReactDom = require( 'react-dom' ), React = require( 'react' ), debug = require( 'debug' )( 'calypso:post-editor' ), page = require( 'page' ), @@ -9,11 +9,12 @@ var ReactDom = require( 'react-dom' ), debounce = require( 'lodash/function/debounce' ), throttle = require( 'lodash/function/throttle' ), assign = require( 'lodash/object/assign' ); - +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; /** * Internal dependencies */ -var actions = require( 'lib/posts/actions' ), +const actions = require( 'lib/posts/actions' ), config = require( 'config' ), route = require( 'lib/route' ), PostEditStore = require( 'lib/posts/post-edit-store' ), @@ -48,8 +49,20 @@ var actions = require( 'lib/posts/actions' ), stats = require( 'lib/posts/stats' ), analytics = require( 'analytics' ), postTypesList = require( 'lib/post-types-list')(); - -var messages = { +import { + setContent, + setExcerpt, + stopEditing, + setTitle, + setRawContent, + save, + autosave, + setPostPrivate, + setPostPublished, + resetRawContent +} from 'state/ui/editor/post/actions'; + +const messages = { post: { publishFailure: function() { return i18n.translate( 'Publishing of post failed.' ); @@ -164,12 +177,37 @@ var messages = { } }; -var PostEditor = React.createClass( { +const PostEditor = React.createClass( { propTypes: { + setContent: React.PropTypes.func, + setExcerpt: React.PropTypes.func, + stopEditing: React.PropTypes.func, + setTitle: React.PropTypes.func, + setRawContent: React.PropTypes.func, + save: React.PropTypes.func, + autosave: React.PropTypes.func, + setPostPrivate: React.PropTypes.func, + setPostPublished: React.PropTypes.func, + resetRawContent: React.PropTypes.func, preferences: React.PropTypes.object, sites: React.PropTypes.object }, + getDefaultProps: function() { + return { + setContent: () => {}, + setExcerpt: () => {}, + stopEditing: () => {}, + setTitle: () => {}, + setRawContent: () => {}, + save: () => {}, + autosave: () => {}, + setPostPrivate: () => {}, + setPostPublished: () => {}, + resetRawContent: () => {} + }; + }, + _previewWindow: null, mixins: [ @@ -223,7 +261,10 @@ var PostEditor = React.createClass( { componentWillUnmount: function() { PostEditStore.removeListener( 'change', this.onEditedPostChange ); + // TODO: REDUX - remove flux actions when whole post-editor is reduxified actions.stopEditing(); + + this.props.stopEditing(); this.debouncedAutosave.cancel(); this.debouncedSaveRawContent.cancel(); this._previewWindow = null; @@ -451,7 +492,12 @@ var PostEditor = React.createClass( { content: autosave.content }; + // TODO: REDUX - remove flux actions when whole post-editor is reduxified actions.edit( edits ); + + this.props.setTitle( autosave.title ); + this.props.setExcerpt( autosave.excerpt ); + this.props.setContent( autosave.content ); }, closeAutosaveDialog: function() { @@ -524,7 +570,10 @@ var PostEditor = React.createClass( { }, saveRawContent: function() { + // TODO: REDUX - remove flux actions when whole post-editor is reduxified actions.editRawContent( this.refs.editor.getContent( { format: 'raw' } ) ); + + this.props.setRawContent( this.refs.editor.getContent( { format: 'raw' } ) ); }, autosave: function() { @@ -535,8 +584,11 @@ var PostEditor = React.createClass( { } this.saveRawContent(); + // TODO: REDUX - remove flux actions when whole post-editor is reduxified actions.edit( { content: this.refs.editor.getContent() } ); + this.props.setContent( this.refs.editor.getContent() ); + // Make sure that after TinyMCE processing that the post is still dirty if ( ! PostEditStore.isDirty() || ! PostEditStore.hasContent() || ! this.state.post ) { return; @@ -554,7 +606,9 @@ var PostEditor = React.createClass( { } }.bind( this ); } + this.props.autosave( callback ); + // TODO: REDUX - remove flux actions when whole post-editor is reduxified actions.autosave( callback ); }, @@ -605,6 +659,10 @@ var PostEditor = React.createClass( { edits.content = this.refs.editor.getContent(); + this.props.setContent( edits.content ); + this.props.save(); + + // TODO: REDUX - remove flux actions when whole post-editor is reduxified actions.saveEdited( edits, function( error ) { if ( error && 'NO_CHANGE' !== error.message ) { this.onSaveDraftFailure( error ); @@ -646,6 +704,10 @@ var PostEditor = React.createClass( { }.bind( this ); if ( status === 'publish' ) { + this.props.setContent( this.refs.editor.getContent() ); + this.props.autosave( previewPost ); + + // TODO: REDUX - remove flux actions when whole post-editor is reduxified actions.edit( { content: this.refs.editor.getContent() } ); actions.autosave( previewPost ); } else { @@ -714,12 +776,18 @@ var PostEditor = React.createClass( { // determine if this is a private publish if ( utils.isPrivate( this.state.post ) ) { edits.status = 'private'; + this.props.setPostPrivate(); + } else { + this.props.setPostPublished(); } // Update content on demand to avoid unnecessary lag and because it is expensive // to serialize when TinyMCE is the active mode edits.content = this.refs.editor.getContent(); + this.props.setContent( edits.content ); + this.props.save(); + actions.saveEdited( edits, function( error ) { if ( error && 'NO_CHANGE' !== error.message ) { this.onPublishFailure( error ); @@ -834,18 +902,38 @@ var PostEditor = React.createClass( { // dispatching inside a dispatch which can happen if for example the // title field is focused when toggling the editor. this._switchEditorTimeout = setTimeout( function() { + // TODO: REDUX - remove flux actions when whole post-editor is reduxified actions.edit( { content: content } ); actions.resetRawContent(); + this.props.setContent( content ); + this.props.resetRawContent(); + if ( mode === 'html' ) { // Set raw content directly to avoid race conditions actions.editRawContent( content ); + this.props.setRawContent( content ); } else { this.saveRawContent(); + this.props.save(); } }.bind( this ), 0 ); } } ); -module.exports = PostEditor; +export default connect( + null, + dispatch => bindActionCreators( { + setContent, + setExcerpt, + stopEditing, + setTitle, + setRawContent, + save, + autosave, + setPostPrivate, + setPostPublished, + resetRawContent + }, dispatch ) +)( PostEditor ); diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index fcef53d9ceba62..593a15d3af8b0b 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -155,6 +155,36 @@ export function setPostPasswordProtected( newPassword ) { return { type: 'TODO' }; } +export function setContent( newContent ) { + debug( 'setContent', newContent ); + return { type: 'TODO' }; +} + +export function setRawContent( htmlContent ) { + debug( 'setRawContent', htmlContent ); + return { type: 'TODO' }; +} + +export function stopEditing() { + debug( 'stopEditing' ); + return { type: 'TODO' }; +} + +export function save( callback ) { + debug( 'save', callback ); + return { type: 'TODO' }; +} + +export function autosave( callback ) { + debug( 'autosave', callback ); + return { type: 'TODO' }; +} + +export function setPostPublished() { + debug( 'setPostPublished' ); + return { type: 'TODO' }; +} + export const EDITING_MODES = { EXISTING: 'EDITING_MODE_EXISTING', NEW: 'EDITING_MODE_NEW' From c9cc6ed45884fb5cd4669f58ee246aeb3b57182e Mon Sep 17 00:00:00 2001 From: artpi Date: Wed, 10 Feb 2016 14:04:54 +0100 Subject: [PATCH 19/22] Remove log that shouldnt be here --- .../post-editor/editor-sharing/npm-debug.log | 27 ------------------- 1 file changed, 27 deletions(-) delete mode 100644 client/post-editor/editor-sharing/npm-debug.log diff --git a/client/post-editor/editor-sharing/npm-debug.log b/client/post-editor/editor-sharing/npm-debug.log deleted file mode 100644 index fbe96db7cd6d47..00000000000000 --- a/client/post-editor/editor-sharing/npm-debug.log +++ /dev/null @@ -1,27 +0,0 @@ -0 info it worked if it ends with ok -1 verbose cli [ '/usr/local/Cellar/node/5.1.0/bin/node', -1 verbose cli '/usr/local/bin/npm', -1 verbose cli 'run', -1 verbose cli 'build' ] -2 info using npm@3.5.2 -3 info using node@v5.1.0 -4 verbose stack Error: missing script: build -4 verbose stack at run (/usr/local/lib/node_modules/npm/lib/run-script.js:147:19) -4 verbose stack at /usr/local/lib/node_modules/npm/lib/run-script.js:57:5 -4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:345:5 -4 verbose stack at checkBinReferences_ (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:309:45) -4 verbose stack at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:343:3) -4 verbose stack at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:113:5) -4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:232:12 -4 verbose stack at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:76:16 -4 verbose stack at tryToString (fs.js:414:3) -4 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:401:12) -5 verbose cwd /Users/Artpi/GIT/calypso/client/post-editor/editor-sharing -6 error Darwin 15.2.0 -7 error argv "/usr/local/Cellar/node/5.1.0/bin/node" "/usr/local/bin/npm" "run" "build" -8 error node v5.1.0 -9 error npm v3.5.2 -10 error missing script: build -11 error If you need help, you may report this error at: -11 error -12 verbose exit [ 1, true ] From 0f662cef812b766f517caa33566f4327eaefe2e6 Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 16 Feb 2016 00:17:02 +0100 Subject: [PATCH 20/22] postDate format information --- client/state/ui/editor/post/actions.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index 593a15d3af8b0b..9d5ed0734e7461 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -66,7 +66,8 @@ export function removeFeaturedImage() { } export function setDate( postDate ) { - debug( 'setDate', postDate ); + //Previous action was sending it formatted + debug( 'setDate', postDate, ( postDate ? postDate.format() : null ) ); return { type: 'TODO' }; } From 962a4bd0c0addff3f23f583c3e47cbd5a339ed4f Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 16 Feb 2016 13:00:07 +0100 Subject: [PATCH 21/22] Add missing export for resetRawContent --- client/state/ui/editor/post/actions.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/state/ui/editor/post/actions.js b/client/state/ui/editor/post/actions.js index 9d5ed0734e7461..31006372117a46 100644 --- a/client/state/ui/editor/post/actions.js +++ b/client/state/ui/editor/post/actions.js @@ -166,6 +166,11 @@ export function setRawContent( htmlContent ) { return { type: 'TODO' }; } +export function resetRawContent() { + debug( 'resetRawContent' ); + return { type: 'TODO' }; +} + export function stopEditing() { debug( 'stopEditing' ); return { type: 'TODO' }; From 2f78c97c168f09c910e6aab8e3f7204b66085d40 Mon Sep 17 00:00:00 2001 From: artpi Date: Tue, 16 Feb 2016 13:02:58 +0100 Subject: [PATCH 22/22] Add defaultProps and proptypes for setFeaturedImage --- .../editor-featured-image/preview-container.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/post-editor/editor-featured-image/preview-container.jsx b/client/post-editor/editor-featured-image/preview-container.jsx index 70b18a1e4a3cdf..2c65dc80faac85 100644 --- a/client/post-editor/editor-featured-image/preview-container.jsx +++ b/client/post-editor/editor-featured-image/preview-container.jsx @@ -18,6 +18,7 @@ const EditorFeaturedImagePreviewContainer = React.createClass( { displayName: 'EditorFeaturedImagePreviewContainer', propTypes: { + setFeaturedImage: PropTypes.func, siteId: PropTypes.number.isRequired, itemId: PropTypes.oneOfType( [ PropTypes.number, @@ -26,6 +27,12 @@ const EditorFeaturedImagePreviewContainer = React.createClass( { maxWidth: PropTypes.number }, + getDefaultProps: function() { + return { + setFeaturedImage: () => {} + }; + }, + getInitialState: function() { return { image: null