Fix modal and selecTab in Features

This commit is contained in:
carmenmaymo 2025-03-11 13:01:54 +01:00
parent abd446a1e3
commit ab9c2ead76
No known key found for this signature in database
GPG key ID: 6023F686B0F3102E
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',
),