[CORL-155] User Suspending and Banning (#2247)

* feat: suspending, banning, now propogation

* feat: adapting to `now`

* feat: support auth for suspension/banned

* feat: added trace-id to requests

* feat: new mutation api with hooks support

* feat: added user status filtering, current field

* feat: Implement filter by status, adapt to new USER_STATUS type, add lookup helper <3

* fix: typo

* fix: tests

* chore: rename banned status to ban status

* test: feature test + lots of test helper improvements e.g. types

* fix: add translation to ban user modal

* fix: translation

* fix: test
This commit is contained in:
Wyatt Johnson
2019-04-22 22:57:32 +00:00
committed by GitHub
parent b63c00f26f
commit dbbc1af42e
147 changed files with 4609 additions and 1468 deletions
@@ -1,79 +1,68 @@
import { graphql } from "react-relay";
import { ConnectionHandler, Environment } from "relay-runtime";
import {
commitMutationPromiseNormalized,
createMutationContainer,
MutationInput,
MutationResponsePromise,
} from "talk-framework/lib/relay";
import { RejectCommentMutation as MutationTypes } from "talk-admin/__generated__/RejectCommentMutation.graphql";
import { getQueueConnection } from "talk-admin/helpers";
export type RejectCommentInput = MutationInput<MutationTypes>;
const mutation = graphql`
mutation RejectCommentMutation($input: RejectCommentInput!) {
rejectComment(input: $input) {
comment {
id
status
}
moderationQueues {
unmoderated {
count
}
reported {
count
}
pending {
count
}
}
clientMutationId
}
}
`;
import {
commitMutationPromiseNormalized,
createMutation,
MutationInput,
} from "talk-framework/lib/relay";
let clientMutationId = 0;
function commit(environment: Environment, input: RejectCommentInput) {
return commitMutationPromiseNormalized<MutationTypes>(environment, {
mutation,
variables: {
input: {
...input,
clientMutationId: clientMutationId.toString(),
},
},
optimisticResponse: {
rejectComment: {
comment: {
id: input.commentID,
status: "REJECTED",
},
clientMutationId: (clientMutationId++).toString(),
},
} as any, // TODO: (cvle) generated types should contain one for the optimistic response.
updater: store => {
const connections = [
getQueueConnection("reported", store),
getQueueConnection("pending", store),
getQueueConnection("unmoderated", store),
].filter(c => c);
connections.forEach(con =>
ConnectionHandler.deleteNode(con, input.commentID)
);
},
});
}
export const withRejectCommentMutation = createMutationContainer(
const RejectCommentMutation = createMutation(
"rejectComment",
commit
(environment: Environment, input: MutationInput<MutationTypes>) =>
commitMutationPromiseNormalized<MutationTypes>(environment, {
mutation: graphql`
mutation RejectCommentMutation($input: RejectCommentInput!) {
rejectComment(input: $input) {
comment {
id
status
}
moderationQueues {
unmoderated {
count
}
reported {
count
}
pending {
count
}
}
clientMutationId
}
}
`,
variables: {
input: {
...input,
clientMutationId: clientMutationId.toString(),
},
},
optimisticResponse: {
rejectComment: {
comment: {
id: input.commentID,
status: "REJECTED",
},
clientMutationId: (clientMutationId++).toString(),
},
},
updater: store => {
const connections = [
getQueueConnection("reported", store),
getQueueConnection("pending", store),
getQueueConnection("unmoderated", store),
].filter(c => c);
connections.forEach(con =>
ConnectionHandler.deleteNode(con, input.commentID)
);
},
})
);
export type RejectCommentMutation = (
input: RejectCommentInput
) => MutationResponsePromise<MutationTypes, "rejectComment">;
export default RejectCommentMutation;