-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
My Jetpack: handle redirect when no connection (#22549)
* [not verified] my-jetpack: add useMyJetpackConnection() simple hook * [not verified] my-jetpack: use custom hook to deal with connection * [not verified] changelog * [not verified] my-jetpack: when the site is not connected, redirect to the Jetpack dashboard. * [not verified] my-jetpack: do not render app when no site connected * [not verified] my-jetpack: fix rebasing issues * [not verified] my-jetpack: add options to useMyJetpackConnection() hook * [not verified] my-jetpack: redirect to Jetpack dashboard when no connection * [not verified] my-jetpack: expose redirectUrl from useMyJetpackConnection hook * [not verified] my-jetpack: set url in no conenction global error * [not verified] my-jetpack: check whether user is conected before to redirect * [not verified] my-jetpack: check user when no render because lack of connection * [not verified] my-jetpack: simplify connection status cmp * [not verified] my-jetpack: check only site when redirect because of connection * [not verified] my-jetpack: restore redirectUri prop to connection component * changelog
- Loading branch information
Showing
5 changed files
with
24 additions
and
22 deletions.
There are no files selected for viewing
18 changes: 4 additions & 14 deletions
18
projects/packages/my-jetpack/_inc/components/connections-section/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,18 @@ | ||
/* global myJetpackRest */ | ||
/* global myJetpackInitialState */ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React, { useCallback } from 'react'; | ||
import React from 'react'; | ||
import { ConnectionStatusCard } from '@automattic/jetpack-connection'; | ||
import useMyJetpackConnection from '../../hooks/use-my-jetpack-connection'; | ||
|
||
/** | ||
* Plan section component. | ||
* | ||
* @returns {object} ConnectionsSection React component. | ||
*/ | ||
export default function ConnectionsSection() { | ||
const { apiRoot, apiNonce } = myJetpackRest; | ||
const redirectAfterDisconnect = useCallback( () => { | ||
window.location = myJetpackInitialState.topJetpackMenuItemUrl; | ||
}, [] ); | ||
|
||
const { apiRoot, apiNonce, redirectUrl } = useMyJetpackConnection(); | ||
return ( | ||
<ConnectionStatusCard | ||
apiRoot={ apiRoot } | ||
apiNonce={ apiNonce } | ||
redirectUri={ myJetpackInitialState.redirectUri } | ||
onDisconnected={ redirectAfterDisconnect } | ||
/> | ||
<ConnectionStatusCard apiRoot={ apiRoot } apiNonce={ apiNonce } redirectUri={ redirectUrl } /> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
projects/packages/my-jetpack/changelog/update-my-jetpack-remove-connections-section
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: added | ||
|
||
My Jetpack: handle redirect when no connection #22549 |