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.

fix: regressions from documents table upgrade

Brad Barbinbdb3a47d4c0b
diff --git a/apps/carbon/app/components/Search/DebouncedInput/DebouncedInput.tsx b/apps/carbon/app/components/Search/DebouncedInput/DebouncedInput.tsx
index 47b9ef6962..d9932490e6 100644
--- a/apps/carbon/app/components/Search/DebouncedInput/DebouncedInput.tsx
+++ b/apps/carbon/app/components/Search/DebouncedInput/DebouncedInput.tsx
@@ -26,6 +26,7 @@ const DebouncedInput = ({ param, ...props }: DebounceInputProps) => {
<Input
defaultValue={params.get(param) || ""}
onChange={(e) => setQuery(e.target.value)}
+ className="w-[140px]"
{...props}
/>
);
diff --git a/apps/carbon/app/components/Table/components/Columns.tsx b/apps/carbon/app/components/Table/components/Columns.tsx
index 5bcf23d5a7..558a48e7fc 100644
--- a/apps/carbon/app/components/Table/components/Columns.tsx
+++ b/apps/carbon/app/components/Table/components/Columns.tsx
@@ -1,10 +1,13 @@
import {
+ Drawer,
+ DrawerBody,
+ DrawerContent,
+ DrawerDescription,
+ DrawerHeader,
+ DrawerTitle,
+ DrawerTrigger,
HStack,
IconButton,
- Popover,
- PopoverContent,
- PopoverHeader,
- PopoverTrigger,
} from "@carbon/react";
import type { Column, ColumnOrderState } from "@tanstack/react-table";
import { Reorder } from "framer-motion";
@@ -31,24 +34,21 @@ const Columns = <T extends object>({
setColumnOrder,
}: ColumnsProps<T>) => {
return (
- <Popover>
- <PopoverTrigger asChild>
+ <Drawer>
+ <DrawerTrigger asChild>
<IconButton
aria-label="Columns"
title="Columns"
variant="ghost"
icon={<BsLayoutThreeColumns />}
/>
- </PopoverTrigger>
- <PopoverContent className="w-96">
- <PopoverHeader>
- <p className="text-sm">Edit column view</p>
- <p className="text-xs text-muted-foreground">
- Manage and reorder columns
- </p>
- </PopoverHeader>
-
- <div className="max-h-48 overflow-y-auto">
+ </DrawerTrigger>
+ <DrawerContent>
+ <DrawerHeader>
+ <DrawerTitle>Edit column view</DrawerTitle>
+ <DrawerDescription>Manage and reorder columns</DrawerDescription>
+ </DrawerHeader>
+ <DrawerBody>
<Reorder.Group
axis="y"
values={columnOrder}
@@ -56,7 +56,7 @@ const Columns = <T extends object>({
if (withSelectableRows) newOrder.unshift("select");
setColumnOrder(newOrder);
}}
- className="space-y-2"
+ className="w-full space-y-2"
>
{columns.reduce<JSX.Element[]>((acc, column) => {
if (isColumnToggable(column))
@@ -64,9 +64,9 @@ const Columns = <T extends object>({
<Reorder.Item
key={column.id}
value={column.id}
- className="rounded-lg"
+ className="w-full rounded-lg"
>
- <HStack>
+ <HStack className="w-full">
<IconButton
aria-label="Drag handle"
icon={<MdOutlineDragIndicator />}
@@ -105,9 +105,9 @@ const Columns = <T extends object>({
return acc;
}, [])}
</Reorder.Group>
- </div>
- </PopoverContent>
- </Popover>
+ </DrawerBody>
+ </DrawerContent>
+ </Drawer>
);
};
diff --git a/apps/carbon/app/modules/documents/documents.service.ts b/apps/carbon/app/modules/documents/documents.service.ts
index 01e7838c0d..104829ef80 100644
--- a/apps/carbon/app/modules/documents/documents.service.ts
+++ b/apps/carbon/app/modules/documents/documents.service.ts
@@ -143,7 +143,7 @@ export function getDocumentType(
return "Text";
}
- if (["png", "jpg", "jpeg", "gif"].includes(extension)) {
+ if (["png", "jpg", "jpeg", "gif", "avif"].includes(extension)) {
return "Image";
}
@@ -211,11 +211,13 @@ export async function upsertDocument(
.select("*")
.single();
}
+
+ const { extension, ...data } = document;
return client
.from("document")
.update(
sanitize({
- ...document,
+ ...data,
type,
updatedAt: new Date().toISOString(),
})
diff --git a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx
index d6ade1fb22..1578f64023 100644
--- a/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx
+++ b/apps/carbon/app/modules/documents/ui/Documents/DocumentsTable.tsx
@@ -64,8 +64,6 @@ const DocumentsTable = memo(
download,
edit,
favorite,
- isImage,
- isPdf,
label,
setLabel,
} = useDocument();
@@ -170,10 +168,10 @@ const DocumentsTable = memo(
<DocumentIcon type={row.original.type!} />
<Hyperlink onClick={() => download(row.original)}>
{row.original.type &&
- (isImage(row.original.type) || isPdf(row.original.type)) ? (
+ ["Image", "PDF"].includes(row.original.type) ? (
<HoverCard>
<HoverCardTrigger>{row.original.name}</HoverCardTrigger>
- {isPdf(row.original.type) ? (
+ {row.original.type === "PDF" ? (
<HoverCardContent className="w-[425px] h-[550px] overflow-hidden p-0">
<iframe
seamless
@@ -343,8 +341,6 @@ const DocumentsTable = memo(
}, [
download,
extensions,
- isImage,
- isPdf,
labelOptions,
onDeleteLabel,
onFavorite,
diff --git a/apps/carbon/app/routes/x+/documents+/search.$documentId.tsx b/apps/carbon/app/routes/x+/documents+/search.$documentId.tsx
index 64a79c08c8..e3e641df9f 100644
--- a/apps/carbon/app/routes/x+/documents+/search.$documentId.tsx
+++ b/apps/carbon/app/routes/x+/documents+/search.$documentId.tsx
@@ -50,13 +50,13 @@ export async function action({ request }: ActionFunctionArgs) {
return validationError(validation.error);
}
- const { id, type, ...document } = validation.data;
+ const { id, extension, ...document } = validation.data;
if (!id) throw new Error("Could not find documentId");
const updateDocument = await upsertDocument(client, {
id,
...document,
- name: `${document.name}.${type}`,
+ name: `${document.name}.${extension}`,
updatedBy: userId,
});
@@ -87,6 +87,7 @@ export default function EditDocumentRoute() {
name: name ?? "",
description: document.description ?? "",
type: document.type ?? "",
+ extension: document.extension ?? "",
size: document.size ?? 0,
readGroups: document.readGroups ?? [],
writeGroups: document.writeGroups ?? [],