From b485a2cfb052b262c27703585695ccd7058fdda5 Mon Sep 17 00:00:00 2001 From: Avisek Date: Fri, 15 May 2026 22:07:03 +0530 Subject: [PATCH 1/2] feat: implement row details sheet with integrated view and edit modes for table records --- cmd/server/update.go | 4 +- .../src/components/rows/RowUpsertForm.tsx | 421 ++++++++---------- frontend/src/components/tables/DataView.tsx | 76 ++++ .../src/components/tables/RowDetailsSheet.tsx | 74 +-- frontend/src/hooks/useRows.tsx | 7 + frontend/src/pages/TableRows.tsx | 25 +- internal/router/handler.go | 3 - makefile | 6 + 8 files changed, 317 insertions(+), 299 deletions(-) create mode 100644 frontend/src/components/tables/DataView.tsx diff --git a/cmd/server/update.go b/cmd/server/update.go index fdd5877..cc4cd8f 100644 --- a/cmd/server/update.go +++ b/cmd/server/update.go @@ -12,7 +12,7 @@ import ( func runAutoUpdate(cmd string, currentVersion string, disableAutoUpdate bool) error { if disableAutoUpdate { - logger.Info("Auto-update disabled using DISABLE_AUTO_UPDATE=true") + logger.Info("Auto-update disabled using disable_auto_update: true in config file") return nil } @@ -21,7 +21,7 @@ func runAutoUpdate(cmd string, currentVersion string, disableAutoUpdate bool) er return nil } - logger.Info("Checking for updates...You can disable auto-update by setting DISABLE_AUTO_UPDATE=true") + logger.Info("Checking for updates...You can disable auto-update by setting disable_auto_update: true in config file") repo := selfupdate.ParseSlug("biisal/rowsql") diff --git a/frontend/src/components/rows/RowUpsertForm.tsx b/frontend/src/components/rows/RowUpsertForm.tsx index 7b728d3..45d5f05 100644 --- a/frontend/src/components/rows/RowUpsertForm.tsx +++ b/frontend/src/components/rows/RowUpsertForm.tsx @@ -51,33 +51,22 @@ function buildDefaultCols(cols: ColValue[]): ColField[] { useAutoIncrement: false, })); } -import { - Sheet, - SheetClose, - SheetContent, - SheetDescription, - SheetFooter, - SheetHeader, - SheetTitle, - SheetTrigger, -} from "@/components/ui/sheet"; import { Button } from "@/components/ui/button"; -import { Loader2, Plus, Save } from "lucide-react"; +import { Loader2, Save } from "lucide-react"; import { ScrollArea } from "@/components/ui/scroll-area"; import { useRowContext } from "@/hooks/useRows"; +import { SheetFooter } from "@/components/ui/sheet"; interface RowUpsertFormProps { - children?: React.ReactNode; hash?: string; + goBack: () => void; } -export const RowUpsertForm = ({ hash, children }: RowUpsertFormProps) => { +export const RowUpsertForm = ({ hash, goBack }: RowUpsertFormProps) => { const { page, tableName } = useRowContext(); const navigate = useNavigate(); - const isEdit = !!hash; - const { data, isPending } = useQuery( rowInsertOrUpdateFormOptions({ path: { tableName }, @@ -136,231 +125,207 @@ export const RowUpsertForm = ({ hash, children }: RowUpsertFormProps) => { ); }; return ( - - - {children || ( - - )} - - e.preventDefault()} - className="min-w-[90%] md:min-w-xl flex flex-col p-0" - > - {isPending ? ( -
- -
- ) : ( -
- - - {isEdit ? "Update" : "Insert"} Row - - {isEdit - ? "Update the details of the existing record." - : "Fill in the fields below to add a new record to the table."} - - + <> + {isPending ? ( +
+ +
+ ) : ( + + + {form.formState.errors.cols?.message && ( +
+ {form.formState.errors.cols.message} +
+ )} - {form.formState.errors.cols?.message && ( -
- {form.formState.errors.cols.message} -
- )} + +
+ {fields.length === 0 ? ( +
+ No columns found for this table. +
+ ) : ( + fields.map((field, index) => { + const { columnName, columnType } = field; - -
- {fields.length === 0 ? ( -
- No columns found for this table. -
- ) : ( - fields.map((field, index) => { - const { columnName, columnType } = field; + return ( + { + // eslint-disable-next-line react-hooks/incompatible-library + const useDefault = form.watch( + `cols.${index}.useDefault`, + ); + const useAutoIncrement = form.watch( + `cols.${index}.useAutoIncrement`, + ); + const isDisabled = useDefault || useAutoIncrement; - return ( - { - const useDefault = form.watch( - `cols.${index}.useDefault`, - ); - const useAutoIncrement = form.watch( - `cols.${index}.useAutoIncrement`, - ); - const isDisabled = useDefault || useAutoIncrement; - - return ( - - - {columnName.replace(/_/g, " ")} - - ({columnType.dataType}) + return ( + + + {columnName.replace(/_/g, " ")} + + ({columnType.dataType}) + + {columnType.isUnique && ( + + • Unique - {columnType.isUnique && ( - - • Unique - - )} - - - {columnType.hasDefault && ( - ( - - )} - /> )} + - {columnType.hasAutoIncrement && ( - ( - - )} - /> - )} + {columnType.hasDefault && ( + ( + + )} + /> + )} - {columnType.inputType === "checkbox" ? ( -
- - inputField.onChange(c === true) - } - /> - - Enable {columnName.replace(/_/g, " ")} - -
- ) : columnType.inputType === "textarea" || - columnType.inputType === "json" ? ( -