import React from 'react'; import * as WpPluginsLib from '@wordpress/plugins'; import { PluginSidebar } from '@wordpress/edit-post'; import { PanelBody, Icon } from '@wordpress/components'; import { withSelect } from '@wordpress/data'; import UISidebarSelectControl from '../UIComponents/UISidebarSelectControl'; import SidebarSprocketIcon from '../Common/SidebarSprocketIcon'; import styled from 'styled-components'; import { __ } from '@wordpress/i18n'; import { BackgroudAppContext } from '../../iframe/useBackgroundApp'; import { refreshToken } from '../../constants/leadinConfig'; import { getOrCreateBackgroundApp } from '../../utils/backgroundAppUtils'; export function registerHubspotSidebar() { const ContentTypeLabelStyle = styled.div` white-space: normal; text-transform: none; `; const ContentTypeLabel = ( {__( 'Select the content type HubSpot Analytics uses to track this page', 'leadin' )} ); const LeadinPluginSidebar = ({ postType }: { postType: string }) => postType ? ( } > ) : null; const LeadinPluginSidebarWrapper = withSelect((select: Function) => { const data = select('core/editor'); return { postType: data && data.getCurrentPostType() && data.getEditedPostAttribute('meta'), }; })(LeadinPluginSidebar); if (WpPluginsLib) { WpPluginsLib.registerPlugin('leadin', { render: LeadinPluginSidebarWrapper, icon: SidebarSprocketIcon, }); } }