diff --git a/src/core/client/framework/helpers/urls.tsx b/src/core/client/framework/helpers/urls.tsx index d80f6c9af..a55750d41 100644 --- a/src/core/client/framework/helpers/urls.tsx +++ b/src/core/client/framework/helpers/urls.tsx @@ -1,5 +1,7 @@ export default { - admin: "/admin", + admin: { + moderateReported: "/admin/moderate/reported", + }, embed: { stream: "/embed/stream", auth: "/embed/auth", diff --git a/src/core/client/install/App/steps/FinalStep.tsx b/src/core/client/install/App/steps/FinalStep.tsx index d8a448d77..a781d8f42 100644 --- a/src/core/client/install/App/steps/FinalStep.tsx +++ b/src/core/client/install/App/steps/FinalStep.tsx @@ -28,7 +28,12 @@ class FinalStep extends Component { - diff --git a/src/core/client/stream/tabs/Configure/Configure.tsx b/src/core/client/stream/tabs/Configure/Configure.tsx index 1af3d32e3..f52093e1d 100644 --- a/src/core/client/stream/tabs/Configure/Configure.tsx +++ b/src/core/client/stream/tabs/Configure/Configure.tsx @@ -6,13 +6,16 @@ import { HorizontalGutter } from "coral-ui/components"; import ConfigureStreamContainer from "./ConfigureStream"; import HorizontalRule from "./HorizontalRule"; +import ModerateStreamContainer from "./ModerateStreamContainer"; import OpenOrCloseStreamContainer from "./OpenOrCloseStream"; export interface Props { viewer: PropTypesOf["viewer"]; - settings: PropTypesOf["settings"]; + settings: PropTypesOf["settings"] & + PropTypesOf["settings"]; story: PropTypesOf["story"] & - PropTypesOf["story"]; + PropTypesOf["story"] & + PropTypesOf["story"]; } const Configure: FunctionComponent = props => { @@ -20,10 +23,15 @@ 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 96e1c0579..d36736429 100644 --- a/src/core/client/stream/tabs/Configure/ConfigureContainer.tsx +++ b/src/core/client/stream/tabs/Configure/ConfigureContainer.tsx @@ -31,6 +31,7 @@ const enhanced = withFragmentContainer({ fragment ConfigureContainer_story on Story { ...ConfigureStreamContainer_story ...OpenOrCloseStreamContainer_story + ...ModerateStreamContainer_story } `, viewer: graphql` @@ -41,6 +42,7 @@ const enhanced = withFragmentContainer({ settings: graphql` fragment ConfigureContainer_settings on Settings { ...UserBoxContainer_settings + ...ModerateStreamContainer_settings } `, })(StreamContainer); diff --git a/src/core/client/stream/tabs/Configure/ModerateStreamContainer.tsx b/src/core/client/stream/tabs/Configure/ModerateStreamContainer.tsx new file mode 100644 index 000000000..6d7df52f3 --- /dev/null +++ b/src/core/client/stream/tabs/Configure/ModerateStreamContainer.tsx @@ -0,0 +1,80 @@ +import { Localized } from "fluent-react/compat"; +import React, { FunctionComponent, useMemo } from "react"; +import { graphql } from "react-relay"; + +import { urls } from "coral-framework/helpers"; +import { ExternalLink } from "coral-framework/lib/i18n/components"; +import { + withFragmentContainer, + withLocalStateContainer, +} from "coral-framework/lib/relay"; +import { Typography } from "coral-ui/components"; + +import { ModerateStreamContainer_settings } from "coral-stream/__generated__/ModerateStreamContainer_settings.graphql"; +import { ModerateStreamContainer_story } from "coral-stream/__generated__/ModerateStreamContainer_story.graphql"; +import { ModerateStreamContainerLocal } from "coral-stream/__generated__/ModerateStreamContainerLocal.graphql"; + +interface Props { + local: ModerateStreamContainerLocal; + settings: ModerateStreamContainer_settings; + story: ModerateStreamContainer_story; +} + +const ModerateStreamContainer: FunctionComponent = ({ + local: { accessToken }, + settings, + story: { id }, +}) => { + const href = useMemo(() => { + let link = urls.admin.moderateReported + "/" + id; + if ( + accessToken && + settings.auth.integrations.sso.enabled && + settings.auth.integrations.sso.targetFilter.admin + ) { + link += `#accessToken=${accessToken}`; + } + + return link; + }, [accessToken, settings, id]); + + return ( +
+ + + Moderate this stream + + +
+ ); +}; + +const enhanced = withFragmentContainer({ + settings: graphql` + fragment ModerateStreamContainer_settings on Settings { + auth { + integrations { + sso { + enabled + targetFilter { + admin + } + } + } + } + } + `, + story: graphql` + fragment ModerateStreamContainer_story on Story { + id + } + `, +})( + withLocalStateContainer(graphql` + fragment ModerateStreamContainerLocal on Local { + accessToken + } + `)(ModerateStreamContainer) +); + +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 bdebe109e..9a17e5fcb 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 @@ -52,6 +52,23 @@ exports[`renders configure 1`] = ` + +
- -
-
-

- Close Comment Stream -

+
-

- This comment stream is currently open. By closing this comment stream, + Close Comment Stream + +

+

+ This comment stream is currently open. By closing this comment stream, no new comments may be submitted and all previously submitted comments will still be displayed. -

- +

+ +
diff --git a/src/core/client/stream/test/fixtures.ts b/src/core/client/stream/test/fixtures.ts index 9ad509e7b..cf336b8f1 100644 --- a/src/core/client/stream/test/fixtures.ts +++ b/src/core/client/stream/test/fixtures.ts @@ -77,6 +77,7 @@ export const settings = createFixture({ allowRegistration: true, targetFilter: { stream: true, + admin: true, }, }, local: { diff --git a/src/locales/en-US/stream.ftl b/src/locales/en-US/stream.ftl index 44d7499e2..d81a0303d 100644 --- a/src/locales/en-US/stream.ftl +++ b/src/locales/en-US/stream.ftl @@ -428,6 +428,8 @@ configure-openStream-description = stream new comments may be submitted and displayed. configure-openStream-openStream = Open Stream +configure-moderateThisStream = Moderate this stream + comments-tombstone-ignore = This comment is hidden because you ignored {$username} comments-tombstone-deleted = This comment is no longer available. The commenter has deleted their account.