[WEB-3944] fix: Error Toast message content update while uploading images (#6969)
* fix: handled svg uploads * chore: proper error message with all allowed types --------- Co-authored-by: sangeethailango <sangeethailango21@gmail.com>
This commit is contained in:
parent
f60f57ef11
commit
101994840a
3 changed files with 25 additions and 7 deletions
|
|
@ -137,7 +137,7 @@ class UserAssetsV2Endpoint(BaseAPIView):
|
||||||
if type not in allowed_types:
|
if type not in allowed_types:
|
||||||
return Response(
|
return Response(
|
||||||
{
|
{
|
||||||
"error": "Invalid file type. Only JPEG and PNG files are allowed.",
|
"error": "Invalid file type. Only JPEG, PNG, WebP, JPG and GIF files are allowed.",
|
||||||
"status": False,
|
"status": False,
|
||||||
},
|
},
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
|
|
@ -351,7 +351,7 @@ class WorkspaceFileAssetEndpoint(BaseAPIView):
|
||||||
if type not in allowed_types:
|
if type not in allowed_types:
|
||||||
return Response(
|
return Response(
|
||||||
{
|
{
|
||||||
"error": "Invalid file type. Only JPEG and PNG files are allowed.",
|
"error": "Invalid file type. Only JPEG, PNG, WebP, JPG and GIF files are allowed.",
|
||||||
"status": False,
|
"status": False,
|
||||||
},
|
},
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
|
|
@ -552,7 +552,7 @@ class ProjectAssetEndpoint(BaseAPIView):
|
||||||
if type not in allowed_types:
|
if type not in allowed_types:
|
||||||
return Response(
|
return Response(
|
||||||
{
|
{
|
||||||
"error": "Invalid file type. Only JPEG and PNG files are allowed.",
|
"error": "Invalid file type. Only JPEG, PNG, WebP, JPG and GIF files are allowed.",
|
||||||
"status": False,
|
"status": False,
|
||||||
},
|
},
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ class EntityAssetEndpoint(BaseAPIView):
|
||||||
if type not in allowed_types:
|
if type not in allowed_types:
|
||||||
return Response(
|
return Response(
|
||||||
{
|
{
|
||||||
"error": "Invalid file type. Only JPEG and PNG files are allowed.",
|
"error": "Invalid file type. Only JPEG, PNG, WebP, JPG and GIF files are allowed.",
|
||||||
"status": False,
|
"status": False,
|
||||||
},
|
},
|
||||||
status=status.HTTP_400_BAD_REQUEST,
|
status=status.HTTP_400_BAD_REQUEST,
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import { useOutsideClickDetector } from "@plane/hooks";
|
||||||
// plane types
|
// plane types
|
||||||
import { EFileAssetType } from "@plane/types/src/enums";
|
import { EFileAssetType } from "@plane/types/src/enums";
|
||||||
// ui
|
// ui
|
||||||
import { Button, Input, Loader } from "@plane/ui";
|
import { Button, Input, Loader, TOAST_TYPE, setToast } from "@plane/ui";
|
||||||
// helpers
|
// helpers
|
||||||
import { getFileURL } from "@/helpers/file.helper";
|
import { getFileURL } from "@/helpers/file.helper";
|
||||||
// hooks
|
// hooks
|
||||||
|
|
@ -114,7 +114,16 @@ export const ImagePickerPopover: React.FC<Props> = observer((props) => {
|
||||||
},
|
},
|
||||||
image
|
image
|
||||||
)
|
)
|
||||||
.then((res) => uploadCallback(res.asset_url));
|
.then((res) => uploadCallback(res.asset_url))
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error uploading user cover image:", error);
|
||||||
|
setIsImageUploading(false);
|
||||||
|
setToast({
|
||||||
|
message: error?.error ?? "The image could not be uploaded",
|
||||||
|
type: TOAST_TYPE.ERROR,
|
||||||
|
title: "Image not uploaded",
|
||||||
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
if (!workspaceSlug) return;
|
if (!workspaceSlug) return;
|
||||||
await fileService
|
await fileService
|
||||||
|
|
@ -126,7 +135,16 @@ export const ImagePickerPopover: React.FC<Props> = observer((props) => {
|
||||||
},
|
},
|
||||||
image
|
image
|
||||||
)
|
)
|
||||||
.then((res) => uploadCallback(res.asset_url));
|
.then((res) => uploadCallback(res.asset_url))
|
||||||
|
.catch((error) => {
|
||||||
|
console.error("Error uploading project cover image:", error);
|
||||||
|
setIsImageUploading(false);
|
||||||
|
setToast({
|
||||||
|
message: error?.error ?? "The image could not be uploaded",
|
||||||
|
type: TOAST_TYPE.ERROR,
|
||||||
|
title: "Image not uploaded",
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue