🐛 Fix discerning file and folder roots (#862)

This commit is contained in:
Montassar Ghanmy
2025-03-25 00:34:34 +01:00
committed by GitHub
parent 6d3aea3624
commit 1f975f1ed5
4 changed files with 12 additions and 10 deletions
@@ -33,8 +33,8 @@ const PendingRootRow = ({
const uploadedFilesSize = root.uploadedSize; const uploadedFilesSize = root.uploadedSize;
const uploadProgress = Math.floor((uploadedFilesSize / root.size) * 100); const uploadProgress = Math.floor((uploadedFilesSize / root.size) * 100);
const isUploadCompleted = root.status === 'completed'; const isUploadCompleted = root.status === 'completed';
const isFileRoot = root.isUnknownFormat || rootKey.includes('.'); const isFileRoot = root.isFileRoot;
const fileType = isFileRoot ? rootKey.split('.').pop() : ''; const fileType = isFileRoot && rootKey.includes('.') ? rootKey.split('.').pop() : '';
// Callback function to open the folder after the upload is completed // Callback function to open the folder after the upload is completed
const handleShowFolder = useCallback(() => { const handleShowFolder = useCallback(() => {
@@ -116,7 +116,10 @@ const PendingRootRow = ({
return rootName; return rootName;
}; };
const showFileFolderTestId = !showFolder || isFileRoot ? 'testid:upload-root-modal-row-show-file' : 'testid:upload-root-modal-row-show-folder'; const showFileFolderTestId =
!showFolder || isFileRoot
? 'testid:upload-root-modal-row-show-file'
: 'testid:upload-root-modal-row-show-folder';
return ( return (
<div className="root-row testid:upload-root-modal-row"> <div className="root-row testid:upload-root-modal-row">
@@ -105,8 +105,8 @@ class FileUploadService {
this.rootStates.failed[key] = true; this.rootStates.failed[key] = true;
} }
// Check if the root is a file with unknow format // Check if the root is a file regardless of the file format
const isUnknownFormat = const isFileRoot =
this.groupedPendingFiles[key]?.length === 1 && this.groupedPendingFiles[key]?.length === 1 &&
this.groupedPendingFiles[key][0].originalFile?.name === key; this.groupedPendingFiles[key][0].originalFile?.name === key;
@@ -142,7 +142,7 @@ class FileUploadService {
size: this.rootSizes[key], size: this.rootSizes[key],
uploadedSize, uploadedSize,
status, status,
isUnknownFormat, isFileRoot,
}; };
return acc; return acc;
@@ -253,10 +253,9 @@ class FileUploadService {
}, },
callback: async (filePayload, context) => { callback: async (filePayload, context) => {
const root = filePayload.root; const root = filePayload.root;
const isUnknownFormat = const isFileRoot =
this.groupedPendingFiles[root]?.length === 1 && this.groupedPendingFiles[root]?.length === 1 &&
this.groupedPendingFiles[root][0].originalFile?.name === root; this.groupedPendingFiles[root][0].originalFile?.name === root;
const isFileRoot = isUnknownFormat || filePayload.root.includes('.');
const file = filePayload.file; const file = filePayload.file;
if (file) { if (file) {
@@ -9,7 +9,7 @@ export const RootPendingFilesListState = atom<
uploadedSize: number; uploadedSize: number;
status: string; status: string;
items: PendingFileRecoilType[]; items: PendingFileRecoilType[];
isUnknownFormat: boolean; isFileRoot: boolean;
}; };
} }
| undefined | undefined
@@ -94,7 +94,7 @@ export type UploadRootType = {
uploadedSize: number; uploadedSize: number;
status: string; status: string;
items: PendingFileRecoilType[]; items: PendingFileRecoilType[];
isUnknownFormat: boolean; isFileRoot: boolean;
}; };
export type UploadRootListType = { export type UploadRootListType = {