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.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix: allow employees without permissions to download files from MES
Brad Barbin6090385f735d
diff --git a/apps/mes/app/components/JobOperation.tsx b/apps/mes/app/components/JobOperation.tsxindex 04d1d91226..5bbb7eb5ed 100644--- a/apps/mes/app/components/JobOperation.tsx+++ b/apps/mes/app/components/JobOperation.tsx@@ -1446,8 +1446,6 @@ function useOperation(function useFiles(job: Job) {const user = useUser();- const { carbon } = useCarbon();-const getFilePath = useCallback((file: StorageItem) => {const companyId = user.company.id;@@ -1473,34 +1471,15 @@ function useFiles(job: Job) {const downloadFile = useCallback(async (file: StorageItem) => {- const type = getFileType(file.name);- if (type === "PDF") {- const url = path.to.file.previewFile(`private/${getFilePath(file)}`);- window.open(url, "_blank");- } else {- const result = await carbon?.storage- .from("private")- .download(getFilePath(file));-- if (!result || result.error) {- toast.error(result?.error?.message || "Error downloading file");- return;- }-- const a = document.createElement("a");- document.body.appendChild(a);- const url = window.URL.createObjectURL(result.data);- a.href = url;- a.download = file.name;- a.click();-- setTimeout(() => {- window.URL.revokeObjectURL(url);- document.body.removeChild(a);- }, 0);- }+ const url = path.to.file.previewFile(`private/${getFilePath(file)}`);+ const a = document.createElement("a");+ document.body.appendChild(a);+ a.href = url;+ a.download = file.name;+ a.click();+ document.body.removeChild(a);},- [carbon?.storage, getFilePath]+ [getFilePath]);const downloadModel = useCallback(@@ -1510,28 +1489,14 @@ function useFiles(job: Job) {return;}- const result = await carbon?.storage- .from("private")- .download(model.modelPath);-- if (!result || result.error) {- toast.error(result?.error?.message || "Error downloading file");- return;- }-+ const url = path.to.file.previewFile(`private/${model.modelPath}`);const a = document.createElement("a");document.body.appendChild(a);- const url = window.URL.createObjectURL(result.data);a.href = url;a.download = model.modelName;a.click();-- setTimeout(() => {- window.URL.revokeObjectURL(url);- document.body.removeChild(a);- }, 0);+ document.body.removeChild(a);},- // eslint-disable-next-line react-hooks/exhaustive-deps[]);diff --git a/packages/react/src/Badge.tsx b/packages/react/src/Badge.tsxindex 8494a61572..58da391ced 100644--- a/packages/react/src/Badge.tsx+++ b/packages/react/src/Badge.tsx@@ -10,7 +10,7 @@ import { LuX } from "react-icons/lu";import { cn } from "./utils/cn";const badgeVariants = cva(- "inline-flex items-center rounded-md px-2 py-0.5 pb-px min-h-[1.25rem] font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 uppercase font-bold text-[11px] truncate tracking-tight",+ "inline-flex items-center rounded-md px-2 min-h-[1.25rem] font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 uppercase font-bold text-[11px] truncate tracking-tight",{variants: {variant: {