Skip to content

Commit

Permalink
feat: add ProjectMemberListEntry
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Slartibartfass2 committed Jan 22, 2025
1 parent 61af41c commit 744c92f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<script lang="ts">
import Button from "$lib/components/primitives/button/button.svelte";
import type { User } from "$lib/model/backend";
import { getNameAsString } from "$lib/utils/common-helper";
import { cn } from "$lib/utils/shadcn-helper";
import Trash from "lucide-svelte/icons/trash";
interface Props {
member: User;
isCurrentUser: boolean;
isInvitationPending: boolean;
isAdminView: boolean;
}
let { member, isCurrentUser, isInvitationPending, isAdminView }: Props = $props();
const role = member.isAdmin ? "Admin" : "Member";
const isRoleReadonly = isCurrentUser || !isAdminView;
</script>

<div class="flex flex-col md:flex-row items-center justify-between px-4 gap-4">
<div class="flex flex-col">
<h3>
{getNameAsString(member)}
{#if isCurrentUser}
<span class="text-gray-400"> - You</span>
{/if}
</h3>
<span class="text-hint text-primary">{member.email}</span>
</div>
<div class="flex flex-row gap-2.5 items-center">
{#if isInvitationPending}
<span class="text-hint">Invitation Pending ...</span>
{/if}
<Button
class={cn(
"w-[7.7rem]",
isRoleReadonly
? "hover:bg-transparent hover:cursor-default"
: "bg-gray-100 border border-gray-300 hover:bg-gray-200",
)}
variant={isRoleReadonly ? "ghost" : "secondary"}
>
<!-- Take maximum space so that text is left aligned -->
<span class="flex w-full">Role: {role}</span>
</Button>
{#if isAdminView}
<Button
class="bg-gray-100 border border-gray-300 hover:bg-gray-200 size-10"
disabled={isCurrentUser}
>
<Trash class=" text-red-500 !size-6" />
</Button>
{/if}
</div>
</div>
2 changes: 1 addition & 1 deletion src/lib/utils/common-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ function doesPaperNeedReview(paper: Paper, numberOfRequiredReviews: number): boo
);
}

export { getNames, isPaperUndecided, doesPaperNeedReview };
export { getNameAsString, getNames, isPaperUndecided, doesPaperNeedReview };

0 comments on commit 744c92f

Please sign in to comment.