Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

Disabling file upload

Kartik Bajajd702bb30013f
diff --git a/apps/erp/app/routes/share+/scar.$id.tsx b/apps/erp/app/routes/share+/scar.$id.tsx
index 0b360845b7..2553cf98eb 100644
--- a/apps/erp/app/routes/share+/scar.$id.tsx
+++ b/apps/erp/app/routes/share+/scar.$id.tsx
@@ -381,27 +381,6 @@ function useTaskNotes({
const fetcher = useFetcher<typeof action>();
const [content, setContent] = useState(initialContent ?? {});
- const onUploadImage = async (file: File) => {
- // const fileType = file.name.split(".").pop();
- // const fileName = `${companyId}/parts/${nanoid()}.${fileType}`;
-
- // const result = await carbon?.storage.from("private").upload(fileName, file);
-
- // if (result?.error) {
- // toast.error("Failed to upload image");
- // throw new Error(result.error.message);
- // }
-
- // if (!result?.data) {
- // throw new Error("Failed to upload image");
- // }
-
- // return getPrivateUrl(result.data.path);
- return "";
- };
-
- // const table = getTable(type);
-
const onUpdateContent = useDebounce(
async (content: JSONContent) => {
fetcher.submit(
@@ -417,7 +396,6 @@ function useTaskNotes({
content,
setContent,
onUpdateContent,
- onUploadImage,
};
}
@@ -440,7 +418,7 @@ export function TaskItem({
type,
});
const statusAction = statusActions[currentStatus];
- const { content, setContent, onUpdateContent, onUploadImage } = useTaskNotes({
+ const { content, setContent, onUpdateContent } = useTaskNotes({
initialContent: (task.notes ?? {}) as JSONContent,
taskId: task.id!,
type,
@@ -476,7 +454,7 @@ export function TaskItem({
<Editor
className="w-full min-h-[100px]"
initialValue={content}
- onUpload={onUploadImage}
+ disableFileUpload
onChange={(value) => {
setContent(value);
onUpdateContent(value);
diff --git a/packages/react/src/Editor/Editor.tsx b/packages/react/src/Editor/Editor.tsx
index 7cddbc8e21..5ba99be58e 100644
--- a/packages/react/src/Editor/Editor.tsx
+++ b/packages/react/src/Editor/Editor.tsx
@@ -34,6 +34,7 @@ interface EditorProp {
initialValue?: JSONContent;
onChange: (value: JSONContent) => void;
onUpload?: (file: File) => Promise<string>;
+ disableFileUpload?: boolean;
}
const defaultOnUpload = async (file: File) => {
@@ -48,6 +49,7 @@ const Editor = ({
initialValue,
onChange,
onUpload,
+ disableFileUpload,
}: EditorProp) => {
const [openNode, setOpenNode] = useState(false);
const [openColor, setOpenColor] = useState(false);
@@ -58,6 +60,10 @@ const Editor = ({
return createImageUpload({
onUpload: uploadHandler,
validateFn: (file) => {
+ if (disableFileUpload) {
+ toast.error("File upload is not supported for external scars");
+ return false;
+ }
if (!file.type.includes("image/")) {
toast.error(`File type ${file.type} not supported.`);
return false;
@@ -68,7 +74,7 @@ const Editor = ({
return true;
},
});
- }, [onUpload]);
+ }, [onUpload, disableFileUpload]);
const suggestionItems = useMemo(
() => getSuggestionItems(uploadFn),