[WEB-3996] fix: attachment icon rendering and added support for rar and zip icons (#7007)

* chore: zip and rar file icon

* chore: zip and rar file icon

* fix: attachment icon

* chore: application/x-rar type added

* fix: compressed file extensions

* chore: updated file upload extensions

---------

Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
This commit is contained in:
Anmol Singh Bhatia 2025-05-02 16:53:06 +05:30 committed by GitHub
parent dbc00e4add
commit fbca9d9a7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 41 additions and 2 deletions

View file

@ -376,10 +376,21 @@ ATTACHMENT_MIME_TYPES = [
"video/x-ms-wmv",
# Archives
"application/zip",
"application/x-rar",
"application/x-rar-compressed",
"application/x-zip-compressed",
"application/x-tar",
"application/gzip",
"application/x-zip",
"application/x-zip-compressed",
"application/x-7z-compressed",
"application/x-compressed",
"application/x-compressed-tar",
"application/x-compressed-tar-gz",
"application/x-compressed-tar-bz2",
"application/x-compressed-tar-zip",
"application/x-compressed-tar-7z",
"application/x-compressed-tar-rar",
"application/x-compressed-tar-zip",
# 3D Models
"model/gltf-binary",
"model/gltf+json",

View file

@ -10,10 +10,12 @@ import {
JpgIcon,
PdfIcon,
PngIcon,
RarIcon,
SheetIcon,
SvgIcon,
TxtIcon,
VideoIcon,
ZipIcon,
} from "@/components/icons/attachment";
export const getFileIcon = (fileType: string, size: number = 28) => {
@ -52,6 +54,10 @@ export const getFileIcon = (fileType: string, size: number = 28) => {
return <VideoIcon height={size} width={size} />;
case "mkv":
return <VideoIcon height={size} width={size} />;
case "zip":
return <ZipIcon height={size} width={size} />;
case "rar":
return <RarIcon height={size} width={size} />;
default:
return <DefaultIcon height={size} width={size} />;

View file

@ -18,3 +18,5 @@ export * from "./svg-file-icon";
export * from "./tune-icon";
export * from "./txt-file-icon";
export * from "./video-file-icon";
export * from "./zip-file-icon";
export * from "./rar-file-icon";

View file

@ -0,0 +1,10 @@
import React from "react";
import Image from "next/image";
// image
import RarFileIcon from "@/public/attachment/rar-icon.png";
// type
import type { ImageIconPros } from "../types";
export const RarIcon: React.FC<ImageIconPros> = ({ width, height }) => (
<Image src={RarFileIcon} height={height} width={width} alt="RarFileIcon" />
);

View file

@ -0,0 +1,10 @@
import React from "react";
import Image from "next/image";
// image
import ZipFileIcon from "@/public/attachment/zip-icon.png";
// type
import type { ImageIconPros } from "../types";
export const ZipIcon: React.FC<ImageIconPros> = ({ width, height }) => (
<Image src={ZipFileIcon} height={height} width={width} alt="ZipFileIcon" />
);

View file

@ -38,7 +38,7 @@ export const IssueAttachmentsListItem: FC<TIssueAttachmentsListItem> = observer(
// derived values
const attachment = attachmentId ? getAttachmentById(attachmentId) : undefined;
const fileName = getFileName(attachment?.attributes.name ?? "");
const fileExtension = getFileExtension(attachment?.asset_url ?? "");
const fileExtension = getFileExtension(attachment?.attributes.name ?? "");
const fileIcon = getFileIcon(fileExtension, 18);
const fileURL = getFileURL(attachment?.asset_url ?? "");
// hooks

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7 KiB