PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.1.21
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.1.21
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
leadin / scripts / gutenberg / MeetingsBlock / registerMeetingBlock.tsx

registerMeetingBlock.tsx in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.1.21, at scripts/gutenberg/MeetingsBlock/registerMeetingBlock.tsx

72 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React from 'react';
2 import * as WpBlocksApi from '@wordpress/blocks';
3 import CalendarIcon from '../Common/CalendarIcon';
4 import { connectionStatus } from '../../constants/leadinConfig';
5 import MeetingGutenbergPreview from './MeetingGutenbergPreview';
6 import MeetingSaveBlock from './MeetingSaveBlock';
7 import MeetingEdit from '../../shared/Meeting/MeetingEdit';
8 import ErrorHandler from '../../shared/Common/ErrorHandler';
9 import { __ } from '@wordpress/i18n';
10 import { isFullSiteEditor } from '../../utils/withMetaData';
11
12 const ConnectionStatus = {
13 Connected: 'Connected',
14 NotConnected: 'NotConnected',
15 };
16
17 export interface IMeetingBlockAttributes {
18 attributes: {
19 url: string;
20 preview?: boolean;
21 };
22 }
23
24 export interface IMeetingBlockProps extends IMeetingBlockAttributes {
25 setAttributes: Function;
26 isSelected: boolean;
27 }
28
29 export default function registerMeetingBlock() {
30 const editComponent = (props: IMeetingBlockProps) => {
31 if (props.attributes.preview) {
32 return <MeetingGutenbergPreview />;
33 } else if (connectionStatus === ConnectionStatus.Connected) {
34 return <MeetingEdit {...props} preview={true} origin="gutenberg" />;
35 } else {
36 return <ErrorHandler status={401} />;
37 }
38 };
39
40 // We do not support the full site editor: https://issues.hubspotcentral.com/browse/WP-1033
41 if (!WpBlocksApi || isFullSiteEditor()) {
42 return null;
43 }
44
45 WpBlocksApi.registerBlockType('leadin/hubspot-meeting-block', {
46 title: __('Hubspot Meetings Scheduler', 'leadin'),
47 description: __(
48 'Schedule meetings faster and forget the back-and-forth emails Your calendar stays full, and you stay productive',
49 'leadin'
50 ),
51 icon: CalendarIcon,
52 category: 'leadin-blocks',
53 attributes: {
54 url: {
55 type: 'string',
56 default: '',
57 } as WpBlocksApi.BlockAttribute<string>,
58 preview: {
59 type: 'boolean',
60 default: false,
61 } as WpBlocksApi.BlockAttribute<boolean>,
62 },
63 example: {
64 attributes: {
65 preview: true,
66 },
67 },
68 edit: editComponent,
69 save: props => <MeetingSaveBlock {...props} />,
70 });
71 }
72