Rename some pending entries to nodes

This commit is contained in:
Hakan Shehu
2025-02-19 19:50:43 +01:00
parent f9a72f49fd
commit f7a1388536
23 changed files with 37 additions and 64 deletions

View File

@@ -19,6 +19,6 @@ export const createNodeInteractionsTable: Migration = {
.execute();
},
down: async (db) => {
await db.schema.dropTable('entry_interactions').execute();
await db.schema.dropTable('node_interactions').execute();
},
};

View File

@@ -148,12 +148,12 @@ export const fetchNode = async (
database:
| Kysely<WorkspaceDatabaseSchema>
| Transaction<WorkspaceDatabaseSchema>,
entryId: string
nodeId: string
): Promise<LocalNode | undefined> => {
const node = await database
.selectFrom('nodes')
.selectAll()
.where('id', '=', entryId)
.where('id', '=', nodeId)
.executeTakeFirst();
return node ? mapNode(node) : undefined;

View File

@@ -28,14 +28,14 @@ export class NodeCollaboratorUpdateMutationHandler
if (result === 'unauthorized') {
throw new MutationError(
MutationErrorCode.NodeCollaboratorUpdateForbidden,
"You don't have permission to update collaborators for this entry."
"You don't have permission to update collaborators for this node."
);
}
if (result !== 'success') {
throw new MutationError(
MutationErrorCode.NodeCollaboratorUpdateFailed,
'Something went wrong while updating collaborators for the entry.'
'Something went wrong while updating collaborators for the node.'
);
}

View File

@@ -106,7 +106,7 @@ export class NodeMarkOpenedMutationHandler
});
if (!createdInteraction || !createdMutation) {
throw new Error('Failed to create entry interaction');
throw new Error('Failed to create node interaction');
}
workspace.mutations.triggerSync();

View File

@@ -107,7 +107,7 @@ export class NodeMarkSeenMutationHandler
});
if (!createdInteraction || !createdMutation) {
throw new Error('Failed to create entry interaction');
throw new Error('Failed to create node interaction');
}
workspace.mutations.triggerSync();

View File

@@ -97,7 +97,7 @@ export class NodeService {
.executeTakeFirst();
if (!createdNode) {
throw new Error('Failed to create entry');
throw new Error('Failed to create node');
}
const createdNodeUpdate = await trx
@@ -156,7 +156,7 @@ export class NodeService {
});
if (!createdNode) {
throw new Error('Failed to create entry');
throw new Error('Failed to create node');
}
this.debug(`Created node ${createdNode.id} with type ${createdNode.type}`);

View File

