Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Do not display arrow icons on leaf node of folders #1826 #1862

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"] == FileType.FOLDER.value 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