/**
* WordPress dependencies
*/
import { Button, DropdownMenu, MenuGroup, MenuItem } from '@wordpress/components';
import { useEffect } from '@wordpress/element';
import { __ } from '@wordpress/i18n';
import { desktop, external, moreVertical, pencil } from '@wordpress/icons';
/**
* Internal dependencies
*/
import { LeafIcon } from '../../../../../common/icons/leaf-icon';
import { HydratedPost } from '../../../../../common/providers/base-wordpress-provider';
import { TrafficBoostLink } from '../../provider';
import { isExternalURL } from '../utils';
import { LinkCounter } from './link-counter';
/**
* Props structure for VerticalMoreMenu.
*
* @since 3.19.0
*/
interface VerticalMoreMenuProps {
post: HydratedPost;
onEditClick: ( post: HydratedPost ) => void;
onViewInNewTabClick: ( post: HydratedPost ) => void;
onViewInParseLyClick: ( post: HydratedPost ) => void;
}
/**
* VerticalMoreMenu component.
*
* This component is used to display a dropdown menu with actions for a post.
*
* @since 3.19.0
*
* @param {VerticalMoreMenuProps} props The component's props.
*/
const VerticalMoreMenu = ( {
post,
onEditClick,
onViewInNewTabClick,
onViewInParseLyClick,
}: VerticalMoreMenuProps ): React.JSX.Element => {
/**
* Handles the click event for the dropdown menu items.
*
* @since 3.19.0
*
* @param {string} type The type of action to perform.
* @param {Function} onClose The function to call when the action is performed.
*/
const onClickHandler = ( type: string, onClose: () => void ) => {
switch ( type ) {
case 'edit':
onEditClick( post );
break;
case 'view-in-new-tab':
onViewInNewTabClick( post );
break;
case 'view-in-parse-ly':
onViewInParseLyClick( post );
break;
}
onClose();
};
return (