@automattic/jetpack-connection 0.30.12 → 0.31.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
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
### This is a list detailing changes for the Jetpack RNA Connection Component releases.
|
|
4
4
|
|
|
5
|
+
## [0.31.0] - 2024-01-18
|
|
6
|
+
### Changed
|
|
7
|
+
- Allow using blog ID instead of site suffix in checkout URL. [#34976]
|
|
8
|
+
|
|
5
9
|
## [0.30.12] - 2024-01-04
|
|
6
10
|
### Changed
|
|
7
11
|
- Updated package dependencies. [#34815] [#34816]
|
|
@@ -680,6 +684,7 @@
|
|
|
680
684
|
- `Main` and `ConnectUser` components added.
|
|
681
685
|
- `JetpackRestApiClient` API client added.
|
|
682
686
|
|
|
687
|
+
[0.31.0]: https://github.com/Automattic/jetpack-connection-js/compare/v0.30.12...v0.31.0
|
|
683
688
|
[0.30.12]: https://github.com/Automattic/jetpack-connection-js/compare/v0.30.11...v0.30.12
|
|
684
689
|
[0.30.11]: https://github.com/Automattic/jetpack-connection-js/compare/v0.30.10...v0.30.11
|
|
685
690
|
[0.30.10]: https://github.com/Automattic/jetpack-connection-js/compare/v0.30.9...v0.30.10
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import restApi from '@automattic/jetpack-api';
|
|
2
2
|
import { getCalypsoOrigin } from '@automattic/jetpack-connection';
|
|
3
|
-
import { useDispatch } from '@wordpress/data';
|
|
3
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
4
4
|
import debugFactory from 'debug';
|
|
5
5
|
import { useEffect, useState, useMemo } from 'react';
|
|
6
6
|
import useConnection from '../../components/use-connection';
|
|
@@ -30,6 +30,7 @@ const defaultAdminUrl =
|
|
|
30
30
|
* @param {Function} props.siteProductAvailabilityHandler - The function used to check whether the site already has the requested product. This will be checked after registration and the checkout page will be skipped if the promise returned resloves true.
|
|
31
31
|
* @param {Function} props.from - The plugin slug initiated the flow.
|
|
32
32
|
* @param {number} [props.quantity] - The quantity of the product to purchase.
|
|
33
|
+
* @param {boolean} [props.useBlogIdSuffix] - Use blog ID instead of site suffix in the checkout URL.
|
|
33
34
|
* @returns {Function} The useEffect hook.
|
|
34
35
|
*/
|
|
35
36
|
export default function useProductCheckoutWorkflow( {
|
|
@@ -41,6 +42,7 @@ export default function useProductCheckoutWorkflow( {
|
|
|
41
42
|
siteProductAvailabilityHandler = null,
|
|
42
43
|
quantity = null,
|
|
43
44
|
from,
|
|
45
|
+
useBlogIdSuffix = false,
|
|
44
46
|
} = {} ) {
|
|
45
47
|
debug( 'productSlug is %s', productSlug );
|
|
46
48
|
debug( 'redirectUrl is %s', redirectUrl );
|
|
@@ -49,6 +51,11 @@ export default function useProductCheckoutWorkflow( {
|
|
|
49
51
|
const [ hasCheckoutStarted, setCheckoutStarted ] = useState( false );
|
|
50
52
|
const { registerSite } = useDispatch( STORE_ID );
|
|
51
53
|
|
|
54
|
+
const blogID = useSelect( select => select( STORE_ID ).getBlogId(), [ STORE_ID ] );
|
|
55
|
+
debug( 'blogID is %s', blogID ?? 'undefined' );
|
|
56
|
+
|
|
57
|
+
useBlogIdSuffix = useBlogIdSuffix && !! blogID;
|
|
58
|
+
|
|
52
59
|
const { isUserConnected, isRegistered, handleConnectUser } = useConnection( {
|
|
53
60
|
redirectUri: redirectUrl,
|
|
54
61
|
from,
|
|
@@ -61,7 +68,7 @@ export default function useProductCheckoutWorkflow( {
|
|
|
61
68
|
|
|
62
69
|
const checkoutPath = shouldConnectAfterCheckout
|
|
63
70
|
? 'checkout/jetpack/'
|
|
64
|
-
: `checkout/${ siteSuffix }/`;
|
|
71
|
+
: `checkout/${ useBlogIdSuffix ? blogID.toString() : siteSuffix }/`;
|
|
65
72
|
|
|
66
73
|
const quantitySuffix = quantity != null ? `:-q-${ quantity }` : '';
|
|
67
74
|
|
|
@@ -102,6 +109,8 @@ export default function useProductCheckoutWorkflow( {
|
|
|
102
109
|
from,
|
|
103
110
|
redirectUrl,
|
|
104
111
|
adminUrl,
|
|
112
|
+
useBlogIdSuffix,
|
|
113
|
+
blogID,
|
|
105
114
|
] );
|
|
106
115
|
|
|
107
116
|
debug( 'isRegistered is %s', isRegistered );
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/jetpack-connection",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.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": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@automattic/jetpack-analytics": "^0.1.29",
|
|
18
18
|
"@automattic/jetpack-api": "^0.16.8",
|
|
19
|
-
"@automattic/jetpack-components": "^0.
|
|
19
|
+
"@automattic/jetpack-components": "^0.46.0",
|
|
20
20
|
"@automattic/jetpack-config": "^0.1.24",
|
|
21
21
|
"@wordpress/base-styles": "4.39.0",
|
|
22
22
|
"@wordpress/browserslist-config": "5.31.0",
|