mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-31 17:15:32 +08:00
### What problem does this PR solve? Feat: Filter document by running status and file type. #3221 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -1,28 +1,18 @@
|
||||
import { FilterCollection } from '@/components/list-filter-bar/interface';
|
||||
import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks';
|
||||
import { groupListByType } from '@/utils/dataset-util';
|
||||
import { useMemo } from 'react';
|
||||
|
||||
export type OwnerFilterType = {
|
||||
id: string;
|
||||
label: string;
|
||||
count: number;
|
||||
};
|
||||
|
||||
export function useSelectOwners() {
|
||||
const { list } = useFetchKnowledgeList();
|
||||
|
||||
const owners = useMemo(() => {
|
||||
const ownerList: OwnerFilterType[] = [];
|
||||
list.forEach((x) => {
|
||||
const item = ownerList.find((y) => y.id === x.tenant_id);
|
||||
if (!item) {
|
||||
ownerList.push({ id: x.tenant_id, label: x.nickname, count: 1 });
|
||||
} else {
|
||||
item.count += 1;
|
||||
}
|
||||
});
|
||||
|
||||
return ownerList;
|
||||
return groupListByType(list, 'tenant_id', 'nickname');
|
||||
}, [list]);
|
||||
|
||||
return owners;
|
||||
const filters: FilterCollection[] = [
|
||||
{ field: 'owner', list: owners, label: 'Owner' },
|
||||
];
|
||||
|
||||
return filters;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user