@automattic/jetpack-connection 0.29.10 → 0.30.1

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,14 @@
2
2
 
3
3
  ### This is a list detailing changes for the Jetpack RNA Connection Component releases.
4
4
 
5
+ ## [0.30.1] - 2023-10-10
6
+ ### Changed
7
+ - Updated package dependencies. [#33428]
8
+
9
+ ## [0.30.0] - 2023-09-25
10
+ ### Added
11
+ - Handle connection error codes and display proper error messages. Enabled for the "private network" error only at the moment. [#32898]
12
+
5
13
  ## [0.29.10] - 2023-09-13
6
14
  ### Changed
7
15
  - Updated package dependencies. [#33001]
@@ -628,6 +636,8 @@
628
636
  - `Main` and `ConnectUser` components added.
629
637
  - `JetpackRestApiClient` API client added.
630
638
 
639
+ [0.30.1]: https://github.com/Automattic/jetpack-connection-js/compare/v0.30.0...v0.30.1
640
+ [0.30.0]: https://github.com/Automattic/jetpack-connection-js/compare/v0.29.10...v0.30.0
631
641
  [0.29.10]: https://github.com/Automattic/jetpack-connection-js/compare/v0.29.9...v0.29.10
632
642
  [0.29.9]: https://github.com/Automattic/jetpack-connection-js/compare/v0.29.8...v0.29.9
633
643
  [0.29.8]: https://github.com/Automattic/jetpack-connection-js/compare/v0.29.7...v0.29.8
@@ -58,6 +58,7 @@ const ConnectScreen = ( {
58
58
 
59
59
  const displayButtonError = Boolean( registrationError );
60
60
  const buttonIsLoading = siteIsRegistering || userIsConnecting;
61
+ const errorCode = registrationError?.response?.code;
61
62
 
62
63
  return (
63
64
  <ConnectScreenVisual
@@ -67,6 +68,7 @@ const ConnectScreen = ( {
67
68
  buttonLabel={ buttonLabel }
68
69
  handleButtonClick={ handleRegisterSite }
69
70
  displayButtonError={ displayButtonError }
71
+ errorCode={ errorCode }
70
72
  buttonIsLoading={ buttonIsLoading }
71
73
  footer={ footer }
72
74
  isOfflineMode={ isOfflineMode }
@@ -22,14 +22,29 @@ const ConnectScreenVisual = props => {
22
22
  buttonLabel,
23
23
  handleButtonClick,
24
24
  displayButtonError,
25
+ errorCode,
25
26
  buttonIsLoading,
26
27
  footer,
27
28
  isOfflineMode,
28
29
  logo,
29
30
  } = props;
30
31
 
31
- const errorMessage = isOfflineMode
32
- ? createInterpolateElement( __( 'Unavailable in <a>Offline Mode</a>', 'jetpack' ), {
32
+ const getErrorMessage = () => {
33
+ // Explicit error code takes precedence over the offline mode.
34
+ switch ( errorCode ) {
35
+ case 'fail_domain_forbidden':
36
+ case 'fail_ip_forbidden':
37
+ case 'fail_domain_tld':
38
+ case 'fail_subdomain_wpcom':
39
+ case 'siteurl_private_ip':
40
+ return __(
41
+ 'Your site host is on a private network. Jetpack can only connect to public sites.',
42
+ 'jetpack'
43
+ );
44
+ }
45
+
46
+ if ( isOfflineMode ) {
47
+ return createInterpolateElement( __( 'Unavailable in <a>Offline Mode</a>', 'jetpack' ), {
33
48
  a: (
34
49
  <a
35
50
  href={ getRedirectUrl( 'jetpack-support-development-mode' ) }
@@ -37,8 +52,11 @@ const ConnectScreenVisual = props => {
37
52
  rel="noopener noreferrer"
38
53
  />
39
54
  ),
40
- } )
41
- : undefined;
55
+ } );
56
+ }
57
+ };
58
+
59
+ const errorMessage = getErrorMessage( errorCode, isOfflineMode );
42
60
 
43
61
  return (
44
62
  <ConnectScreenLayout
@@ -87,6 +105,8 @@ ConnectScreenVisual.propTypes = {
87
105
  handleButtonClick: PropTypes.func,
88
106
  /** Whether the error message appears or not. */
89
107
  displayButtonError: PropTypes.bool,
108
+ /** The connection error code. */
109
+ errorCode: PropTypes.string,
90
110
  /** Whether the button is loading or not. */
91
111
  buttonIsLoading: PropTypes.bool,
92
112
  /** Node that will be rendered after ToS */
@@ -101,6 +121,7 @@ ConnectScreenVisual.defaultProps = {
101
121
  isLoading: false,
102
122
  buttonIsLoading: false,
103
123
  displayButtonError: false,
124
+ errorCode: null,
104
125
  handleButtonClick: () => {},
105
126
  footer: null,
106
127
  isOfflineMode: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/jetpack-connection",
3
- "version": "0.29.10",
3
+ "version": "0.30.1",
4
4
  "description": "Jetpack Connection Component",
5
5
  "homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/connection/#readme",
6
6
  "bugs": {
@@ -15,22 +15,22 @@
15
15
  "license": "GPL-2.0-or-later",
16
16
  "dependencies": {
17
17
  "@automattic/jetpack-analytics": "^0.1.27",
18
- "@automattic/jetpack-api": "^0.16.2",
19
- "@automattic/jetpack-components": "^0.42.3",
18
+ "@automattic/jetpack-api": "^0.16.3",
19
+ "@automattic/jetpack-components": "^0.43.1",
20
20
  "@automattic/jetpack-config": "^0.1.21",
21
- "@wordpress/base-styles": "4.32.0",
22
- "@wordpress/browserslist-config": "5.24.0",
23
- "@wordpress/components": "25.7.0",
24
- "@wordpress/data": "9.11.0",
25
- "@wordpress/element": "5.18.0",
26
- "@wordpress/i18n": "4.41.0",
27
- "@wordpress/icons": "9.32.0",
21
+ "@wordpress/base-styles": "4.34.0",
22
+ "@wordpress/browserslist-config": "5.26.0",
23
+ "@wordpress/components": "25.9.0",
24
+ "@wordpress/data": "9.13.0",
25
+ "@wordpress/element": "5.20.0",
26
+ "@wordpress/i18n": "4.43.0",
27
+ "@wordpress/icons": "9.34.0",
28
28
  "classnames": "2.3.2",
29
29
  "debug": "4.3.4",
30
30
  "prop-types": "^15.7.2"
31
31
  },
32
32
  "devDependencies": {
33
- "@automattic/jetpack-base-styles": "^0.6.9",
33
+ "@automattic/jetpack-base-styles": "^0.6.10",
34
34
  "@babel/core": "7.22.17",
35
35
  "@babel/preset-react": "7.22.15",
36
36
  "@storybook/addon-actions": "7.1.0",