import { h, Component } from 'preact';
import PropTypes from 'prop-types';
import { Button } from '@crayons';
import { Options } from './Options';
const Icon = () => (
);
export class EditorActions extends Component {
constructor(props) {
super(props);
this.state = {
moreConfigShowing: false,
};
}
setCommonProps = ({ moreConfigShowing = false }) => {
return {
moreConfigShowing,
};
};
toggleMoreConfig = (e) => {
const { moreConfigShowing } = this.state;
e.preventDefault();
this.setState({
...this.setCommonProps({ moreConfigShowing: !moreConfigShowing }),
});
};
render() {
const {
onSaveDraft,
onPublish,
onClearChanges,
published,
edited,
version,
passedData,
onConfigChange,
submitting,
} = this.props;
const { moreConfigShowing } = this.state;
return submitting ? (
) : (
{published || version === 'v1' ? (
''
) : (
)}
{version === 'v2' && (
{moreConfigShowing && (
)}
)}
{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';