Skip to content

Commit

Permalink
make generated column as uneditable (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
invisal authored Sep 17, 2024
1 parent 06b870a commit e570d68
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/components/gui/table-cell/create-editable-cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,14 @@ export default function createEditableCell<T = unknown>({
state.exitEditMode();
}, [setEditValue, state, value]);

if (editMode && (editor === undefined || editor === "input")) {
const uneditableColumn =
!!header.headerData?.constraint?.generatedExpression;

if (
!uneditableColumn &&
editMode &&
(editor === undefined || editor === "input")
) {
return (
<div
className={cn(
Expand Down
9 changes: 7 additions & 2 deletions src/components/gui/table-cell/generic-cell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ export default function GenericCell({
if (
header.foreignKey?.foreignTableName &&
header.foreignKey.foreignColumns &&
header.foreignKey?.foreignSchemaName
header.foreignKey?.foreignSchemaName &&
value !== undefined
) {
return (
<div className="flex items-center shrink-0 cursor-pointer ml-2">
Expand All @@ -232,7 +233,11 @@ export default function GenericCell({
}

if (value === undefined) {
return <span className={textBaseStyle}>DEFAULT</span>;
return (
<span className={textBaseStyle}>
{header.headerData?.constraint?.generatedExpression ?? "DEFAULT"}
</span>
);
}

if (typeof value === "string") {
Expand Down

0 comments on commit e570d68

Please sign in to comment.