From 157cf7d96617fe754492a1a54151e452b9e377ab Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Tue, 17 Dec 2024 15:03:15 +0100
Subject: [PATCH 1/4] =?UTF-8?q?=E2=8F=AA=EF=B8=8F=20Revert=20recent=20chan?=
=?UTF-8?q?ges=20from=20PCP-4025?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../SettingsBlocks/FeatureSettingsBlock.js | 78 ++++++++-----------
1 file changed, 32 insertions(+), 46 deletions(-)
diff --git a/modules/ppcp-settings/resources/js/Components/ReusableComponents/SettingsBlocks/FeatureSettingsBlock.js b/modules/ppcp-settings/resources/js/Components/ReusableComponents/SettingsBlocks/FeatureSettingsBlock.js
index f2d66e9a3..e2681a909 100644
--- a/modules/ppcp-settings/resources/js/Components/ReusableComponents/SettingsBlocks/FeatureSettingsBlock.js
+++ b/modules/ppcp-settings/resources/js/Components/ReusableComponents/SettingsBlocks/FeatureSettingsBlock.js
@@ -11,56 +11,42 @@ const FeatureSettingsBlock = ( { title, description, ...props } ) => {
}
return (
- <>
-
- { notes.map( ( note, index ) => (
- { note }
- ) ) }
-
- >
+
+ { notes.map( ( note, index ) => (
+ { note }
+ ) ) }
+
);
};
return (
- (
- <>
-
-
- { title }
- { props.actionProps?.enabled && (
-
- ) }
-
-
- { description }
- { printNotes() }
-
-
-
-
- { props.actionProps?.buttons.map(
- ( button ) => (
-
- )
- ) }
-
-
- >
- ),
- ] }
- />
+
+
+
+ { title }
+ { props.actionProps?.enabled && (
+
+ ) }
+
+
+ { description }
+ { printNotes() }
+
+
+
+
+ { props.actionProps?.buttons.map( ( button ) => (
+
+ ) ) }
+
+
+
);
};
From 4cbcdce75d4a9c5c81ecb551468c26c4d675e88f Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Tue, 17 Dec 2024 15:04:26 +0100
Subject: [PATCH 2/4] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Use=20Icon=20component?=
=?UTF-8?q?=20instead=20of=20getImage()=20helper?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../js/Components/Screens/Overview/TabOverview.js | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabOverview.js b/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabOverview.js
index fb7fe30c6..1c3947449 100644
--- a/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabOverview.js
+++ b/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabOverview.js
@@ -1,13 +1,14 @@
import { __ } from '@wordpress/i18n';
import { useState } from '@wordpress/element';
-import { Button } from '@wordpress/components';
+import { Button, Icon } from '@wordpress/components';
+import { useDispatch } from '@wordpress/data';
+import { reusableBlock } from '@wordpress/icons';
+
import SettingsCard from '../../ReusableComponents/SettingsCard';
import TodoSettingsBlock from '../../ReusableComponents/SettingsBlocks/TodoSettingsBlock';
import FeatureSettingsBlock from '../../ReusableComponents/SettingsBlocks/FeatureSettingsBlock';
import { TITLE_BADGE_POSITIVE } from '../../ReusableComponents/TitleBadge';
-import data from '../../../utils/data';
import { useMerchantInfo } from '../../../data/common/hooks';
-import { useDispatch } from '@wordpress/data';
import { STORE_NAME } from '../../../data/common';
const TabOverview = () => {
@@ -88,7 +89,7 @@ const TabOverview = () => {
onClick={ refreshHandler }
disabled={ isRefreshing }
>
- { data().getImage( 'icon-refresh.svg' ) }
+
{ isRefreshing
? __(
'Refreshing…',
From 11599102f4668b39a62ba13ceacc00fc5e12c238 Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Tue, 17 Dec 2024 15:05:05 +0100
Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=92=A1=20Add=20code=20remarks=20on=20?=
=?UTF-8?q?planned=20improvements?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../resources/js/Components/Screens/Overview/TabOverview.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabOverview.js b/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabOverview.js
index 1c3947449..102426d0a 100644
--- a/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabOverview.js
+++ b/modules/ppcp-settings/resources/js/Components/Screens/Overview/TabOverview.js
@@ -32,6 +32,7 @@ const TabOverview = () => {
const result = await refreshFeatureStatuses();
+ // TODO: Implement the refresh logic, remove this debug code -- PCP-4024
if ( result && ! result.success ) {
console.error(
'Failed to refresh features:',
@@ -128,6 +129,7 @@ const TabOverview = () => {
);
};
+// TODO: This list should be refactored into a separate module, maybe utils/thingsToDoNext.js
const todosDataDefault = [
{
value: 'paypal_later_messaging',
@@ -163,6 +165,7 @@ const todosDataDefault = [
},
];
+// TODO: Hardcoding this list here is not the best idea. Can we move this to a REST API response?
const featuresDefault = [
{
id: 'save_paypal_and_venmo',
From a77b209e3e2602c04c8cd713e4463a816779c2bc Mon Sep 17 00:00:00 2001
From: Philipp Stracker
Date: Tue, 17 Dec 2024 15:05:34 +0100
Subject: [PATCH 4/4] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Simplify=20Redux=20con?=
=?UTF-8?q?trollers?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../resources/js/data/common/actions.js | 12 ++++-
.../resources/js/data/common/controls.js | 52 ++++---------------
2 files changed, 21 insertions(+), 43 deletions(-)
diff --git a/modules/ppcp-settings/resources/js/data/common/actions.js b/modules/ppcp-settings/resources/js/data/common/actions.js
index 1982d7f42..ccbf34ce0 100644
--- a/modules/ppcp-settings/resources/js/data/common/actions.js
+++ b/modules/ppcp-settings/resources/js/data/common/actions.js
@@ -187,7 +187,13 @@ export const connectViaIdAndSecret = function* () {
* @return {Action} The action.
*/
export const refreshMerchantData = function* () {
- return yield { type: ACTION_TYPES.DO_REFRESH_MERCHANT };
+ const result = yield { type: ACTION_TYPES.DO_REFRESH_MERCHANT };
+
+ if ( result.success && result.merchant ) {
+ yield hydrate( result );
+ }
+
+ return result;
};
/**
@@ -201,7 +207,9 @@ export const refreshFeatureStatuses = function* () {
const result = yield { type: ACTION_TYPES.DO_REFRESH_FEATURES };
if ( result && result.success ) {
- return yield dispatch( STORE_NAME ).refreshMerchantData();
+ // TODO: Review if we can get the updated feature details in the result.data instead of
+ // doing a second refreshMerchantData() request.
+ yield refreshMerchantData();
}
return result;
diff --git a/modules/ppcp-settings/resources/js/data/common/controls.js b/modules/ppcp-settings/resources/js/data/common/controls.js
index e095d6acb..a088660b9 100644
--- a/modules/ppcp-settings/resources/js/data/common/controls.js
+++ b/modules/ppcp-settings/resources/js/data/common/controls.js
@@ -7,11 +7,9 @@
* @file
*/
-import { dispatch } from '@wordpress/data';
import apiFetch from '@wordpress/api-fetch';
import {
- STORE_NAME,
REST_PERSIST_PATH,
REST_MANUAL_CONNECTION_PATH,
REST_CONNECTION_URL_PATH,
@@ -23,7 +21,7 @@ import ACTION_TYPES from './action-types';
export const controls = {
async [ ACTION_TYPES.DO_PERSIST_DATA ]( { data } ) {
try {
- return await apiFetch( {
+ await apiFetch( {
path: REST_PERSIST_PATH,
method: 'POST',
data,
@@ -34,10 +32,8 @@ export const controls = {
},
async [ ACTION_TYPES.DO_SANDBOX_LOGIN ]() {
- let result = null;
-
try {
- result = await apiFetch( {
+ return apiFetch( {
path: REST_CONNECTION_URL_PATH,
method: 'POST',
data: {
@@ -46,20 +42,16 @@ export const controls = {
},
} );
} catch ( e ) {
- result = {
+ return {
success: false,
error: e,
};
}
-
- return result;
},
async [ ACTION_TYPES.DO_PRODUCTION_LOGIN ]( { products } ) {
- let result = null;
-
try {
- result = await apiFetch( {
+ return apiFetch( {
path: REST_CONNECTION_URL_PATH,
method: 'POST',
data: {
@@ -68,13 +60,11 @@ export const controls = {
},
} );
} catch ( e ) {
- result = {
+ return {
success: false,
error: e,
};
}
-
- return result;
},
async [ ACTION_TYPES.DO_MANUAL_CONNECTION ]( {
@@ -82,10 +72,8 @@ export const controls = {
clientSecret,
useSandbox,
} ) {
- let result = null;
-
try {
- result = await apiFetch( {
+ return await apiFetch( {
path: REST_MANUAL_CONNECTION_PATH,
method: 'POST',
data: {
@@ -95,54 +83,36 @@ export const controls = {
},
} );
} catch ( e ) {
- result = {
+ return {
success: false,
error: e,
};
}
-
- return result;
},
async [ ACTION_TYPES.DO_REFRESH_MERCHANT ]() {
- let result = null;
-
try {
- result = await apiFetch( { path: REST_HYDRATE_MERCHANT_PATH } );
-
- if ( result.success && result.merchant ) {
- await dispatch( STORE_NAME ).hydrate( result );
- }
+ return await apiFetch( { path: REST_HYDRATE_MERCHANT_PATH } );
} catch ( e ) {
- result = {
+ return {
success: false,
error: e,
};
}
-
- return result;
},
async [ ACTION_TYPES.DO_REFRESH_FEATURES ]() {
- let result = null;
-
try {
- result = await apiFetch( {
+ return await apiFetch( {
path: REST_REFRESH_FEATURES_PATH,
method: 'POST',
} );
-
- if ( result.success ) {
- result = await dispatch( STORE_NAME ).refreshMerchantData();
- }
} catch ( e ) {
- result = {
+ return {
success: false,
error: e,
message: e.message,
};
}
-
- return result;
},
};