Skip to content

Commit

Permalink
move localization to common
Browse files Browse the repository at this point in the history
  • Loading branch information
marcushaddon committed Nov 6, 2023
1 parent 05776e8 commit e07e71e
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import React, {
useEffect,
useMemo,
useRef,
useState,
} from "react";

import { MediaContainer } from "coral-admin/components/MediaContainer";
Expand Down Expand Up @@ -183,7 +184,7 @@ const ModerateCard: FunctionComponent<Props> = ({
}
}, [selected, div]);

// const [showModerationReason, setShowModerationReason] = useState(false);
const [showModerationReason, setShowModerationReason] = useState(false);

const commentBody = useMemo(
() =>
Expand Down Expand Up @@ -375,7 +376,7 @@ const ModerateCard: FunctionComponent<Props> = ({
onClick={
dsaFeaturesEnabled
? () => {
toggleVisibility();
setShowModerationReason(true);// toggleVisibility();
}
: onReject
}
Expand Down Expand Up @@ -412,7 +413,7 @@ const ModerateCard: FunctionComponent<Props> = ({
[styles.miniButton]: mini,
})}
/>
<ModerationReason onReason={onReason} onCancel={() => null} />
{showModerationReason && <ModerationReason onReason={onReason} onCancel={() => setShowModerationReason(false)} /> }
</Flex>
{moderatedBy}
</Flex>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ const DetailedExplantion: FunctionComponent<Props> = ({
}) => {
return (
<>
<Localized id={`moderationReason-rejectionReason-${code}`}>
<Localized id={`common-moderationReason-rejectionReason-${code}`}>
<RadioButton value={code} name={code} key={code} checked>
{unsnake(code)}
</RadioButton>
</Localized>

<Localized id="moderationReason-changeReason">
<Localized id="common-moderationReason-changeReason">
<Button
className={cn(styles.optionAction, styles.changeReason)}
variant="none"
Expand All @@ -41,20 +41,20 @@ const DetailedExplantion: FunctionComponent<Props> = ({
</Button>
</Localized>

<Localized id="moderationReason-detailedExplanation">
<Localized id="common-moderationReason-detailedExplanation">
<Label className={cn(styles.sectionLabel, styles.explanationLabel)}>
Explanation
</Label>
</Localized>

<Localized
id="moderationReason-detailedExplanation-placeholder"
id="common-moderationReason-detailedExplanation-placeholder"
attrs={{ placeholder: true }}
>
<TextArea
className={styles.detailedExplanation}
placeholder="Add your explanation"
data-testid="moderation-reason-legal-grounds"
data-testid="moderation-reason-detailed-explanation"
value={value || undefined}
onChange={(e) => onChange(e.target.value)}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const ModerationReason: FunctionComponent<Props> = ({ onCancel, onReason }) => {
)}

<Flex className={styles.buttons}>
<Localized id="moderationReason-cancel">
<Localized id="common-moderationReason-cancel">
<Button
className={styles.cancelButton}
variant="outlined"
Expand All @@ -69,7 +69,7 @@ const ModerationReason: FunctionComponent<Props> = ({ onCancel, onReason }) => {
</Button>
</Localized>

<Localized id="moderationReason-reject">
<Localized id="common-moderationReason-reject">
<Button
className={styles.rejectButton}
disabled={reasonCode === null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface Props {
const AddExpanationButton: FunctionComponent<{ onClick: () => void }> = ({
onClick,
}) => (
<Localized id="moderationReason-addExplanation">
<Localized id="common-moderationReason-addExplanation">
<Button
onClick={onClick}
className={styles.optionAction}
Expand All @@ -37,7 +37,7 @@ const Reasons: FunctionComponent<Props> = ({
}) => {
return (
<>
<Localized id="moderationReason-reason">
<Localized id="common-moderationReason-reason">
<span className={styles.sectionLabel}>Reason</span>
</Localized>

Expand All @@ -49,7 +49,7 @@ const Reasons: FunctionComponent<Props> = ({
)
.map((code) => (
<>
<Localized id={`moderationReason-rejectionReason-${code}`}>
<Localized id={`common-moderationReason-rejectionReason-${code}`}>
<RadioButton
value={code}
name={code}
Expand All @@ -71,13 +71,13 @@ const Reasons: FunctionComponent<Props> = ({
</>
))}

<Localized id="moderationReason-reason-moreReasons">
<Localized id="common-moderationReason-reason-moreReasons">
<span className={styles.sectionLabel}>+ More reasons</span>
</Localized>

<>
<Localized
id={`moderationReason-rejectionReason-${GQLREJECTION_REASON_CODE.OTHER}`}
id={`common-moderationReason-rejectionReason-${GQLREJECTION_REASON_CODE.OTHER}`}
>
<RadioButton
value={GQLREJECTION_REASON_CODE.OTHER}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ it("requires moderation reason when DSA features enabled", async () => {
await waitFor(() => {
expect(screen.queryByTestId("moderation-reason-modal")).toBeVisible();
});
// BOOKMARK: continue here

const reasonModal = screen.queryByTestId("moderation-reason-modal")!;

const submitReasonButton = within(reasonModal).getByRole("button", {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,7 @@ it("requires rection reason when dsaFeaturesEnabled", async () => {
commentRevisionID: firstComment.revision!.id,
reason: {
code: "OTHER",
additionalInfo: "really weird comment tbh",
detailedExplanation: "really weird comment tbh",
},
});
return {
Expand Down
29 changes: 0 additions & 29 deletions locales/en-US/admin.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -1101,35 +1101,6 @@ moderate-searchBar-comboBoxTextField =
moderate-searchBar-goTo = Go to
moderate-searchBar-seeAllResults = See all results
moderationReason-reason =
Reason
moderationReason-addExplanation =
Add explanation
moderationReason-reject =
Reject
moderationReason-cancel =
Cancel
moderationReason-rejectionReason-OFFENSIVE =
Offensive
moderationReason-rejectionReason-ABUSIVE =
Abusive
moderationReason-rejectionReason-SPAM =
Spam
moderationReason-rejectionReason-BANNED_WORD =
Banned word
moderationReason-rejectionReason-AD =
Ad
moderationReason-reason-moreReasons =
+ More reasons
moderationReason-rejectionReason-OTHER =
Other
moderationReason-changeReason =
Change reason
moderationReason-detailedExplanation =
Detailed explanation
moderationReason-detailedExplanation-placeholder =
.placeholder = Add your explanation
moderateCardDetails-tab-info = Info
moderateCardDetails-tab-edits = Edit history
moderateCardDetails-tab-automatedActions = Automated actions
Expand Down
29 changes: 29 additions & 0 deletions locales/en-US/common.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,32 @@ common-error-traceID = Trace ID
common-username =
.aria-label = User { $username }
common-moderationReason-reason =
Reason
common-moderationReason-addExplanation =
Add explanation
common-moderationReason-reject =
Reject
common-moderationReason-cancel =
Cancel
common-moderationReason-rejectionReason-OFFENSIVE =
Offensive
common-moderationReason-rejectionReason-ABUSIVE =
Abusive
common-moderationReason-rejectionReason-SPAM =
Spam
common-moderationReason-rejectionReason-BANNED_WORD =
Banned word
common-moderationReason-rejectionReason-AD =
Ad
common-moderationReason-reason-moreReasons =
+ More reasons
common-moderationReason-rejectionReason-OTHER =
Other
common-moderationReason-changeReason =
Change reason
common-moderationReason-detailedExplanation =
Detailed explanation
common-moderationReason-detailedExplanation-placeholder =
.placeholder = Add your explanation

0 comments on commit e07e71e

Please sign in to comment.