@automattic/jetpack-connection 0.29.9 → 0.30.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,14 @@
2
2
 
3
3
  ### This is a list detailing changes for the Jetpack RNA Connection Component releases.
4
4
 
5
+ ## [0.30.0] - 2023-09-25
6
+ ### Added
7
+ - Handle connection error codes and display proper error messages. Enabled for the "private network" error only at the moment. [#32898]
8
+
9
+ ## [0.29.10] - 2023-09-13
10
+ ### Changed
11
+ - Updated package dependencies. [#33001]
12
+
5
13
  ## [0.29.9] - 2023-09-04
6
14
  ### Changed
7
15
  - Updated package dependencies. [#32803]
@@ -624,5 +632,7 @@
624
632
  - `Main` and `ConnectUser` components added.
625
633
  - `JetpackRestApiClient` API client added.
626
634
 
635
+ [0.30.0]: https://github.com/Automattic/jetpack-connection-js/compare/v0.29.10...v0.30.0
636
+ [0.29.10]: https://github.com/Automattic/jetpack-connection-js/compare/v0.29.9...v0.29.10
627
637
  [0.29.9]: https://github.com/Automattic/jetpack-connection-js/compare/v0.29.8...v0.29.9
628
638
  [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.9",
3
+ "version": "0.30.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.27",
18
18
  "@automattic/jetpack-api": "^0.16.2",
19
- "@automattic/jetpack-components": "^0.42.1",
19
+ "@automattic/jetpack-components": "^0.42.5",
20
20
  "@automattic/jetpack-config": "^0.1.21",
21
21
  "@wordpress/base-styles": "4.32.0",
22
22
  "@wordpress/browserslist-config": "5.24.0",
@@ -30,9 +30,9 @@
30
30
  "prop-types": "^15.7.2"
31
31
  },
32
32
  "devDependencies": {
33
- "@automattic/jetpack-base-styles": "^0.6.8",
34
- "@babel/core": "7.22.11",
35
- "@babel/preset-react": "7.22.5",
33
+ "@automattic/jetpack-base-styles": "^0.6.9",
34
+ "@babel/core": "7.22.17",
35
+ "@babel/preset-react": "7.22.15",
36
36
  "@storybook/addon-actions": "7.1.0",
37
37
  "@testing-library/dom": "8.19.1",
38
38
  "@testing-library/react": "13.4.0",