Skip to content
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

✨ Subject type filter #225

Merged
merged 3 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 48 additions & 24 deletions app/reports/page-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@ import { ModActionPanelQuick } from '../actions/ModActionPanel/QuickAction'
import { ButtonGroup } from '@/common/buttons'
import { SubjectTable } from 'components/subject/table'
import { useTitle } from 'react-use'
import { LanguagePicker } from '@/common/LanguagePicker'
import { QueueSelector, QUEUE_NAMES } from '@/reports/QueueSelector'
import { simpleHash, unique } from '@/lib/util'
import { useEmitEvent } from '@/mod-event/helpers/emitEvent'
import { useFluentReportSearchParams } from '@/reports/useFluentReportSearch'
import { useLabelerAgent } from '@/shell/ConfigurationContext'
import { WorkspacePanel } from 'components/workspace/Panel'
import { useWorkspaceOpener } from '@/common/useWorkspaceOpener'
import { EmbedTypePickerForModerationQueue } from '@/common/EmbedTypePicker'
import { QUEUE_SEED } from '@/lib/constants'
import QueueFilterPanel from '@/reports/QueueFilter/Panel'

const TABS = [
{
Expand Down Expand Up @@ -106,13 +105,15 @@ const ResolvedFilters = () => {
const appealed = params.get('appealed')

const updateParams = useCallback(
(key: string, newState: boolean) => {
(updates: Record<string, boolean>) => {
const nextParams = new URLSearchParams(params)
if (nextParams.get(key) == `${newState}`) {
nextParams.delete(key)
} else {
nextParams.set(key, `${newState}`)
}
Object.entries(updates).forEach(([key, newState]) => {
if (nextParams.get(key) === `${newState}`) {
nextParams.delete(key)
} else {
nextParams.set(key, `${newState}`)
}
})
router.push((pathname ?? '') + '?' + nextParams.toString())
},
[params, pathname, router],
Expand All @@ -126,20 +127,29 @@ const ResolvedFilters = () => {
{
id: 'takendown',
text: 'Taken Down',
onClick: () => updateParams('takendown', true),
onClick: () => updateParams({ takendown: true }),
isActive: takendown === 'true',
},
{
id: 'includeMuted',
text: 'Show Muted',
onClick: () => updateParams('includeMuted', true),
isActive: includeMuted === 'true',
},
{
id: 'onlyMuted',
text: 'Only Muted',
onClick: () => updateParams('onlyMuted', true),
isActive: onlyMuted === 'true',
id: 'mute',
text:
includeMuted === 'true'
? 'Include Muted'
: onlyMuted === 'true'
? 'Only Muted'
: 'Mutes',
onClick: () => {
// setting a param to it's current value toggles it off
// so we toggle off includeMuted and toggle on onlyMuted
if (includeMuted === 'true') {
updateParams({ includeMuted: true, onlyMuted: true })
Copy link
Contributor Author

@foysalit foysalit Nov 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'd move most of these into the new useQueueFilters hook but trying not to bite into too much in one go.

} else if (onlyMuted === 'true') {
updateParams({ onlyMuted: true })
} else {
updateParams({ includeMuted: true })
}
},
isActive: includeMuted === 'true' || onlyMuted === 'true',
},
{
id: 'appealed',
Expand All @@ -151,12 +161,12 @@ const ResolvedFilters = () => {
: 'Appeals',
onClick: () => {
if (appealed === 'true') {
updateParams('appealed', false)
updateParams({ appealed: false })
} else if (appealed === 'false') {
// setting the same value toggles the param off
updateParams('appealed', false)
updateParams({ appealed: false })
} else {
updateParams('appealed', true)
updateParams({ appealed: true })
}
},
isActive: appealed === 'true' || appealed === 'false',
Expand Down Expand Up @@ -237,8 +247,7 @@ export const ReportsPageContent = () => {
</SectionHeader>
<div className="md:flex mt-2 mb-2 flex-row justify-between px-4 sm:px-6 lg:px-8">
<div className="flex flex-row items-center gap-2">
<LanguagePicker />
<EmbedTypePickerForModerationQueue />
<QueueFilterPanel />
</div>
<ResolvedFilters />
</div>
Expand Down Expand Up @@ -294,6 +303,8 @@ function useModerationQueueQuery() {
const tags = params.get('tags')
const excludeTags = params.get('excludeTags')
const queueName = params.get('queueName')
const subjectType = params.get('subjectType')
const collections = params.get('collections')
const { sortField, sortDirection } = getSortParams(params)
const { lastReviewedBy, subject, reporters, includeAllUserRecords } =
useFluentReportSearchParams()
Expand All @@ -316,6 +327,8 @@ function useModerationQueueQuery() {
queueName,
includeMuted,
onlyMuted,
subjectType,
collections,
},
],
queryFn: async ({ pageParam }) => {
Expand All @@ -329,6 +342,17 @@ function useModerationQueueQuery() {

if (subject) {
queryParams.subject = subject
} else {
if (subjectType) {
queryParams.subjectType = subjectType
}

if (subjectType === 'record') {
const collectionNames = collections?.split(',')
if (collectionNames?.length) {
queryParams.collections = collectionNames
}
}
}

if (takendown) {
Expand Down
86 changes: 0 additions & 86 deletions components/common/EmbedTypePicker.tsx

This file was deleted.

Loading
Loading