Skip to content

Commit 6d4716c

Browse files
authored
Remove integrations from public repo and sync changes (#369)
* Change icon size * Remove integrations * Add no cache header * Add analytics event tracking * Add small announcement improvements * Remove peer approval setting * Do not load countries when user has no permission * Add tab query params to settings * Decrease navigation font size * Change order of providers * Increase padding for modals * Show page only when user is fully loaded and found * Remove unused state * Remove integrations page
1 parent 859916b commit 6d4716c

Some content is hidden

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

50 files changed

+174
-4250
lines changed

docker/default.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# simple server configuration to replace nginx's default
21
server {
32
listen 80 default_server;
43
listen [::]:80 default_server;
@@ -7,10 +6,14 @@ server {
76

87
location / {
98
try_files $uri $uri.html $uri/ =404;
9+
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
10+
expires off;
1011
}
1112

1213
error_page 404 /404.html;
1314
location = /404.html {
1415
internal;
16+
add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0";
17+
expires off;
1518
}
1619
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ import InlineLink from "@components/InlineLink";
55
import Paragraph from "@components/Paragraph";
66
import { RestrictedAccess } from "@components/ui/RestrictedAccess";
77
import useFetchApi from "@utils/api";
8-
import { isLocalDev, isNetBirdHosted } from "@utils/netbird";
98
import { ExternalLinkIcon } from "lucide-react";
109
import React from "react";
1110
import ActivityIcon from "@/assets/icons/ActivityIcon";
1211
import { ActivityEvent } from "@/interfaces/ActivityEvent";
1312
import PageContainer from "@/layouts/PageContainer";
1413
import ActivityTable from "@/modules/activity/ActivityTable";
15-
import { EventStreamingCard } from "@/modules/integrations/event-streaming/EventStreamingCard";
1614

1715
export default function Activity() {
1816
const { data: events, isLoading } = useFetchApi<ActivityEvent[]>("/events");
@@ -50,7 +48,6 @@ export default function Activity() {
5048
</Paragraph>
5149
</div>
5250
<RestrictedAccess page={"Activity"}>
53-
{(isLocalDev() || isNetBirdHosted()) && <EventStreamingCard />}
5451
<ActivityTable events={events} isLoading={isLoading} />
5552
</RestrictedAccess>
5653
</PageContainer>

src/app/(dashboard)/integrations/layout.tsx

Lines changed: 0 additions & 8 deletions
This file was deleted.

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

Lines changed: 0 additions & 39 deletions
This file was deleted.

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
LockIcon,
99
ShieldIcon,
1010
} from "lucide-react";
11-
import React, { useState } from "react";
11+
import { useSearchParams } from "next/navigation";
12+
import React, { useEffect, useState } from "react";
1213
import { useLoggedInUser } from "@/contexts/UsersProvider";
1314
import PageContainer from "@/layouts/PageContainer";
1415
import { useAccount } from "@/modules/account/useAccount";
@@ -18,10 +19,18 @@ import GroupsTab from "@/modules/settings/GroupsTab";
1819
import PermissionsTab from "@/modules/settings/PermissionsTab";
1920

2021
export default function NetBirdSettings() {
21-
const [tab, setTab] = useState("authentication");
22+
const queryParams = useSearchParams();
23+
const queryTab = queryParams.get("tab");
24+
const [tab, setTab] = useState(queryTab || "authentication");
2225
const { isOwner } = useLoggedInUser();
2326
const account = useAccount();
2427

28+
useEffect(() => {
29+
if (queryTab) {
30+
setTab(queryTab);
31+
}
32+
}, [queryTab]);
33+
2534
return (
2635
<PageContainer>
2736
<VerticalTabs value={tab} onChange={setTab}>

src/assets/icons/IconProperties.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export type IconProps = {
55
};
66

77
export const defaultIconProps: IconProps = {
8-
size: 16,
8+
size: 15,
99
className:
1010
"dark:fill-nb-gray-400 fill-gray-500 peer-data-[active=true]/icon:dark:fill-white peer-data-[active=true]/icon:fill-gray-900 shrink-0",
1111
autoHeight: false,

src/components/SidebarItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default function SidebarItem({
6060
<li className={"px-4 cursor-pointer"}>
6161
<button
6262
className={classNames(
63-
"rounded-lg text-base w-full ",
63+
"rounded-lg text-[.95rem] w-full ",
6464
"font-normal ",
6565
className,
6666
isChild ? "pl-7 pr-2 py-2 mt-1 mb-0.5" : "py-2 px-3",

src/contexts/AnalyticsProvider.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const AnalyticsContext = React.createContext(
1919
{} as {
2020
initialized: boolean;
2121
trackPageView: () => void;
22+
trackEvent: (category: string, action: string, label: string) => void;
2223
},
2324
);
2425
const config = loadConfig();
@@ -51,8 +52,20 @@ export default function AnalyticsProvider({ children }: Props) {
5152
ReactGA.send({ hitType: "pageview", page: path, title: document.title });
5253
};
5354

55+
const trackEvent = (category: string, action: string, label: string) => {
56+
if (isProduction() && ReactGA.isInitialized) {
57+
ReactGA.event({
58+
category: category,
59+
action: action,
60+
label: label,
61+
});
62+
}
63+
};
64+
5465
return (
55-
<AnalyticsContext.Provider value={{ initialized, trackPageView }}>
66+
<AnalyticsContext.Provider
67+
value={{ initialized, trackPageView, trackEvent }}
68+
>
5669
{children}
5770
</AnalyticsContext.Provider>
5871
);

src/contexts/AnnouncementProvider.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface Announcement extends AnnouncementVariant {
1313
linkText?: string;
1414
isExternal?: boolean;
1515
closeable: boolean;
16+
isCloudOnly: boolean;
1617
}
1718

1819
interface AnnouncementInfo extends Announcement {
@@ -29,6 +30,9 @@ const AnnouncementContext = React.createContext(
2930
bannerHeight: number;
3031
announcements?: AnnouncementInfo[];
3132
closeAnnouncement: (hash: string) => void;
33+
setAnnouncements: React.Dispatch<
34+
React.SetStateAction<AnnouncementInfo[] | undefined>
35+
>;
3236
},
3337
);
3438

@@ -43,6 +47,7 @@ export default function AnnouncementProvider({ children }: Props) {
4347
const { permission } = useLoggedInUser();
4448

4549
useEffect(() => {
50+
if (announcements && announcements.length > 0) return;
4651
if (permission?.dashboard_view === "blocked") return;
4752
const initial = initialAnnouncements.map((announcement) => {
4853
const hash = md5(announcement.text).toString();
@@ -51,12 +56,12 @@ export default function AnnouncementProvider({ children }: Props) {
5156
...announcement,
5257
hash,
5358
isOpen,
54-
};
59+
} as AnnouncementInfo;
5560
});
5661
if (initial.length > 0) {
5762
setAnnouncements(initial);
5863
}
59-
}, [closedAnnouncements]);
64+
}, [closedAnnouncements, announcements]);
6065

6166
const closeAnnouncement = (hash: string) => {
6267
setClosedAnnouncements([...closedAnnouncements, hash]);
@@ -81,7 +86,12 @@ export default function AnnouncementProvider({ children }: Props) {
8186

8287
return (
8388
<AnnouncementContext.Provider
84-
value={{ bannerHeight: height, announcements, closeAnnouncement }}
89+
value={{
90+
bannerHeight: height,
91+
announcements,
92+
closeAnnouncement,
93+
setAnnouncements,
94+
}}
8595
>
8696
{children}
8797
</AnnouncementContext.Provider>

src/contexts/CountryProvider.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ const CountryContext = React.createContext(
1717
);
1818

1919
export default function CountryProvider({ children }: Props) {
20-
const { isUser } = useLoggedInUser();
20+
const { permission } = useLoggedInUser();
2121

2222
const getRegionByPeer = (peer: Peer) => "Unknown";
2323

24-
return isUser ? (
24+
return permission?.dashboard_view != "full" ? (
2525
<CountryContext.Provider
2626
value={{ countries: [], isLoading: false, getRegionByPeer }}
2727
>
@@ -35,7 +35,7 @@ export default function CountryProvider({ children }: Props) {
3535
function CountryProviderContent({ children }: Props) {
3636
const { data: countries, isLoading } = useFetchApi<Country[]>(
3737
"/locations/countries",
38-
false,
38+
true,
3939
false,
4040
);
4141

0 commit comments

Comments
 (0)