PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.0.7
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.0.7
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 / Sidebar / contentType.tsx

contentType.tsx in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.0.7, at scripts/gutenberg/Sidebar/contentType.tsx

83 lines 2.7 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 { registerPlugin } from '@wordpress/plugins';
3 import { PluginSidebar } from '@wordpress/edit-post';
4 import { PanelBody, Icon } from '@wordpress/components';
5 import { withSelect } from '@wordpress/data';
6 import UISidebarSelectControl from '../UIComponents/UISidebarSelectControl';
7 import SidebarSprocketIcon from '../Common/SidebarSprocketIcon';
8 import styled from 'styled-components';
9 import { __ } from '@wordpress/i18n';
10 import { BackgroudAppContext } from '../../iframe/useBackgroundApp';
11 import { refreshToken } from '../../constants/leadinConfig';
12 import { getOrCreateBackgroundApp } from '../../utils/backgroundAppUtils';
13
14 export function registerHubspotSidebar() {
15 const ContentTypeLabelStyle = styled.div`
16 white-space: normal;
17 text-transform: none;
18 `;
19
20 const ContentTypeLabel = (
21 <ContentTypeLabelStyle>
22 {__(
23 'Select the content type HubSpot Analytics uses to track this page.',
24 'leadin'
25 )}
26 </ContentTypeLabelStyle>
27 );
28
29 const LeadinPluginSidebar = ({ postType }: { postType: string }) =>
30 postType ? (
31 <PluginSidebar
32 name="leadin"
33 title="HubSpot"
34 icon={
35 <Icon
36 className="hs-plugin-sidebar-sprocket"
37 icon={SidebarSprocketIcon()}
38 />
39 }
40 >
41 <PanelBody title={__('HubSpot Analytics', 'leadin')} initialOpen={true}>
42 <BackgroudAppContext.Provider
43 value={refreshToken && getOrCreateBackgroundApp(refreshToken)}
44 >
45 <UISidebarSelectControl
46 metaKey="content-type"
47 className="select-content-type"
48 label={ContentTypeLabel}
49 options={[
50 { label: __('Detect Automatically', 'leadin'), value: '' },
51 { label: __('Blog Post', 'leadin'), value: 'blog-post' },
52 {
53 label: __('Knowledge Article', 'leadin'),
54 value: 'knowledge-article',
55 },
56 { label: __('Landing Page', 'leadin'), value: 'landing-page' },
57 { label: __('Listing Page', 'leadin'), value: 'listing-page' },
58 {
59 label: __('Standard Page', 'leadin'),
60 value: 'standard-page',
61 },
62 ]}
63 />
64 </BackgroudAppContext.Provider>
65 </PanelBody>
66 </PluginSidebar>
67 ) : null;
68 const LeadinPluginSidebarWrapper = withSelect((select: Function) => {
69 const data = select('core/editor');
70 return {
71 postType:
72 data &&
73 data.getCurrentPostType() &&
74 data.getEditedPostAttribute('meta'),
75 };
76 })(LeadinPluginSidebar);
77
78 registerPlugin('leadin', {
79 render: LeadinPluginSidebarWrapper,
80 icon: SidebarSprocketIcon,
81 });
82 }
83