feat(workspace): decouple folder sharing with independent mount points & real-time sync
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 58s
MindSift CI & Docker Release / Build, Test in Container & Push (push) Successful in 58s
This commit is contained in:
1 parent
1776e87029
commit
6c1898d489
5 files changed
+225
-13
No files matched your search
@@ -131,7 +131,8 @@ export const WorkspaceView: React.FC<WorkspaceViewProps> = ({
|
||||
created.sharedWith?.some(
|
||||
(s) => s.userId === currentUser.id || s.targetId === currentUser.id
|
||||
) || false;
|
||||
if (!isOwner && !isShared) {
|
||||
const isFolderShared = Boolean(created.sharedFolderId || created.isSharedFolder);
|
||||
if (!isOwner && !isShared && !isFolderShared) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -146,6 +147,7 @@ export const WorkspaceView: React.FC<WorkspaceViewProps> = ({
|
||||
} else if (msg.event === 'WORKSPACE_FOLDERS_UPDATED') {
|
||||
api.getFolders().then(setFolders).catch(() => {});
|
||||
api.getSharedFolders().then(setSharedFolders).catch(() => {});
|
||||
api.getDocuments().then(setDocs).catch(() => {});
|
||||
}
|
||||
});
|
||||
return unsub;
|
||||
@@ -403,6 +405,24 @@ export const WorkspaceView: React.FC<WorkspaceViewProps> = ({
|
||||
}
|
||||
}, []);
|
||||
|
||||
const handleShareFolderClick = useCallback(
|
||||
async (folderPath: string, existingSf?: SharedFolder) => {
|
||||
if (existingSf) {
|
||||
openFolderShareModal(existingSf);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const clean = folderPath.trim().replace(/^\/+|\/+$/g, '');
|
||||
const sf = await api.createSharedFolder({ name: clean, mountPath: clean });
|
||||
setSharedFolders((prev) => [...prev.filter((f) => f.id !== sf.id), sf]);
|
||||
openFolderShareModal(sf);
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
},
|
||||
[openFolderShareModal]
|
||||
);
|
||||
|
||||
const handleToggleRollupTodo = async (doc: Document, blockId: string, currentChecked: boolean) => {
|
||||
triggerHaptic(10);
|
||||
const updatedBlocks = (doc.blocks || []).map((b) =>
|
||||
@@ -599,8 +619,8 @@ export const WorkspaceView: React.FC<WorkspaceViewProps> = ({
|
||||
|
||||
{/* Scrollable Navigation Tree */}
|
||||
<div className="flex-1 overflow-y-auto p-2 space-y-3">
|
||||
{/* Drop target for moving docs to root */}
|
||||
{draggingDocId && (
|
||||
{/* Drop target for moving docs or folders to root */}
|
||||
{(draggingDocId || draggingFolderPath) && (
|
||||
<div
|
||||
onDragOver={(e) => {
|
||||
e.preventDefault();
|
||||
@@ -727,16 +747,16 @@ export const WorkspaceView: React.FC<WorkspaceViewProps> = ({
|
||||
>
|
||||
<Plus className="w-3 h-3" />
|
||||
</button>
|
||||
{sharedFolderObj && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => openFolderShareModal(sharedFolderObj)}
|
||||
className="p-1 rounded-btn hover:bg-canvas text-accent"
|
||||
title="Ordner teilen und Berechtigungen"
|
||||
>
|
||||
<Users className="w-3 h-3" />
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleShareFolderClick(folderPath, sharedFolderObj)}
|
||||
className={`p-1 rounded-btn hover:bg-canvas ${
|
||||
sharedFolderObj ? 'text-accent' : 'text-faint hover:text-accent'
|
||||
}`}
|
||||
title="Ordner teilen und Berechtigungen"
|
||||
>
|
||||
<Users className="w-3 h-3" />
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => handleDeleteFolder(folderPath)}
|
||||
|
||||
Reference in new issue
Block a user