Skip to content

Commit

Permalink
feat: Do not display arrow icons on leaf node of folders infiniflow#1826
Browse files Browse the repository at this point in the history
  • Loading branch information
cike8899 committed Aug 7, 2024
1 parent e34817c commit 8d12dcc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions api/db/services/file_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ def get_by_pf_id(cls, tenant_id, pf_id, page_number, items_per_page,
if file["type"] == FileType.FOLDER.value:
file["size"] = cls.get_folder_size(file["id"])
file['kbs_info'] = []
children = list(cls.model.select().where(
(cls.model.tenant_id == tenant_id),
(cls.model.parent_id == file["id"]),
~(cls.model.id == file["id"]),
).dicts())
file["has_child_folder"] = any(value["type"] == "folder" for value in children)
continue
kbs_info = cls.get_kb_id_by_file_id(file['id'])
file['kbs_info'] = kbs_info
Expand Down
1 change: 1 addition & 0 deletions web/src/interfaces/database/file-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface IFile {
update_date: string;
update_time: number;
source_type: string;
has_child_folder?: boolean;
}

export interface IFolder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { IFile } from '@/interfaces/database/file-manager';
import type { GetProp, TreeSelectProps } from 'antd';
import { TreeSelect } from 'antd';
import { useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';

type DefaultOptionType = GetProp<TreeSelectProps, 'treeData'>[number];

Expand All @@ -12,6 +13,7 @@ interface IProps {
}

const AsyncTreeSelect = ({ value, onChange }: IProps) => {
const { t } = useTranslation();
const { fetchList } = useFetchPureFileList();
const [treeData, setTreeData] = useState<Omit<DefaultOptionType, 'label'>[]>(
[],
Expand All @@ -30,7 +32,10 @@ const AsyncTreeSelect = ({ value, onChange }: IProps) => {
pId: x.parent_id,
value: x.id,
title: x.name,
isLeaf: false,
isLeaf:
typeof x.has_child_folder === 'boolean'
? !x.has_child_folder
: false,
})),
);
});
Expand All @@ -53,7 +58,7 @@ const AsyncTreeSelect = ({ value, onChange }: IProps) => {
style={{ width: '100%' }}
value={value}
dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
placeholder="Please select"
placeholder={t('fileManager.pleaseSelect')}
onChange={handleChange}
loadData={onLoadData}
treeData={treeData}
Expand Down

0 comments on commit 8d12dcc

Please sign in to comment.