@automattic/jetpack-connection 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/helpers/get-user-connection-url.ts +45 -0
- package/hooks/use-restore-connection/index.jsx +2 -1
- package/index.jsx +1 -0
- package/package.json +21 -20
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
### This is a list detailing changes for the Jetpack RNA Connection Component releases.
|
|
4
4
|
|
|
5
|
+
## [1.4.0] - 2025-08-04
|
|
6
|
+
### Added
|
|
7
|
+
- Add "from" argument to user connection url. [#44587]
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
- My Jetpack: Unify the user connection flow with a unified screen. [#44469]
|
|
11
|
+
|
|
12
|
+
## [1.3.2] - 2025-07-30
|
|
13
|
+
### Changed
|
|
14
|
+
- Update dependencies.
|
|
15
|
+
|
|
5
16
|
## [1.3.1] - 2025-07-28
|
|
6
17
|
### Changed
|
|
7
18
|
- Internal updates.
|
|
@@ -1116,6 +1127,8 @@
|
|
|
1116
1127
|
- `Main` and `ConnectUser` components added.
|
|
1117
1128
|
- `JetpackRestApiClient` API client added.
|
|
1118
1129
|
|
|
1130
|
+
[1.4.0]: https://github.com/Automattic/jetpack-connection-js/compare/v1.3.2...v1.4.0
|
|
1131
|
+
[1.3.2]: https://github.com/Automattic/jetpack-connection-js/compare/v1.3.1...v1.3.2
|
|
1119
1132
|
[1.3.1]: https://github.com/Automattic/jetpack-connection-js/compare/v1.3.0...v1.3.1
|
|
1120
1133
|
[1.3.0]: https://github.com/Automattic/jetpack-connection-js/compare/v1.2.14...v1.3.0
|
|
1121
1134
|
[1.2.14]: https://github.com/Automattic/jetpack-connection-js/compare/v1.2.13...v1.2.14
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { getJetpackAdminPageUrl, getMyJetpackUrl } from '@automattic/jetpack-script-data';
|
|
2
|
+
import { addQueryArgs } from '@wordpress/url';
|
|
3
|
+
|
|
4
|
+
export type UserConnectionUrlOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* The URL to redirect to after authentication.
|
|
7
|
+
*
|
|
8
|
+
* Defaults to the My Jetpack URL if not provided.
|
|
9
|
+
*/
|
|
10
|
+
redirect_url?: string | null;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The `from` to pass to Calypso for identification.
|
|
14
|
+
*
|
|
15
|
+
* This is typically used to identify the source of the connection request.
|
|
16
|
+
* If not provided, defaults to 'my-jetpack'.
|
|
17
|
+
*/
|
|
18
|
+
from?: string | null;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Whether to skip the pricing page after authentication.
|
|
22
|
+
*
|
|
23
|
+
* @default true
|
|
24
|
+
*/
|
|
25
|
+
skip_pricing?: boolean;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Generates the user connection URL.
|
|
30
|
+
*
|
|
31
|
+
* @param options - Options for generating the user connection URL.
|
|
32
|
+
*
|
|
33
|
+
* @return The URL for user connection.
|
|
34
|
+
*/
|
|
35
|
+
export function getUserConnectionUrl( options: UserConnectionUrlOptions = {} ): string {
|
|
36
|
+
const { redirect_url, from, skip_pricing = true } = options;
|
|
37
|
+
|
|
38
|
+
return addQueryArgs( getJetpackAdminPageUrl(), {
|
|
39
|
+
// 'connect_url_redirect' is handled in \Automattic\Jetpack\Connection\Webhooks::controller()
|
|
40
|
+
connect_url_redirect: 1,
|
|
41
|
+
redirect_after_auth: redirect_url ?? getMyJetpackUrl(),
|
|
42
|
+
from: from ?? 'my-jetpack',
|
|
43
|
+
skip_pricing,
|
|
44
|
+
} );
|
|
45
|
+
}
|
|
@@ -2,6 +2,7 @@ import restApi from '@automattic/jetpack-api';
|
|
|
2
2
|
import { getScriptData } from '@automattic/jetpack-script-data';
|
|
3
3
|
import { useDispatch } from '@wordpress/data';
|
|
4
4
|
import { useEffect, useState } from 'react';
|
|
5
|
+
import { getUserConnectionUrl } from '../../helpers/get-user-connection-url';
|
|
5
6
|
import { STORE_ID } from '../../state/store';
|
|
6
7
|
|
|
7
8
|
const { apiRoot, apiNonce } =
|
|
@@ -19,7 +20,7 @@ export default function useRestoreConnection() {
|
|
|
19
20
|
|
|
20
21
|
const { disconnectUserSuccess, setConnectionErrors } = useDispatch( STORE_ID );
|
|
21
22
|
|
|
22
|
-
const USER_CONNECTION_URL =
|
|
23
|
+
const USER_CONNECTION_URL = getUserConnectionUrl();
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Initiate connection restore.
|
package/index.jsx
CHANGED
|
@@ -38,6 +38,7 @@ export { default as ManageConnectionDialog } from './components/manage-connectio
|
|
|
38
38
|
*/
|
|
39
39
|
export { default as thirdPartyCookiesFallbackHelper } from './helpers/third-party-cookies-fallback';
|
|
40
40
|
export { default as getCalypsoOrigin } from './helpers/get-calypso-origin';
|
|
41
|
+
export * from './helpers/get-user-connection-url.ts';
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* Store
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/jetpack-connection",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Jetpack Connection Component",
|
|
5
5
|
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/connection/#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -11,14 +11,27 @@
|
|
|
11
11
|
"url": "https://github.com/Automattic/jetpack.git",
|
|
12
12
|
"directory": "projects/js-packages/connection"
|
|
13
13
|
},
|
|
14
|
-
"author": "Automattic",
|
|
15
14
|
"license": "GPL-2.0-or-later",
|
|
15
|
+
"author": "Automattic",
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"./state/store.jsx",
|
|
18
|
+
"*.css",
|
|
19
|
+
"*.scss"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./index.jsx"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
27
|
+
"test-coverage": "pnpm run test --coverage"
|
|
28
|
+
},
|
|
16
29
|
"dependencies": {
|
|
17
|
-
"@automattic/jetpack-analytics": "^1.0.
|
|
18
|
-
"@automattic/jetpack-api": "^1.0.
|
|
19
|
-
"@automattic/jetpack-components": "^1.1.
|
|
20
|
-
"@automattic/jetpack-config": "^1.0.
|
|
21
|
-
"@automattic/jetpack-script-data": "^0.5.
|
|
30
|
+
"@automattic/jetpack-analytics": "^1.0.4",
|
|
31
|
+
"@automattic/jetpack-api": "^1.0.6",
|
|
32
|
+
"@automattic/jetpack-components": "^1.1.17",
|
|
33
|
+
"@automattic/jetpack-config": "^1.0.4",
|
|
34
|
+
"@automattic/jetpack-script-data": "^0.5.1",
|
|
22
35
|
"@wordpress/base-styles": "6.2.0",
|
|
23
36
|
"@wordpress/browserslist-config": "6.26.0",
|
|
24
37
|
"@wordpress/components": "29.12.0",
|
|
@@ -26,6 +39,7 @@
|
|
|
26
39
|
"@wordpress/element": "6.26.0",
|
|
27
40
|
"@wordpress/i18n": "5.26.0",
|
|
28
41
|
"@wordpress/icons": "10.26.0",
|
|
42
|
+
"@wordpress/url": "4.26.0",
|
|
29
43
|
"clsx": "2.1.1",
|
|
30
44
|
"debug": "4.4.1",
|
|
31
45
|
"prop-types": "^15.7.2"
|
|
@@ -47,18 +61,5 @@
|
|
|
47
61
|
"peerDependencies": {
|
|
48
62
|
"react": "^18.0.0",
|
|
49
63
|
"react-dom": "^18.0.0"
|
|
50
|
-
},
|
|
51
|
-
"type": "module",
|
|
52
|
-
"exports": {
|
|
53
|
-
".": "./index.jsx"
|
|
54
|
-
},
|
|
55
|
-
"sideEffects": [
|
|
56
|
-
"./state/store.jsx",
|
|
57
|
-
"*.css",
|
|
58
|
-
"*.scss"
|
|
59
|
-
],
|
|
60
|
-
"scripts": {
|
|
61
|
-
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
|
|
62
|
-
"test-coverage": "pnpm run test --coverage"
|
|
63
64
|
}
|
|
64
65
|
}
|