Skip to content

Commit db07745

Browse files
committed
Update some styles and hide block button
1 parent d278bfa commit db07745

File tree

6 files changed

+113
-68
lines changed

6 files changed

+113
-68
lines changed

src/app/(dashboard)/team/user/page.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,7 @@ function UserInformationCard({ user }: Readonly<{ user: User }>) {
289289
const neverLoggedIn = dayjs(user.last_login).isBefore(
290290
dayjs().subtract(1000, "years"),
291291
);
292+
const isPendingApproval = user?.pending_approval;
292293

293294
return (
294295
<Card>
@@ -328,18 +329,20 @@ function UserInformationCard({ user }: Readonly<{ user: User }>) {
328329

329330
{!isServiceUser && (
330331
<>
331-
{!user.is_current && user.role != Role.Owner && (
332-
<Card.ListItem
333-
tooltip={false}
334-
label={
335-
<>
336-
<Ban size={16} />
337-
Block User
338-
</>
339-
}
340-
value={<UserBlockCell user={user} isUserPage={true} />}
341-
/>
342-
)}
332+
{!user.is_current &&
333+
user.role != Role.Owner &&
334+
!isPendingApproval && (
335+
<Card.ListItem
336+
tooltip={false}
337+
label={
338+
<>
339+
<Ban size={16} />
340+
Block User
341+
</>
342+
}
343+
value={<UserBlockCell user={user} isUserPage={true} />}
344+
/>
345+
)}
343346

344347
<Card.ListItem
345348
label={

src/app/error/page.tsx

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ export default function ErrorPage() {
5151
return null;
5252
}
5353

54-
const isBlockedUser = error?.code === 403 && error?.message?.toLowerCase().includes("blocked");
55-
const isPendingApproval = error?.code === 403 && error?.message?.toLowerCase().includes("pending approval");
54+
const isBlockedUser =
55+
error?.code === 403 && error?.message?.toLowerCase().includes("blocked");
56+
const isPendingApproval =
57+
error?.code === 403 &&
58+
error?.message?.toLowerCase().includes("pending approval");
5659

5760
const getTitle = () => {
5861
if (isBlockedUser) return "User Account Blocked";
@@ -71,21 +74,21 @@ export default function ErrorPage() {
7174
};
7275

7376
return (
74-
<div className="flex items-center justify-center flex-col h-screen max-w-lg mx-auto">
77+
<div className="flex items-center justify-center flex-col h-screen max-w-xl mx-auto">
7578
<div className="bg-nb-gray-930 mb-3 border border-nb-gray-900 h-12 w-12 rounded-md flex items-center justify-center">
7679
<NetBirdIcon size={23} />
7780
</div>
78-
81+
7982
<h1 className="text-center mt-2">{getTitle()}</h1>
8083

8184
<Paragraph className="text-center mt-2 block">
8285
{getDescription()}
8386
</Paragraph>
8487

8588
{error && (
86-
<div className="bg-black border border-nb-gray-800 rounded-md p-4 mt-4 max-w-md font-mono">
87-
<div className="text-center text-sm text-green-400">
88-
<div>response_message: {error.message}</div>
89+
<div className="bg-nb-gray-930 border border-nb-gray-800 rounded-md p-4 mt-4 max-w-md font-mono mb-2">
90+
<div className="text-center text-sm text-netbird">
91+
<div>response_message: {error.message}</div>
8992
</div>
9093
</div>
9194
)}
@@ -96,25 +99,17 @@ export default function ErrorPage() {
9699

97100
<div className="mt-5 space-y-3">
98101
{!isBlockedUser && !isPendingApproval && (
99-
<Button
100-
variant="default-outline"
101-
size="sm"
102-
onClick={handleRetry}
103-
>
102+
<Button variant="default-outline" size="sm" onClick={handleRetry}>
104103
<RefreshCw size={16} className="mr-2" />
105104
Try Again
106105
</Button>
107106
)}
108-
109-
<Button
110-
variant="primary"
111-
size="sm"
112-
onClick={handleLogout}
113-
>
107+
108+
<Button variant="primary" size="sm" onClick={handleLogout}>
114109
{isBlockedUser || isPendingApproval ? "Sign Out" : "Logout"}
115110
<ArrowRightIcon size={16} />
116111
</Button>
117112
</div>
118113
</div>
119114
);
120-
}
115+
}

src/modules/users/table-cells/UserActionCell.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Button from "@components/Button";
22
import { notify } from "@components/Notification";
33
import { useApiCall } from "@utils/api";
44
import { isNetBirdHosted } from "@utils/netbird";
5-
import { CheckCircle, Trash2, XCircle } from "lucide-react";
5+
import { Trash2, XCircle } from "lucide-react";
66
import * as React from "react";
77
import { useMemo } from "react";
88
import { useSWRConfig } from "swr";
@@ -57,15 +57,17 @@ export default function UserActionCell({
5757
confirmText: "Reject",
5858
cancelText: "Cancel",
5959
type: "danger",
60+
maxWidthClass: "max-w-md",
6061
});
6162
if (!choice) return;
62-
63+
6364
notify({
6465
title: `'${name}' rejected`,
6566
description: "User was successfully rejected and removed.",
6667
promise: userRequest.del("", `/${user.id}/reject`).then(() => {
6768
mutate(`/users?service_user=${serviceUser}`);
6869
}),
70+
6971
loadingMessage: "Rejecting the user...",
7072
});
7173
};
@@ -78,6 +80,7 @@ export default function UserActionCell({
7880
"Deleting this user will remove their devices and remove dashboard access. This action cannot be undone.",
7981
confirmText: "Delete",
8082
cancelText: "Cancel",
83+
maxWidthClass: "max-w-md",
8184
type: "danger",
8285
});
8386
if (!choice) return;
@@ -97,30 +100,30 @@ export default function UserActionCell({
97100
{!serviceUser && isNetBirdHosted() && !isPendingApproval && (
98101
<UserResendInviteButton user={user} />
99102
)}
100-
103+
101104
{isPendingApproval && canManageUsers && (
102105
<>
103106
<Button
104107
variant={"secondary"}
105108
size={"xs"}
106-
className={"h-[32px]"}
107109
onClick={approveUser}
108110
data-cy={"approve-user"}
109111
>
110112
Approve
111113
</Button>
112114
<Button
113115
variant={"danger-outline"}
114-
size={"sm"}
116+
size={"xs"}
117+
className={"!px-3"}
115118
onClick={rejectUser}
116119
data-cy={"reject-user"}
117120
>
118-
<XCircle size={16} />
121+
<XCircle size={14} />
119122
Reject
120123
</Button>
121124
</>
122125
)}
123-
126+
124127
{!isPendingApproval && (
125128
<Button
126129
variant={"danger-outline"}

src/modules/users/table-cells/UserBlockCell.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ export default function UserBlockCell({ user, isUserPage = false }: Props) {
6161
});
6262
};
6363

64+
if (user?.pending_approval) return;
65+
6466
return !disabled ? (
6567
<div className={"flex"}>
6668
<ToggleSwitch

src/modules/users/table-cells/UserNameCell.tsx

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@ export default function UserNameCell({ user }: Readonly<Props>) {
1010
const status = user.status;
1111
const isCurrent = user.is_current;
1212

13+
const getStatusIcon = () => {
14+
if (user?.pending_approval) {
15+
return {
16+
color: "bg-netbird text-netbird-950",
17+
icon: <Clock size={12} />,
18+
};
19+
}
20+
if (status === "blocked") {
21+
return { color: "bg-red-500 text-red-100", icon: <Ban size={12} /> };
22+
}
23+
if (status === "invited") {
24+
return {
25+
color: "bg-yellow-400 text-yellow-900",
26+
icon: <Clock size={12} />,
27+
};
28+
}
29+
return { color: "bg-gray-400", icon: <Clock size={12} /> };
30+
};
31+
32+
const { color, icon } = getStatusIcon();
33+
1334
return (
1435
<div
1536
className={cn("flex gap-4 px-2 py-1 items-center")}
@@ -29,12 +50,10 @@ export default function UserNameCell({ user }: Readonly<Props>) {
2950
<div
3051
className={cn(
3152
"w-5 h-5 absolute -right-1 -bottom-1 bg-nb-gray-930 rounded-full flex items-center justify-center border-2 border-nb-gray-950",
32-
status == "invited" && "bg-yellow-400 text-yellow-900",
33-
status == "blocked" && "bg-red-500 text-red-100",
53+
color,
3454
)}
3555
>
36-
{status == "invited" && <Clock size={12} />}
37-
{status == "blocked" && <Ban size={12} />}
56+
{icon}
3857
</div>
3958
)}
4059
</div>
Lines changed: 49 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import FullTooltip from "@components/FullTooltip";
2+
import InlineLink from "@components/InlineLink";
23
import { cn } from "@utils/helpers";
3-
import { HelpCircle } from "lucide-react";
4+
import { ExternalLinkIcon, HelpCircle } from "lucide-react";
45
import React from "react";
56
import { User } from "@/interfaces/User";
67

@@ -14,7 +15,7 @@ export default function UserStatusCell({ user }: Readonly<Props>) {
1415

1516
const getStatusDisplay = () => {
1617
if (isPendingApproval) {
17-
return { text: "Pending Approval", color: "bg-orange-400" };
18+
return { text: "Pending Approval", color: "bg-netbird" };
1819
}
1920
if (status === "blocked") {
2021
return { text: "Blocked", color: "bg-red-500" };
@@ -31,32 +32,54 @@ export default function UserStatusCell({ user }: Readonly<Props>) {
3132
const { text, color } = getStatusDisplay();
3233

3334
return (
34-
<div
35-
className={cn("flex gap-2.5 items-center text-nb-gray-300 text-sm")}
36-
data-cy={"user-status-cell"}
37-
>
38-
<span className={cn("h-2 w-2 rounded-full", color)}></span>
39-
{text}
40-
{isPendingApproval && (
41-
<FullTooltip
42-
content={
43-
<div className={"max-w-xs text-xs"}>
44-
<p>This user requires approval from an administrator.</p>
45-
<p className="mt-2">
46-
To disable user approval requirements for new users, go to the account{" "}
47-
<span className="text-nb-gray-200 inline-flex gap-1 items-center max-h-[22px] font-medium bg-nb-gray-900 py-[3px] text-[11px] px-[5px] border border-nb-gray-800 rounded-[4px]">
48-
Settings
49-
</span>{" "}
50-
and disable "User Approval Required".
51-
</p>
35+
<div onClick={(e) => e.stopPropagation()}>
36+
<FullTooltip
37+
content={
38+
<div className={"max-w-xs text-xs flex flex-col gap-2"}>
39+
<div>
40+
This user needs to be approved by an administrator before it can
41+
join your organization.
5242
</div>
53-
}
54-
interactive={true}
55-
side="right"
43+
44+
<div>
45+
If you want to disable approval for new users, go to{" "}
46+
<InlineLink href={"/settings?tab=authentication"}>
47+
Settings
48+
</InlineLink>{" "}
49+
and disable{" "}
50+
<span className={"font-medium text-white"}>
51+
{"'User Approval Required'"}
52+
</span>
53+
.
54+
</div>
55+
<div>
56+
Learn more about{" "}
57+
<InlineLink
58+
href={
59+
"https://docs.netbird.io/how-to/add-users-to-your-network#user-approval"
60+
}
61+
target={"_blank"}
62+
>
63+
User Approval <ExternalLinkIcon size={12} />
64+
</InlineLink>
65+
</div>
66+
</div>
67+
}
68+
interactive={true}
69+
side="right"
70+
disabled={!isPendingApproval}
71+
>
72+
<div
73+
className={cn("flex gap-2.5 items-center text-nb-gray-300 text-sm")}
74+
data-cy={"user-status-cell"}
5675
>
57-
<HelpCircle size={14} className="text-orange-400 cursor-help" />
58-
</FullTooltip>
59-
)}
76+
<span className={cn("h-2 w-2 rounded-full", color)}></span>
77+
{text}
78+
{isPendingApproval && (
79+
<HelpCircle size={14} className="text-netbird cursor-help" />
80+
)}
81+
</div>
82+
</FullTooltip>
6083
</div>
6184
);
6285
}

0 commit comments

Comments
 (0)