Skip to content

Commit b3461bc

Browse files
coder-karenmatticbot
authored andcommitted
Connector: improve connection and disconnection flows (#47902)
Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/23938692821 Upstream-Ref: Automattic/jetpack@3db4980
1 parent b5820c9 commit b3461bc

File tree

7 files changed

+169
-146
lines changed

7 files changed

+169
-146
lines changed

jetpack_vendor/automattic/jetpack-connection/src/connectors/class-wpcom-connector.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ class Wpcom_Connector {
3535
*/
3636
const MODULE_ID = '@automattic/jetpack-connection-connectors';
3737

38+
/**
39+
* Screen ID assigned by WordPress to the Gutenberg plugin's connectors submenu page.
40+
*
41+
* @var string
42+
*/
43+
const GUTENBERG_CONNECTORS_SCREEN_ID = 'settings_page_options-connectors-wp-admin';
44+
45+
/**
46+
* Page slug registered by the Gutenberg plugin for the connectors submenu page.
47+
*
48+
* @var string
49+
*/
50+
const GUTENBERG_CONNECTORS_PAGE_SLUG = 'options-connectors-wp-admin';
51+
3852
/**
3953
* Initialize the connector.
4054
*/
@@ -277,7 +291,7 @@ private static function resolve_user_fields( $wp_user, $wpcom_user_data ) {
277291
*/
278292
private static function is_connectors_screen( $screen ) {
279293
return 'options-connectors' === $screen->id
280-
|| 'settings_page_options-connectors-wp-admin' === $screen->id;
294+
|| static::GUTENBERG_CONNECTORS_SCREEN_ID === $screen->id;
281295
}
282296

283297
/**
@@ -289,6 +303,11 @@ private static function is_connectors_screen( $screen ) {
289303
* `options-general.php` for menu highlighting, so we distinguish them by
290304
* checking the actual script filename being served.
291305
*
306+
* Note: for the Gutenberg case we use the registered page slug directly,
307+
* not `$screen->id`. WordPress auto-prefixes screen IDs for submenu pages
308+
* (e.g. `settings_page_options-connectors-wp-admin`), so using `$screen->id`
309+
* as the `page=` parameter produces an invalid URL.
310+
*
292311
* The result is suitable for the `redirect_uri` parameter accepted by the
293312
* `jetpack/v4/connection/register` REST endpoint (which wraps it in `admin_url()`).
294313
*
@@ -304,8 +323,8 @@ private static function get_connectors_page_path() {
304323

305324
// Gutenberg plugin registers the page under options-general.php.
306325
$screen = get_current_screen();
307-
if ( $screen ) {
308-
return 'options-general.php?page=' . rawurlencode( $screen->id );
326+
if ( $screen && static::GUTENBERG_CONNECTORS_SCREEN_ID === $screen->id ) {
327+
return 'options-general.php?page=' . static::GUTENBERG_CONNECTORS_PAGE_SLUG;
309328
}
310329

311330
return 'options-connectors.php';

jetpack_vendor/automattic/jetpack-connection/src/connectors/js/connectors-card.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -519,18 +519,22 @@ function ExpandedDetails( { isConnecting = false, onConnect = null } ) {
519519
};
520520

521521
const handleUnlinkUser = () => {
522-
if ( currentUser?.isOwner && currentUser?.hasOtherConnectedUsers ) {
523-
setPendingConfirm( {
524-
title: __( 'Disconnect user account', 'jetpack-connection' ),
525-
message: __(
526-
'Disconnecting the owner account will remove the WordPress.com account connection for all users on this site. The site will remain connected to WordPress.com.',
527-
'jetpack-connection'
528-
),
529-
onConfirm: executeUnlinkUser,
530-
} );
531-
} else {
532-
executeUnlinkUser();
533-
}
522+
const message =
523+
currentUser?.isOwner && currentUser?.hasOtherConnectedUsers
524+
? __(
525+
'Disconnecting the owner account will remove the WordPress.com account connection for all users on this site. The site will remain connected to WordPress.com.',
526+
'jetpack-connection'
527+
)
528+
: __(
529+
'Are you sure you want to disconnect your WordPress.com account? The site will remain connected to WordPress.com.',
530+
'jetpack-connection'
531+
);
532+
533+
setPendingConfirm( {
534+
title: __( 'Disconnect user account', 'jetpack-connection' ),
535+
message,
536+
onConfirm: executeUnlinkUser,
537+
} );
534538
};
535539

536540
return createElement(

jetpack_vendor/i18n-map.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
),
3535
'jetpack-connection' => array(
3636
'path' => 'jetpack_vendor/automattic/jetpack-connection',
37-
'ver' => '8.2.0-alpha1775120614',
37+
'ver' => '8.2.0-alpha1775202404',
3838
),
3939
'jetpack-explat' => array(
4040
'path' => 'jetpack_vendor/automattic/jetpack-explat',

0 commit comments

Comments
 (0)