diff --git a/src/core/client/stream/tabs/Configure/Configure.tsx b/src/core/client/stream/tabs/Configure/Configure.tsx index 0d7b3270c..1d9c349e9 100644 --- a/src/core/client/stream/tabs/Configure/Configure.tsx +++ b/src/core/client/stream/tabs/Configure/Configure.tsx @@ -13,7 +13,8 @@ import { QAConfigContainer } from "./Q&A"; export interface Props { viewer: PropTypesOf["viewer"]; settings: PropTypesOf["settings"] & - PropTypesOf["settings"]; + PropTypesOf["settings"] & + PropTypesOf["settings"]; story: PropTypesOf["story"] & PropTypesOf["story"] & PropTypesOf["story"] & @@ -31,8 +32,7 @@ const Configure: FunctionComponent = props => { /> - - + diff --git a/src/core/client/stream/tabs/Configure/ConfigureContainer.tsx b/src/core/client/stream/tabs/Configure/ConfigureContainer.tsx index 5733cce58..d5b5aa639 100644 --- a/src/core/client/stream/tabs/Configure/ConfigureContainer.tsx +++ b/src/core/client/stream/tabs/Configure/ConfigureContainer.tsx @@ -44,6 +44,7 @@ const enhanced = withFragmentContainer({ fragment ConfigureContainer_settings on Settings { ...UserBoxContainer_settings ...ModerateStreamContainer_settings + ...QAConfigContainer_settings } `, })(StreamContainer); diff --git a/src/core/client/stream/tabs/Configure/Q&A/QAConfigContainer.tsx b/src/core/client/stream/tabs/Configure/Q&A/QAConfigContainer.tsx index 012d18274..335a11c9f 100644 --- a/src/core/client/stream/tabs/Configure/Q&A/QAConfigContainer.tsx +++ b/src/core/client/stream/tabs/Configure/Q&A/QAConfigContainer.tsx @@ -5,10 +5,12 @@ import { useMutation, withFragmentContainer, } from "coral-framework/lib/relay"; -import { GQLSTORY_MODE } from "coral-framework/schema"; +import { GQLFEATURE_FLAG, GQLSTORY_MODE } from "coral-framework/schema"; +import { QAConfigContainer_settings } from "coral-stream/__generated__/QAConfigContainer_settings.graphql"; import { QAConfigContainer_story } from "coral-stream/__generated__/QAConfigContainer_story.graphql"; +import HorizontalRule from "../HorizontalRule"; import DisableQA from "./DisableQA"; import EnableQA from "./EnableQA"; import ExpertSelectionQuery from "./ExpertSelectionQuery"; @@ -16,9 +18,10 @@ import UpdateStoryModeMutation from "./UpdateStoryModeMutation"; interface Props { story: QAConfigContainer_story; + settings: QAConfigContainer_settings; } -const QAConfigContainer: FunctionComponent = ({ story }) => { +const QAConfigContainer: FunctionComponent = ({ story, settings }) => { const [waiting, setWaiting] = useState(false); const updateStoryMode = useMutation(UpdateStoryModeMutation); @@ -36,13 +39,22 @@ const QAConfigContainer: FunctionComponent = ({ story }) => { const isQA = story.settings.mode === GQLSTORY_MODE.QA; + // Check if we're allowed to show Q&A based on feature flags + if (!settings.featureFlags.includes(GQLFEATURE_FLAG.ENABLE_QA)) { + return null; + } + return isQA ? ( <> + ) : ( - + <> + + + ); }; @@ -55,5 +67,10 @@ const enhanced = withFragmentContainer({ } } `, + settings: graphql` + fragment QAConfigContainer_settings on Settings { + featureFlags + } + `, })(QAConfigContainer); export default enhanced; diff --git a/src/core/client/stream/test/configure/__snapshots__/renderConfigure.spec.tsx.snap b/src/core/client/stream/test/configure/__snapshots__/renderConfigure.spec.tsx.snap index 2698945b3..57408f199 100644 --- a/src/core/client/stream/test/configure/__snapshots__/renderConfigure.spec.tsx.snap +++ b/src/core/client/stream/test/configure/__snapshots__/renderConfigure.spec.tsx.snap @@ -287,43 +287,6 @@ announcements relating to the comments on this story.
-
-

- Switch to Q&A Format -

-
-

- The Q&A format allows community members to submit questions for chosen -experts to answer. -

- -
-
-
diff --git a/src/core/client/stream/test/fixtures.ts b/src/core/client/stream/test/fixtures.ts index 3b0ce12a5..065875dcd 100644 --- a/src/core/client/stream/test/fixtures.ts +++ b/src/core/client/stream/test/fixtures.ts @@ -109,6 +109,7 @@ export const settings = createFixture({ deleteAccount: true, }, multisite: false, + featureFlags: [], }); export const site = createFixture({ diff --git a/src/core/server/graph/schema/schema.graphql b/src/core/server/graph/schema/schema.graphql index d66a4c4a5..7d49f67cf 100644 --- a/src/core/server/graph/schema/schema.graphql +++ b/src/core/server/graph/schema/schema.graphql @@ -341,6 +341,11 @@ enum FEATURE_FLAG { toxic comments. """ DISABLE_WARN_USER_OF_TOXIC_COMMENT + + """ + ENABLE_QA when enabled will turn off Q&A features client side. + """ + ENABLE_QA } # The moderation mode of the site. @@ -1481,7 +1486,7 @@ type Settings { """ featureFlags provides the enabled feature flags. """ - featureFlags: [FEATURE_FLAG!]! @auth(roles: [ADMIN]) + featureFlags: [FEATURE_FLAG!]! @auth(roles: [ADMIN, MODERATOR]) """ createdAt is the time that the Settings was created at.