diff --git a/components/mod-event/FilterPanel.tsx b/components/mod-event/FilterPanel.tsx index 076982c..18187aa 100644 --- a/components/mod-event/FilterPanel.tsx +++ b/components/mod-event/FilterPanel.tsx @@ -17,6 +17,7 @@ import { useState } from 'react' import { RepoFinder } from '@/repositories/Finder' import { Dropdown } from '@/common/Dropdown' import { ChevronDownIcon } from '@heroicons/react/24/solid' +import { ActionPolicySelector } from '@/reports/ModerationForm/ActionPolicySelector' export const EventFilterPanel = ({ limit, @@ -271,6 +272,17 @@ export const EventFilterPanel = ({ + {types.includes(MOD_EVENTS.TAKEDOWN) && ( +
+ + { + changeListFilter({ field: 'policy', value: policy }) + }} + /> + +
+ )} {types.includes(MOD_EVENTS.TAG) && (
diff --git a/components/mod-event/useModEventList.tsx b/components/mod-event/useModEventList.tsx index 76f9370..4c273a2 100644 --- a/components/mod-event/useModEventList.tsx +++ b/components/mod-event/useModEventList.tsx @@ -62,6 +62,7 @@ const initialListState = { removedLabels: [], addedTags: '', removedTags: '', + policy: '', showContentPreview: false, limit: 25, } @@ -157,6 +158,7 @@ type EventListFilterPayload = | { field: 'removedLabels'; value: string[] } | { field: 'addedTags'; value: string } | { field: 'removedTags'; value: string } + | { field: 'policy'; value: string } | { field: 'limit'; value: number } type EventListAction = @@ -246,6 +248,7 @@ export const useModEventList = ( addedTags, removedTags, reportTypes, + policy, limit, } = listState const queryParams: ToolsOzoneModerationQueryEvents.QueryParams = { @@ -335,6 +338,10 @@ export const useModEventList = ( }) } + if (filterTypes.includes(MOD_EVENTS.TAKEDOWN) && policy) { + queryParams.policy = policy + } + const { data } = await labelerAgent.tools.ozone.moderation.queryEvents({ ...queryParams, }) @@ -372,6 +379,7 @@ export const useModEventList = ( listState.createdBy || listState.subject || listState.oldestFirst || + listState.policy || listState.reportTypes.length > 0 || listState.addedLabels.length > 0 || listState.removedLabels.length > 0 || diff --git a/components/reports/ModerationForm/ActionPolicySelector.tsx b/components/reports/ModerationForm/ActionPolicySelector.tsx index a2e8d70..bb3d6a4 100644 --- a/components/reports/ModerationForm/ActionPolicySelector.tsx +++ b/components/reports/ModerationForm/ActionPolicySelector.tsx @@ -18,10 +18,6 @@ export const ActionPolicySelector = ({ const policyList = Object.values(data?.value || {}) const matchingPolicies = policyList ?.filter((tpl) => { - if (selected && tpl.name !== selected) { - return false - } - if (query.length) { return tpl.name.toLowerCase().includes(query.toLowerCase()) } diff --git a/components/setting/policy/Editor.tsx b/components/setting/policy/Editor.tsx index 41cf26c..81e558f 100644 --- a/components/setting/policy/Editor.tsx +++ b/components/setting/policy/Editor.tsx @@ -24,12 +24,16 @@ export const PolicyEditor = ({ id="name" name="name" required - placeholder="Name of the policy. Only alphabets are allowed." + placeholder="Name of the policy. Only alphabetic characters are allowed." className="block w-full" pattern="[A-Za-z ]+" /> - +