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

Connection: improve connection info for multidomain setups #33857

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ const ConnectionStatusCard = props => {
[ onDisconnected, setConnectionStatus ]
);

/**
* Compare the two values and set IsMultidomain to true if they are the same
*/
const isMultidomain =
window.myJetpackInitialState.siteSuffix !== window.myJetpackInitialState.wpcomURLSuffix;

const isIDC = window.hasOwnProperty( 'JP_IDENTITY_CRISIS__INITIAL_STATE' ) ?? false;

return (
<div className={ styles[ 'connection-status-card' ] }>
<H3>{ title }</H3>
Expand All @@ -119,7 +127,7 @@ const ConnectionStatusCard = props => {
<img src={ cloud } alt="" className={ styles.cloud } />
<div
className={ classNames( styles.line, {
[ styles.disconnected ]: ! isRegistered || ! isUserConnected,
[ styles.disconnected ]: ! isRegistered || ! isUserConnected || isIDC,
} ) }
/>
<div className={ styles[ 'avatar-wrapper' ] }>
Expand All @@ -142,16 +150,44 @@ const ConnectionStatusCard = props => {
/>
) : (
<>
<ConnectionListItem
onClick={ openManageConnectionDialog }
text={ __( 'Site connected.', 'jetpack-my-jetpack' ) }
actionText={
isUserConnected && userConnectionData.currentUser?.isMaster
? __( 'Manage', 'jetpack-my-jetpack' )
: null
}
/>
{ isUserConnected && (
{ isIDC && (
<ConnectionListItem
text={ __( 'This site is in Safe Mode.', 'jetpack-my-jetpack' ) }
status="error"
/>
) }
{ isMultidomain && ! isIDC && (
<div>
<ConnectionListItem
text={ __( 'This site is using multiple domains.', 'jetpack-my-jetpack' ) }
/>
<ConnectionListItem
onClick={ openManageConnectionDialog }
text={ sprintf(
/* translators: placeholder is domain name */
__( 'Site connected as %s', 'jetpack-my-jetpack' ),
window.myJetpackInitialState.wpcomURL
) }
actionText={
isUserConnected && userConnectionData.currentUser?.isMaster
? __( 'Manage', 'jetpack-my-jetpack' )
: ' '
}
/>
</div>
) }
{ ! isMultidomain && ! isIDC && (
<ConnectionListItem
onClick={ openManageConnectionDialog }
text={ __( 'Site connected.', 'jetpack-my-jetpack' ) }
actionText={
isUserConnected && userConnectionData.currentUser?.isMaster
? __( 'Manage', 'jetpack-my-jetpack' )
: ' '
}
/>
) }
{ isUserConnected && ! isIDC && (
<ConnectionListItem
onClick={ openManageConnectionDialog }
actionText={ __( 'Manage', 'jetpack-my-jetpack' ) }
Expand All @@ -167,7 +203,8 @@ const ConnectionStatusCard = props => {
) }
{ isUserConnected &&
userConnectionData?.connectionOwner &&
! userConnectionData.currentUser?.isMaster && (
! userConnectionData.currentUser?.isMaster &&
! isIDC && (
<ConnectionListItem
text={ sprintf(
/* translators: placeholder is the username of the Jetpack connection owner */
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Connection: improve connection card for multidomain setups.
2 changes: 2 additions & 0 deletions projects/packages/my-jetpack/src/class-initializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,8 @@ public static function enqueue_scripts() {
'isEnabled' => Jetpack_Manage::could_use_jp_manage(),
'isAgencyAccount' => Jetpack_Manage::is_agency_account(),
),
'wpcomURL' => self::get_site()->data->URL,
'wpcomURLSuffix' => ( new Status() )->get_site_suffix( self::get_site()->data->URL ),
)
);

Expand Down
Loading