mirror of
https://github.com/wassname/talk.git
synced 2026-09-10 12:43:11 +08:00
[CORL-294] Moderate a single story + quick search (#2286)
* feat: allow passing a `storyID` to `Query.moderationQueues` * feat: moderate by story * feat: implement search story combobox * feat: add translations * fix: tests * fix: duplicate id * fix: rename file * chore: add more comments * fix: add missing translation * review: use query parameter "q" instead of url path * chore: move placeholder logic inside, maybe this makes it clearer :-D
This commit is contained in:
@@ -1,39 +1,35 @@
|
||||
import { graphql } from "react-relay";
|
||||
import { Environment } from "relay-runtime";
|
||||
|
||||
import { createFetchContainer, fetchQuery } from "talk-framework/lib/relay";
|
||||
import {
|
||||
createFetch,
|
||||
fetchQuery,
|
||||
FetchVariables,
|
||||
} from "talk-framework/lib/relay";
|
||||
import { RefreshSettingsQuery as QueryTypes } from "talk-stream/__generated__/RefreshSettingsQuery.graphql";
|
||||
|
||||
export type RefreshSettingsVariables = QueryTypes["variables"];
|
||||
|
||||
const query = graphql`
|
||||
query RefreshSettingsQuery($storyID: ID!) {
|
||||
settings {
|
||||
...StreamContainer_settings
|
||||
}
|
||||
# We also refrech story props that are
|
||||
# dependent on the settings.
|
||||
story(id: $storyID) {
|
||||
closedAt
|
||||
isClosed
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
function fetch(environment: Environment, variables: RefreshSettingsVariables) {
|
||||
return fetchQuery<QueryTypes["response"]["settings"]>(
|
||||
environment,
|
||||
query,
|
||||
variables,
|
||||
{ force: true }
|
||||
);
|
||||
}
|
||||
|
||||
export const withRefreshSettingsFetch = createFetchContainer(
|
||||
const RefreshSettingsFetch = createFetch(
|
||||
"refreshSettings",
|
||||
fetch
|
||||
(environment: Environment, variables: FetchVariables<QueryTypes>) => {
|
||||
return fetchQuery<QueryTypes>(
|
||||
environment,
|
||||
graphql`
|
||||
query RefreshSettingsQuery($storyID: ID!) {
|
||||
settings {
|
||||
...StreamContainer_settings
|
||||
}
|
||||
# We also refrech story props that are
|
||||
# dependent on the settings.
|
||||
story(id: $storyID) {
|
||||
closedAt
|
||||
isClosed
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables,
|
||||
{ force: true }
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
export type RefreshSettingsFetch = (
|
||||
variables: RefreshSettingsVariables
|
||||
) => Promise<QueryTypes["response"]["settings"]>;
|
||||
export default RefreshSettingsFetch;
|
||||
|
||||
@@ -1,4 +1 @@
|
||||
export {
|
||||
withRefreshSettingsFetch,
|
||||
RefreshSettingsFetch,
|
||||
} from "./RefreshSettingsQuery";
|
||||
export { default as RefreshSettingsFetch } from "./RefreshSettingsQuery";
|
||||
|
||||
@@ -24,7 +24,7 @@ exports[`renders correctly 1`] = `
|
||||
}
|
||||
}
|
||||
/>
|
||||
<withContext(withContext(createMutationContainer(withContext(createFetchContainer(withContext(withLocalStateContainer(Relay(PostCommentFormContainer))))))))
|
||||
<withContext(withContext(createMutationContainer(withContext(withFetch(withContext(withLocalStateContainer(Relay(PostCommentFormContainer))))))))
|
||||
settings={
|
||||
Object {
|
||||
"reaction": Object {
|
||||
@@ -170,7 +170,7 @@ exports[`when there is more disables load more button 1`] = `
|
||||
}
|
||||
}
|
||||
/>
|
||||
<withContext(withContext(createMutationContainer(withContext(createFetchContainer(withContext(withLocalStateContainer(Relay(PostCommentFormContainer))))))))
|
||||
<withContext(withContext(createMutationContainer(withContext(withFetch(withContext(withLocalStateContainer(Relay(PostCommentFormContainer))))))))
|
||||
settings={
|
||||
Object {
|
||||
"reaction": Object {
|
||||
@@ -330,7 +330,7 @@ exports[`when there is more renders a load more button 1`] = `
|
||||
}
|
||||
}
|
||||
/>
|
||||
<withContext(withContext(createMutationContainer(withContext(createFetchContainer(withContext(withLocalStateContainer(Relay(PostCommentFormContainer))))))))
|
||||
<withContext(withContext(createMutationContainer(withContext(withFetch(withContext(withLocalStateContainer(Relay(PostCommentFormContainer))))))))
|
||||
settings={
|
||||
Object {
|
||||
"reaction": Object {
|
||||
@@ -490,7 +490,7 @@ exports[`when use is logged in renders correctly 1`] = `
|
||||
}
|
||||
}
|
||||
/>
|
||||
<withContext(withContext(createMutationContainer(withContext(createFetchContainer(withContext(withLocalStateContainer(Relay(PostCommentFormContainer))))))))
|
||||
<withContext(withContext(createMutationContainer(withContext(withFetch(withContext(withLocalStateContainer(Relay(PostCommentFormContainer))))))))
|
||||
settings={
|
||||
Object {
|
||||
"reaction": Object {
|
||||
|
||||
@@ -5,12 +5,13 @@ import { graphql } from "react-relay";
|
||||
import { isBeforeDate } from "talk-common/utils";
|
||||
import { withContext } from "talk-framework/lib/bootstrap";
|
||||
import { InvalidRequestError } from "talk-framework/lib/errors";
|
||||
import { withFragmentContainer } from "talk-framework/lib/relay";
|
||||
import { PropTypesOf } from "talk-framework/types";
|
||||
import {
|
||||
RefreshSettingsFetch,
|
||||
withRefreshSettingsFetch,
|
||||
} from "talk-stream/fetches";
|
||||
FetchProp,
|
||||
withFetch,
|
||||
withFragmentContainer,
|
||||
} from "talk-framework/lib/relay";
|
||||
import { PropTypesOf } from "talk-framework/types";
|
||||
import { RefreshSettingsFetch } from "talk-stream/fetches";
|
||||
|
||||
import { EditCommentFormContainer_comment as CommentData } from "talk-stream/__generated__/EditCommentFormContainer_comment.graphql";
|
||||
import { EditCommentFormContainer_settings as SettingsData } from "talk-stream/__generated__/EditCommentFormContainer_settings.graphql";
|
||||
@@ -37,7 +38,7 @@ interface Props {
|
||||
story: StoryData;
|
||||
onClose?: () => void;
|
||||
autofocus: boolean;
|
||||
refreshSettings: RefreshSettingsFetch;
|
||||
refreshSettings: FetchProp<typeof RefreshSettingsFetch>;
|
||||
}
|
||||
|
||||
interface State {
|
||||
@@ -156,7 +157,7 @@ const enhanced = withContext(({ sessionStorage, browserInfo }) => ({
|
||||
// Disable autofocus on ios and enable for the rest.
|
||||
autofocus: !browserInfo.ios,
|
||||
}))(
|
||||
withRefreshSettingsFetch(
|
||||
withFetch(RefreshSettingsFetch)(
|
||||
withEditCommentMutation(
|
||||
withFragmentContainer<Props>({
|
||||
comment: graphql`
|
||||
|
||||
@@ -7,7 +7,9 @@ import {
|
||||
ModerationNudgeError,
|
||||
} from "talk-framework/lib/errors";
|
||||
import {
|
||||
FetchProp,
|
||||
graphql,
|
||||
withFetch,
|
||||
withFragmentContainer,
|
||||
withLocalStateContainer,
|
||||
} from "talk-framework/lib/relay";
|
||||
@@ -16,10 +18,7 @@ import { PropTypesOf } from "talk-framework/types";
|
||||
import { PostCommentFormContainer_settings as SettingsData } from "talk-stream/__generated__/PostCommentFormContainer_settings.graphql";
|
||||
import { PostCommentFormContainer_story as StoryData } from "talk-stream/__generated__/PostCommentFormContainer_story.graphql";
|
||||
import { PostCommentFormContainerLocal as Local } from "talk-stream/__generated__/PostCommentFormContainerLocal.graphql";
|
||||
import {
|
||||
RefreshSettingsFetch,
|
||||
withRefreshSettingsFetch,
|
||||
} from "talk-stream/fetches";
|
||||
import { RefreshSettingsFetch } from "talk-stream/fetches";
|
||||
import {
|
||||
CreateCommentMutation,
|
||||
withCreateCommentMutation,
|
||||
@@ -37,7 +36,7 @@ import {
|
||||
|
||||
interface Props {
|
||||
createComment: CreateCommentMutation;
|
||||
refreshSettings: RefreshSettingsFetch;
|
||||
refreshSettings: FetchProp<typeof RefreshSettingsFetch>;
|
||||
sessionStorage: PromisifiedStorage;
|
||||
settings: SettingsData;
|
||||
local: Local;
|
||||
@@ -214,7 +213,7 @@ const enhanced = withContext(({ sessionStorage }) => ({
|
||||
sessionStorage,
|
||||
}))(
|
||||
withCreateCommentMutation(
|
||||
withRefreshSettingsFetch(
|
||||
withFetch(RefreshSettingsFetch)(
|
||||
withLocalStateContainer(
|
||||
graphql`
|
||||
fragment PostCommentFormContainerLocal on Local {
|
||||
|
||||
@@ -8,16 +8,17 @@ import {
|
||||
InvalidRequestError,
|
||||
ModerationNudgeError,
|
||||
} from "talk-framework/lib/errors";
|
||||
import { withFragmentContainer } from "talk-framework/lib/relay";
|
||||
import {
|
||||
FetchProp,
|
||||
withFetch,
|
||||
withFragmentContainer,
|
||||
} from "talk-framework/lib/relay";
|
||||
import { PromisifiedStorage } from "talk-framework/lib/storage";
|
||||
import { PropTypesOf } from "talk-framework/types";
|
||||
import { ReplyCommentFormContainer_comment as CommentData } from "talk-stream/__generated__/ReplyCommentFormContainer_comment.graphql";
|
||||
import { ReplyCommentFormContainer_settings as SettingsData } from "talk-stream/__generated__/ReplyCommentFormContainer_settings.graphql";
|
||||
import { ReplyCommentFormContainer_story as StoryData } from "talk-stream/__generated__/ReplyCommentFormContainer_story.graphql";
|
||||
import {
|
||||
RefreshSettingsFetch,
|
||||
withRefreshSettingsFetch,
|
||||
} from "talk-stream/fetches";
|
||||
import { RefreshSettingsFetch } from "talk-stream/fetches";
|
||||
import {
|
||||
CreateCommentReplyMutation,
|
||||
withCreateCommentReplyMutation,
|
||||
@@ -42,7 +43,7 @@ interface Props {
|
||||
onClose?: () => void;
|
||||
autofocus: boolean;
|
||||
localReply?: boolean;
|
||||
refreshSettings: RefreshSettingsFetch;
|
||||
refreshSettings: FetchProp<typeof RefreshSettingsFetch>;
|
||||
}
|
||||
|
||||
interface State {
|
||||
@@ -204,7 +205,7 @@ const enhanced = withContext(({ sessionStorage, browserInfo }) => ({
|
||||
// Disable autofocus on ios and enable for the rest.
|
||||
autofocus: !browserInfo.ios,
|
||||
}))(
|
||||
withRefreshSettingsFetch(
|
||||
withFetch(RefreshSettingsFetch)(
|
||||
withCreateCommentReplyMutation(
|
||||
withFragmentContainer<Props>({
|
||||
settings: graphql`
|
||||
|
||||
Reference in New Issue
Block a user