mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
Moved AuthorContextMenu to newer syntax
This commit is contained in:
parent
65eb942c73
commit
aa8b729180
@ -1,37 +1,24 @@
|
||||
import React from 'react';
|
||||
import React, {useContext} from 'react';
|
||||
import AppContext from '../../AppContext';
|
||||
|
||||
class AuthorContextMenu extends React.Component {
|
||||
static contextType = AppContext;
|
||||
const AuthorContextMenu = (props) => {
|
||||
const {dispatchAction} = useContext(AppContext);
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {};
|
||||
const deleteComment = (event) => {
|
||||
dispatchAction('deleteComment', props.comment);
|
||||
props.close();
|
||||
};
|
||||
|
||||
this.deleteComment = this.deleteComment.bind(this);
|
||||
}
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<button className="w-full mb-3 text-left text-[14px]" onClick={props.toggleEdit}>
|
||||
Edit
|
||||
</button>
|
||||
<button className="w-full text-left text-[14px]" onClick={deleteComment}>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
deleteComment(event) {
|
||||
this.context.onAction('deleteComment', this.props.comment);
|
||||
this.close();
|
||||
}
|
||||
|
||||
close() {
|
||||
this.props.close();
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<button className="w-full mb-3 text-left text-[14px]" onClick={this.props.toggleEdit}>
|
||||
Edit
|
||||
</button>
|
||||
<button className="w-full text-left text-[14px]" onClick={this.deleteComment}>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default AuthorContextMenu;
|
||||
|
Loading…
Reference in New Issue
Block a user