Skip to content

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

Show add collaborator box only for spaces

Hakan Shehu6e661894d254
diff --git a/apps/desktop/src/renderer/components/chats/chat-header.tsx b/apps/desktop/src/renderer/components/chats/chat-header.tsx
index 8b7a5355..b3bd90a1 100644
--- a/apps/desktop/src/renderer/components/chats/chat-header.tsx
+++ b/apps/desktop/src/renderer/components/chats/chat-header.tsx
@@ -25,7 +25,7 @@ export const ChatHeader = ({ chat, role }: ChatHeaderProps) => {
</div>
<div className="flex items-center gap-2">
<EntryCollaboratorsPopover
- entryId={chat.id}
+ entry={chat}
entries={[chat]}
role={role}
/>
diff --git a/apps/desktop/src/renderer/components/collaborators/entry-collaborators-popover.tsx b/apps/desktop/src/renderer/components/collaborators/entry-collaborators-popover.tsx
index dfa2753d..0b75cef3 100644
--- a/apps/desktop/src/renderer/components/collaborators/entry-collaborators-popover.tsx
+++ b/apps/desktop/src/renderer/components/collaborators/entry-collaborators-popover.tsx
@@ -9,13 +9,13 @@ import {
} from '@/renderer/components/ui/popover';
interface EntryCollaboratorsPopoverProps {
- entryId: string;
+ entry: Entry;
entries: Entry[];
role: EntryRole;
}
export const EntryCollaboratorsPopover = ({
- entryId,
+ entry,
entries,
role,
}: EntryCollaboratorsPopoverProps) => {
@@ -25,7 +25,7 @@ export const EntryCollaboratorsPopover = ({
<UserRoundPlus className="size-5 cursor-pointer text-muted-foreground hover:text-foreground" />
</PopoverTrigger>
<PopoverContent className="mr-2 max-h-128 w-128 overflow-auto">
- <EntryCollaborators entryId={entryId} entries={entries} role={role} />
+ <EntryCollaborators entry={entry} entries={entries} role={role} />
</PopoverContent>
</Popover>
);
diff --git a/apps/desktop/src/renderer/components/collaborators/entry-collaborators.tsx b/apps/desktop/src/renderer/components/collaborators/entry-collaborators.tsx
index 92e600d4..6309350e 100644
--- a/apps/desktop/src/renderer/components/collaborators/entry-collaborators.tsx
+++ b/apps/desktop/src/renderer/components/collaborators/entry-collaborators.tsx
@@ -12,33 +12,34 @@ import { Separator } from '@/renderer/components/ui/separator';
import { buildEntryCollaborators } from '@/shared/lib/entries';
interface EntryCollaboratorsProps {
- entryId: string;
+ entry: Entry;
entries: Entry[];
role: EntryRole;
}
export const EntryCollaborators = ({
- entryId,
+ entry,
entries,
role,
}: EntryCollaboratorsProps) => {
const collaborators = buildEntryCollaborators(entries);
const directCollaborators = collaborators.filter(
- (collaborator) => collaborator.entryId === entryId
+ (collaborator) => collaborator.entryId === entry.id
);
const directCollaboratorIds = directCollaborators.map(
(collaborator) => collaborator.collaboratorId
);
const isAdmin = hasEntryRole(role, 'admin');
- const ancestors = entries.filter((entry) => entry.id !== entryId);
+ const canAddCollaborator = isAdmin && entry.type === 'space';
+ const ancestors = entries.filter((entry) => entry.id !== entry.id);
return (
<div className="flex flex-col gap-2">
- {isAdmin && (
+ {canAddCollaborator && (
<React.Fragment>
<EntryCollaboratorCreate
- entryId={entryId}
+ entryId={entry.id}
existingCollaborators={directCollaboratorIds}
/>
<Separator />
@@ -67,7 +68,7 @@ export const EntryCollaborators = ({
return (
<EntryCollaborator
key={collaborator.collaboratorId}
- entryId={entryId}
+ entryId={entry.id}
collaboratorId={collaborator.collaboratorId}
role={collaborator.role}
canEdit={canEdit}
@@ -85,7 +86,7 @@ export const EntryCollaborators = ({
</div>
{ancestors.map((node) => {
const inheritCollaborators = collaborators.filter(
- (collaborator) => collaborator.entryId === entryId
+ (collaborator) => collaborator.entryId === node.id
);
if (inheritCollaborators.length === 0) {
@@ -105,7 +106,7 @@ export const EntryCollaborators = ({
return (
<EntryCollaborator
key={collaborator.collaboratorId}
- entryId={entryId}
+ entryId={node.id}
collaboratorId={collaborator.collaboratorId}
role={collaborator.role}
canEdit={canEdit}
diff --git a/apps/desktop/src/renderer/components/spaces/space-settings-dialog.tsx b/apps/desktop/src/renderer/components/spaces/space-settings-dialog.tsx
index e3e95f9b..6764a3f9 100644
--- a/apps/desktop/src/renderer/components/spaces/space-settings-dialog.tsx
+++ b/apps/desktop/src/renderer/components/spaces/space-settings-dialog.tsx
@@ -102,11 +102,7 @@ export const SpaceSettingsDialog = ({
className="focus-visible:ring-0 focus-visible:ring-offset-0"
value="collaborators"
>
- <EntryCollaborators
- entryId={space.id}
- entries={[space]}
- role={role}
- />
+ <EntryCollaborators entry={space} entries={[space]} role={role} />
</TabsContent>
{canDelete && (
<TabsContent