Skip to content

Commit

Permalink
✨ Allow managing page size for event stream (#256)
Browse files Browse the repository at this point in the history
  • Loading branch information
foysalit authored Dec 5, 2024
1 parent c3cf1b2 commit a646d5a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions components/mod-event/EventList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export const ModEventList = (
) => {
const {
types,
limit,
reportTypes,
addedLabels,
removedLabels,
Expand Down Expand Up @@ -267,6 +268,7 @@ export const ModEventList = (
{showFiltersPanel && (
<EventFilterPanel
{...{
limit,
types,
reportTypes,
addedLabels,
Expand Down
22 changes: 22 additions & 0 deletions components/mod-event/FilterPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ import { useFilterMacroUpsertMutation } from './useFilterMacrosList'
import { MacroList } from './MacroPicker'
import { useState } from 'react'
import { RepoFinder } from '@/repositories/Finder'
import { Dropdown } from '@/common/Dropdown'
import { ChevronDownIcon } from '@heroicons/react/24/solid'

export const EventFilterPanel = ({
limit,
types,
reportTypes,
addedLabels,
Expand Down Expand Up @@ -121,6 +124,7 @@ export const EventFilterPanel = ({
}}
/>
</div>

<h5 className="text-gray-700 dark:text-gray-100 font-medium">
Comment/Note
</h5>
Expand Down Expand Up @@ -162,6 +166,24 @@ export const EventFilterPanel = ({
</FormLabel>
)}

<FormLabel label="Page Size" htmlFor="limit" className="flex-1 mt-2">
<Dropdown
className="inline-flex justify-center rounded-md border border-gray-300 dark:border-teal-500 bg-white dark:bg-slate-800 dark:text-gray-100 dark:focus:border-teal-500 dark px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 dark:hover:bg-slate-700"
items={[25, 50, 75, 100].map((size) => ({
id: `${size}`,
text: `${size} per page`,
onClick: () =>
changeListFilter({ field: 'limit', value: size }),
}))}
>
{limit} per page
<ChevronDownIcon
className="ml-2 -mr-1 h-5 w-5 text-violet-200 hover:text-violet-100"
aria-hidden="true"
/>
</Dropdown>
</FormLabel>

<FormLabel
label="Event Author DID"
htmlFor="createdBy"
Expand Down
5 changes: 4 additions & 1 deletion components/mod-event/useModEventList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ const initialListState = {
addedTags: '',
removedTags: '',
showContentPreview: false,
limit: 25,
}

const getReposAndRecordsForEvents = async (
Expand Down Expand Up @@ -156,6 +157,7 @@ type EventListFilterPayload =
| { field: 'removedLabels'; value: string[] }
| { field: 'addedTags'; value: string }
| { field: 'removedTags'; value: string }
| { field: 'limit'; value: number }

type EventListAction =
| {
Expand Down Expand Up @@ -244,8 +246,10 @@ export const useModEventList = (
addedTags,
removedTags,
reportTypes,
limit,
} = listState
const queryParams: ToolsOzoneModerationQueryEvents.QueryParams = {
limit,
cursor: pageParam,
includeAllUserRecords,
}
Expand Down Expand Up @@ -332,7 +336,6 @@ export const useModEventList = (
}

const { data } = await labelerAgent.tools.ozone.moderation.queryEvents({
limit: 25,
...queryParams,
})
const { repos, records } = await getReposAndRecordsForEvents(
Expand Down

0 comments on commit a646d5a

Please sign in to comment.