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

Sharing: fix connecting conflicting accounts #12707

Merged
merged 2 commits into from
Apr 3, 2017
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
19 changes: 11 additions & 8 deletions client/my-sites/sharing/connections/account-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import classNames from 'classnames';
import { connect } from 'react-redux';
import { filter, find, identity, isEqual } from 'lodash';
import { localize } from 'i18n-calypso';
import Gridicon from 'gridicons';
import Notice from 'components/notice';

/**
* Internal dependencies
Expand Down Expand Up @@ -113,12 +113,21 @@ class AccountDialog extends Component {
const connectedAccounts = this.getAccountsByConnectedStatus( true );

if ( connectedAccounts.length ) {
const hasConflictingAccounts = this.isSelectedAccountConflicting();

return (
<div className="account-dialog__connected-accounts">
<h3 className="account-dialog__connected-accounts-heading">{ this.props.translate( 'Connected' ) }</h3>
<ul className="account-dialog__accounts">
{ this.getAccountElements( connectedAccounts ) }
</ul>
{ hasConflictingAccounts &&
<Notice
status="is-warning"
icon="notice"
text={ this.props.translate( 'The marked connection will be replaced with your selection.' ) }
isCompact />
Copy link
Contributor

Choose a reason for hiding this comment

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

Would we have needed to apply showDismiss={ false } since the default is true and previously we'd disabled it? Or are styles hiding the dismiss?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at https://wpcalypso.wordpress.com/devdocs/design/notices I don't believe compact notices have a dismiss option, I could add it if it's more clear

}
</div>
);
}
Expand Down Expand Up @@ -152,13 +161,6 @@ class AccountDialog extends Component {
{ action: 'connect', label: this.props.translate( 'Connect' ), isPrimary: true }
];

if ( this.isSelectedAccountConflicting() ) {
this.props.warningNotice( this.props.translate( 'The connection marked {{icon/}} will be replaced with your selection.', {
components: { icon: <Gridicon icon="notice" size={ 18 } /> },
context: 'Sharing: Publicize confirmation',
} ), { showDismiss: false } );
}

return (
<Dialog isVisible={ this.props.isVisible } buttons={ buttons } additionalClassNames={ classes } onClose={ this.onClose }>
<h2 className="account-dialog__authorizing-service">
Expand All @@ -170,6 +172,7 @@ class AccountDialog extends Component {
<p className="account-dialog__authorizing-disclaimer">{ this.getDisclaimerText() }</p>
<ul className="account-dialog__accounts">{ this.getAccountElements( this.getAccountsByConnectedStatus( false ) ) }</ul>
{ this.getConnectedAccountsContent() }

</Dialog>
);
}
Expand Down
6 changes: 3 additions & 3 deletions client/my-sites/sharing/connections/service.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import React, { Component, PropTypes } from 'react';
import classnames from 'classnames';
import { connect } from 'react-redux';
import { identity, find, replace, some } from 'lodash';
import { identity, isEqual, find, replace, some } from 'lodash';
import { localize } from 'i18n-calypso';
import SocialLogo from 'social-logos';

Expand Down Expand Up @@ -234,15 +234,15 @@ class SharingService extends Component {
}

componentWillReceiveProps( nextProps ) {
if ( this.props.siteUserConnections.length !== nextProps.siteUserConnections.length ) {
if ( ! isEqual( this.props.siteUserConnections, nextProps.siteUserConnections ) ) {
this.setState( {
isConnecting: false,
isDisconnecting: false,
isSelectingAccount: false,
} );
}

if ( this.props.brokenConnections.length !== nextProps.brokenConnections.length ) {
if ( ! isEqual( this.props.brokenConnections, nextProps.brokenConnections ) ) {
this.setState( { isRefreshing: false } );
}

Expand Down