Add new allowed trust center file types
Signed-off-by: Émile Ré <nemile.re@gmail.com>
This commit is contained in:
@@ -38,6 +38,23 @@ type ContextType = {
|
||||
};
|
||||
};
|
||||
|
||||
const acceptedFileTypes = {
|
||||
"application/json": [".json"],
|
||||
"application/msword": [".doc"],
|
||||
"application/pdf": [".pdf"],
|
||||
"application/vnd.ms-excel": [".xls"],
|
||||
"application/vnd.ms-powerpoint": [".ppt"],
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation": [".pptx"],
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": [".docx"],
|
||||
"image/jpeg": [".jpeg", ".jpg"],
|
||||
"image/png": [".png"],
|
||||
"image/svg+xml": [".svg"],
|
||||
"image/webp": [".webp"],
|
||||
"text/csv": [".csv"],
|
||||
"text/markdown": [".md"],
|
||||
}
|
||||
|
||||
export default function TrustCenterFilesTab() {
|
||||
const { __ } = useTranslate();
|
||||
const { organization } = useOutletContext<ContextType>();
|
||||
@@ -80,10 +97,10 @@ export default function TrustCenterFilesTab() {
|
||||
if (acceptedFiles.length > 0) {
|
||||
const file = acceptedFiles[0];
|
||||
|
||||
if (file.type !== "application/pdf") {
|
||||
if (!Object.keys(acceptedFileTypes).includes(file.type)) {
|
||||
createForm.setError("root", {
|
||||
type: "manual",
|
||||
message: __("Only PDF files are allowed"),
|
||||
message: __("File type is not allowed"),
|
||||
});
|
||||
return;
|
||||
}
|
||||
@@ -225,11 +242,11 @@ export default function TrustCenterFilesTab() {
|
||||
<form onSubmit={handleCreate}>
|
||||
<DialogContent padded className="space-y-4">
|
||||
<Dropzone
|
||||
description={__("Upload PDF file (max 10MB)")}
|
||||
description={__("Upload file (max 10MB)")}
|
||||
isUploading={isUploading}
|
||||
onDrop={handleFileUpload}
|
||||
maxSize={10}
|
||||
accept={{ "application/pdf": [".pdf"] }}
|
||||
accept={acceptedFileTypes}
|
||||
/>
|
||||
{uploadedFile && (
|
||||
<div className="text-sm text-txt-secondary">
|
||||
|
||||
@@ -1742,11 +1742,7 @@ func (s *DocumentService) Export(
|
||||
return fmt.Errorf("cannot load document version for %q: %w", documentID, err)
|
||||
}
|
||||
|
||||
pdfOptions := ExportPDFOptions{
|
||||
WithWatermark: options.WithWatermark,
|
||||
WatermarkEmail: options.WatermarkEmail,
|
||||
WithSignatures: options.WithSignatures,
|
||||
}
|
||||
pdfOptions := ExportPDFOptions(options)
|
||||
|
||||
exportedPDF, err := exportDocumentPDF(
|
||||
ctx,
|
||||
|
||||
@@ -222,10 +222,37 @@ func (s *Service) WithTenant(tenantID gid.TenantID) *TenantService {
|
||||
fileValidator: &filevalidation.FileValidator{
|
||||
MaxFileSize: 10 * 1024 * 1024, // 10MB
|
||||
AllowedMimeTypes: map[string]bool{
|
||||
"application/pdf": true,
|
||||
"application/json": true,
|
||||
"application/msword": true,
|
||||
"application/pdf": true,
|
||||
"application/vnd.ms-excel": true,
|
||||
"application/vnd.ms-powerpoint": true,
|
||||
"application/vnd.openxmlformats-officedocument.presentationml.presentation": true,
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": true,
|
||||
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": true,
|
||||
"image/jpeg": true,
|
||||
"image/png": true,
|
||||
"image/svg+xml": true,
|
||||
"image/webp": true,
|
||||
"text/csv": true,
|
||||
"text/markdown": true,
|
||||
},
|
||||
AllowedExtensions: map[string][]string{
|
||||
".pdf": {"application/pdf"},
|
||||
".csv": {"text/csv"},
|
||||
".doc": {"application/msword"},
|
||||
".docx": {"application/vnd.openxmlformats-officedocument.wordprocessingml.document"},
|
||||
".jpeg": {"image/jpeg"},
|
||||
".jpg": {"image/jpeg"},
|
||||
".json": {"application/json"},
|
||||
".md": {"text/markdown"},
|
||||
".pdf": {"application/pdf"},
|
||||
".png": {"image/png"},
|
||||
".ppt": {"application/vnd.ms-powerpoint"},
|
||||
".pptx": {"application/vnd.openxmlformats-officedocument.presentationml.presentation"},
|
||||
".svg": {"image/svg+xml"},
|
||||
".webp": {"image/webp"},
|
||||
".xls": {"application/vnd.ms-excel"},
|
||||
".xlsx": {"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user