Skip to content

Commit

Permalink
🐛 Fix file icons for root upload (#826)
Browse files Browse the repository at this point in the history
  • Loading branch information
MontaGhanmy authored Feb 27, 2025
1 parent 5bd1109 commit 4d4c242
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,24 @@ import {
} from 'app/atoms/icons-colored';

// Map mime types to their respective JSX icon elements
export const fileTypeIconsMap = {
'application/pdf': <FileTypePdfIcon />,
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': (
<FileTypeDocumentIcon />
),
'application/msword': <FileTypeDocumentIcon />,
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': <FileTypeSpreadsheetIcon />,
'application/vnd.ms-excel': <FileTypeSpreadsheetIcon />,
'application/vnd.ms-powerpoint': <FileTypeSlidesIcon />,
'application/vnd.openxmlformats-officedocument.presentationml.presentation': (
<FileTypeSlidesIcon />
),
'application/zip': <FileTypeArchiveIcon />,
'application/x-rar-compressed': <FileTypeArchiveIcon />,
'application/x-tar': <FileTypeArchiveIcon />,
'application/x-7z-compressed': <FileTypeArchiveIcon />,
'application/x-bzip': <FileTypeArchiveIcon />,
'application/x-bzip2': <FileTypeArchiveIcon />,
'application/x-gzip': <FileTypeArchiveIcon />,
'video/mp4': <FileTypeMediaIcon />,
'video/mpeg': <FileTypeMediaIcon />,
'video/ogg': <FileTypeMediaIcon />,
'video/webm': <FileTypeMediaIcon />,
'video/quicktime': <FileTypeMediaIcon />,
export const fileTypeIconsMap: Record<string, JSX.Element> = {
pdf: <FileTypePdfIcon />,
doc: <FileTypeDocumentIcon />,
docx: <FileTypeDocumentIcon />,
xls: <FileTypeSpreadsheetIcon />,
xlsx: <FileTypeSpreadsheetIcon />,
ppt: <FileTypeSlidesIcon />,
pptx: <FileTypeSlidesIcon />,
zip: <FileTypeArchiveIcon />,
rar: <FileTypeArchiveIcon />,
tar: <FileTypeArchiveIcon />,
'7z': <FileTypeArchiveIcon />,
bz: <FileTypeArchiveIcon />,
bz2: <FileTypeArchiveIcon />,
gz: <FileTypeArchiveIcon />,
mp4: <FileTypeMediaIcon />,
mpeg: <FileTypeMediaIcon />,
ogg: <FileTypeMediaIcon />,
webm: <FileTypeMediaIcon />,
mov: <FileTypeMediaIcon />,
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ const PendingRootRow = ({
const { restore } = useDriveActions();
const { refresh, children } = useDriveItem(item?.parent_id || '');

const firstPendingFile = root.items[0];
const uploadedFilesSize = root.uploadedSize;
const uploadProgress = Math.floor((uploadedFilesSize / root.size) * 100);
const isUploadCompleted = root.status === 'completed';
const isFileRoot = rootKey.includes('.');
const fileType = isFileRoot ? rootKey.split('.').pop() : '';

// Callback function to open the folder after the upload is completed
const handleShowFolder = useCallback(() => {
Expand Down Expand Up @@ -122,7 +122,7 @@ const PendingRootRow = ({
<div className="flex items-center">
<div className="w-10 h-10 flex items-center justify-center bg-[#f3f3f7] rounded-md">
<div className="w-full h-full flex items-center justify-center testid:upload-root-modal-row-type">
{itemTypeIcon(firstPendingFile?.type)}
{itemTypeIcon(fileType || '')}
</div>
</div>
<p className="ml-4">
Expand Down Expand Up @@ -163,9 +163,9 @@ const PendingRootRow = ({
</button>
) : (
!['cancelled', 'failed'].includes(root.status) &&
firstPendingFile?.status !== 'error' && (
root?.status !== 'error' && (
<>
{root.status === 'paused' ? (
{root.status === 'failed' ? (
<button
onClick={() => pauseOrResumeRootUpload(rootKey)}
className="hover:bg-blue-100 p-2 rounded-md transition-all duration-200 testid:upload-root-modal-row-resume"
Expand Down

0 comments on commit 4d4c242

Please sign in to comment.