Skip to content

Commit cb619e9

Browse files
committed
Add dimensions check, fix upload
1 parent 44cc6dd commit cb619e9

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/components/Agentic/IncidentTemplate/MCPServerDialog/ToolsStep/index.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import * as s from "./styles";
1919
import type { ToolsStepProps } from "./types";
2020

2121
const MAX_ICON_FILE_SIZE = 1024 * 1024; // in bytes
22+
const MAX_ICON_WIDTH = 500; // in pixels
23+
const MAX_ICON_HEIGHT = 500; // in pixels
2224

2325
export const ToolsStep = ({
2426
onCancel,
@@ -47,8 +49,7 @@ export const ToolsStep = ({
4749
isString(window.digmaApiProxyPrefix)
4850
? window.digmaApiProxyPrefix
4951
: "/api/"
50-
}mcp/icon`,
51-
withCredentials: true,
52+
}/Agentic/mcp/icon`,
5253
onSuccess: (response) => {
5354
setIconId(response.id);
5455
setDropzoneError(undefined);
@@ -111,11 +112,27 @@ export const ToolsStep = ({
111112

112113
if (acceptedFiles.length > 0) {
113114
const file = acceptedFiles[0];
114-
setFileToUpload(file);
115-
const formData = new FormData();
116-
formData.append("icon_image", file);
115+
const image = new Image();
117116

118-
void upload(formData);
117+
image.onload = () => {
118+
if (
119+
image.width > MAX_ICON_WIDTH ||
120+
image.height > MAX_ICON_HEIGHT
121+
) {
122+
setDropzoneError(
123+
`Image dimensions should not exceed ${MAX_ICON_WIDTH}x${MAX_ICON_HEIGHT}px.`
124+
);
125+
return;
126+
}
127+
128+
setFileToUpload(file);
129+
const formData = new FormData();
130+
formData.append("icon_image", file);
131+
132+
void upload(formData);
133+
};
134+
135+
image.src = window.URL.createObjectURL(file);
119136
}
120137
}
121138
}

src/hooks/useFormDataRequest.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export interface UseFormDataRequestOptions<T> {
2020
export const useFormDataRequest = <T = unknown>({
2121
method = "POST",
2222
url,
23-
withCredentials,
2423
onSuccess,
2524
onError
2625
}: UseFormDataRequestOptions<T>): UseFormDataRequestResult => {
@@ -38,7 +37,6 @@ export const useFormDataRequest = <T = unknown>({
3837
const response = await axios.request<T>({
3938
method,
4039
url,
41-
withCredentials,
4240
data: formData,
4341
signal: abortControllerRef.current.signal,
4442
onUploadProgress: (progressEvent: AxiosProgressEvent) => {

0 commit comments

Comments
 (0)