Skip to content

Commit

Permalink
Hide empty collaborators on public projects
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Nov 25, 2024
1 parent 76e262b commit a73f5c4
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 85 deletions.
170 changes: 86 additions & 84 deletions src/lib/components/projects/Collaborators.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -86,94 +86,96 @@
}
</script>

<SidebarGroup name="collaborators">
<SidebarItem slot="title">
<People16 slot="start" />
{$_("projects.collaborators.title")}
</SidebarItem>

<span slot="action">
{#if project.add_remove_access}
<Button
ghost
mode="primary"
size="small"
minW={false}
on:click={() => (show = "invite")}
slot="action"
>
<PlusCircle16 height={14} width={14} />
{$_("projects.collaborators.add")}
</Button>
{/if}
</span>

{#each Object.entries(group(sort(users))) as [key, members]}
{#if members.length}
<header>
<h4>{$_(accessLabels[key])}</h4>
</header>
{/if}
{#each members as user}
{#if isProjectUser || project.edit_access}
<SidebarItem small>
<Avatar user={user.user} slot="start" />
{getUserName(user.user)}
<Flex gap={0} slot="end">
{#if project.add_remove_access && !isMe(user, $me)}
<Tooltip caption={actions.update}>
<Button
ghost
mode="primary"
minW={false}
size="small"
title={actions.update}
on:click={() => {
user_to_update = user;
show = "update";
}}
>
<Pencil16 height={14} width={14} />
</Button>
</Tooltip>
<Tooltip caption={actions.remove}>
<Button
ghost
mode="danger"
minW={false}
size="small"
title={actions.remove}
on:click={() => {
user_to_update = user;
show = "remove";
}}
>
<XCircle16 height={14} width={14} />
</Button>
</Tooltip>
{/if}
</Flex>
</SidebarItem>
{:else}
<SidebarItem small>
<Avatar user={user.user} slot="start" />
{getUserName(user.user)}
</SidebarItem>
{/if}
{/each}
{:else}
<Empty>
{$_("projects.collaborators.empty")}
{#if users.length > 0 || project.add_remove_access}
<SidebarGroup name="collaborators">
<SidebarItem slot="title">
<People16 slot="start" />
{$_("projects.collaborators.title")}
</SidebarItem>

<span slot="action">
{#if project.add_remove_access}
<Action title={actions.invite} on:click={() => (show = "invite")}>
<Button
ghost
mode="primary"
size="small"
minW={false}
on:click={() => (show = "invite")}
slot="action"
>
<PlusCircle16 height={14} width={14} />
{$_("projects.collaborators.add")}
</Action>
</Button>
{/if}
</span>

{#each Object.entries(group(sort(users))) as [key, members]}
{#if members.length}
<header>
<h4>{$_(accessLabels[key])}</h4>
</header>
{/if}
</Empty>
{/each}
</SidebarGroup>
{#each members as user}
{#if isProjectUser || project.edit_access}
<SidebarItem small>
<Avatar user={user.user} slot="start" />
{getUserName(user.user)}
<Flex gap={0} slot="end">
{#if project.add_remove_access && !isMe(user, $me)}
<Tooltip caption={actions.update}>
<Button
ghost
mode="primary"
minW={false}
size="small"
title={actions.update}
on:click={() => {
user_to_update = user;
show = "update";
}}
>
<Pencil16 height={14} width={14} />
</Button>
</Tooltip>
<Tooltip caption={actions.remove}>
<Button
ghost
mode="danger"
minW={false}
size="small"
title={actions.remove}
on:click={() => {
user_to_update = user;
show = "remove";
}}
>
<XCircle16 height={14} width={14} />
</Button>
</Tooltip>
{/if}
</Flex>
</SidebarItem>
{:else}
<SidebarItem small>
<Avatar user={user.user} slot="start" />
{getUserName(user.user)}
</SidebarItem>
{/if}
{/each}
{:else}
<Empty>
{$_("projects.collaborators.empty")}
{#if project.add_remove_access}
<Action title={actions.invite} on:click={() => (show = "invite")}>
{$_("projects.collaborators.add")}
</Action>
{/if}
</Empty>
{/each}
</SidebarGroup>
{/if}

{#if show}
{#if show && project.add_remove_access}
<Portal>
<Modal on:close={hide}>
<h1 slot="title">{actions[show]}</h1>
Expand Down
1 change: 0 additions & 1 deletion src/routes/(app)/projects/[id]-[slug]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import * as projects from "$lib/api/projects";
import * as collaborators from "$lib/api/collaborators";
import { search } from "$lib/api/documents";
import { breadcrumbTrail } from "$lib/utils/navigation";
import { getPinnedAddons } from "$lib/api/addons";

export async function load({ params, url, parent, data, fetch }) {
const id = parseInt(params.id, 10);
Expand Down

0 comments on commit a73f5c4

Please sign in to comment.