mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-28 06:28:47 +00:00
feat(ui): Improve UI for admins and owners
- Make 3 dots unclickable if there no available actions for an user. - Remove "Add permissions" for admins because they have same permissions as owner
This commit is contained in:
@@ -86,6 +86,21 @@ export const ShowUsers = () => {
|
|||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody>
|
<TableBody>
|
||||||
{data?.map((member) => {
|
{data?.map((member) => {
|
||||||
|
const canEditPermissions = member.role === "member";
|
||||||
|
const canDelete =
|
||||||
|
member.role !== "owner" &&
|
||||||
|
!isCloud &&
|
||||||
|
member.user.id !== session?.user?.id;
|
||||||
|
const canUnlink =
|
||||||
|
member.role !== "owner" &&
|
||||||
|
!(
|
||||||
|
member.role === "admin" &&
|
||||||
|
member.user.id === session?.user?.id
|
||||||
|
);
|
||||||
|
|
||||||
|
const hasAnyAction =
|
||||||
|
canEditPermissions || canDelete || canUnlink;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow key={member.id}>
|
<TableRow key={member.id}>
|
||||||
<TableCell className="w-[100px]">
|
<TableCell className="w-[100px]">
|
||||||
@@ -114,13 +129,16 @@ export const ShowUsers = () => {
|
|||||||
</TableCell>
|
</TableCell>
|
||||||
|
|
||||||
<TableCell className="text-right flex justify-end">
|
<TableCell className="text-right flex justify-end">
|
||||||
|
{hasAnyAction ? (
|
||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>
|
<DropdownMenuTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
className="h-8 w-8 p-0"
|
className="h-8 w-8 p-0"
|
||||||
>
|
>
|
||||||
<span className="sr-only">Open menu</span>
|
<span className="sr-only">
|
||||||
|
Open menu
|
||||||
|
</span>
|
||||||
<MoreHorizontal className="h-4 w-4" />
|
<MoreHorizontal className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
@@ -129,17 +147,13 @@ export const ShowUsers = () => {
|
|||||||
Actions
|
Actions
|
||||||
</DropdownMenuLabel>
|
</DropdownMenuLabel>
|
||||||
|
|
||||||
{member.role !== "owner" && (
|
{canEditPermissions && (
|
||||||
<AddUserPermissions
|
<AddUserPermissions
|
||||||
userId={member.user.id}
|
userId={member.user.id}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{member.role !== "owner" && (
|
{canDelete && (
|
||||||
<>
|
|
||||||
{!isCloud &&
|
|
||||||
member.user.id !==
|
|
||||||
session?.user?.id && (
|
|
||||||
<DialogAction
|
<DialogAction
|
||||||
title="Delete User"
|
title="Delete User"
|
||||||
description="Are you sure you want to delete this user?"
|
description="Are you sure you want to delete this user?"
|
||||||
@@ -164,19 +178,14 @@ export const ShowUsers = () => {
|
|||||||
>
|
>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
className="w-full cursor-pointer text-red-500 hover:!text-red-600"
|
className="w-full cursor-pointer text-red-500 hover:!text-red-600"
|
||||||
onSelect={(e) =>
|
onSelect={(e) => e.preventDefault()}
|
||||||
e.preventDefault()
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
Delete User
|
Delete User
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DialogAction>
|
</DialogAction>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!(
|
{canUnlink && (
|
||||||
member.role === "admin" &&
|
|
||||||
member.user.id === session?.user?.id
|
|
||||||
) && (
|
|
||||||
<DialogAction
|
<DialogAction
|
||||||
title="Unlink User"
|
title="Unlink User"
|
||||||
description="Are you sure you want to unlink this user?"
|
description="Are you sure you want to unlink this user?"
|
||||||
@@ -218,18 +227,26 @@ export const ShowUsers = () => {
|
|||||||
>
|
>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
className="w-full cursor-pointer text-red-500 hover:!text-red-600"
|
className="w-full cursor-pointer text-red-500 hover:!text-red-600"
|
||||||
onSelect={(e) =>
|
onSelect={(e) => e.preventDefault()}
|
||||||
e.preventDefault()
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
Unlink User
|
Unlink User
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
</DialogAction>
|
</DialogAction>
|
||||||
)}
|
)}
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</DropdownMenuContent>
|
</DropdownMenuContent>
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
) : (
|
||||||
|
<Button
|
||||||
|
variant="ghost"
|
||||||
|
className="h-8 w-8 p-0"
|
||||||
|
disabled
|
||||||
|
>
|
||||||
|
<span className="sr-only">
|
||||||
|
No actions available
|
||||||
|
</span>
|
||||||
|
<MoreHorizontal className="h-4 w-4 text-muted-foreground" />
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user