From e5ea1ee17996fbebda2de05e632993df1d979f34 Mon Sep 17 00:00:00 2001 From: Tessa Thornton Date: Thu, 12 Mar 2020 18:19:26 -0400 Subject: [PATCH] [CORL-959] pass siteID through to approved and rejected route queries (#2884) * pass siteID through to approved and rejected route queries * Fix tests Co-authored-by: Wyatt Johnson --- .../Moderate/Queue/ApprovedQueueRoute.tsx | 23 +++++++++++++++---- .../Moderate/Queue/RejectedQueueRoute.tsx | 23 +++++++++++++++---- .../test/moderate/rejectedQueue.spec.tsx | 5 ++++ src/core/server/graph/loaders/Comments.ts | 2 ++ src/core/server/graph/schema/schema.graphql | 11 ++++----- 5 files changed, 50 insertions(+), 14 deletions(-) diff --git a/src/core/client/admin/routes/Moderate/Queue/ApprovedQueueRoute.tsx b/src/core/client/admin/routes/Moderate/Queue/ApprovedQueueRoute.tsx index 176553289..f9d04761a 100644 --- a/src/core/client/admin/routes/Moderate/Queue/ApprovedQueueRoute.tsx +++ b/src/core/client/admin/routes/Moderate/Queue/ApprovedQueueRoute.tsx @@ -17,6 +17,7 @@ interface ApprovedQueueRouteProps { query: ApprovedQueueRoute_query; relay: RelayPaginationProp; storyID?: string; + siteID?: string; } // TODO: use generated types @@ -87,10 +88,12 @@ const enhanced = (withPaginationContainer< count: { type: "Int!", defaultValue: 5 } cursor: { type: "Cursor" } storyID: { type: "ID" } + siteID: { type: "ID" } ) { comments( status: APPROVED storyID: $storyID + siteID: $siteID first: $count after: $cursor ) @connection(key: "ApprovedQueue_comments") { @@ -134,11 +137,17 @@ const enhanced = (withPaginationContainer< # Notice that we re-use our fragment, and the shape of this query matches our fragment spec. query ApprovedQueueRoutePaginationQuery( $storyID: ID + $siteID: ID $count: Int! $cursor: Cursor ) { ...ApprovedQueueRoute_query - @arguments(storyID: $storyID, count: $count, cursor: $cursor) + @arguments( + storyID: $storyID + siteID: $siteID + count: $count + cursor: $cursor + ) } `, } @@ -147,14 +156,20 @@ const enhanced = (withPaginationContainer< enhanced.routeConfig = { Component: enhanced, query: graphql` - query ApprovedQueueRouteQuery($storyID: ID) { - ...ApprovedQueueRoute_query @arguments(storyID: $storyID) + query ApprovedQueueRouteQuery($storyID: ID, $siteID: ID) { + ...ApprovedQueueRoute_query @arguments(storyID: $storyID, siteID: $siteID) } `, cacheConfig: { force: true }, render: function RejectedRouteRender({ Component, props, match }) { if (Component && props) { - return ; + return ( + + ); } return ; }, diff --git a/src/core/client/admin/routes/Moderate/Queue/RejectedQueueRoute.tsx b/src/core/client/admin/routes/Moderate/Queue/RejectedQueueRoute.tsx index 1651e3ac3..a3ebf01e4 100644 --- a/src/core/client/admin/routes/Moderate/Queue/RejectedQueueRoute.tsx +++ b/src/core/client/admin/routes/Moderate/Queue/RejectedQueueRoute.tsx @@ -17,6 +17,7 @@ interface RejectedQueueRouteProps { query: RejectedQueueRoute_query; relay: RelayPaginationProp; storyID?: string; + siteID?: string; } // TODO: use generated types @@ -87,10 +88,12 @@ const enhanced = (withPaginationContainer< count: { type: "Int!", defaultValue: 5 } cursor: { type: "Cursor" } storyID: { type: "ID" } + siteID: { type: "ID" } ) { comments( status: REJECTED storyID: $storyID + siteID: $siteID first: $count after: $cursor ) @connection(key: "RejectedQueue_comments") { @@ -134,11 +137,17 @@ const enhanced = (withPaginationContainer< # Notice that we re-use our fragment, and the shape of this query matches our fragment spec. query RejectedQueueRoutePaginationQuery( $storyID: ID + $siteID: ID $count: Int! $cursor: Cursor ) { ...RejectedQueueRoute_query - @arguments(storyID: $storyID, count: $count, cursor: $cursor) + @arguments( + storyID: $storyID + siteID: $siteID + count: $count + cursor: $cursor + ) } `, } @@ -147,14 +156,20 @@ const enhanced = (withPaginationContainer< enhanced.routeConfig = { Component: enhanced, query: graphql` - query RejectedQueueRouteQuery($storyID: ID) { - ...RejectedQueueRoute_query @arguments(storyID: $storyID) + query RejectedQueueRouteQuery($storyID: ID, $siteID: ID) { + ...RejectedQueueRoute_query @arguments(storyID: $storyID, siteID: $siteID) } `, cacheConfig: { force: true }, render: function RejectedRouteRender({ Component, props, match }) { if (Component && props) { - return ; + return ( + + ); } return ; }, diff --git a/src/core/client/admin/test/moderate/rejectedQueue.spec.tsx b/src/core/client/admin/test/moderate/rejectedQueue.spec.tsx index 9ee42091e..57f9ddc9e 100644 --- a/src/core/client/admin/test/moderate/rejectedQueue.spec.tsx +++ b/src/core/client/admin/test/moderate/rejectedQueue.spec.tsx @@ -74,6 +74,7 @@ it("renders rejected queue with comments", async () => { first: 5, status: "REJECTED", storyID: null, + siteID: null, }); return { edges: [ @@ -112,6 +113,7 @@ it("shows a moderate story", async () => { first: 5, status: "REJECTED", storyID: null, + siteID: null, }); return { edges: [ @@ -155,6 +157,7 @@ it("renders rejected queue with comments and load more", async () => { first: 5, status: GQLCOMMENT_STATUS.REJECTED, storyID: null, + siteID: null, }); return { edges: [ @@ -178,6 +181,7 @@ it("renders rejected queue with comments and load more", async () => { after: rejectedComments[1].createdAt, status: GQLCOMMENT_STATUS.REJECTED, storyID: null, + siteID: null, }); return { edges: [ @@ -269,6 +273,7 @@ it("approves comment in rejected queue", async () => { first: 5, status: "REJECTED", storyID: null, + siteID: null, }); return { edges: [ diff --git a/src/core/server/graph/loaders/Comments.ts b/src/core/server/graph/loaders/Comments.ts index 489cf5584..96da21723 100644 --- a/src/core/server/graph/loaders/Comments.ts +++ b/src/core/server/graph/loaders/Comments.ts @@ -138,6 +138,7 @@ export default (ctx: Context) => ({ first, after, storyID, + siteID, status, tag, query, @@ -151,6 +152,7 @@ export default (ctx: Context) => ({ ...queryFilter(query), ...tagFilter(tag), storyID, + siteID, status, }, isNil diff --git a/src/core/server/graph/schema/schema.graphql b/src/core/server/graph/schema/schema.graphql index 7d49f67cf..4cf3ca649 100644 --- a/src/core/server/graph/schema/schema.graphql +++ b/src/core/server/graph/schema/schema.graphql @@ -2944,6 +2944,7 @@ type Query { first: Int = 10 @constraint(max: 50) after: Cursor storyID: ID + siteID: ID status: COMMENT_STATUS tag: TAG query: String @@ -6415,16 +6416,14 @@ type Mutation { """ addStoryExpert adds an expert to a story. """ - addStoryExpert( - input: AddExpertInput! - ): AddExpertPayload! @auth(roles: [ADMIN, MODERATOR]) + addStoryExpert(input: AddExpertInput!): AddExpertPayload! + @auth(roles: [ADMIN, MODERATOR]) """ removeStoryExpert removes an expert from a story. """ - removeStoryExpert( - input: RemoveExpertInput! - ): RemoveExpertPayload! @auth(roles: [ADMIN, MODERATOR]) + removeStoryExpert(input: RemoveExpertInput!): RemoveExpertPayload! + @auth(roles: [ADMIN, MODERATOR]) } ##################