Skip to content

Commit 29ef216

Browse files
authored
Forms: Add option to connect form to MailPoet (#44431)
1 parent 2671326 commit 29ef216

File tree

6 files changed

+68
-2
lines changed

6 files changed

+68
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: added
3+
4+
Forms: Add toggle to enable MailPoet integration.

projects/packages/forms/src/blocks/contact-form/attributes.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,8 @@ export default {
4444
sendToSalesforce: false,
4545
},
4646
},
47+
connectMailPoet: {
48+
type: 'boolean',
49+
default: false,
50+
},
4751
};

projects/packages/forms/src/blocks/contact-form/components/jetpack-integrations-modal/active-integrations/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { JetpackIcon } from '@automattic/jetpack-components';
33
import { Spinner, Tooltip } from '@wordpress/components';
44
import { __ } from '@wordpress/i18n';
55
import AkismetIcon from '../../../../../icons/akismet';
6+
import MailPoetOrangeIcon from '../../../../../icons/mailpoet-orange';
67
import SalesforceCircleIcon from '../../../../../icons/salesforce-circle';
78
import { isValidSalesforceOrgId } from '../salesforce-card';
89
import './style.scss';
@@ -30,6 +31,15 @@ export default function ActiveIntegrations( { integrations, attributes, isLoadin
3031
} );
3132
}
3233
break;
34+
case 'mailpoet':
35+
if ( integration.isActive && attributes.connectMailPoet ) {
36+
acc.push( {
37+
...integration,
38+
icon: <MailPoetOrangeIcon width={ 30 } height={ 30 } />,
39+
tooltip: __( 'MailPoet is connected for this form', 'jetpack-forms' ),
40+
} );
41+
}
42+
break;
3343
case 'salesforce':
3444
if (
3545
attributes.salesforceData?.sendToSalesforce &&

projects/packages/forms/src/blocks/contact-form/components/jetpack-integrations-modal/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ const IntegrationsModal = ( {
9898
onToggle={ () => toggleCard( 'mailpoet' ) }
9999
data={ findIntegrationById( 'mailpoet' ) }
100100
refreshStatus={ refreshIntegrations }
101+
connectMailPoet={ attributes.connectMailPoet }
102+
setAttributes={ setAttributes }
101103
/>
102104
) }
103105
<SalesforceCard

projects/packages/forms/src/blocks/contact-form/components/jetpack-integrations-modal/mailpoet-card.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@ import MailPoetIcon from '../../../../icons/mailpoet';
55
import IntegrationCard from './integration-card';
66
import type { SingleIntegrationCardProps, IntegrationCardData } from '../../../../types';
77

8+
interface MailPoetCardProps extends SingleIntegrationCardProps {
9+
connectMailPoet: boolean;
10+
setAttributes: ( attrs: { connectMailPoet: boolean } ) => void;
11+
}
12+
813
const MailPoetCard = ( {
914
isExpanded,
1015
onToggle,
16+
connectMailPoet,
17+
setAttributes,
1118
data,
1219
refreshStatus,
13-
}: SingleIntegrationCardProps ) => {
20+
}: MailPoetCardProps ) => {
1421
const {
1522
isConnected: mailpoetActiveWithKey = false,
1623
settingsUrl = '',
@@ -19,7 +26,10 @@ const MailPoetCard = ( {
1926

2027
const cardData: IntegrationCardData = {
2128
...data,
22-
showHeaderToggle: false,
29+
showHeaderToggle: true,
30+
headerToggleValue: connectMailPoet ?? false,
31+
isHeaderToggleEnabled: true,
32+
onHeaderToggleChange: ( value: boolean ) => setAttributes( { connectMailPoet: value } ),
2333
isLoading: ! data || typeof data.isInstalled === 'undefined',
2434
refreshStatus,
2535
trackEventName: 'jetpack_forms_upsell_mailpoet_click',
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { __ } from '@wordpress/i18n';
2+
import { SVG, Circle, Path, SVGProps } from '@wordpress/primitives';
3+
4+
const ICON_SIZE = 152;
5+
const CENTER = ICON_SIZE / 2;
6+
7+
const MailPoetOrangeIcon = ( props: SVGProps & { width?: number; height?: number } ) => {
8+
return (
9+
<SVG
10+
width={ props.width || 32 }
11+
height={ props.height || 32 }
12+
viewBox={ `0 0 ${ ICON_SIZE } ${ ICON_SIZE }` }
13+
fill="none"
14+
xmlns="http://www.w3.org/2000/svg"
15+
role="img"
16+
aria-label={ __( 'MailPoet icon', 'jetpack-forms' ) }
17+
{ ...props }
18+
>
19+
<Circle cx={ CENTER } cy={ CENTER } r={ CENTER } fill="#FF5301" />
20+
<g
21+
transform={ `translate(${ CENTER },${ CENTER }) scale(0.6) translate(-${ CENTER },-${ CENTER })` }
22+
>
23+
<Path
24+
d="M37.71,89.1c3.5,0,5.9-.8,7.2-2.3a8,8,0,0,0,2-5.4V35.7l17,45.1a12.68,12.68,0,0,0,3.7,5.4c1.6,1.3,4,2,7.2,2a12.54,12.54,0,0,0,5.9-1.4,8.41,8.41,0,0,0,3.9-5l18.1-50V81a8.53,8.53,0,0,0,2.1,6.1c1.4,1.4,3.7,2.2,6.9,2.2,3.5,0,5.9-.8,7.2-2.3a8,8,0,0,0,2-5.4V8.7a7.48,7.48,0,0,0-3.3-6.6c-2.1-1.4-5-2.1-8.6-2.1a19.3,19.3,0,0,0-9.4,2,11.63,11.63,0,0,0-5.1,6.8L74.91,67.1,54.41,8.4a12.4,12.4,0,0,0-4.5-6.2c-2.1-1.5-5-2.2-8.8-2.2a16.51,16.51,0,0,0-8.9,2.1c-2.3,1.5-3.5,3.9-3.5,7.2V80.8c0,2.8.7,4.8,2,6.2C32.21,88.4,34.41,89.1,37.71,89.1Z"
25+
fill="#FFF"
26+
/>
27+
<Path
28+
d="M149,116.6l-2.4-1.9a7.4,7.4,0,0,0-9.4.3,19.65,19.65,0,0,1-12.5,4.6h-21.4A37.08,37.08,0,0,0,77,130.5l-1.1,1.2-1.1-1.1a37.25,37.25,0,0,0-26.3-10.9H27a19.59,19.59,0,0,1-12.4-4.6,7.28,7.28,0,0,0-9.4-.3l-2.4,1.9A7.43,7.43,0,0,0,0,122.2a7.14,7.14,0,0,0,2.4,5.7A37.28,37.28,0,0,0,27,137.4h21.6a19.59,19.59,0,0,1,18.9,14.4v.2c.1.7,1.2,4.4,8.5,4.4s8.4-3.7,8.5-4.4v-.2a19.59,19.59,0,0,1,18.9-14.4H125a37.28,37.28,0,0,0,24.6-9.5,7.42,7.42,0,0,0,2.4-5.7A7.86,7.86,0,0,0,149,116.6Z"
29+
fill="#FFF"
30+
/>
31+
</g>
32+
</SVG>
33+
);
34+
};
35+
36+
export default MailPoetOrangeIcon;

0 commit comments

Comments
 (0)