import { h } from 'preact'; import { useState } from 'preact/hooks'; import PropTypes from 'prop-types'; import { Options } from './Options'; import { Button } from '@crayons'; const Icon = () => ( Post options ); export const EditorActions = ({ onSaveDraft, onPublish, onClearChanges, published, edited, version, passedData, onConfigChange, submitting, }) => { const [moreConfigShowing, setMoreConfig] = useState(false); const isVersion1 = version === 'v1'; const isVersion2 = version === 'v2'; const toggleMoreConfig = (e) => { e.preventDefault(); setMoreConfig(!moreConfigShowing); }; if (submitting) { return (
); } return (
{!(published || isVersion1) && ( )} {isVersion2 && (
)} {edited && ( )}
); }; EditorActions.propTypes = { onSaveDraft: PropTypes.func.isRequired, onPublish: PropTypes.func.isRequired, published: PropTypes.bool.isRequired, edited: PropTypes.bool.isRequired, version: PropTypes.string.isRequired, onClearChanges: PropTypes.func.isRequired, passedData: PropTypes.string.isRequired, onConfigChange: PropTypes.func.isRequired, submitting: PropTypes.bool.isRequired, }; EditorActions.displayName = 'EditorActions';