import React from 'react'; import { __ } from '@wordpress/i18n'; import ButtonInput from '@/components/Inputs/ButtonInput'; interface ActivationCopyProps { /** Integration key, must exist in `activationConfigs`. */ type: string; /** * Whether the integration's feature toggle is already enabled. When true the * user only needs to connect; when false the toggle still has to be enabled. */ enabled?: boolean; } interface ActivationState { message: string; cta: string; } interface ActivationConfig { /** Settings route the call-to-action button links to. */ to: string; /** Copy shown when the feature toggle is still off. */ disabled: ActivationState; /** Copy shown when the toggle is on but the integration is not connected. */ disconnected: ActivationState; } /** * Copy per integration for the activation prompt. Single source of truth so a * new gated integration only adds an entry here. Mirrors `upsellConfigs` in * UpsellCopy, but for "enable/connect this integration" instead of "upgrade". */ const activationConfigs: Record = { search_console: { to: '/settings/integrations', disabled: { message: __( 'To view your Google Searches, enable the Search Console integration.', 'burst-statistics' ), cta: __( 'Enable Search Console', 'burst-statistics' ) }, disconnected: { message: __( 'To view your Google Searches, connect the Search Console integration.', 'burst-statistics' ), cta: __( 'Connect Search Console', 'burst-statistics' ) } } }; /** * Activation call-to-action card: a short message and a button that routes to * the integration's settings tab (where its toggle and connect flow live). * Meant to be dropped inside an OverlayBlock, alongside UpsellCopy. * * @param {ActivationCopyProps} props - Component props. * @return {JSX.Element|null} The activation card, or null for an unknown type. */ const ActivationCopy: React.FC = ({ type, enabled = false }) => { const config = activationConfigs[ type ]; if ( ! config ) { return null; } const copy = enabled ? config.disconnected : config.disabled; return (

{ copy.message }

{ copy.cta }
); }; export default ActivationCopy;