File size: 1,142 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Gridicon } from '@automattic/components';
import { Button } from '@wordpress/components';
import clsx from 'clsx';
import { localize } from 'i18n-calypso';
import PropTypes from 'prop-types';

import './comment-approve-action.scss';

const noop = () => {};

const CommentApproveAction = ( { translate, status, approveComment, unapproveComment } ) => {
	const isApproved = status === 'approved';
	const buttonStyle = clsx( 'comments__comment-actions-approve', {
		'is-approved': isApproved,
	} );

	return (
		<Button className={ buttonStyle } onClick={ ! isApproved ? approveComment : unapproveComment }>
			<Gridicon icon="checkmark" size={ 18 } />
			<span className="comments__comment-actions-like-label">
				{ isApproved ? translate( 'Approved' ) : translate( 'Approve' ) }
			</span>
		</Button>
	);
};

CommentApproveAction.propTypes = {
	translate: PropTypes.func.isRequired,
	approveComment: PropTypes.func,
	unapproveComment: PropTypes.func,
	status: PropTypes.string.isRequired,
};

CommentApproveAction.defaultProps = {
	approveComment: noop,
	unapproveComment: noop,
};

export default localize( CommentApproveAction );