From 845b49968ee7e5108ebd6db70d4d10d85a55e917 Mon Sep 17 00:00:00 2001 From: Philipinho <16838612+Philipinho@users.noreply.github.com> Date: Sat, 18 Apr 2026 13:34:33 +0100 Subject: [PATCH] feat(base): replace property type picker with read-only display --- .../base/components/grid/grid-header-cell.tsx | 19 +--- .../components/property/property-menu.tsx | 91 ++++--------------- .../src/features/base/types/base.types.ts | 1 - 3 files changed, 17 insertions(+), 94 deletions(-) diff --git a/apps/client/src/features/base/components/grid/grid-header-cell.tsx b/apps/client/src/features/base/components/grid/grid-header-cell.tsx index 23220423..9d54c80b 100644 --- a/apps/client/src/features/base/components/grid/grid-header-cell.tsx +++ b/apps/client/src/features/base/components/grid/grid-header-cell.tsx @@ -2,8 +2,7 @@ import { memo, useCallback, useRef } from "react"; import { Header, flexRender } from "@tanstack/react-table"; import { useSortable } from "@dnd-kit/sortable"; import { CSS } from "@dnd-kit/utilities"; -import { Loader, Popover, Tooltip } from "@mantine/core"; -import { useTranslation } from "react-i18next"; +import { Popover } from "@mantine/core"; import { useAtom } from "jotai"; import { IBaseRow, IBaseProperty, EditingCell } from "@/features/base/types/base.types"; import { activePropertyMenuAtom, propertyMenuDirtyAtom, editingCellAtom } from "@/features/base/atoms/base-atoms"; @@ -50,14 +49,12 @@ type GridHeaderCellProps = { export const GridHeaderCell = memo(function GridHeaderCell({ header, }: GridHeaderCellProps) { - const { t } = useTranslation(); const property = header.column.columnDef.meta?.property as | IBaseProperty | undefined; const isRowNumber = header.column.id === "__row_number"; const isPinned = header.column.getIsPinned(); const pinOffset = isPinned ? header.column.getStart("left") : undefined; - const isConverting = !!property?.pendingType; const [activePropertyMenu, setActivePropertyMenu] = useAtom(activePropertyMenuAtom) as unknown as [string | null, (val: string | null) => void]; const menuOpened = activePropertyMenu === header.column.id; @@ -141,20 +138,6 @@ export const GridHeaderCell = memo(function GridHeaderCell({ {flexRender(header.column.columnDef.header, header.getContext())} - {isConverting && ( - - - - )} )} {header.column.getCanResize() && ( diff --git a/apps/client/src/features/base/components/property/property-menu.tsx b/apps/client/src/features/base/components/property/property-menu.tsx index 4bcfadcb..0c034848 100644 --- a/apps/client/src/features/base/components/property/property-menu.tsx +++ b/apps/client/src/features/base/components/property/property-menu.tsx @@ -14,20 +14,16 @@ import { IconTrash, IconPencil, IconChevronRight, - IconTransform, IconSettings, } from "@tabler/icons-react"; -import { - IBaseProperty, - BasePropertyType, -} from "@/features/base/types/base.types"; +import { IBaseProperty } from "@/features/base/types/base.types"; import { useAtom } from "jotai"; import { propertyMenuCloseRequestAtom } from "@/features/base/atoms/base-atoms"; import { useUpdatePropertyMutation, useDeletePropertyMutation, } from "@/features/base/queries/base-property-query"; -import { PropertyTypePicker } from "./property-type-picker"; +import { propertyTypes } from "./property-type-picker"; import { PropertyOptions } from "./property-options"; import { useTranslation } from "react-i18next"; import { isSystemPropertyType } from "@/features/base/hooks/use-base-table"; @@ -40,7 +36,7 @@ type PropertyMenuContentProps = { onDirtyChange?: (dirty: boolean) => void; }; -type MenuPanel = "main" | "rename" | "changeType" | "options" | "confirmDelete" | "confirmDiscard"; +type MenuPanel = "main" | "rename" | "options" | "confirmDelete" | "confirmDiscard"; export function PropertyMenuContent({ property, @@ -113,20 +109,6 @@ export function PropertyMenuContent({ [handleRenameAndClose, onClose], ); - const handleTypeChange = useCallback( - (type: BasePropertyType) => { - if (type !== property.type) { - updatePropertyMutation.mutate({ - propertyId: property.id, - baseId: property.baseId, - type, - }); - } - onClose(); - }, - [property, updatePropertyMutation, onClose], - ); - const handleOptionsUpdate = useCallback( (typeOptions: Record) => { updatePropertyMutation.mutate({ @@ -197,7 +179,6 @@ export function PropertyMenuContent({ setPanel("rename")} - onChangeType={() => setPanel("changeType")} onOptions={() => setPanel("options")} onDelete={() => setPanel("confirmDelete")} /> @@ -217,13 +198,6 @@ export function PropertyMenuContent({ /> )} - {panel === "changeType" && ( - setPanel("main")} - /> - )} {(panel === "options" || panel === "confirmDiscard") && ( @@ -343,13 +317,11 @@ function MenuItem({ function MainPanel({ property, onRename, - onChangeType, onOptions, onDelete, }: { property: IBaseProperty; onRename: () => void; - onChangeType: () => void; onOptions: () => void; onDelete: () => void; }) { @@ -365,6 +337,9 @@ function MainPanel({ property.type === "number" || property.type === "date"); + const typeDef = propertyTypes.find((pt) => pt.type === property.type); + const TypeIcon = typeDef?.icon; + return ( {!isSystem && ( - } - label={t("Change type")} - rightIcon={} - onClick={onChangeType} - /> + + {t("Type")} + : null} + readOnly + /> + )} {hasOptions && ( void; - onBack: () => void; -}) { - const { t } = useTranslation(); - - return ( - - - - - - - {t("Change type")} - - - - - - - ); -} diff --git a/apps/client/src/features/base/types/base.types.ts b/apps/client/src/features/base/types/base.types.ts index a31e4578..bed18b0a 100644 --- a/apps/client/src/features/base/types/base.types.ts +++ b/apps/client/src/features/base/types/base.types.ts @@ -217,7 +217,6 @@ export type UpdatePropertyInput = { propertyId: string; baseId: string; name?: string; - type?: BasePropertyType; typeOptions?: TypeOptions; requestId?: string; };