@@ -17,11 +17,11 @@ import { Spinner } from '@/renderer/components/ui/spinner';
interface DatabaseDeleteDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
entryId: string;
databaseId: string;
}
export const DatabaseDeleteDialog = ({
entryId,
databaseId,
open,
onOpenChange,
}: DatabaseDeleteDialogProps) => {
@@ -50,13 +50,13 @@ export const DatabaseDeleteDialog = ({
mutate({
input: {
type: 'database_delete',
databaseId: entryId,
databaseId,
accountId: workspace.accountId,
workspaceId: workspace.id,
},
onSuccess() {
onOpenChange(false);
layout.close(entryId);
layout.close(databaseId);
},
onError(error) {
toast({

View File

@@ -105,7 +105,7 @@ export const DatabaseSettings = ({ database, role }: DatabaseSettingsProps) => {
</DropdownMenuContent>
</DropdownMenu>
<DatabaseDeleteDialog
entryId={database.id}
databaseId={database.id}
open={showDeleteDialog}
onOpenChange={setShowDeleteModal}
/>

View File

@@ -101,8 +101,6 @@ export const FolderBody = ({ folder }: FolderBodyProps) => {
workspaceId: workspace.id,
filePath,
parentId: folder.id,
entryId: folder.id,
rootId: folder.rootId,
});
if (!mutationResult.success) {

View File

@@ -17,11 +17,11 @@ import { Spinner } from '@/renderer/components/ui/spinner';
interface FolderDeleteDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
entryId: string;
folderId: string;
}
export const FolderDeleteDialog = ({
entryId,
folderId,
open,
onOpenChange,
}: FolderDeleteDialogProps) => {
@@ -50,13 +50,13 @@ export const FolderDeleteDialog = ({
mutate({
input: {
type: 'folder_delete',
folderId: entryId,
folderId: folderId,
accountId: workspace.accountId,
workspaceId: workspace.id,
},
onSuccess() {
onOpenChange(false);
layout.close(entryId);
layout.close(folderId);
},
onError(error) {
toast({

View File

@@ -105,7 +105,7 @@ export const FolderSettings = ({ folder, role }: FolderSettingsProps) => {
</DropdownMenuContent>
</DropdownMenu>
<FolderDeleteDialog
entryId={folder.id}
folderId={folder.id}
open={showDeleteDialog}
onOpenChange={setShowDeleteModal}
/>

View File

@@ -29,7 +29,7 @@ export const ContainerBreadcrumb = ({
// Show ellipsis if we have more than 3 nodes (first + last two)
const showEllipsis = breadcrumb.length > 3;
// Get visible entries: first entry + last two entries
// Get visible entries: first node + last two entries
const visibleItems = showEllipsis
? [breadcrumb[0], ...breadcrumb.slice(-2)]
: breadcrumb;

View File

@@ -17,11 +17,11 @@ import { Spinner } from '@/renderer/components/ui/spinner';
interface RecordDeleteDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
entryId: string;
recordId: string;
}
export const RecordDeleteDialog = ({
entryId,
recordId,
open,
onOpenChange,
}: RecordDeleteDialogProps) => {
@@ -50,13 +50,13 @@ export const RecordDeleteDialog = ({
mutate({
input: {
type: 'record_delete',
recordId: entryId,
recordId: recordId,
accountId: workspace.accountId,
workspaceId: workspace.id,
},
onSuccess() {
onOpenChange(false);
layout.close(entryId);
layout.close(recordId);
},
onError(error) {
toast({

View File

@@ -76,7 +76,7 @@ export const RecordSettings = ({ record, role }: RecordSettingsProps) => {
</DropdownMenuContent>
</DropdownMenu>
<RecordDeleteDialog
entryId={record.id}
recordId={record.id}
open={showDeleteDialog}
onOpenChange={setShowDeleteModal}
/>

View File

@@ -1,12 +0,0 @@
import { createContext, useContext } from 'react';
interface ContainerContext {
entryId: string;
mode: 'main' | 'modal' | 'panel';
}
export const ContainerContext = createContext<ContainerContext>(
{} as ContainerContext
);
export const useContainer = () => useContext(ContainerContext);

View File

@@ -8,7 +8,7 @@ interface FolderContext {
files: LocalFileNode[];
onClick: (event: React.MouseEvent<HTMLElement>, id: string) => void;
onDoubleClick: (event: React.MouseEvent<HTMLElement>, id: string) => void;
onMove: (entryId: string, targetId: string) => void;
onMove: (nodeId: string, targetId: string) => void;
}
export const FolderContext = createContext<FolderContext>({} as FolderContext);

View File

@@ -16,12 +16,12 @@ interface RadarContext {
getChatState: (
accountId: string,
workspaceId: string,
entryId: string
chatId: string
) => ChatReadState;
getChannelState: (
accountId: string,
workspaceId: string,
entryId: string
channelId: string
) => ChannelReadState;
markNodeAsSeen: (
accountId: string,

View File

@@ -32,15 +32,13 @@ export const FileCommand: EditorCommand = {
return;
}
const { accountId, workspaceId, documentId, rootId } = context;
const { accountId, workspaceId, documentId } = context;
const output = await window.colanode.executeMutation({
type: 'file_create',
filePath,
accountId,
workspaceId,
parentId: documentId,
rootId,
entryId: documentId,
});
if (!output.success) {

View File

@@ -50,8 +50,6 @@ export const FileNode = Node.create<FileNodeOptions>({
(async () => {
const fileCreateResult = await window.colanode.executeMutation({
type: 'file_create',
entryId: options.context.documentId,
rootId: options.context.rootId,
filePath: path,
accountId: options.context.accountId,
workspaceId: options.context.workspaceId,

View File

@@ -52,10 +52,10 @@ export const RadarProvider = ({ children }: RadarProviderProps) => {
hasUnseenChanges: false,
};
},
getChatState: (accountId, workspaceId, entryId) => {
getChatState: (accountId, workspaceId, chatId) => {
const workspaceState = radarData[accountId]?.[workspaceId];
if (workspaceState) {
const chatState = workspaceState.nodeStates[entryId];
const chatState = workspaceState.nodeStates[chatId];
if (chatState && chatState.type === 'chat') {
return chatState;
}
@@ -63,15 +63,15 @@ export const RadarProvider = ({ children }: RadarProviderProps) => {
return {
type: 'chat',
chatId: entryId,
chatId: chatId,
unseenMessagesCount: 0,
mentionsCount: 0,
};
},
getChannelState: (accountId, workspaceId, entryId) => {
getChannelState: (accountId, workspaceId, channelId) => {
const workspaceState = radarData[accountId]?.[workspaceId];
if (workspaceState) {
const channelState = workspaceState.nodeStates[entryId];
const channelState = workspaceState.nodeStates[channelId];
if (channelState && channelState.type === 'channel') {
return channelState;
}
@@ -79,7 +79,7 @@ export const RadarProvider = ({ children }: RadarProviderProps) => {
return {
type: 'channel',
channelId: entryId,
channelId: channelId,
unseenMessagesCount: 0,
mentionsCount: 0,
};

View File

@@ -3,8 +3,6 @@ export type FileCreateMutationInput = {
accountId: string;
workspaceId: string;
parentId: string;
entryId: string;
rootId: string;
filePath: string;
};

View File

@@ -18,10 +18,3 @@ export const EditorNodeTypes = {
};
export type SortDirection = 'asc' | 'desc';
export const EntryRoles = {
Admin: 'admin',
Editor: 'editor',
Collaborator: 'collaborator',
Viewer: 'viewer',
};

View File

@@ -6,14 +6,14 @@ export const extractDocumentText = (id: string, content: DocumentContent) => {
};
export const extractBlockTexts = (
entryId: string,
nodeId: string,
blocks: Record<string, Block> | undefined | null
): string | null => {
if (!blocks) {
return null;
}
const result = collectBlockText(entryId, blocks);
const result = collectBlockText(nodeId, blocks);
return result.length > 0 ? result : null;
};