-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Advanced tag filters #266
Changes from 10 commits
314efe1
4c09587
055dcc8
5ddeacc
7b2ba1f
343ef37
efa025a
8a2bce5
50c65f2
5a0957f
8ab42cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,7 +32,7 @@ import { | |
ChevronUpIcon, | ||
} from '@heroicons/react/24/outline' | ||
import { LabelSelector } from '@/common/labels/Selector' | ||
import { pluralize, takesKeyboardEvt } from '@/lib/util' | ||
import { takesKeyboardEvt } from '@/lib/util' | ||
import { Loading } from '@/common/Loader' | ||
import { ActionDurationSelector } from '@/reports/ModerationForm/ActionDurationSelector' | ||
import { MOD_EVENTS } from '@/mod-event/constants' | ||
|
@@ -201,6 +201,7 @@ function Form( | |
const shouldShowDurationInHoursField = | ||
isTakedownEvent || isMuteEvent || isMuteReporterEvent | ||
const canManageChat = usePermission('canManageChat') | ||
const canTakedown = usePermission('canTakedown') | ||
|
||
// navigate to next or prev report | ||
const navigateQueue = (delta: 1 | -1) => { | ||
|
@@ -500,7 +501,13 @@ function Form( | |
submitForm() | ||
} | ||
useKeyPressEvent('c', safeKeyHandler(onCancel)) | ||
useKeyPressEvent('s', safeKeyHandler(submitForm)) | ||
useKeyPressEvent( | ||
's', | ||
safeKeyHandler((e) => { | ||
e.stopImmediatePropagation() | ||
submitForm() | ||
}), | ||
) | ||
useKeyPressEvent('n', safeKeyHandler(submitAndGoNext)) | ||
useKeyPressEvent( | ||
'a', | ||
|
@@ -522,9 +529,11 @@ function Form( | |
) | ||
useKeyPressEvent( | ||
't', | ||
safeKeyHandler(() => { | ||
setModEventType(MOD_EVENTS.TAKEDOWN) | ||
}), | ||
canTakedown | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixes #244 |
||
? safeKeyHandler(() => { | ||
setModEventType(MOD_EVENTS.TAKEDOWN) | ||
}) | ||
: undefined, | ||
) | ||
|
||
return ( | ||
|
@@ -644,8 +653,8 @@ function Form( | |
{!!subjectStatus?.tags?.length && ( | ||
<div className={`mb-3`}> | ||
<FormLabel label="Tags"> | ||
<LabelList className="-ml-1 flex-wrap"> | ||
{subjectStatus.tags.map((tag) => { | ||
<LabelList className="-ml-1 flex-wrap gap-1"> | ||
{subjectStatus.tags.sort().map((tag) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes having the lang tags being placed in random places. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that |
||
return <SubjectTag key={tag} tag={tag} /> | ||
})} | ||
</LabelList> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ const Timer = () => { | |
}, 1000) | ||
|
||
return ( | ||
<div className="flex flex-row justify-center py-4"> | ||
<div className="flex flex-row justify-center py-4 dark:text-gray-200"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixes #152 |
||
<p className="font-bold text-xl">{getDuration(seconds)}</p> | ||
</div> | ||
) | ||
|
@@ -44,41 +44,7 @@ export default function SurpriseMePage() { | |
<> | ||
{/* This is valid jsx but because of a known bug, typescript is confused */} | ||
{/* @ts-ignore:next-line */} | ||
<style global jsx> | ||
{` | ||
.game-block { | ||
margin: 0; | ||
padding: 0; | ||
width: 1.5em; | ||
height: 1.5em; | ||
border: 1px solid #ddd; | ||
} | ||
.piece-i { | ||
background-color: #ec858b; | ||
} | ||
.piece-j { | ||
background-color: #f1b598; | ||
} | ||
.piece-l { | ||
background-color: #f8efae; | ||
} | ||
.piece-o { | ||
background-color: #b5a677; | ||
} | ||
.piece-s { | ||
background-color: #816e56; | ||
} | ||
.piece-t { | ||
background-color: #b77c72; | ||
} | ||
.piece-z { | ||
background-color: #e3be58; | ||
} | ||
.piece-preview { | ||
background-color: #eee; | ||
} | ||
`} | ||
</style> | ||
|
||
<Timer /> | ||
<ClientOnlyTetris /> | ||
</> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,12 +27,12 @@ export function SetupModal({ | |
className="mx-auto h-20 w-auto" | ||
title="Icon from Flaticon: https://www.flaticon.com/free-icons/lifeguard-tower" | ||
src="/img/logo-colorful.png" | ||
alt="Ozone - Bluesky Admin" | ||
alt="Ozone - ATProto Moderation Service" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addresses #216 |
||
width={200} | ||
height={200} | ||
/> | ||
<h2 className="mt-6 text-center text-3xl font-bold tracking-tight text-gray-900 dark:text-gray-200"> | ||
Bluesky Admin Tools | ||
Ozone Moderation Service | ||
</h2> | ||
{title && ( | ||
<p className="mt-2 text-center text-sm text-gray-600 dark:text-gray-100"> | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,38 @@ | ||
import { Popover, Transition } from '@headlessui/react' | ||
import { ChevronDownIcon } from '@heroicons/react/20/solid' | ||
import { QueueFilterLanguage } from './Language' | ||
import { QueueFilterSubjectType } from './SubjectType' | ||
import { useSearchParams } from 'next/navigation' | ||
import { useQueueFilterBuilder } from '../useQueueFilter' | ||
import { ToolsOzoneModerationQueryStatuses } from '@atproto/api' | ||
import { getLanguageFlag } from 'components/tags/SubjectTag' | ||
import { getCollectionName } from '../helpers/subject' | ||
import { classNames } from '@/lib/util' | ||
import { QueueFilterTags } from './Tag' | ||
|
||
const buildTagFilterSummary = (tags: string[]) => { | ||
if (!tags.filter(Boolean).length) { | ||
return '' | ||
} | ||
|
||
const list = tags.map((tag) => { | ||
return tag | ||
.split('&&') | ||
.map((t) => { | ||
if (t.startsWith('lang:')) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should probably trim here ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the sort should be fine, we don't depend on the order anywhere |
||
const langCode = t.split(':')[1] | ||
return getLanguageFlag(langCode) || langCode | ||
} | ||
return t | ||
}) | ||
.join(' && ') | ||
}) | ||
|
||
if (list.length === 1) { | ||
return list[0] | ||
} | ||
|
||
return `(${list.join(') OR (')})` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we mixing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm... we could replace && with AND i guess since this is purely for display purposes. |
||
} | ||
|
||
// Takes all the queue filters manageable in the panel and displays a summary of selections made | ||
const FilterSummary = ({ | ||
|
@@ -17,7 +42,7 @@ const FilterSummary = ({ | |
}) => { | ||
const { tags, excludeTags, collections, subjectType } = queueFilters | ||
if ( | ||
!tags?.length && | ||
!tags?.filter(Boolean).length && | ||
!excludeTags?.length && | ||
!collections?.length && | ||
!subjectType | ||
|
@@ -36,16 +61,9 @@ const FilterSummary = ({ | |
inclusions.push('Only Records') | ||
} | ||
|
||
tags?.forEach((tag) => { | ||
if (tag.startsWith('lang:')) { | ||
const langCode = tag.split(':')[1] | ||
inclusions.push(getLanguageFlag(langCode) || langCode) | ||
} | ||
|
||
if (tag.startsWith('embed:')) { | ||
inclusions.push(tag.split(':')[1]) | ||
} | ||
}) | ||
if (tags?.length) { | ||
inclusions.push(buildTagFilterSummary(tags)) | ||
} | ||
|
||
excludeTags?.forEach((tag) => { | ||
if (tag.startsWith('lang:')) { | ||
|
@@ -57,6 +75,7 @@ const FilterSummary = ({ | |
exclusions.push(tag.split(':')[1]) | ||
} | ||
}) | ||
|
||
return ( | ||
<> | ||
{!!inclusions.length && inclusions.join(' ')} | ||
|
@@ -117,12 +136,13 @@ export const QueueFilterPanel = () => { | |
leaveFrom="transform scale-100 opacity-100" | ||
leaveTo="transform scale-95 opacity-0" | ||
> | ||
<Popover.Panel className="absolute left-0 z-10 mt-1 flex w-screen max-w-max -translate-x-1/5 px-4"> | ||
<div className="w-fit-content flex-auto rounded bg-white dark:bg-slate-800 p-4 text-sm leading-6 shadow-lg dark:shadow-slate-900 ring-1 ring-gray-900/5"> | ||
<Popover.Panel className="absolute left-0 z-10 mt-1 flex max-w-max -translate-x-1/5 px-4"> | ||
<div className="flex-auto w-96 rounded bg-white dark:bg-slate-800 p-4 text-sm leading-6 shadow-lg dark:shadow-slate-900 ring-1 ring-gray-900/5"> | ||
<div className="flex flex-row px-2 gap-6"> | ||
<QueueFilterLanguage /> | ||
<QueueFilterSubjectType /> | ||
</div> | ||
|
||
<QueueFilterTags /> | ||
</div> | ||
</Popover.Panel> | ||
</Transition> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to the PR. fixes #265