From 8cfced464b7f43cd6d14c8f4a9322a4bc986c0c5 Mon Sep 17 00:00:00 2001 From: Kiwi Date: Thu, 6 Jun 2019 20:58:11 +0200 Subject: [PATCH] chore: rename accept comment to approve comment (#2341) --- ...tMutation.ts => ApproveCommentMutation.ts} | 18 ++-- src/core/client/admin/mutations/index.ts | 2 +- .../{AcceptButton.css => ApproveButton.css} | 0 ...Button.spec.tsx => ApproveButton.spec.tsx} | 10 +- .../{AcceptButton.tsx => ApproveButton.tsx} | 10 +- .../moderate/components/ModerateCard.spec.tsx | 6 +- .../moderate/components/ModerateCard.tsx | 16 ++-- ...c.tsx.snap => ApproveButton.spec.tsx.snap} | 16 ++-- .../__snapshots__/ModerateCard.spec.tsx.snap | 14 +-- .../containers/ModerateCardContainer.tsx | 16 ++-- .../moderate/containers/QueueContainer.tsx | 2 +- .../containers/RejectedQueueContainer.tsx | 2 +- .../decisionHistory.spec.tsx.snap | 12 +-- src/core/client/admin/test/fixtures.ts | 6 +- .../__snapshots__/moderate.spec.tsx.snap | 94 +++++++++---------- .../admin/test/moderate/moderate.spec.tsx | 54 +++++------ ...ment.spec.tsx => ApprovedComment.spec.tsx} | 6 +- ...cceptedComment.tsx => ApprovedComment.tsx} | 12 +-- .../{AcceptedIcon.css => ApprovedIcon.css} | 0 ...tedIcon.spec.tsx => ApprovedIcon.spec.tsx} | 4 +- .../{AcceptedIcon.tsx => ApprovedIcon.tsx} | 6 +- ...tsx.snap => ApprovedComment.spec.tsx.snap} | 6 +- ...ec.tsx.snap => ApprovedIcon.spec.tsx.snap} | 2 +- .../DecisionHistoryItemContainer.tsx | 6 +- src/core/client/framework/lib/rest.ts | 2 +- src/core/client/stream/local/local.graphql | 2 +- ...tMutation.ts => ApproveCommentMutation.ts} | 18 ++-- .../ModerationDropdownContainer.tsx | 18 ++-- .../tabs/Comments/helpers/isCommentVisible.ts | 2 +- .../stream/tabs/Comments/helpers/isVisible.ts | 2 +- .../test/comments/stream/moderation.spec.tsx | 6 +- .../server/graph/tenant/mutators/Actions.ts | 8 +- .../tenant/resolvers/AcceptCommentPayload.ts | 7 -- .../tenant/resolvers/ApproveCommentPayload.ts | 7 ++ .../tenant/resolvers/ModerationQueues.ts | 4 +- .../server/graph/tenant/resolvers/Mutation.ts | 4 +- .../server/graph/tenant/resolvers/index.ts | 4 +- .../server/graph/tenant/schema/schema.graphql | 24 ++--- src/core/server/models/comment/constants.ts | 2 +- src/core/server/models/comment/index.ts | 2 +- src/core/server/models/story/counts/empty.ts | 2 +- src/core/server/models/story/counts/index.ts | 6 +- .../comments/moderation/counts.spec.ts | 24 ++--- .../comments/moderation/index.spec.ts | 24 ++--- .../services/comments/moderation/index.ts | 4 +- .../services/comments/pipeline/index.spec.ts | 6 +- .../comments/pipeline/phases/staff.ts | 2 +- src/locales/en-US/admin.ftl | 6 +- 48 files changed, 253 insertions(+), 253 deletions(-) rename src/core/client/admin/mutations/{AcceptCommentMutation.ts => ApproveCommentMutation.ts} (81%) rename src/core/client/admin/routes/moderate/components/{AcceptButton.css => ApproveButton.css} (100%) rename src/core/client/admin/routes/moderate/components/{AcceptButton.spec.tsx => ApproveButton.spec.tsx} (64%) rename src/core/client/admin/routes/moderate/components/{AcceptButton.tsx => ApproveButton.tsx} (72%) rename src/core/client/admin/routes/moderate/components/__snapshots__/{AcceptButton.spec.tsx.snap => ApproveButton.spec.tsx.snap} (67%) rename src/core/client/admin/views/decisionHistory/components/{AcceptedComment.spec.tsx => ApprovedComment.spec.tsx} (73%) rename src/core/client/admin/views/decisionHistory/components/{AcceptedComment.tsx => ApprovedComment.tsx} (77%) rename src/core/client/admin/views/decisionHistory/components/{AcceptedIcon.css => ApprovedIcon.css} (100%) rename src/core/client/admin/views/decisionHistory/components/{AcceptedIcon.spec.tsx => ApprovedIcon.spec.tsx} (73%) rename src/core/client/admin/views/decisionHistory/components/{AcceptedIcon.tsx => ApprovedIcon.tsx} (55%) rename src/core/client/admin/views/decisionHistory/components/__snapshots__/{AcceptedComment.spec.tsx.snap => ApprovedComment.spec.tsx.snap} (80%) rename src/core/client/admin/views/decisionHistory/components/__snapshots__/{AcceptedIcon.spec.tsx.snap => ApprovedIcon.spec.tsx.snap} (81%) rename src/core/client/stream/tabs/Comments/Comment/ModerationDropdown/{AcceptCommentMutation.ts => ApproveCommentMutation.ts} (61%) delete mode 100644 src/core/server/graph/tenant/resolvers/AcceptCommentPayload.ts create mode 100644 src/core/server/graph/tenant/resolvers/ApproveCommentPayload.ts diff --git a/src/core/client/admin/mutations/AcceptCommentMutation.ts b/src/core/client/admin/mutations/ApproveCommentMutation.ts similarity index 81% rename from src/core/client/admin/mutations/AcceptCommentMutation.ts rename to src/core/client/admin/mutations/ApproveCommentMutation.ts index 6d16fd363..391fab9bf 100644 --- a/src/core/client/admin/mutations/AcceptCommentMutation.ts +++ b/src/core/client/admin/mutations/ApproveCommentMutation.ts @@ -1,7 +1,7 @@ import { graphql } from "react-relay"; import { ConnectionHandler, Environment } from "relay-runtime"; -import { AcceptCommentMutation as MutationTypes } from "coral-admin/__generated__/AcceptCommentMutation.graphql"; +import { ApproveCommentMutation as MutationTypes } from "coral-admin/__generated__/ApproveCommentMutation.graphql"; import { getQueueConnection } from "coral-admin/helpers"; import { commitMutationPromiseNormalized, @@ -11,19 +11,19 @@ import { let clientMutationId = 0; -const AcceptCommentMutation = createMutation( - "acceptComment", +const ApproveCommentMutation = createMutation( + "approveComment", ( environment: Environment, input: MutationInput & { storyID?: string } ) => commitMutationPromiseNormalized(environment, { mutation: graphql` - mutation AcceptCommentMutation( - $input: AcceptCommentInput! + mutation ApproveCommentMutation( + $input: ApproveCommentInput! $storyID: ID ) { - acceptComment(input: $input) { + approveComment(input: $input) { comment { id status @@ -51,10 +51,10 @@ const AcceptCommentMutation = createMutation( }, }, optimisticResponse: { - acceptComment: { + approveComment: { comment: { id: input.commentID, - status: "ACCEPTED", + status: "APPROVED", }, clientMutationId: (clientMutationId++).toString(), }, @@ -73,4 +73,4 @@ const AcceptCommentMutation = createMutation( }) ); -export default AcceptCommentMutation; +export default ApproveCommentMutation; diff --git a/src/core/client/admin/mutations/index.ts b/src/core/client/admin/mutations/index.ts index 2730bd096..b96ef22e9 100644 --- a/src/core/client/admin/mutations/index.ts +++ b/src/core/client/admin/mutations/index.ts @@ -1,6 +1,6 @@ export { default as SignInMutation } from "./SignInMutation"; export { default as SetRedirectPathMutation } from "./SetRedirectPathMutation"; -export { default as AcceptCommentMutation } from "./AcceptCommentMutation"; +export { default as ApproveCommentMutation } from "./ApproveCommentMutation"; export { default as RejectCommentMutation } from "./RejectCommentMutation"; export { default as UpdateSettingsMutation } from "./UpdateSettingsMutation"; export { diff --git a/src/core/client/admin/routes/moderate/components/AcceptButton.css b/src/core/client/admin/routes/moderate/components/ApproveButton.css similarity index 100% rename from src/core/client/admin/routes/moderate/components/AcceptButton.css rename to src/core/client/admin/routes/moderate/components/ApproveButton.css diff --git a/src/core/client/admin/routes/moderate/components/AcceptButton.spec.tsx b/src/core/client/admin/routes/moderate/components/ApproveButton.spec.tsx similarity index 64% rename from src/core/client/admin/routes/moderate/components/AcceptButton.spec.tsx rename to src/core/client/admin/routes/moderate/components/ApproveButton.spec.tsx index e27c93433..832ac2d97 100644 --- a/src/core/client/admin/routes/moderate/components/AcceptButton.spec.tsx +++ b/src/core/client/admin/routes/moderate/components/ApproveButton.spec.tsx @@ -1,24 +1,24 @@ import React from "react"; import { createRenderer } from "react-test-renderer/shallow"; -import AcceptButton from "./AcceptButton"; +import ApproveButton from "./ApproveButton"; import { PropTypesOf } from "coral-framework/types"; it("renders correctly", () => { - const props: PropTypesOf = { + const props: PropTypesOf = { invert: false, }; const renderer = createRenderer(); - renderer.render(); + renderer.render(); expect(renderer.getRenderOutput()).toMatchSnapshot(); }); it("renders correctly inverted", () => { - const props: PropTypesOf = { + const props: PropTypesOf = { invert: true, }; const renderer = createRenderer(); - renderer.render(); + renderer.render(); expect(renderer.getRenderOutput()).toMatchSnapshot(); }); diff --git a/src/core/client/admin/routes/moderate/components/AcceptButton.tsx b/src/core/client/admin/routes/moderate/components/ApproveButton.tsx similarity index 72% rename from src/core/client/admin/routes/moderate/components/AcceptButton.tsx rename to src/core/client/admin/routes/moderate/components/ApproveButton.tsx index 8c6abfb0b..8be2ef2ac 100644 --- a/src/core/client/admin/routes/moderate/components/AcceptButton.tsx +++ b/src/core/client/admin/routes/moderate/components/ApproveButton.tsx @@ -5,24 +5,24 @@ import React, { FunctionComponent } from "react"; import { PropTypesOf } from "coral-framework/types"; import { BaseButton, Icon } from "coral-ui/components"; -import styles from "./AcceptButton.css"; +import styles from "./ApproveButton.css"; interface Props extends PropTypesOf { invert?: boolean; } -const AcceptButton: FunctionComponent = ({ +const ApproveButton: FunctionComponent = ({ invert, className, ...rest }) => ( - + done @@ -31,4 +31,4 @@ const AcceptButton: FunctionComponent = ({ ); -export default AcceptButton; +export default ApproveButton; diff --git a/src/core/client/admin/routes/moderate/components/ModerateCard.spec.tsx b/src/core/client/admin/routes/moderate/components/ModerateCard.spec.tsx index d3f2ee985..f8609bf45 100644 --- a/src/core/client/admin/routes/moderate/components/ModerateCard.spec.tsx +++ b/src/core/client/admin/routes/moderate/components/ModerateCard.spec.tsx @@ -20,7 +20,7 @@ const baseProps: PropTypesOf = { viewContextHref: "http://localhost/comment", suspectWords: ["idiot"], bannedWords: ["fuck"], - onAccept: noop, + onApprove: noop, onReject: noop, showStory: false, }; @@ -44,10 +44,10 @@ it("renders reply correctly", () => { expect(renderer.getRenderOutput()).toMatchSnapshot(); }); -it("renders accepted correctly", () => { +it("renders approved correctly", () => { const props: PropTypesOf = { ...baseProps, - status: "accepted", + status: "approved", }; const renderer = createRenderer(); renderer.render(); diff --git a/src/core/client/admin/routes/moderate/components/ModerateCard.tsx b/src/core/client/admin/routes/moderate/components/ModerateCard.tsx index 8eb0e17c9..66961dad7 100644 --- a/src/core/client/admin/routes/moderate/components/ModerateCard.tsx +++ b/src/core/client/admin/routes/moderate/components/ModerateCard.tsx @@ -6,7 +6,7 @@ import { PropTypesOf } from "coral-framework/types"; import { Card, Flex, HorizontalGutter, TextLink } from "coral-ui/components"; import MarkersContainer from "../containers/MarkersContainer"; -import AcceptButton from "./AcceptButton"; +import ApproveButton from "./ApproveButton"; import CommentContent from "./CommentContent"; import InReplyTo from "./InReplyTo"; import RejectButton from "./RejectButton"; @@ -22,7 +22,7 @@ interface Props { body: string; inReplyTo: string | null; comment: PropTypesOf["comment"]; - status: "accepted" | "rejected" | "undecided"; + status: "approved" | "rejected" | "undecided"; viewContextHref: string; suspectWords: ReadonlyArray; bannedWords: ReadonlyArray; @@ -30,7 +30,7 @@ interface Props { storyTitle?: React.ReactNode; storyHref?: string; onModerateStory?: React.EventHandler; - onAccept: () => void; + onApprove: () => void; onReject: () => void; /** * If set to true, it means this comment is about to be removed @@ -51,7 +51,7 @@ const ModerateCard: FunctionComponent = ({ status, suspectWords, bannedWords, - onAccept, + onApprove, onReject, dangling, showStory, @@ -136,10 +136,10 @@ const ModerateCard: FunctionComponent = ({ invert={status === "rejected"} disabled={status === "rejected" || dangling} /> - diff --git a/src/core/client/admin/routes/moderate/components/__snapshots__/AcceptButton.spec.tsx.snap b/src/core/client/admin/routes/moderate/components/__snapshots__/ApproveButton.spec.tsx.snap similarity index 67% rename from src/core/client/admin/routes/moderate/components/__snapshots__/AcceptButton.spec.tsx.snap rename to src/core/client/admin/routes/moderate/components/__snapshots__/ApproveButton.spec.tsx.snap index 8839b592b..941572a80 100644 --- a/src/core/client/admin/routes/moderate/components/__snapshots__/AcceptButton.spec.tsx.snap +++ b/src/core/client/admin/routes/moderate/components/__snapshots__/ApproveButton.spec.tsx.snap @@ -7,14 +7,14 @@ exports[`renders correctly 1`] = ` "aria-label": true, } } - id="moderate-comment-acceptButton" + id="moderate-comment-approveButton" > done @@ -30,14 +30,14 @@ exports[`renders correctly inverted 1`] = ` "aria-label": true, } } - id="moderate-comment-acceptButton" + id="moderate-comment-approveButton" > done diff --git a/src/core/client/admin/routes/moderate/components/__snapshots__/ModerateCard.spec.tsx.snap b/src/core/client/admin/routes/moderate/components/__snapshots__/ModerateCard.spec.tsx.snap index f46f25c76..7e965e933 100644 --- a/src/core/client/admin/routes/moderate/components/__snapshots__/ModerateCard.spec.tsx.snap +++ b/src/core/client/admin/routes/moderate/components/__snapshots__/ModerateCard.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`renders accepted correctly 1`] = ` +exports[`renders approved correctly 1`] = ` - - @@ -280,7 +280,7 @@ exports[`renders dangling correctly 1`] = ` invert={false} onClick={[Function]} /> - - @@ -479,7 +479,7 @@ exports[`renders reply correctly 1`] = ` invert={false} onClick={[Function]} /> - @@ -604,7 +604,7 @@ exports[`renders story info 1`] = ` invert={false} onClick={[Function]} /> - diff --git a/src/core/client/admin/routes/moderate/containers/ModerateCardContainer.tsx b/src/core/client/admin/routes/moderate/containers/ModerateCardContainer.tsx index 5b36ee313..caf62ae79 100644 --- a/src/core/client/admin/routes/moderate/containers/ModerateCardContainer.tsx +++ b/src/core/client/admin/routes/moderate/containers/ModerateCardContainer.tsx @@ -8,7 +8,7 @@ import { } from "coral-admin/__generated__/ModerateCardContainer_comment.graphql"; import { ModerateCardContainer_settings as SettingsData } from "coral-admin/__generated__/ModerateCardContainer_settings.graphql"; import NotAvailable from "coral-admin/components/NotAvailable"; -import { AcceptCommentMutation } from "coral-admin/mutations"; +import { ApproveCommentMutation } from "coral-admin/mutations"; import { RejectCommentMutation } from "coral-admin/mutations"; import { MutationProp, @@ -22,7 +22,7 @@ import ModerateCard from "../components/ModerateCard"; interface Props { comment: CommentData; settings: SettingsData; - acceptComment: MutationProp; + approveComment: MutationProp; rejectComment: MutationProp; danglingLogic: (status: COMMENT_STATUS) => boolean; match: Match; @@ -32,8 +32,8 @@ interface Props { function getStatus(comment: CommentData) { switch (comment.status) { - case "ACCEPTED": - return "accepted"; + case "APPROVED": + return "approved"; case "REJECTED": return "rejected"; default: @@ -42,8 +42,8 @@ function getStatus(comment: CommentData) { } class ModerateCardContainer extends React.Component { - private handleAccept = () => { - this.props.acceptComment({ + private handleApprove = () => { + this.props.approveComment({ commentID: this.props.comment.id, commentRevisionID: this.props.comment.revision.id, storyID: this.props.match.params.storyID, @@ -81,7 +81,7 @@ class ModerateCardContainer extends React.Component { viewContextHref={comment.permalink} suspectWords={settings.wordList.suspect} bannedWords={settings.wordList.banned} - onAccept={this.handleAccept} + onApprove={this.handleApprove} onReject={this.handleReject} dangling={danglingLogic(comment.status)} showStory={showStoryInfo} @@ -135,7 +135,7 @@ const enhanced = withFragmentContainer({ `, })( withRouter( - withMutation(AcceptCommentMutation)( + withMutation(ApproveCommentMutation)( withMutation(RejectCommentMutation)(ModerateCardContainer) ) ) diff --git a/src/core/client/admin/routes/moderate/containers/QueueContainer.tsx b/src/core/client/admin/routes/moderate/containers/QueueContainer.tsx index 9a54812e9..a0bf11636 100644 --- a/src/core/client/admin/routes/moderate/containers/QueueContainer.tsx +++ b/src/core/client/admin/routes/moderate/containers/QueueContainer.tsx @@ -23,7 +23,7 @@ interface QueueContainerProps { // TODO: use generated types const danglingLogic = (status: string) => - ["ACCEPTED", "REJECTED"].indexOf(status) >= 0; + ["APPROVED", "REJECTED"].indexOf(status) >= 0; export class QueueContainer extends React.Component { public static routeConfig: RouteProps; diff --git a/src/core/client/admin/routes/moderate/containers/RejectedQueueContainer.tsx b/src/core/client/admin/routes/moderate/containers/RejectedQueueContainer.tsx index 7486dd261..bd6e94328 100644 --- a/src/core/client/admin/routes/moderate/containers/RejectedQueueContainer.tsx +++ b/src/core/client/admin/routes/moderate/containers/RejectedQueueContainer.tsx @@ -19,7 +19,7 @@ interface RejectedQueueContainerProps { } // TODO: use generated types -const danglingLogic = (status: string) => ["ACCEPTED"].indexOf(status) >= 0; +const danglingLogic = (status: string) => ["APPROVED"].indexOf(status) >= 0; export class RejectedQueueContainer extends React.Component< RejectedQueueContainerProps diff --git a/src/core/client/admin/test/decisionHistory/__snapshots__/decisionHistory.spec.tsx.snap b/src/core/client/admin/test/decisionHistory/__snapshots__/decisionHistory.spec.tsx.snap index 55ca11d5a..2234414dc 100644 --- a/src/core/client/admin/test/decisionHistory/__snapshots__/decisionHistory.spec.tsx.snap +++ b/src/core/client/admin/test/decisionHistory/__snapshots__/decisionHistory.spec.tsx.snap @@ -39,7 +39,7 @@ exports[`loads more 1`] = ` > @@ -48,7 +48,7 @@ exports[`loads more 1`] = `

- Accepted comment by + Approved comment by dany @@ -167,7 +167,7 @@ exports[`loads more 1`] = ` > @@ -176,7 +176,7 @@ exports[`loads more 1`] = `

- Accepted comment by + Approved comment by dany @@ -296,7 +296,7 @@ exports[`render popover content 1`] = ` > @@ -305,7 +305,7 @@ exports[`render popover content 1`] = `

- Accepted comment by + Approved comment by addy diff --git a/src/core/client/admin/test/fixtures.ts b/src/core/client/admin/test/fixtures.ts index 068a841d7..1094aaa80 100644 --- a/src/core/client/admin/test/fixtures.ts +++ b/src/core/client/admin/test/fixtures.ts @@ -196,7 +196,7 @@ export const moderationActions = createFixtures([ }, }, createdAt: "2018-11-29T16:01:51.897Z", - status: GQLCOMMENT_STATUS.ACCEPTED, + status: GQLCOMMENT_STATUS.APPROVED, __typename: "CommentModerationAction", }, { @@ -228,7 +228,7 @@ export const moderationActions = createFixtures([ }, }, createdAt: "2018-11-29T16:01:42.060Z", - status: GQLCOMMENT_STATUS.ACCEPTED, + status: GQLCOMMENT_STATUS.APPROVED, __typename: "CommentModerationAction", }, { @@ -260,7 +260,7 @@ export const moderationActions = createFixtures([ }, }, createdAt: "2018-11-29T16:01:30.648Z", - status: GQLCOMMENT_STATUS.ACCEPTED, + status: GQLCOMMENT_STATUS.APPROVED, __typename: "CommentModerationAction", }, ]); diff --git a/src/core/client/admin/test/moderate/__snapshots__/moderate.spec.tsx.snap b/src/core/client/admin/test/moderate/__snapshots__/moderate.spec.tsx.snap index a1c5ebb6b..a97508d3b 100644 --- a/src/core/client/admin/test/moderate/__snapshots__/moderate.spec.tsx.snap +++ b/src/core/client/admin/test/moderate/__snapshots__/moderate.spec.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`rejected queue accepts comment in rejected queue: count should be 1 1`] = ` +exports[`rejected queue approves comment in rejected queue: count should be 1 1`] = ` `; -exports[`rejected queue accepts comment in rejected queue: dangling 1`] = ` +exports[`rejected queue approves comment in rejected queue: dangling 1`] = `

`; -exports[`reported queue accepts comment in reported queue: count should be 1 1`] = ` +exports[`reported queue approves comment in reported queue: count should be 1 1`] = ` `; -exports[`reported queue accepts comment in reported queue: dangling 1`] = ` +exports[`reported queue approves comment in reported queue: dangling 1`] = `
`; -exports[`single comment view accepts single comment 1`] = ` +exports[`single comment view approves single comment 1`] = `