diff --git a/apps/comments-ui/src/App.js b/apps/comments-ui/src/App.js
index fd6e32970e..589140c731 100644
--- a/apps/comments-ui/src/App.js
+++ b/apps/comments-ui/src/App.js
@@ -282,6 +282,7 @@ export default class App extends React.Component {
colorScheme: this.props.colorScheme,
avatarSaturation: this.props.avatarSaturation,
accentColor: this.props.accentColor,
+ commentsEnabled: this.props.commentsEnabled,
dispatchAction: (_action, data) => this.dispatchAction(_action, data),
/**
diff --git a/apps/comments-ui/src/components/Comment.js b/apps/comments-ui/src/components/Comment.js
index ead1ed541a..e9fdb42e4d 100644
--- a/apps/comments-ui/src/components/Comment.js
+++ b/apps/comments-ui/src/components/Comment.js
@@ -21,7 +21,7 @@ const Comment = (props) => {
setIsInReplyMode(current => !current);
};
- const {admin, avatarSaturation} = useContext(AppContext);
+ const {admin, avatarSaturation, member, commentsEnabled} = useContext(AppContext);
const comment = props.comment;
const hasReplies = comment.replies && comment.replies.length > 0;
const isNotPublished = comment.status !== 'published';
@@ -35,6 +35,10 @@ const Comment = (props) => {
}
}
+ const paidOnly = commentsEnabled === 'paid';
+ const isPaidMember = member && !!member.paid;
+ const canReply = member && (isPaidMember || !paidOnly);
+
if (isInEditMode) {
return (
@@ -55,7 +59,7 @@ const Comment = (props) => {
- {(isNotPublished || !props.parent) &&
}
+ {canReply && (isNotPublished || !props.parent) &&
}
{formatRelativeTime(comment.created_at)}
diff --git a/apps/comments-ui/src/components/CommentsBox.js b/apps/comments-ui/src/components/CommentsBox.js
index 73d2cc4556..c06cde0cc0 100644
--- a/apps/comments-ui/src/components/CommentsBox.js
+++ b/apps/comments-ui/src/components/CommentsBox.js
@@ -5,6 +5,7 @@ import Loading from './Loading';
import Form from './Form';
import Comment from './Comment';
import Pagination from './Pagination';
+import NotPaidBox from './NotPaidBox';
const CommentsBox = (props) => {
const luminance = (r, g, b) => {
@@ -40,7 +41,7 @@ const CommentsBox = (props) => {
}
};
- const {accentColor, pagination, member, comments} = useContext(AppContext);
+ const {accentColor, pagination, member, comments, commentsEnabled} = useContext(AppContext);
const commentsElements = comments.slice().reverse().map(comment => );
@@ -50,6 +51,9 @@ const CommentsBox = (props) => {
'--gh-accent-color': accentColor ?? 'blue'
};
+ const paidOnly = commentsEnabled === 'paid';
+ const isPaidMember = member && !!member.paid;
+
return (
@@ -59,7 +63,7 @@ const CommentsBox = (props) => {
{commentsElements}
- { member ? : }
+ { member ? (isPaidMember || !paidOnly ? : ) : }
>
: }
diff --git a/apps/comments-ui/src/components/Like.js b/apps/comments-ui/src/components/Like.js
index 38fcae5aac..822d2ef74f 100644
--- a/apps/comments-ui/src/components/Like.js
+++ b/apps/comments-ui/src/components/Like.js
@@ -3,33 +3,42 @@ import {ReactComponent as LikeIcon} from '../images/icons/like.svg';
import AppContext from '../AppContext';
function Like(props) {
- const {onAction, member} = useContext(AppContext);
+ const {dispatchAction, member, commentsEnabled} = useContext(AppContext);
const [animationClass, setAnimation] = useState('');
- let likeCursor = 'cursor-pointer';
- if (!member) {
- likeCursor = 'cursor-text';
- }
+ const paidOnly = commentsEnabled === 'paid';
+ const isPaidMember = member && !!member.paid;
+ const canLike = member && (isPaidMember || !paidOnly);
const toggleLike = () => {
- if (member) {
- if (!props.comment.liked) {
- onAction('likeComment', props.comment);
- setAnimation('animate-heartbeat');
- setTimeout(() => {
- setAnimation('');
- }, 400);
- } else {
- onAction('unlikeComment', props.comment);
- }
+ if (!canLike) {
+ return;
+ }
+
+ if (!props.comment.liked) {
+ dispatchAction('likeComment', props.comment);
+ setAnimation('animate-heartbeat');
+ setTimeout(() => {
+ setAnimation('');
+ }, 400);
+ } else {
+ dispatchAction('unlikeComment', props.comment);
}
};
+ // If can like: use