-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6f1fc21
commit 51eef54
Showing
4 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
src/lib/components/composites/project-components/settings/ProjectMemberListEntry.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<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-row items-center justify-between px-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>Invitation Pending ...</span> | ||
{/if} | ||
<Button | ||
class={cn( | ||
"w-[7.6rem]", | ||
isRoleReadonly | ||
? "hover:bg-transparent hover:cursor-default" | ||
: "bg-gray-100 border border-gray-300 hover:bg-gray-200", | ||
)} | ||
variant={isRoleReadonly ? "ghost" : "secondary"}>Role: {role}</Button | ||
> | ||
{#if isAdminView} | ||
<Button | ||
class="bg-gray-100 border border-gray-300 hover:bg-gray-200 p-3" | ||
disabled={isCurrentUser} | ||
> | ||
<Trash class="text-red-500" strokeWidth="3" /> | ||
</Button> | ||
{/if} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { BackendController } from "$lib/controller/backend-controller"; | ||
import type { PageLoad } from "./$types"; | ||
|
||
export const load: PageLoad = ({ params }) => { | ||
const projectId = Number(params.projectId); | ||
const projectController = BackendController.getInstance().project(projectId); | ||
const loadingMembers = projectController.getMembers(); | ||
|
||
// attach noop-catch to handle promise rejection correctly (see https://svelte.dev/docs/kit/load#Streaming-with-promises) | ||
loadingMembers.catch(() => {}); | ||
|
||
return { | ||
loadingMembers, | ||
}; | ||
}; |