Skip to content

Commit

Permalink
Social: Remove the flow to update broken connections directly from th…
Browse files Browse the repository at this point in the history
…e editor. (#35343)

* Social: don't allow reconnecting a broken connection from the editor.

* changelog

* Get rid of unused function.
  • Loading branch information
spsiddarthan authored Mar 4, 2024
1 parent cb7749f commit 06763c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 79 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: removed

Removed the flow to reconnect a broken social connection from the editor.
Original file line number Diff line number Diff line change
Expand Up @@ -8,95 +8,18 @@
* not render anything.
*/

import { Button, Notice } from '@wordpress/components';
import { compose } from '@wordpress/compose';
import { withDispatch, withSelect } from '@wordpress/data';
import { Component, Fragment } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { Component } from '@wordpress/element';
import { SOCIAL_STORE_ID } from '../../social-store';

class PublicizeConnectionVerify extends Component {
componentDidMount() {
this.props.refreshConnections();
}

/**
* Opens up popup so user can refresh connection
*
* Displays pop up with to specified URL where user
* can refresh a specific connection.
*
* @param {object} event - Event instance for onClick.
*/
refreshConnectionClick = event => {
const { href, title } = event.target;
event.preventDefault();
// open a popup window
// when it is closed, kick off the tests again
const popupWin = window.open( href, title, '' );
const popupTimer = window.setInterval( () => {
if ( false !== popupWin.closed ) {
window.clearInterval( popupTimer );
this.props.refreshConnections();
}
}, 500 );
};

renderRefreshableConnections() {
const { failedConnections } = this.props;
const refreshableConnections = failedConnections.filter( connection => connection.can_refresh );

if ( refreshableConnections.length ) {
return (
<Notice className="jetpack-publicize-notice" isDismissible={ false } status="error">
<p>
{ __(
'Before you hit Publish, please refresh the following connection(s) to make sure we can share your post:',
'jetpack'
) }
</p>
{ refreshableConnections.map( connection => (
<Button
href={ connection.refresh_url }
isSmall
key={ connection.id }
onClick={ this.refreshConnectionClick }
title={ connection.refresh_text }
>
{ connection.refresh_text }
</Button>
) ) }
</Notice>
);
}

return null;
}

renderNonRefreshableConnections() {
const { failedConnections } = this.props;
const nonRefreshableConnections = failedConnections.filter(
connection => ! connection.can_refresh
);

if ( nonRefreshableConnections.length ) {
return nonRefreshableConnections.map( connection => (
<Notice className="jetpack-publicize-notice" isDismissible={ false } status="error">
<p>{ connection.test_message }</p>
</Notice>
) );
}

return null;
}

render() {
return (
<Fragment>
{ this.renderRefreshableConnections() }
{ this.renderNonRefreshableConnections() }
</Fragment>
);
return null;
}
}

Expand Down

0 comments on commit 06763c3

Please sign in to comment.