Skip to content

Commit 744c92f

Browse files
feat: add ProjectMemberListEntry
This is a component that displays information about a project member an offers actions to change their role or to remove them from the project
1 parent 61af41c commit 744c92f

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<script lang="ts">
2+
import Button from "$lib/components/primitives/button/button.svelte";
3+
import type { User } from "$lib/model/backend";
4+
import { getNameAsString } from "$lib/utils/common-helper";
5+
import { cn } from "$lib/utils/shadcn-helper";
6+
import Trash from "lucide-svelte/icons/trash";
7+
8+
interface Props {
9+
member: User;
10+
isCurrentUser: boolean;
11+
isInvitationPending: boolean;
12+
isAdminView: boolean;
13+
}
14+
15+
let { member, isCurrentUser, isInvitationPending, isAdminView }: Props = $props();
16+
const role = member.isAdmin ? "Admin" : "Member";
17+
const isRoleReadonly = isCurrentUser || !isAdminView;
18+
</script>
19+
20+
<div class="flex flex-col md:flex-row items-center justify-between px-4 gap-4">
21+
<div class="flex flex-col">
22+
<h3>
23+
{getNameAsString(member)}
24+
{#if isCurrentUser}
25+
<span class="text-gray-400"> - You</span>
26+
{/if}
27+
</h3>
28+
<span class="text-hint text-primary">{member.email}</span>
29+
</div>
30+
<div class="flex flex-row gap-2.5 items-center">
31+
{#if isInvitationPending}
32+
<span class="text-hint">Invitation Pending ...</span>
33+
{/if}
34+
<Button
35+
class={cn(
36+
"w-[7.7rem]",
37+
isRoleReadonly
38+
? "hover:bg-transparent hover:cursor-default"
39+
: "bg-gray-100 border border-gray-300 hover:bg-gray-200",
40+
)}
41+
variant={isRoleReadonly ? "ghost" : "secondary"}
42+
>
43+
<!-- Take maximum space so that text is left aligned -->
44+
<span class="flex w-full">Role: {role}</span>
45+
</Button>
46+
{#if isAdminView}
47+
<Button
48+
class="bg-gray-100 border border-gray-300 hover:bg-gray-200 size-10"
49+
disabled={isCurrentUser}
50+
>
51+
<Trash class=" text-red-500 !size-6" />
52+
</Button>
53+
{/if}
54+
</div>
55+
</div>

src/lib/utils/common-helper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ function doesPaperNeedReview(paper: Paper, numberOfRequiredReviews: number): boo
4343
);
4444
}
4545

46-
export { getNames, isPaperUndecided, doesPaperNeedReview };
46+
export { getNameAsString, getNames, isPaperUndecided, doesPaperNeedReview };

0 commit comments

Comments
 (0)