diff --git a/src/core/client/admin/routes/configure/components/OnOffField.tsx b/src/core/client/admin/routes/configure/components/OnOffField.tsx index 75ad343ca..11993bc4b 100644 --- a/src/core/client/admin/routes/configure/components/OnOffField.tsx +++ b/src/core/client/admin/routes/configure/components/OnOffField.tsx @@ -11,48 +11,56 @@ interface Props { name: string; disabled: boolean; invert?: boolean; + onLabel?: React.ReactNode; + offLabel?: React.ReactNode; } const OnOffField: StatelessComponent = ({ name, disabled, + onLabel, + offLabel, invert = false, }) => (
{({ input }) => ( - - - On - - + + {onLabel || ( + + On + + )} + )} {({ input }) => ( - - - Off - - + + {offLabel || ( + + Off + + )} + )}
diff --git a/src/core/client/admin/routes/configure/sections/general/components/GeneralConfig.tsx b/src/core/client/admin/routes/configure/sections/general/components/GeneralConfig.tsx index e9910f508..55db56c2b 100644 --- a/src/core/client/admin/routes/configure/sections/general/components/GeneralConfig.tsx +++ b/src/core/client/admin/routes/configure/sections/general/components/GeneralConfig.tsx @@ -8,6 +8,7 @@ import ClosingCommentStreamsConfigContainer from "../containers/ClosingCommentSt import CommentEditingConfigContainer from "../containers/CommentEditingConfigContainer"; import CommentLengthConfigContainer from "../containers/CommentLengthConfigContainer"; import GuidelinesConfigContainer from "../containers/GuidelinesConfigContainer"; +import SitewideCommentingConfigContainer from "../containers/SitewideCommentingConfigContainer"; interface Props { disabled: boolean; @@ -15,7 +16,8 @@ interface Props { PropTypesOf["settings"] & PropTypesOf["settings"] & PropTypesOf["settings"] & - PropTypesOf["settings"]; + PropTypesOf["settings"] & + PropTypesOf["settings"]; onInitValues: (values: any) => void; } @@ -25,6 +27,11 @@ const General: StatelessComponent = ({ onInitValues, }) => ( + = ({ disabled }) => ( + + +
Sitewide Commenting
+
+ + + Open or close comment streams for new comments sitewide. When new + comments are turned off sitewide, new comments cannot be submitted, but + existing comments can continue to receive “Respect” reactions, be + reported, and be shared. + + + + + + Enable New Comments Sitewide + + + On - Comment streams opened for new comments + + } + offLabel={ + + Off - Comment streams closed for new comments + + } + /> + + + + + + Sitewide Closed Comments Message + + + + + Write a message that will be displayed when comment streams are closed + sitewide + + + + + + {({ input, meta }) => ( + <> + }> + + + {meta.touched && + (meta.error || meta.submitError) && ( + + {meta.error || meta.submitError} + + )} + + )} + +
+); + +export default SitewideCommentingConfig; diff --git a/src/core/client/admin/routes/configure/sections/general/containers/GeneralConfigContainer.tsx b/src/core/client/admin/routes/configure/sections/general/containers/GeneralConfigContainer.tsx index 7dd67c2fc..abce5c7aa 100644 --- a/src/core/client/admin/routes/configure/sections/general/containers/GeneralConfigContainer.tsx +++ b/src/core/client/admin/routes/configure/sections/general/containers/GeneralConfigContainer.tsx @@ -50,6 +50,7 @@ const enhanced = withFragmentContainer({ ...CommentEditingConfigContainer_settings ...ClosedStreamMessageConfigContainer_settings ...ClosingCommentStreamsConfigContainer_settings + ...SitewideCommentingConfigContainer_settings } `, })(GeneralConfigContainer); diff --git a/src/core/client/admin/routes/configure/sections/general/containers/SitewideCommentingConfigContainer.tsx b/src/core/client/admin/routes/configure/sections/general/containers/SitewideCommentingConfigContainer.tsx new file mode 100644 index 000000000..28a140bf9 --- /dev/null +++ b/src/core/client/admin/routes/configure/sections/general/containers/SitewideCommentingConfigContainer.tsx @@ -0,0 +1,38 @@ +import React from "react"; +import { graphql } from "react-relay"; + +import { SitewideCommentingConfigContainer_settings as SettingsData } from "talk-admin/__generated__/SitewideCommentingConfigContainer_settings.graphql"; +import { withFragmentContainer } from "talk-framework/lib/relay"; + +import SitewideCommentingConfig from "../components/SitewideCommentingConfig"; + +interface Props { + settings: SettingsData; + onInitValues: (values: SettingsData) => void; + disabled: boolean; +} + +class SitewideCommentingConfigContainer extends React.Component { + constructor(props: Props) { + super(props); + props.onInitValues(props.settings); + } + + public render() { + const { disabled } = this.props; + return ; + } +} + +const enhanced = withFragmentContainer({ + settings: graphql` + fragment SitewideCommentingConfigContainer_settings on Settings { + disableCommenting { + enabled + message + } + } + `, +})(SitewideCommentingConfigContainer); + +export default enhanced; diff --git a/src/core/client/admin/test/configure/__snapshots__/general.spec.tsx.snap b/src/core/client/admin/test/configure/__snapshots__/general.spec.tsx.snap index a5247bccf..7dd54569f 100644 --- a/src/core/client/admin/test/configure/__snapshots__/general.spec.tsx.snap +++ b/src/core/client/admin/test/configure/__snapshots__/general.spec.tsx.snap @@ -107,6 +107,107 @@ exports[`renders configure general 1`] = ` className="HorizontalGutter-root HorizontalGutter-double" data-testid="configure-generalContainer" > +
+ + Sitewide Commenting + +

+ Open or close comment streams for new comments sitewide. When new comments +are turned off sitewide, new comments cannot be submitted, but existing +comments can continue to receive “Respect” reactions, be reported, and be +shared. +

+
+ + Enable New Comments Sitewide + +
+
+ + +
+
+ + +
+
+
+
+ +

+ Write a message that will be displayed when comment streams are closed sitewide +

+
+
+