feat(dashboard): Improve error messages during file upload (#13991)

* feat(dashboard): Update error message for large files

Update error message for uploads of files that exceed their limit

Related https://github.com/medusajs/medusa/pull/13981

* Added changeset
This commit is contained in:
juanzgc
2025-11-06 14:41:07 -05:00
committed by GitHub
parent 01a5ce949e
commit 5a96bb7da4
3 changed files with 8 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
"@medusajs/dashboard": patch
---
Improve error messaging for file uploads

View File

@@ -513,7 +513,7 @@
"uploadImagesLabel": "Upload images", "uploadImagesLabel": "Upload images",
"uploadImagesHint": "Drag and drop images here or click to upload.", "uploadImagesHint": "Drag and drop images here or click to upload.",
"invalidFileType": "'{{name}}' is not a supported file type. Supported file types are: {{types}}.", "invalidFileType": "'{{name}}' is not a supported file type. Supported file types are: {{types}}.",
"fileTooLarge": "'{{name}}' exceeds the maximum file size of {{size}}. Please upload a smaller file.", "fileTooLarge": "One or more files exceed the maximum file size of {{size}}: {{name}}",
"failedToUpload": "Failed to upload the added media. Please try again.", "failedToUpload": "Failed to upload the added media. Please try again.",
"deleteWarning_one": "You are about to delete {{count}} image. This action cannot be undone.", "deleteWarning_one": "You are about to delete {{count}} image. This action cannot be undone.",
"deleteWarning_other": "You are about to delete {{count}} images. This action cannot be undone.", "deleteWarning_other": "You are about to delete {{count}} images. This action cannot be undone.",

View File

@@ -70,7 +70,7 @@ export const UploadMediaFormItem = ({
const fileSizeRejections = rejectedFiles.filter((f) => f?.reason === "size") const fileSizeRejections = rejectedFiles.filter((f) => f?.reason === "size")
if (fileSizeRejections.length) { if (fileSizeRejections.length) {
const fileNames = fileSizeRejections.map((f) => f.file.name).join(", ") const fileNames = "\n" + fileSizeRejections.slice(0, 5).map((f) => f.file.name).join("\n")
form.setError("media", { form.setError("media", {
type: "file_too_large", type: "file_too_large",
message: t("products.media.fileTooLarge", { message: t("products.media.fileTooLarge", {
@@ -124,7 +124,7 @@ export const UploadMediaFormItem = ({
onUploaded={onUploaded} onUploaded={onUploaded}
/> />
</Form.Control> </Form.Control>
<Form.ErrorMessage /> <Form.ErrorMessage className="whitespace-pre-line" />
</div> </div>
</Form.Item> </Form.Item>
) )