Skip to content

Commit 836a441

Browse files
Merge b8c7555 into 6681c40
2 parents 6681c40 + b8c7555 commit 836a441

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

src/hooks/tests/get-sync-support.test.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,27 @@ describe( 'getSyncSupport', () => {
8181
} );
8282

8383
it( 'returns "already-connected" if site ID is in connectedSiteIds', () => {
84-
const site = { ...baseSite, ID: 42, is_wpcom_atomic: true };
84+
const site = { ...baseSite, ID: 42, is_wpcom_atomic: true, jetpack: true };
8585
expect( getSyncSupport( site, [ 42 ] ) ).toBe( 'already-connected' );
8686
} );
8787

8888
it( 'returns "syncable" for Atomic site', () => {
89-
const site = { ...baseSite, is_wpcom_atomic: true };
89+
const site = { ...baseSite, is_wpcom_atomic: true, jetpack: true };
9090
expect( getSyncSupport( site, [] ) ).toBe( 'syncable' );
9191
} );
9292

9393
it( 'returns "syncable" for Pressable site', () => {
94-
const site = { ...baseSite, hosting_provider_guess: 'pressable' };
94+
const site = { ...baseSite, hosting_provider_guess: 'pressable', jetpack: true };
9595
expect( getSyncSupport( site, [] ) ).toBe( 'syncable' );
9696
} );
97+
98+
it( 'returns "jetpack-disconnected" for Pressable site with broken Jetpack connection', () => {
99+
const site = { ...baseSite, hosting_provider_guess: 'pressable', jetpack: false };
100+
expect( getSyncSupport( site, [] ) ).toBe( 'jetpack-disconnected' );
101+
} );
102+
103+
it( 'returns "jetpack-disconnected" for Atomic site with broken Jetpack connection', () => {
104+
const site = { ...baseSite, is_wpcom_atomic: true, jetpack: false };
105+
expect( getSyncSupport( site, [] ) ).toBe( 'jetpack-disconnected' );
106+
} );
97107
} );

src/hooks/use-fetch-wpcom-sites/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ export function getSyncSupport( site: SitesEndpointSite, connectedSiteIds: numbe
9292
if ( needsTransfer( site ) ) {
9393
return 'needs-transfer';
9494
}
95+
if ( ! site.jetpack ) {
96+
return 'jetpack-disconnected';
97+
}
9598
if ( connectedSiteIds.some( ( id ) => id === site.ID ) ) {
9699
return 'already-connected';
97100
}

src/hooks/use-fetch-wpcom-sites/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export type SyncSupport =
55
| 'already-connected'
66
| 'needs-upgrade'
77
| 'deleted'
8-
| 'missing-permissions';
8+
| 'missing-permissions'
9+
| 'jetpack-disconnected';
910

1011
export type SyncSite = {
1112
id: number;

src/modules/sync/components/sync-sites-modal-selector.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,11 @@ const getSortedSites = ( sites: SyncSite[] ) => {
155155
syncable: 1,
156156
'already-connected': 2,
157157
deleted: 3,
158-
'missing-permissions': 4,
159-
'needs-transfer': 5,
160-
'needs-upgrade': 6,
161-
unsupported: 7,
158+
'jetpack-disconnected': 4,
159+
'missing-permissions': 5,
160+
'needs-transfer': 6,
161+
'needs-upgrade': 7,
162+
unsupported: 8,
162163
};
163164

164165
return [ ...sites ].sort( ( a, b ) => order[ a.syncSupport ] - order[ b.syncSupport ] );
@@ -199,15 +200,18 @@ function SiteItem( {
199200
onClick: () => void;
200201
} ) {
201202
const { __ } = useI18n();
203+
const locale = useI18nLocale();
202204
const isAlreadyConnected = site.syncSupport === 'already-connected';
203205
const isSyncable = site.syncSupport === 'syncable';
204206
const isNeedsTransfer = site.syncSupport === 'needs-transfer';
205207
const isMissingPermissions = site.syncSupport === 'missing-permissions';
206208
const needsUpgrade = site.syncSupport === 'needs-upgrade';
207209
const isDeleted = site.syncSupport === 'deleted';
210+
const isJetpackDisconnected = site.syncSupport === 'jetpack-disconnected';
208211
const isUnsupported = site.syncSupport === 'unsupported';
209212
const isPressable = site.isPressable;
210-
const isDisabled = isDeleted || isUnsupported || needsUpgrade || isMissingPermissions;
213+
const isDisabled =
214+
isDeleted || isJetpackDisconnected || isUnsupported || needsUpgrade || isMissingPermissions;
211215

212216
return (
213217
<div
@@ -323,6 +327,17 @@ function SiteItem( {
323327
{ __( 'Deleted' ) }
324328
</div>
325329
) }
330+
{ isJetpackDisconnected && (
331+
<div className="a8c-body-small text-a8c-gray-30 shrink-0 text-right">
332+
<Button
333+
variant="link"
334+
onClick={ () => getIpcApi().openURL( getLocalizedLink( locale, 'docsSync' ) ) }
335+
>
336+
{ __( 'Check connection' ) }
337+
<ArrowIcon />
338+
</Button>
339+
</div>
340+
) }
326341
{ isUnsupported && (
327342
<div className="a8c-body-small text-a8c-gray-30 shrink-0">{ __( 'Unsupported site' ) }</div>
328343
) }

0 commit comments

Comments
 (0)