Skip to content

Open-source and local-first Slack and Notion alternative that puts you in control of your data

Open record modal on create

Hakan Shehubfac9c3930e8
diff --git a/desktop/src/components/databases/boards/board-view.tsx b/desktop/src/components/databases/boards/board-view.tsx
index bedd9858..a6e5c528 100644
--- a/desktop/src/components/databases/boards/board-view.tsx
+++ b/desktop/src/components/databases/boards/board-view.tsx
@@ -19,8 +19,6 @@ export const BoardView = ({ node }: BoardViewProps) => {
(field) => field.id === node.groupBy,
);
- console.log(node.groupBy, database.fields);
-
if (!groupByField || groupByField.dataType !== 'select') {
return null;
}
diff --git a/desktop/src/components/databases/tables/table-view-name-cell.tsx b/desktop/src/components/databases/tables/table-view-name-cell.tsx
index 68572e2a..01cdeb16 100644
--- a/desktop/src/components/databases/tables/table-view-name-cell.tsx
+++ b/desktop/src/components/databases/tables/table-view-name-cell.tsx
@@ -94,7 +94,7 @@ export const TableViewNameCell = ({ record }: TableViewNameCellProps) => {
{hasName ? (
record.name
) : (
- <span className="text-muted-foreground">Untitled</span>
+ <span className="text-muted-foreground">Unnamed</span>
)}
</div>
<button
diff --git a/desktop/src/components/databases/tables/table-view-record-create-row.tsx b/desktop/src/components/databases/tables/table-view-record-create-row.tsx
index d16e7007..2d43251c 100644
--- a/desktop/src/components/databases/tables/table-view-record-create-row.tsx
+++ b/desktop/src/components/databases/tables/table-view-record-create-row.tsx
@@ -2,8 +2,10 @@ import React from 'react';
import { Icon } from '@/components/ui/icon';
import { useDatabase } from '@/contexts/database';
import { useRecordCreateMutation } from '@/mutations/use-record-create-mutation';
+import { useWorkspace } from '@/contexts/workspace';
export const TableViewRecordCreateRow = () => {
+ const workspace = useWorkspace();
const database = useDatabase();
const { mutate, isPending } = useRecordCreateMutation();
@@ -13,9 +15,16 @@ export const TableViewRecordCreateRow = () => {
disabled={isPending}
className="animate-fade-in flex h-8 w-full cursor-pointer flex-row items-center gap-1 border-b pl-2 text-muted-foreground hover:bg-gray-50"
onClick={() => {
- mutate({
- databaseId: database.id,
- });
+ mutate(
+ {
+ databaseId: database.id,
+ },
+ {
+ onSuccess: (recordId) => {
+ workspace.openModal(recordId);
+ },
+ },
+ );
}}
>
<Icon name="add-line" />
diff --git a/desktop/src/components/records/record-name.tsx b/desktop/src/components/records/record-name.tsx
index 43c60fab..0b4dcc19 100644
--- a/desktop/src/components/records/record-name.tsx
+++ b/desktop/src/components/records/record-name.tsx
@@ -33,6 +33,7 @@ export const RecordName = ({ record }: RecordNameProps) => {
});
}}
className="font-heading border-b border-none pl-1 text-4xl font-bold shadow-none focus-visible:ring-0"
+ placeholder="Unnamed"
/>
);
};
diff --git a/desktop/src/components/ui/smart-text-input.tsx b/desktop/src/components/ui/smart-text-input.tsx
index abec3f2b..4d4a881e 100644
--- a/desktop/src/components/ui/smart-text-input.tsx
+++ b/desktop/src/components/ui/smart-text-input.tsx
@@ -7,10 +7,11 @@ interface SmartTextInputProps {
onChange: (newValue: string) => void;
className?: string;
readOnly?: boolean;
+ placeholder?: string;
}
const SmartTextInput = React.forwardRef<HTMLInputElement, SmartTextInputProps>(
- ({ value, onChange, className, readOnly, ...props }, ref) => {
+ ({ value, onChange, className, readOnly, placeholder, ...props }, ref) => {
const [localValue, setLocalValue] = React.useState(value ?? '');
const initialValue = React.useRef(value ?? '');
@@ -71,6 +72,7 @@ const SmartTextInput = React.forwardRef<HTMLInputElement, SmartTextInputProps>(
onBlur={handleBlur}
onKeyDown={handleKeyDown}
readOnly={readOnly}
+ placeholder={placeholder}
{...props}
/>
);
diff --git a/desktop/src/editor/views/page.tsx b/desktop/src/editor/views/page.tsx
index 47ee8ebc..296e4b84 100644
--- a/desktop/src/editor/views/page.tsx
+++ b/desktop/src/editor/views/page.tsx
@@ -7,7 +7,7 @@ import { useWorkspace } from '@/contexts/workspace';
export const PageNodeView = ({ node }: NodeViewProps) => {
const workspace = useWorkspace();
const id = node.attrs.id;
- const name = node.attrs.name ?? 'Untitled';
+ const name = node.attrs.name ?? 'Unnamed';
const avatar = node.attrs.avatar;
if (!id) {
diff --git a/desktop/src/mutations/use-record-create-mutation.tsx b/desktop/src/mutations/use-record-create-mutation.tsx
index cf64d586..5f6e723a 100644
--- a/desktop/src/mutations/use-record-create-mutation.tsx
+++ b/desktop/src/mutations/use-record-create-mutation.tsx
@@ -26,11 +26,12 @@ export const useRecordCreateMutation = () => {
result.rows && result.rows.length > 0 ? result.rows[0] : null;
const maxIndex = lastChild?.index ? lastChild.index : null;
+ const recordId = NeuronId.generate(NeuronId.Type.Record);
const index = generateNodeIndex(maxIndex, null);
const query = workspace.schema
.insertInto('nodes')
.values({
- id: NeuronId.generate(NeuronId.Type.Record),
+ id: recordId,
type: NodeTypes.Record,
parent_id: input.databaseId,
index,
@@ -42,6 +43,7 @@ export const useRecordCreateMutation = () => {
.compile();
await workspace.mutate(query);
+ return recordId;
},
});
};