Skip to content

Commit d34ae9b

Browse files
authored
Sync changes with netbird cloud (#407)
* Update axa oidc library and package.json * Update ACL port state to show correct value * Filter user groups by unique groups only * Add peer multiselect, optimize dropdown performance for peer selection, remove 'all' group from some dropdowns, various ui / ux optimizations * Add peer multiselect, optimize dropdown performance for peer selection, remove 'all' group from some dropdowns, various ui / ux optimizations
1 parent 650496f commit d34ae9b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2236
-748
lines changed

package-lock.json

Lines changed: 435 additions & 91 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"cypress:open": "cypress open"
1414
},
1515
"dependencies": {
16-
"@axa-fr/react-oidc": "^5.14.0",
16+
"@axa-fr/react-oidc": "^7.22.18",
1717
"@radix-ui/react-accordion": "^1.1.2",
1818
"@radix-ui/react-checkbox": "^1.0.4",
1919
"@radix-ui/react-collapsible": "^1.0.3",
@@ -22,8 +22,9 @@
2222
"@radix-ui/react-label": "^2.0.2",
2323
"@radix-ui/react-popover": "^1.0.7",
2424
"@radix-ui/react-radio-group": "^1.1.3",
25-
"@radix-ui/react-scroll-area": "^1.0.5",
25+
"@radix-ui/react-scroll-area": "^1.1.0",
2626
"@radix-ui/react-select": "^2.0.0",
27+
"@radix-ui/react-slider": "^1.1.2",
2728
"@radix-ui/react-slot": "^1.0.2",
2829
"@radix-ui/react-switch": "^1.0.3",
2930
"@radix-ui/react-tabs": "^1.0.4",
@@ -37,6 +38,7 @@
3738
"@types/node": "20.10.6",
3839
"@types/react": "^18",
3940
"@types/react-dom": "^18",
41+
"@types/react-window": "^1.8.8",
4042
"autoprefixer": "^10",
4143
"class-variance-authority": "^0.7.0",
4244
"clsx": "^2.0.0",
@@ -67,6 +69,7 @@
6769
"react-jwt": "^1.2.0",
6870
"react-loading-skeleton": "^3.3.1",
6971
"react-responsive": "^9.0.2",
72+
"react-virtuoso": "^4.9.0",
7073
"swr": "^2.2.4",
7174
"tailwind-merge": "^1.14.0",
7275
"tailwindcss-animate": "^1.0.7",

src/app/(dashboard)/peer/page.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ function PeerOverview() {
327327
disabled={isUser}
328328
onChange={setSelectedGroups}
329329
values={selectedGroups}
330+
hideAllGroup={true}
330331
peer={peer}
331332
/>
332333
</FullTooltip>

src/app/(dashboard)/peers/page.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ import Breadcrumbs from "@components/Breadcrumbs";
44
import InlineLink from "@components/InlineLink";
55
import Paragraph from "@components/Paragraph";
66
import SkeletonTable from "@components/skeletons/SkeletonTable";
7-
import useFetchApi from "@utils/api";
7+
import { usePortalElement } from "@hooks/usePortalElement";
88
import { ExternalLinkIcon } from "lucide-react";
9-
import React, { lazy, Suspense, useEffect } from "react";
9+
import React, { lazy, Suspense } from "react";
1010
import PeerIcon from "@/assets/icons/PeerIcon";
11-
import { useGroups } from "@/contexts/GroupsProvider";
11+
import PeersProvider, { usePeers } from "@/contexts/PeersProvider";
1212
import { useLoggedInUser, useUsers } from "@/contexts/UsersProvider";
13-
import { Peer } from "@/interfaces/Peer";
1413
import PageContainer from "@/layouts/PageContainer";
1514
import { SetupModalContent } from "@/modules/setup-netbird-modal/SetupModal";
1615

@@ -21,24 +20,22 @@ export default function Peers() {
2120

2221
return (
2322
<PageContainer>
24-
{permission?.dashboard_view === "blocked" ? (
23+
{permission.dashboard_view === "blocked" ? (
2524
<PeersBlockedView />
2625
) : (
27-
<PeersView />
26+
<PeersProvider>
27+
<PeersView />
28+
</PeersProvider>
2829
)}
2930
</PageContainer>
3031
);
3132
}
3233

3334
function PeersView() {
34-
const { data: peers, isLoading } = useFetchApi<Peer[]>("/peers");
35+
const { peers, isLoading } = usePeers();
3536
const { users } = useUsers();
36-
const { refresh } = useGroups();
37-
38-
useEffect(() => {
39-
refresh();
40-
// eslint-disable-next-line react-hooks/exhaustive-deps
41-
}, []);
37+
const { ref: headingRef, portalTarget } =
38+
usePortalElement<HTMLHeadingElement>();
4239

4340
const peersWithUser = peers?.map((peer) => {
4441
if (!users) return peer;
@@ -58,7 +55,7 @@ function PeersView() {
5855
icon={<PeerIcon size={13} />}
5956
/>
6057
</Breadcrumbs>
61-
<h1>{peers && peers.length > 1 ? `${peers.length} Peers` : "Peers"}</h1>
58+
<h1 ref={headingRef}>Peers</h1>
6259
<Paragraph>
6360
A list of all machines and devices connected to your private network.
6461
Use this view to manage peers.
@@ -76,7 +73,11 @@ function PeersView() {
7673
</Paragraph>
7774
</div>
7875
<Suspense fallback={<SkeletonTable />}>
79-
<PeersTable isLoading={isLoading} peers={peersWithUser} />
76+
<PeersTable
77+
isLoading={isLoading}
78+
peers={peersWithUser}
79+
headingTarget={portalTarget}
80+
/>
8081
</Suspense>
8182
</>
8283
);

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

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ function UserOverview({ user }: Props) {
187187
)}
188188
</div>
189189

190-
<div className={"flex gap-10 w-full mt-8 max-w-6xl"}>
190+
<div className={"flex gap-10 w-full mt-8 max-w-6xl items-start"}>
191191
<UserInformationCard user={user} />
192192
<div className={"flex flex-col gap-8 w-1/2 "}>
193193
{!user.is_service_user && (
@@ -200,6 +200,7 @@ function UserOverview({ user }: Props) {
200200
disabled={isUser}
201201
onChange={setSelectedGroups}
202202
values={selectedGroups}
203+
hideAllGroup={true}
203204
/>
204205
</div>
205206
)}
@@ -214,6 +215,8 @@ function UserOverview({ user }: Props) {
214215
<UserRoleSelector
215216
value={role}
216217
onChange={setRole}
218+
hideOwner={user.is_service_user}
219+
currentUser={user}
217220
disabled={
218221
isLoggedInUser ||
219222
!isOwnerOrAdmin ||
@@ -301,15 +304,18 @@ function UserInformationCard({ user }: { user: User }) {
301304

302305
{!isServiceUser && (
303306
<>
304-
<Card.ListItem
305-
label={
306-
<>
307-
<Ban size={16} />
308-
Block User
309-
</>
310-
}
311-
value={<UserBlockCell user={user} isUserPage={true} />}
312-
/>
307+
{!user.is_current && user.role != Role.Owner && (
308+
<Card.ListItem
309+
label={
310+
<>
311+
<Ban size={16} />
312+
Block User
313+
</>
314+
}
315+
value={<UserBlockCell user={user} isUserPage={true} />}
316+
/>
317+
)}
318+
313319
<Card.ListItem
314320
label={
315321
<>

src/app/globals.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,9 @@ p {
6868

6969
.stepper-bg-variant .step-circle {
7070
@apply !border-[#1d2024];
71+
}
72+
73+
.webkit-scroll{
74+
-webkit-overflow-scrolling: touch;
75+
-webkit-transform: translate3d(0, 0, 0);
7176
}

src/assets/os-icons/FreeBSD.png

3.12 KB
Loading

src/auth/OIDCProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"use client";
22

3-
import { OidcProvider } from "@axa-fr/react-oidc";
43
import {
54
AuthorityConfiguration,
65
OidcConfiguration,
7-
} from "@axa-fr/react-oidc/dist/vanilla/oidc";
6+
OidcProvider,
7+
} from "@axa-fr/react-oidc";
88
import FullScreenLoading from "@components/ui/FullScreenLoading";
99
import { useLocalStorage } from "@hooks/useLocalStorage";
1010
import { useRedirect } from "@hooks/useRedirect";
@@ -30,7 +30,7 @@ const auth0AuthorityConfig: AuthorityConfiguration = {
3030
revocation_endpoint: new URL("oauth/revoke", config.authority).href,
3131
end_session_endpoint: new URL("v2/logout", config.authority).href,
3232
userinfo_endpoint: new URL("userinfo", config.authority).href,
33-
//issuer: new URL("", config.authority).href,
33+
issuer: new URL("", config.authority).href,
3434
};
3535

3636
const onEvent = (configurationName: any, eventName: any, data: any) => {

src/auth/SecureProvider.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,17 @@ export const SecureProvider = ({ children }: Props) => {
1111
const currentPath = usePathname();
1212

1313
useEffect(() => {
14+
let timeout: NodeJS.Timeout | undefined = undefined;
1415
if (!isAuthenticated) {
15-
login(currentPath);
16+
timeout = setTimeout(async () => {
17+
if (!isAuthenticated) {
18+
await login(currentPath);
19+
}
20+
}, 1500);
1621
}
22+
return () => {
23+
clearTimeout(timeout);
24+
};
1725
}, [currentPath, isAuthenticated, login]);
1826

1927
return (
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import * as React from "react";
2+
3+
type Props = {
4+
children: React.ReactNode;
5+
};
6+
7+
export const DropdownInfoText = ({ children }: Props) => {
8+
return (
9+
<div className={"text-center pt-2 mb-6 text-nb-gray-400"}>{children}</div>
10+
);
11+
};

0 commit comments

Comments
 (0)