Merge pull request #3201 from woocommerce/PCP-4285-configure-buttons-in-features-section-does-not-work-as-expected

Configure buttons in Features section does not work as expected (4285)
This commit is contained in:
Emili Castells 2025-03-11 17:52:10 +01:00 committed by GitHub
commit 80a99c75d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View file

@ -3,7 +3,8 @@ import { FeatureSettingsBlock } from '../../../../../ReusableComponents/Settings
import { Content } from '../../../../../ReusableComponents/Elements';
import { TITLE_BADGE_POSITIVE } from '../../../../../ReusableComponents/TitleBadge';
import { selectTab, TAB_IDS } from '../../../../../../utils/tabSelector';
import { setActiveModal } from '../../../../../../data/common/actions';
import { useDispatch } from '@wordpress/data';
import { STORE_NAME as COMMON_STORE_NAME } from '../../../../../../data/common';
const FeatureItem = ( {
isBusy,
@ -14,6 +15,7 @@ const FeatureItem = ( {
enabled,
notes,
} ) => {
const { setActiveModal } = useDispatch( COMMON_STORE_NAME );
const getButtonUrl = ( button ) => {
if ( button.urls ) {
return isSandbox ? button.urls.sandbox : button.urls.live;
@ -30,9 +32,11 @@ const FeatureItem = ( {
);
const handleClick = async ( feature ) => {
if ( feature.action?.type === 'tab' ) {
const highlight = Boolean( feature.action?.highlight );
const tabId = TAB_IDS[ feature.action.tab.toUpperCase() ];
await selectTab( tabId, feature.action.section );
await selectTab( tabId, feature.action.section, highlight );
}
if ( feature.action?.modal ) {
setActiveModal( feature.action.modal );
}

View file

@ -106,6 +106,7 @@ class FeaturesDefinition {
'action' => array(
'type' => 'tab',
'tab' => 'settings',
'section' => 'ppcp-save-paypal-and-venmo',
),
'showWhen' => 'enabled',
'class' => 'small-button',
@ -207,7 +208,7 @@ class FeaturesDefinition {
'action' => array(
'type' => 'tab',
'tab' => 'payment_methods',
'section' => 'ppcp-card-payments-card',
'section' => 'ppcp-googlepay',
'highlight' => 'ppcp-googlepay',
'modal' => 'ppcp-googlepay',
),