Skip to content

Commit 6feb484

Browse files
Merge branch 'main' into fetch-channels-from-hydra
2 parents f9ccc6b + 1043417 commit 6feb484

65 files changed

Lines changed: 3427 additions & 534 deletions

Some content is hidden

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

frontend/package-lock.json

Lines changed: 1127 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"format": "biome format --write ."
1515
},
1616
"dependencies": {
17+
"@ark-ui/react": "^5.37.2",
1718
"@tanstack/react-query": "^5.60.0",
1819
"lucide-preact": "^1.17.0",
1920
"preact": "^10.24.0",

frontend/src/App.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
2-
import { Route, Switch } from "wouter-preact";
2+
import { Redirect, Route, Switch } from "wouter-preact";
33
import { Footer } from "@/components/footer/Footer";
4+
import { Disclaimer } from "@/components/header/Disclaimer";
45
import { HeaderBar } from "@/components/header/HeaderBar";
56
import { Home } from "@/routes/Home";
67
import { UserSettings } from "@/routes/UserSettings";
7-
import { Disclaimer } from "./components/header/Disclaimer";
88

99
const queryClient = new QueryClient({
1010
defaultOptions: {
@@ -23,7 +23,11 @@ export function App() {
2323
<main>
2424
<Switch>
2525
<Route path="/ui-v2/" component={Home} />
26-
<Route path="/ui-v2/user" component={UserSettings} />
26+
<Route path="/ui-v2/user">
27+
<Redirect to="/ui-v2/user/subscriptions" />
28+
</Route>
29+
<Route path="/ui-v2/user/subscriptions" component={UserSettings} />
30+
<Route path="/ui-v2/user/tokens" component={UserSettings} />
2731
<Route>
2832
<p>Page not found</p>
2933
</Route>

frontend/src/api/client.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@
88
* - Throws `ApiError` on non-2xx (TanStack Query marks the query as failed). `ApiError.status` lets consumers discriminate errors (e.g. treat 401 as "not logged in").
99
*
1010
*/
11-
function getCsrfToken(): string | null {
12-
const match = document.cookie.match(/(?:^|;\s*)csrftoken=([^;]*)/);
13-
return match ? decodeURIComponent(match[1]) : null;
14-
}
11+
import { getCsrfToken } from "@/utils/csrf";
1512

1613
const UNSAFE_METHODS = new Set(["POST", "PUT", "PATCH", "DELETE"]);
1714

frontend/src/components/AutoSubscribeToggle.tsx

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

frontend/src/components/footer/Footer.module.css

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,40 @@
1-
import { getConfig } from "@/config";
2-
import styles from "./Footer.module.css";
1+
import { useServerInfo } from "@/hooks/useServerInfo";
32

43
function Revision() {
5-
const { production, revision } = getConfig();
6-
const shortRev = revision.slice(0, 8);
4+
const serverInfo = useServerInfo();
5+
6+
if (serverInfo) {
7+
const { production, revision } = serverInfo;
8+
const shortRev = revision.slice(0, 8);
79

8-
if (production) {
910
return (
10-
<a href={`https://github.com/NixOS/nix-security-tracker/commit/${revision}`}>{shortRev}</a>
11+
<p>
12+
Running revision{" "}
13+
{production ? (
14+
<a href={`https://github.com/NixOS/nix-security-tracker/commit/${revision}`}>
15+
{shortRev}
16+
</a>
17+
) : (
18+
<span>{shortRev} (development)</span>
19+
)}
20+
</p>
1121
);
22+
} else {
23+
return null;
1224
}
13-
14-
return <span>{shortRev} (development)</span>;
1525
}
1626

1727
export function Footer() {
1828
return (
19-
<footer className={styles.footer}>
29+
<footer className="bg-nixos-blue box spacious column gap text-white centered">
2030
<p>
2131
Nixpkgs security tracker is part of{" "}
2232
<a href="https://nixos.org/community/teams/security/">NixOS security infrastructure</a>.
2333
</p>
24-
<p>
25-
<a href="https://github.com/NixOS/nix-security-tracker">Source code</a>, running revision{" "}
34+
<div className="row gap-big">
35+
<a href="https://github.com/NixOS/nix-security-tracker">Source code</a>
2636
<Revision />
27-
</p>
37+
</div>
2838
</footer>
2939
);
3040
}

frontend/src/components/header/AuthStatus.module.css

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,62 @@
1-
import { LogInIcon, LogOutIcon, UserIcon } from "lucide-preact";
2-
import { Link } from "wouter-preact";
1+
import { BellIcon, KeyRoundIcon, LogInIcon, LogOutIcon } from "lucide-preact";
2+
import { useLocation } from "wouter-preact";
3+
import { Avatar } from "@/components/ui/Avatar";
4+
import { Menu } from "@/components/ui/Menu";
5+
import { Skeleton } from "@/components/ui/Skeleton";
36
import { LOGIN_URL, logout, useAuth } from "@/hooks/useAuth";
4-
import styles from "./AuthStatus.module.css";
57

68
export function AuthStatus() {
79
const { user, isAuthenticated, isLoading } = useAuth();
10+
const [, setLocation] = useLocation();
811

912
if (isLoading) {
10-
return <span>Loading...</span>;
13+
return (
14+
<div className="row box compact centered gap-small">
15+
<Skeleton width="6em" height="1em" />
16+
<Skeleton shape="circle" width="2em" height="2em" />
17+
</div>
18+
);
1119
}
1220

1321
if (!isAuthenticated || !user) {
1422
return (
1523
<div className="row gap-small centered">
1624
<LogInIcon />
17-
<a href={LOGIN_URL} className={styles.loginLink}>
18-
Login with GitHub
19-
</a>
25+
<a href={LOGIN_URL}>Login with GitHub</a>
2026
</div>
2127
);
2228
}
2329

2430
return (
25-
<div className="row gap centered">
26-
<Link className="row gap-small centered" href="/ui-v2/user" title={user.username}>
27-
{user.avatar_url ? (
28-
<img src={user.avatar_url} alt="avatar" className={styles.avatar} />
29-
) : (
30-
<UserIcon className={`${styles.avatar} ${styles.placeholder}`} />
31-
)}
32-
</Link>
33-
<button type="button" onClick={logout} className={styles.logoutButton} title="Logout">
34-
<LogOutIcon />
35-
</button>
36-
</div>
31+
<Menu
32+
trigger={
33+
<div className="row box compact centered gap-small">
34+
<div>User settings</div>
35+
<Avatar avatarUrl={user.avatar_url} username={user.username} />
36+
</div>
37+
}
38+
label={user.username}
39+
items={[
40+
{
41+
value: "subscriptions",
42+
label: "Subscriptions",
43+
icon: <BellIcon size="1em" />,
44+
onSelect: () => setLocation("/ui-v2/user/subscriptions"),
45+
},
46+
{
47+
value: "tokens",
48+
label: "API Tokens",
49+
icon: <KeyRoundIcon size="1em" />,
50+
onSelect: () => setLocation("/ui-v2/user/tokens"),
51+
},
52+
{ type: "separator" },
53+
{
54+
value: "logout",
55+
label: "Logout",
56+
icon: <LogOutIcon size="1em" />,
57+
onSelect: logout,
58+
},
59+
]}
60+
/>
3761
);
3862
}

frontend/src/components/header/Disclaimer.module.css

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

0 commit comments

Comments
 (0)