Skip to content

Commit

Permalink
Merge pull request #4603 from coralproject/feat/CORL-3161-option-hide…
Browse files Browse the repository at this point in the history
…-unmoderated-count

[CORL-3161]: Add config for whether to show unmoderated counts in moderation queue
  • Loading branch information
tessalt committed May 6, 2024
2 parents f19f05b + 23f7624 commit 47be7d2
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import PerspectiveConfig from "./PerspectiveConfig";
import PremoderateEmailAddressConfig from "./PremoderateEmailAddressConfig";
import PreModerationConfigContainer from "./PreModerationConfigContainer";
import RecentCommentHistoryConfig from "./RecentCommentHistoryConfig";
import UnmoderatedCountsConfig from "./UnmoderatedCountsConfig";

interface Props {
submitting: boolean;
Expand All @@ -46,6 +47,7 @@ export const ModerationConfigContainer: React.FunctionComponent<Props> = ({
<HorizontalGutter size="double" data-testid="configure-moderationContainer">
<PreModerationConfigContainer disabled={submitting} settings={settings} />
<PerspectiveConfig disabled={submitting} />
<UnmoderatedCountsConfig disabled={submitting} />
<AkismetConfig disabled={submitting} />
<NewCommentersConfigContainer disabled={submitting} settings={settings} />
<RecentCommentHistoryConfig disabled={submitting} />
Expand All @@ -61,6 +63,7 @@ const enhanced = withFragmentContainer<Props>({
fragment ModerationConfigContainer_settings on Settings {
...AkismetConfig_formValues @relay(mask: false)
...PerspectiveConfig_formValues @relay(mask: false)
...UnmoderatedCountsConfig_formValues @relay(mask: false)
...PreModerationConfigContainer_formValues @relay(mask: false)
...PreModerationConfigContainer_settings
...RecentCommentHistoryConfig_formValues @relay(mask: false)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Localized } from "@fluent/react/compat";
import React, { FunctionComponent } from "react";
import { graphql } from "react-relay";

import {
FieldSet,
FormField,
FormFieldHeader,
Label,
} from "coral-ui/components/v2";

import ConfigBox from "../../ConfigBox";
import Header from "../../Header";
import OnOffField from "../../OnOffField";

// eslint-disable-next-line no-unused-expressions
graphql`
fragment UnmoderatedCountsConfig_formValues on Settings {
showUnmoderatedCounts
}
`;

interface Props {
disabled: boolean;
}

const UnmoderatedCountsConfig: FunctionComponent<Props> = ({ disabled }) => {
return (
<ConfigBox
title={
<Localized id="configure-moderation-unmoderatedCounts-title">
<Header container={<legend />}>Unmoderated counts</Header>
</Localized>
}
container={<FieldSet />}
>
<FormField container={<FieldSet />}>
<FormFieldHeader>
<Localized id="configure-moderation-unmoderatedCounts-enabled">
<Label component="legend">
Show the number of unmoderated comments in the queue
</Label>
</Localized>
</FormFieldHeader>
<OnOffField name="showUnmoderatedCounts" disabled={disabled} />
</FormField>
</ConfigBox>
);
};

export default UnmoderatedCountsConfig;
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const ModerateNavigationContainer: React.FunctionComponent<Props> = (props) => {
section={props.section}
mode={props.settings?.moderation}
enableForReview={props.settings?.forReviewQueue}
showUnmoderatedCounts={props.settings?.showUnmoderatedCounts}
/>
);
};
Expand All @@ -91,6 +92,7 @@ const enhanced = withFragmentContainer<Props>({
fragment ModerateNavigationContainer_settings on Settings {
moderation
forReviewQueue
showUnmoderatedCounts
}
`,
moderationQueues: graphql`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface Props {
section?: SectionFilter | null;
mode?: "PRE" | "POST" | "SPECIFIC_SITES_PRE" | "%future added value" | null;
enableForReview?: boolean;
showUnmoderatedCounts?: boolean | null;
}

const Navigation: FunctionComponent<Props> = ({
Expand All @@ -42,6 +43,7 @@ const Navigation: FunctionComponent<Props> = ({
section,
mode,
enableForReview,
showUnmoderatedCounts,
}) => {
const { match, router } = useRouter();
const moderationLinks = useMemo(() => {
Expand Down Expand Up @@ -121,7 +123,7 @@ const Navigation: FunctionComponent<Props> = ({
<Localized id="moderate-navigation-unmoderated">
<span>Unmoderated</span>
</Localized>
{isNumber(unmoderatedCount) && (
{showUnmoderatedCounts && isNumber(unmoderatedCount) && (
<Counter data-testid="moderate-navigation-unmoderated-count">
<Localized
id="moderate-navigation-comment-count"
Expand Down
1 change: 1 addition & 0 deletions client/src/core/client/admin/test/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export const settings = createFixture<GQLSettings>({
},
},
protectedEmailDomains: Array.from(PROTECTED_EMAIL_DOMAINS),
showUnmoderatedCounts: true,
});

export const settingsWithMultisite = createFixture<GQLSettings>(
Expand Down
4 changes: 4 additions & 0 deletions locales/en-US/admin.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,10 @@ configure-moderation-newCommenters-approvedCommentsThreshold-description =
not have to be premoderated
configure-moderation-newCommenters-comments = comments
#### Unmoderated counts
configure-moderation-unmoderatedCounts-title = Unmoderated counts
configure-moderation-unmoderatedCounts-enabled = Show the number of unmoderated comments in the queue
#### Email domain
configure-moderation-emailDomains-header = Email domain
configure-moderation-emailDomains-description = Create rules to take action on accounts or comments based on the account holder's email address domain.
Expand Down
2 changes: 2 additions & 0 deletions server/src/core/server/graph/resolvers/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,6 @@ export const Settings: GQLSettingsTypeResolver<Tenant> = {
inPageNotifications: ({
inPageNotifications = { enabled: true, floatingBellIndicator: true },
}) => inPageNotifications,
showUnmoderatedCounts: ({ showUnmoderatedCounts = true }) =>
showUnmoderatedCounts,
};
12 changes: 12 additions & 0 deletions server/src/core/server/graph/schema/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2374,6 +2374,12 @@ type Settings @cacheControl(maxAge: 30) {
whether it's enabled as an option for commenters.
"""
inPageNotifications: InPageNotificationsConfiguration

"""
showUnmoderatedCounts is whether to show the unmoderated comment count in the
moderation queues.
"""
showUnmoderatedCounts: Boolean
}

################################################################################
Expand Down Expand Up @@ -6783,6 +6789,12 @@ input SettingsInput {
inPageNotifications specifies the configuration for in-page notifications
"""
inPageNotifications: InPageNotificationsConfigurationInput

"""
showUnmoderatedCounts is whether or not to show the unmoderated counts in the
moderation queue.
"""
showUnmoderatedCounts: Boolean
}

"""
Expand Down
6 changes: 6 additions & 0 deletions server/src/core/server/models/settings/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@ export type Settings = GlobalModerationSettings &
* as an option for commenters
*/
inPageNotifications?: InPageNotificationsConfig;

/**
* showUnmoderatedCounts specifies whether or not the unmoderated comment count
* is shown in the moderation queue
*/
showUnmoderatedCounts?: boolean;
};

export const defaultRTEConfiguration: RTEConfiguration = {
Expand Down
1 change: 1 addition & 0 deletions server/src/core/server/models/tenant/tenant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export const combineTenantDefaultsAndInput = (
enabled: true,
floatingBellIndicator: true,
},
showUnmoderatedCounts: true,
};

// Create the new Tenant by merging it together with the defaults.
Expand Down

0 comments on commit 47be7d2

Please sign in to comment.