mirror of
https://github.com/wassname/talk.git
synced 2026-08-15 12:55:10 +08:00
chore: rename accept comment to approve comment (#2341)
This commit is contained in:
@@ -16,7 +16,7 @@ enum PROFILE_TAB {
|
||||
|
||||
enum COMMENT_VIEWER_ACTION {
|
||||
EDIT
|
||||
ACCEPT
|
||||
APPROVE
|
||||
REJECT
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -6,17 +6,17 @@ import {
|
||||
createMutation,
|
||||
MutationInput,
|
||||
} from "coral-framework/lib/relay";
|
||||
import { AcceptCommentMutation as MutationTypes } from "coral-stream/__generated__/AcceptCommentMutation.graphql";
|
||||
import { ApproveCommentMutation as MutationTypes } from "coral-stream/__generated__/ApproveCommentMutation.graphql";
|
||||
|
||||
let clientMutationId = 0;
|
||||
|
||||
const AcceptCommentMutation = createMutation(
|
||||
"acceptComment",
|
||||
const ApproveCommentMutation = createMutation(
|
||||
"approveComment",
|
||||
(environment: Environment, input: MutationInput<MutationTypes>) =>
|
||||
commitMutationPromiseNormalized<MutationTypes>(environment, {
|
||||
mutation: graphql`
|
||||
mutation AcceptCommentMutation($input: AcceptCommentInput!) {
|
||||
acceptComment(input: $input) {
|
||||
mutation ApproveCommentMutation($input: ApproveCommentInput!) {
|
||||
approveComment(input: $input) {
|
||||
comment {
|
||||
status
|
||||
}
|
||||
@@ -25,9 +25,9 @@ const AcceptCommentMutation = createMutation(
|
||||
}
|
||||
`,
|
||||
optimisticResponse: {
|
||||
acceptComment: {
|
||||
approveComment: {
|
||||
comment: {
|
||||
status: "ACCEPTED",
|
||||
status: "APPROVED",
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -38,9 +38,9 @@ const AcceptCommentMutation = createMutation(
|
||||
},
|
||||
},
|
||||
updater: store => {
|
||||
store.get(input.commentID)!.setValue("ACCEPT", "lastViewerAction");
|
||||
store.get(input.commentID)!.setValue("APPROVE", "lastViewerAction");
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
export default AcceptCommentMutation;
|
||||
export default ApproveCommentMutation;
|
||||
+9
-9
@@ -11,7 +11,7 @@ import {
|
||||
Icon,
|
||||
} from "coral-ui/components";
|
||||
|
||||
import AcceptCommentMutation from "./AcceptCommentMutation";
|
||||
import ApproveCommentMutation from "./ApproveCommentMutation";
|
||||
import styles from "./ModerationDropdownContainer.css";
|
||||
import RejectCommentMutation from "./RejectCommentMutation";
|
||||
|
||||
@@ -24,24 +24,24 @@ const ModerationDropdownContainer: FunctionComponent<Props> = ({
|
||||
comment,
|
||||
onDismiss,
|
||||
}) => {
|
||||
const accept = useMutation(AcceptCommentMutation);
|
||||
const approve = useMutation(ApproveCommentMutation);
|
||||
const reject = useMutation(RejectCommentMutation);
|
||||
|
||||
const onAccept = useCallback(() => {
|
||||
accept({ commentID: comment.id, commentRevisionID: comment.revision.id });
|
||||
}, [accept, comment]);
|
||||
const onApprove = useCallback(() => {
|
||||
approve({ commentID: comment.id, commentRevisionID: comment.revision.id });
|
||||
}, [approve, comment]);
|
||||
const onReject = useCallback(
|
||||
() =>
|
||||
reject({ commentID: comment.id, commentRevisionID: comment.revision.id }),
|
||||
[accept, comment]
|
||||
[approve, comment]
|
||||
);
|
||||
|
||||
const accepted = comment.status === "ACCEPTED";
|
||||
const approved = comment.status === "APPROVED";
|
||||
const rejected = comment.status === "REJECTED";
|
||||
|
||||
return (
|
||||
<Dropdown>
|
||||
{accepted ? (
|
||||
{approved ? (
|
||||
<Localized id="comments-moderationDropdown-approved">
|
||||
<DropdownButton
|
||||
icon={<Icon className={styles.approved}>check</Icon>}
|
||||
@@ -53,7 +53,7 @@ const ModerationDropdownContainer: FunctionComponent<Props> = ({
|
||||
</Localized>
|
||||
) : (
|
||||
<Localized id="comments-moderationDropdown-approve">
|
||||
<DropdownButton icon={<Icon>check</Icon>} onClick={onAccept}>
|
||||
<DropdownButton icon={<Icon>check</Icon>} onClick={onApprove}>
|
||||
Approve
|
||||
</DropdownButton>
|
||||
</Localized>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { COMMENT_STATUS } from "coral-stream/__generated__/CreateCommentMutation.graphql";
|
||||
|
||||
const VisibleStatus = ["ACCEPTED", "NONE"];
|
||||
const VisibleStatus = ["APPROVED", "NONE"];
|
||||
|
||||
export default function isCommentVisible(comment: {
|
||||
status: COMMENT_STATUS;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// TODO: use generated schema types.
|
||||
const visibleStatuses = ["NONE", "ACCEPTED"];
|
||||
const visibleStatuses = ["NONE", "APPROVED"];
|
||||
|
||||
export default function isVisible(status: any) {
|
||||
return visibleStatuses.includes(status);
|
||||
|
||||
@@ -63,18 +63,18 @@ it("render go to moderate link", async () => {
|
||||
expect(link.props.href).toBe(`/admin/moderate/comment/${firstComment.id}`);
|
||||
});
|
||||
|
||||
it("accept comment", async () => {
|
||||
it("approve comment", async () => {
|
||||
const { testRenderer } = await createTestRenderer({
|
||||
resolvers: createResolversStub<GQLResolver>({
|
||||
Mutation: {
|
||||
acceptComment: ({ variables }) => {
|
||||
approveComment: ({ variables }) => {
|
||||
expectAndFail(variables).toMatchObject({
|
||||
commentID: firstComment.id,
|
||||
commentRevisionID: firstComment.revision.id,
|
||||
});
|
||||
return {
|
||||
comment: pureMerge<typeof firstComment>(firstComment, {
|
||||
status: GQLCOMMENT_STATUS.ACCEPTED,
|
||||
status: GQLCOMMENT_STATUS.APPROVED,
|
||||
}),
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user