From 3089191f6050b4a32d6d06cee9475977f4c2f556 Mon Sep 17 00:00:00 2001 From: Foysal Ahamed Date: Wed, 21 Feb 2024 13:28:32 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9D=87=EF=B8=8F=20Language=20filter=20on=20m?= =?UTF-8?q?oderation=20queue=20(#25)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :sparkles: Use dids in all links instead of handles * :bug: Maintain search params when redirecting * :bug: Wait for auth before attempting to resolve handle * :sparkles: Add language filter to moderation queue * :sparkles: Move lang filter to use tags * :bug: Unique key for option * :sparkles: Add tag display and emit form * :sparkles: Allow multiple language inclusion and exclusion from the language picker * :lipstick: Fix style of the lang picker button * :arrow_up: Upgrade atproto api version * :lipstick: Add inline comments and refactor * :lipstick: Improve the language picker styling and add help text * :bug: Use tag filters in the query key to refresh after lang selection --- app/actions/ModActionPanel/QuickAction.tsx | 35 ++++ app/reports/page-content.tsx | 22 ++- components/common/LanguagePicker.tsx | 216 +++++++++++++++++++++ components/mod-event/EventItem.tsx | 30 +++ components/mod-event/EventList.tsx | 38 +++- components/mod-event/ItemTitle.tsx | 4 + components/mod-event/SelectorButton.tsx | 1 + components/mod-event/constants.ts | 2 + components/mod-event/useModEventList.tsx | 17 +- components/tags/utils.ts | 5 + package.json | 2 +- yarn.lock | 14 +- 12 files changed, 371 insertions(+), 15 deletions(-) create mode 100644 components/common/LanguagePicker.tsx create mode 100644 components/tags/utils.ts diff --git a/app/actions/ModActionPanel/QuickAction.tsx b/app/actions/ModActionPanel/QuickAction.tsx index ee8ff900..cd85aa99 100644 --- a/app/actions/ModActionPanel/QuickAction.tsx +++ b/app/actions/ModActionPanel/QuickAction.tsx @@ -45,6 +45,7 @@ import { SubjectReviewStateBadge } from '@/subject/ReviewStateMarker' import { getProfileUriForDid } from '@/reports/helpers/subject' import { Dialog } from '@headlessui/react' import { SubjectSwitchButton } from '@/common/SubjectSwitchButton' +import { diffTags } from 'components/tags/utils' const FORM_ID = 'mod-action-panel' const useBreakpoint = createBreakpoint({ xs: 340, sm: 640 }) @@ -176,6 +177,7 @@ function Form( const [modEventType, setModEventType] = useState( MOD_EVENTS.ACKNOWLEDGE, ) + const isTagEvent = modEventType === MOD_EVENTS.TAG const isLabelEvent = modEventType === MOD_EVENTS.LABEL const isMuteEvent = modEventType === MOD_EVENTS.MUTE const isCommentEvent = modEventType === MOD_EVENTS.COMMENT @@ -252,6 +254,15 @@ function Form( coreEvent.sticky = true } + if (formData.get('tags')) { + const tags = String(formData.get('tags')) + .split(',') + .map((tag) => tag.trim()) + const { add, remove } = diffTags(subjectStatus?.tags || [], tags) + coreEvent.add = add + coreEvent.remove = remove + } + const { subject: subjectInfo, record: recordInfo } = await createSubjectFromId(subject) @@ -528,6 +539,17 @@ function Form( + {!!subjectStatus?.tags?.length && ( +
+ + + {subjectStatus.tags.map((tag) => { + return {tag} + })} + + +
+ )} {/* This is only meant to be switched on in mobile/small screen view */} {/* The parent component ensures to toggle this based on the screen size */} @@ -568,6 +590,19 @@ function Form( )} + {isTagEvent && ( + + + + )} +