Skip to content

Commit

Permalink
fix: yuque dataset file folder can enter (#3593)
Browse files Browse the repository at this point in the history
  • Loading branch information
newfish-cmyk authored and c121914yu committed Jan 15, 2025
1 parent 0d9f54c commit 68f5afe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions packages/global/core/dataset/apiDataset.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type APIFileItem = {
type: 'file' | 'folder';
updateTime: Date;
createTime: Date;
canEnter?: boolean;
};

export type APIFileServer = {
Expand Down
8 changes: 7 additions & 1 deletion packages/service/core/dataset/apiDataset/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,13 @@ export const useApiDatasetRequest = ({ apiServer }: { apiServer: APIFileServer }
if (files.some((file) => !file.id || !file.name || typeof file.type === 'undefined')) {
return Promise.reject('Invalid file data format');
}
return files;

const formattedFiles = files.map((file) => ({
...file,
canEnter: file.type === 'folder'
}));

return formattedFiles;
};

const getFileContent = async ({ teamId, apiFileId }: { teamId: string; apiFileId: string }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const CustomAPIFileInput = () => {
parentId: '',
parentName: ''
});
const [parentUuid, setParentUuid] = useState<string>('');
const [paths, setPaths] = useState<ParentTreePathItemType[]>([]);

const [searchKey, setSearchKey] = useState('');
Expand Down Expand Up @@ -128,7 +127,7 @@ const CustomAPIFileInput = () => {

const handleItemClick = useCallback(
(item: APIFileItem) => {
if (item.type === 'folder') {
if (item.canEnter) {
setPaths((state) => [...state, { parentId: item.id, parentName: item.name }]);
return setParent({
parentId: item.id,
Expand Down Expand Up @@ -251,6 +250,7 @@ const CustomAPIFileInput = () => {
<Box fontSize={'sm'} fontWeight={'medium'} color={'myGray.900'}>
{item.name}
</Box>
{item.canEnter && <MyIcon name="core/chat/chevronRight" w={'18px'} ml={2} />}
</Flex>
);
})}
Expand Down

0 comments on commit 68f5afe

Please sign in to comment.