Skip to content

Commit

Permalink
Update Blocks Package
Browse files Browse the repository at this point in the history
  • Loading branch information
sdixon194 authored and matticbot committed Sep 26, 2023
1 parent 44bab44 commit 967f829
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

### This is a list detailing changes for the Jetpack RNA Connection Component releases.

## [0.30.0] - 2023-09-25
### Added
- Handle connection error codes and display proper error messages. Enabled for the "private network" error only at the moment. [#32898]

## [0.29.10] - 2023-09-13
### Changed
- Updated package dependencies. [#33001]
Expand Down Expand Up @@ -628,6 +632,7 @@
- `Main` and `ConnectUser` components added.
- `JetpackRestApiClient` API client added.

[0.30.0]: https://github.com/Automattic/jetpack-connection-js/compare/v0.29.10...v0.30.0
[0.29.10]: https://github.com/Automattic/jetpack-connection-js/compare/v0.29.9...v0.29.10
[0.29.9]: https://github.com/Automattic/jetpack-connection-js/compare/v0.29.8...v0.29.9
[0.29.8]: https://github.com/Automattic/jetpack-connection-js/compare/v0.29.7...v0.29.8
2 changes: 2 additions & 0 deletions components/connect-screen/basic/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const ConnectScreen = ( {

const displayButtonError = Boolean( registrationError );
const buttonIsLoading = siteIsRegistering || userIsConnecting;
const errorCode = registrationError?.response?.code;

return (
<ConnectScreenVisual
Expand All @@ -67,6 +68,7 @@ const ConnectScreen = ( {
buttonLabel={ buttonLabel }
handleButtonClick={ handleRegisterSite }
displayButtonError={ displayButtonError }
errorCode={ errorCode }
buttonIsLoading={ buttonIsLoading }
footer={ footer }
isOfflineMode={ isOfflineMode }
Expand Down
29 changes: 25 additions & 4 deletions components/connect-screen/basic/visual.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,41 @@ const ConnectScreenVisual = props => {
buttonLabel,
handleButtonClick,
displayButtonError,
errorCode,
buttonIsLoading,
footer,
isOfflineMode,
logo,
} = props;

const errorMessage = isOfflineMode
? createInterpolateElement( __( 'Unavailable in <a>Offline Mode</a>', 'jetpack' ), {
const getErrorMessage = () => {
// Explicit error code takes precedence over the offline mode.
switch ( errorCode ) {
case 'fail_domain_forbidden':
case 'fail_ip_forbidden':
case 'fail_domain_tld':
case 'fail_subdomain_wpcom':
case 'siteurl_private_ip':
return __(
'Your site host is on a private network. Jetpack can only connect to public sites.',
'jetpack'
);
}

if ( isOfflineMode ) {
return createInterpolateElement( __( 'Unavailable in <a>Offline Mode</a>', 'jetpack' ), {
a: (
<a
href={ getRedirectUrl( 'jetpack-support-development-mode' ) }
target="_blank"
rel="noopener noreferrer"
/>
),
} )
: undefined;
} );
}
};

const errorMessage = getErrorMessage( errorCode, isOfflineMode );

return (
<ConnectScreenLayout
Expand Down Expand Up @@ -87,6 +105,8 @@ ConnectScreenVisual.propTypes = {
handleButtonClick: PropTypes.func,
/** Whether the error message appears or not. */
displayButtonError: PropTypes.bool,
/** The connection error code. */
errorCode: PropTypes.string,
/** Whether the button is loading or not. */
buttonIsLoading: PropTypes.bool,
/** Node that will be rendered after ToS */
Expand All @@ -101,6 +121,7 @@ ConnectScreenVisual.defaultProps = {
isLoading: false,
buttonIsLoading: false,
displayButtonError: false,
errorCode: null,
handleButtonClick: () => {},
footer: null,
isOfflineMode: false,
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "GPL-2.0-or-later",
"require": {},
"require-dev": {
"automattic/jetpack-changelogger": "^3.3.9"
"automattic/jetpack-changelogger": "^3.3.11-alpha"
},
"scripts": {
"test-js": [
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@automattic/jetpack-connection",
"version": "0.29.10",
"version": "0.30.0",
"description": "Jetpack Connection Component",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/js-packages/connection/#readme",
"bugs": {
Expand All @@ -16,7 +16,7 @@
"dependencies": {
"@automattic/jetpack-analytics": "^0.1.27",
"@automattic/jetpack-api": "^0.16.2",
"@automattic/jetpack-components": "^0.42.4",
"@automattic/jetpack-components": "^0.42.5",
"@automattic/jetpack-config": "^0.1.21",
"@wordpress/base-styles": "4.32.0",
"@wordpress/browserslist-config": "5.24.0",
Expand Down

0 comments on commit 967f829

Please sign in to comment.