| 1 |
import UiMenu from 'elementor-app/ui/menu/menu'; |
| 2 |
import { Context as TemplateTypesContext } from '../context/template-types'; |
| 3 |
import Button from 'elementor-app/ui/molecules/button'; |
| 4 |
import AddNewButton from 'elementor-app/ui/molecules/add-new-button'; |
| 5 |
|
| 6 |
import './menu.scss'; |
| 7 |
|
| 8 |
export default function Menu( props ) { |
| 9 |
const { templateTypes } = React.useContext( TemplateTypesContext ), |
| 10 |
actionButton = ( itemProps ) => { |
| 11 |
const className = 'eps-menu-item__action-button'; |
| 12 |
|
| 13 |
if ( props.promotion ) { |
| 14 |
return <Button text={ __( 'Go Pro', 'elementor' ) } hideText icon="eicon-lock" className={ className } />; |
| 15 |
} |
| 16 |
|
| 17 |
const goToCreate = () => { |
| 18 |
location.href = itemProps.urls.create; |
| 19 |
}; |
| 20 |
|
| 21 |
return ( |
| 22 |
<span className={ className }> |
| 23 |
<AddNewButton hideText={ true } size="sm" onClick={ () => goToCreate() } /> |
| 24 |
</span> |
| 25 |
); |
| 26 |
}; |
| 27 |
|
| 28 |
return ( |
| 29 |
<UiMenu menuItems={ templateTypes } actionButton={ actionButton } promotion={ props.promotion }> |
| 30 |
{ props.allPartsButton } |
| 31 |
<div className="eps-menu__title"> |
| 32 |
{ __( 'Site Parts', 'elementor' ) } |
| 33 |
</div> |
| 34 |
</UiMenu> |
| 35 |
); |
| 36 |
} |
| 37 |
|
| 38 |
Menu.propTypes = { |
| 39 |
allPartsButton: PropTypes.element.isRequired, |
| 40 |
promotion: PropTypes.bool, |
| 41 |
}; |
| 42 |
|