From 687148e2c108a6037ec5bc90c5f726b4c8af6f28 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C3=89mile=20R=C3=A9?=
Date: Tue, 31 Mar 2026 16:50:54 +0400
Subject: [PATCH] Unify dropzone accept prop with accept helpers
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Émile Ré
---
.../TrustCenterReferenceDialog.tsx | 7 +-
.../organizations/audits/AuditDetailsPage.tsx | 9 +--
.../brand/CompliancePageBrandPage.tsx | 15 +---
.../NewCompliancePageFileDialog.tsx | 48 ++++--------
.../measures/dialog/CreateEvidenceDialog.tsx | 26 ++++---
packages/helpers/src/fileAccept.ts | 75 +++++++++++++++++++
packages/helpers/src/index.ts | 10 +++
pkg/filevalidation/validator.go | 1 +
8 files changed, 122 insertions(+), 69 deletions(-)
create mode 100644 packages/helpers/src/fileAccept.ts
diff --git a/apps/console/src/components/trustCenter/TrustCenterReferenceDialog.tsx b/apps/console/src/components/trustCenter/TrustCenterReferenceDialog.tsx
index 5e920d5e7..394caba29 100644
--- a/apps/console/src/components/trustCenter/TrustCenterReferenceDialog.tsx
+++ b/apps/console/src/components/trustCenter/TrustCenterReferenceDialog.tsx
@@ -12,6 +12,7 @@
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
+import { acceptImage } from "@probo/helpers";
import { useTranslate } from "@probo/i18n";
import {
Button,
@@ -238,11 +239,7 @@ export const TrustCenterReferenceDialog = forwardRef
{uploadedFile && (
diff --git a/apps/console/src/pages/organizations/audits/AuditDetailsPage.tsx b/apps/console/src/pages/organizations/audits/AuditDetailsPage.tsx
index 849267ed9..506e3f220 100644
--- a/apps/console/src/pages/organizations/audits/AuditDetailsPage.tsx
+++ b/apps/console/src/pages/organizations/audits/AuditDetailsPage.tsx
@@ -304,16 +304,11 @@ export default function AuditDetailsPage(props: Props) {
void handleUploadFile(files)}
- accept={{
- "application/pdf": [".pdf"],
- "application/msword": [".doc"],
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [".docx"],
- "application/vnd.oasis.opendocument.text": [".odt"],
- }}
+ accept={{ "application/pdf": [".pdf"] }}
maxSize={25}
/>
diff --git a/apps/console/src/pages/organizations/compliance-page/brand/CompliancePageBrandPage.tsx b/apps/console/src/pages/organizations/compliance-page/brand/CompliancePageBrandPage.tsx
index 621895c99..818eeb227 100644
--- a/apps/console/src/pages/organizations/compliance-page/brand/CompliancePageBrandPage.tsx
+++ b/apps/console/src/pages/organizations/compliance-page/brand/CompliancePageBrandPage.tsx
@@ -12,6 +12,7 @@
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
+import { acceptImage } from "@probo/helpers";
import { useTranslate } from "@probo/i18n";
import {
Button,
@@ -286,12 +287,7 @@ export function CompliancePageBrandPage(props: { queryRef: PreloadedQuery
)}
@@ -336,12 +332,7 @@ export function CompliancePageBrandPage(props: { queryRef: PreloadedQuery
)}
diff --git a/apps/console/src/pages/organizations/compliance-page/files/_components/NewCompliancePageFileDialog.tsx b/apps/console/src/pages/organizations/compliance-page/files/_components/NewCompliancePageFileDialog.tsx
index 16d3e7557..08fec48ff 100644
--- a/apps/console/src/pages/organizations/compliance-page/files/_components/NewCompliancePageFileDialog.tsx
+++ b/apps/console/src/pages/organizations/compliance-page/files/_components/NewCompliancePageFileDialog.tsx
@@ -12,7 +12,15 @@
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
-import { getTrustCenterVisibilityOptions } from "@probo/helpers";
+import {
+ acceptData,
+ acceptDocument,
+ acceptImage,
+ acceptPresentation,
+ acceptSpreadsheet,
+ acceptText,
+ getTrustCenterVisibilityOptions,
+} from "@probo/helpers";
import { useTranslate } from "@probo/i18n";
import { Badge, Button, Dialog, DialogContent, DialogFooter, type DialogRef, Dropzone, Field, Option, Spinner } from "@probo/ui";
import { useCallback, useState } from "react";
@@ -25,38 +33,12 @@ import { useMutationWithToasts } from "#/hooks/useMutationWithToasts";
import { useOrganizationId } from "#/hooks/useOrganizationId";
const acceptedFileTypes = {
- "application/csv": [".csv"],
- "application/json": [".json"],
- "application/msword": [".doc"],
- "application/pdf": [".pdf"],
- "application/vnd.ms-excel": [".xls"],
- "application/vnd.ms-powerpoint": [".ppt"],
- "application/vnd.oasis.opendocument.presentation": [".odp"],
- "application/vnd.oasis.opendocument.spreadsheet": [".ods"],
- "application/vnd.oasis.opendocument.text": [".odt"],
- "application/vnd.openxmlformats-officedocument.presentationml.presentation": [
- ".pptx",
- ],
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [
- ".xlsx",
- ],
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [
- ".docx",
- ],
- "application/yaml": [".yaml", ".yml"],
- "image/gif": [".gif"],
- "image/jpeg": [".jpeg", ".jpg"],
- "image/png": [".png"],
- "image/svg+xml": [".svg"],
- "image/webp": [".webp"],
- "text/csv": [".csv"],
- "text/json": [".json"],
- "text/markdown": [".md"],
- "text/plain": [".txt"],
- "text/uri-list; charset=utf-8": [".uri"],
- "text/uri-list": [".uri"],
- "text/x-log": [".log"],
- "text/yaml": [".yaml", ".yml"],
+ ...acceptDocument,
+ ...acceptSpreadsheet,
+ ...acceptPresentation,
+ ...acceptText,
+ ...acceptImage,
+ ...acceptData,
};
const createCompliancePageFileMutation = graphql`
diff --git a/apps/console/src/pages/organizations/measures/dialog/CreateEvidenceDialog.tsx b/apps/console/src/pages/organizations/measures/dialog/CreateEvidenceDialog.tsx
index c9aa0e811..f4e4bc6fb 100644
--- a/apps/console/src/pages/organizations/measures/dialog/CreateEvidenceDialog.tsx
+++ b/apps/console/src/pages/organizations/measures/dialog/CreateEvidenceDialog.tsx
@@ -12,6 +12,14 @@
// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.
+import {
+ acceptData,
+ acceptDocument,
+ acceptImage,
+ acceptPresentation,
+ acceptSpreadsheet,
+ acceptText,
+} from "@probo/helpers";
import { useTranslate } from "@probo/i18n";
import {
Breadcrumb,
@@ -124,18 +132,12 @@ function EvidenceUpload({ measureId, connectionId }: Omit) {
isUploading={isUpdating}
onDrop={files => void handleDrop(files)}
accept={{
- "text/plain": [".uri"],
- "text/csv": [".csv"],
- "application/pdf": [".pdf"],
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
- [".docx"],
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
- [".xlsx"],
- "application/vnd.openxmlformats-officedocument.presentationml.presentation":
- [".pptx"],
- "image/jpeg": [".jpg", ".jpeg"],
- "image/png": [".png"],
- "image/webp": [".webp"],
+ ...acceptDocument,
+ ...acceptSpreadsheet,
+ ...acceptPresentation,
+ ...acceptText,
+ ...acceptData,
+ ...acceptImage,
}}
maxSize={20}
/>
diff --git a/packages/helpers/src/fileAccept.ts b/packages/helpers/src/fileAccept.ts
new file mode 100644
index 000000000..2c61b7db5
--- /dev/null
+++ b/packages/helpers/src/fileAccept.ts
@@ -0,0 +1,75 @@
+// Copyright (c) 2025-2026 Probo Inc .
+//
+// Permission to use, copy, modify, and/or distribute this software for any
+// purpose with or without fee is hereby granted, provided that the above
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+// OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+export const acceptDocument = {
+ "application/pdf": [".pdf"],
+ "application/msword": [".doc"],
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [".docx"],
+ "application/vnd.oasis.opendocument.text": [".odt"],
+} satisfies Record;
+
+export const acceptSpreadsheet = {
+ "application/vnd.ms-excel": [".xls"],
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
+ "application/vnd.oasis.opendocument.spreadsheet": [".ods"],
+} satisfies Record;
+
+export const acceptPresentation = {
+ "application/vnd.ms-powerpoint": [".ppt"],
+ "application/vnd.openxmlformats-officedocument.presentationml.presentation": [".pptx"],
+ "application/vnd.oasis.opendocument.presentation": [".odp"],
+} satisfies Record;
+
+export const acceptText = {
+ "text/markdown": [".md"],
+ "text/plain": [".txt"],
+ "text/x-log": [".log"],
+ "text/uri-list": [".uri"],
+ "text/uri-list; charset=utf-8": [".uri"],
+} satisfies Record;
+
+export const acceptImage = {
+ "image/jpeg": [".jpg", ".jpeg"],
+ "image/png": [".png"],
+ "image/gif": [".gif"],
+ "image/svg+xml": [".svg"],
+ "image/webp": [".webp"],
+} satisfies Record;
+
+export const acceptData = {
+ "application/yaml": [".yaml", ".yml"],
+ "application/json": [".json"],
+ "text/yaml": [".yaml", ".yml"],
+ "text/json": [".json"],
+ "text/csv": [".csv"],
+ "application/csv": [".csv"],
+} satisfies Record;
+
+export const acceptVideo = {
+ "video/mp4": [".mp4"],
+ "video/mpeg": [".mpeg", ".mpg"],
+ "video/quicktime": [".mov"],
+ "video/x-msvideo": [".avi"],
+ "video/webm": [".webm"],
+} satisfies Record;
+
+export const acceptAll = {
+ ...acceptDocument,
+ ...acceptSpreadsheet,
+ ...acceptPresentation,
+ ...acceptText,
+ ...acceptImage,
+ ...acceptData,
+ ...acceptVideo,
+} satisfies Record;
diff --git a/packages/helpers/src/index.ts b/packages/helpers/src/index.ts
index f063f911f..a5e4d7692 100644
--- a/packages/helpers/src/index.ts
+++ b/packages/helpers/src/index.ts
@@ -84,6 +84,16 @@ export {
} from "./trustCenterVisibility";
export { promisifyMutation } from "./relay";
export { fileType, fileSize } from "./file";
+export {
+ acceptDocument,
+ acceptSpreadsheet,
+ acceptPresentation,
+ acceptText,
+ acceptImage,
+ acceptData,
+ acceptVideo,
+ acceptAll,
+} from "./fileAccept";
export {
formatDatetime,
formatDate,
diff --git a/pkg/filevalidation/validator.go b/pkg/filevalidation/validator.go
index 063ec1e8a..1ed8f3200 100644
--- a/pkg/filevalidation/validator.go
+++ b/pkg/filevalidation/validator.go
@@ -63,6 +63,7 @@ var FileTypes = []FileType{
{MimeType: "application/vnd.oasis.opendocument.presentation", Extensions: []string{".odp"}, Category: CategoryPresentation},
// Text types
+ {MimeType: "text/markdown", Extensions: []string{".md"}, Category: CategoryText},
{MimeType: "text/plain", Extensions: []string{".txt"}, Category: CategoryText},
{MimeType: "text/x-log", Extensions: []string{".log"}, Category: CategoryText},
{MimeType: "text/uri-list", Extensions: []string{".uri"}, Category: CategoryText},