Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Update sharing container to use selected site from Redux state #756

Merged
merged 2 commits into from
Dec 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions client/my-sites/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var page = require( 'page' ),
var user = require( 'lib/user' )(),
sites = require( 'lib/sites-list' )(),
layoutFocus = require( 'lib/layout-focus' ),
sitesActions = require( 'state/sites/actions' ),
uiActions = require( 'state/ui/actions' ),
NavigationComponent = require( 'my-sites/navigation' ),
route = require( 'lib/route' ),
i18n = require( 'lib/mixins/i18n' ),
Expand Down Expand Up @@ -131,6 +133,13 @@ module.exports = {
return next();
}

function onSelectedSiteAvailable() {
var selectedSite = sites.getSelectedSite();
siteStatsStickyTabActions.saveFilterAndSlug( false, selectedSite.slug );
context.store.dispatch( sitesActions.receiveSite( selectedSite ) );
context.store.dispatch( uiActions.setSelectedSite( selectedSite.ID ) );
}

// If there's a valid site from the url path
// set site visibility to just that site on the picker
if ( ! sites.select( siteID ) ) {
Expand All @@ -146,10 +155,10 @@ module.exports = {
page.redirect( allSitesPath );
}

siteStatsStickyTabActions.saveFilterAndSlug( false, sites.getSelectedSite().slug );
onSelectedSiteAvailable();
} );
} else {
siteStatsStickyTabActions.saveFilterAndSlug( false, sites.getSelectedSite().slug );
onSelectedSiteAvailable();
}

next();
Expand Down
2 changes: 1 addition & 1 deletion client/post-editor/editor-drawer/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ var EditorDrawer = React.createClass( {
}

return (
<EditorSharingContainer site={ this.props.site } currentUserID={ currentUser.ID } />
<EditorSharingContainer currentUserID={ currentUser.ID } />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

);
},

Expand Down
9 changes: 6 additions & 3 deletions client/post-editor/editor-sharing/container.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { connect } from 'react-redux';
import PostEditStore from 'lib/posts/post-edit-store';
import { fetchConnections } from 'state/sharing/publicize/actions';
import { getConnectionsBySiteIdAvailableToCurrentUser, hasFetchedConnections } from 'state/sharing/publicize/selectors';
import { getSelectedSite } from 'state/ui/selectors';
import EditorSharingAccordion from './accordion';

class EditorSharingContainer extends Component {
Expand Down Expand Up @@ -88,10 +89,12 @@ EditorSharingContainer.propTypes = {
};

export default connect(
( state, props ) => {
( state, ownProps ) => {
const site = getSelectedSite( state );
return {
hasFetchedConnections: props.site && hasFetchedConnections( state, props.site.ID ),
connections: props.site ? getConnectionsBySiteIdAvailableToCurrentUser( state, props.site.ID, props.currentUserID ) : null
hasFetchedConnections: site && hasFetchedConnections( state, site.ID ),
connections: site ? getConnectionsBySiteIdAvailableToCurrentUser( state, site.ID, ownProps.currentUserID ) : null,
site
};
}
)( EditorSharingContainer );