From 1cc17eb611e17fe46008a1841c9cf3fc6619a561 Mon Sep 17 00:00:00 2001 From: balibabu Date: Tue, 22 Apr 2025 13:44:41 +0800 Subject: [PATCH] Feat: Filter the knowledge base list using owner #3221 (#7191) ### What problem does this PR solve? Feat: Filter the knowledge base list using owner #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality) --- web/src/components/list-filter-bar.tsx | 43 ++++- web/src/components/ui/pagination.tsx | 117 ++++++++++++++ web/src/hooks/knowledge-hooks.ts | 77 ++++++++- web/src/interfaces/database/knowledge.ts | 7 +- web/src/interfaces/request/knowledge.ts | 10 ++ .../dataset/setting/basic-setting-form.tsx | 2 +- .../datasets/datasets-filter-popover.tsx | 149 ++++++++++++++++++ .../pages/datasets/datasets-pagination.tsx | 96 +++++++++++ web/src/pages/datasets/index.tsx | 61 ++++--- web/src/pages/datasets/use-rename-dataset.ts | 8 +- web/src/pages/datasets/use-select-owners.ts | 28 ++++ web/src/services/knowledge-service.ts | 11 +- 12 files changed, 574 insertions(+), 35 deletions(-) create mode 100644 web/src/components/ui/pagination.tsx create mode 100644 web/src/pages/datasets/datasets-filter-popover.tsx create mode 100644 web/src/pages/datasets/datasets-pagination.tsx create mode 100644 web/src/pages/datasets/use-select-owners.ts diff --git a/web/src/components/list-filter-bar.tsx b/web/src/components/list-filter-bar.tsx index 9732e5d77..f671c987b 100644 --- a/web/src/components/list-filter-bar.tsx +++ b/web/src/components/list-filter-bar.tsx @@ -1,24 +1,57 @@ -import { Filter } from 'lucide-react'; -import { PropsWithChildren } from 'react'; -import { Button } from './ui/button'; +import { ChevronDown } from 'lucide-react'; +import React, { + ChangeEventHandler, + FunctionComponent, + PropsWithChildren, +} from 'react'; +import { Button, ButtonProps } from './ui/button'; import { SearchInput } from './ui/input'; interface IProps { title: string; showDialog?: () => void; + FilterPopover?: FunctionComponent; + searchString?: string; + onSearchChange?: ChangeEventHandler; + count?: number; } +const FilterButton = React.forwardRef< + HTMLButtonElement, + ButtonProps & { count?: number } +>(({ count = 0, ...props }, ref) => { + return ( + + ); +}); + export default function ListFilterBar({ title, children, showDialog, + FilterPopover, + searchString, + onSearchChange, + count, }: PropsWithChildren) { return (
{title}
- - + {FilterPopover ? ( + + + + ) : ( + + )} + + diff --git a/web/src/components/ui/pagination.tsx b/web/src/components/ui/pagination.tsx new file mode 100644 index 000000000..757ffaccc --- /dev/null +++ b/web/src/components/ui/pagination.tsx @@ -0,0 +1,117 @@ +import { ChevronLeft, ChevronRight, MoreHorizontal } from 'lucide-react'; +import * as React from 'react'; + +import { ButtonProps, buttonVariants } from '@/components/ui/button'; +import { cn } from '@/lib/utils'; + +const Pagination = ({ className, ...props }: React.ComponentProps<'nav'>) => ( +