Skip to content
This repository was archived by the owner on Jul 8, 2025. It is now read-only.

Commit 16a7213

Browse files
refactor: implement new UIKit options schema (#179)
1 parent 7031047 commit 16a7213

File tree

5 files changed

+88
-73
lines changed

5 files changed

+88
-73
lines changed

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"@radix-ui/react-dialog": "^1.1.4",
2525
"@radix-ui/react-separator": "^1.1.0",
2626
"@radix-ui/react-slot": "^1.1.0",
27-
"@stacklok/ui-kit": "^1.0.0",
27+
"@stacklok/ui-kit": "1.0.1-0",
2828
"@tanstack/react-query": "^5.64.1",
2929
"@types/prismjs": "^1.26.5",
3030
"@types/react-syntax-highlighter": "^15.5.13",

src/components/Header.tsx

Lines changed: 70 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,77 @@
11
import { Link } from "react-router-dom";
22
import { SidebarTrigger } from "./ui/sidebar";
3-
import { HoverPopover } from "./HoverPopover";
4-
import { Separator, ButtonDarkMode, MenuItem } from "@stacklok/ui-kit";
3+
import { DropdownMenu } from "./HoverPopover";
4+
import { Separator, ButtonDarkMode, OptionsSchema } from "@stacklok/ui-kit";
55
import { WorkspacesSelection } from "@/features/workspace/components/workspaces-selection";
66
import { BookOpenText, Download, ShieldCheck } from "lucide-react";
77
import { Continue, Copilot, Discord, Github, Youtube } from "./icons";
88

9+
const CERTIFICATE_MENU_ITEMS: OptionsSchema<"menu">[] = [
10+
{
11+
icon: <ShieldCheck />,
12+
id: "about-certificate-security",
13+
href: "/certificates/security",
14+
textValue: "About certificate security",
15+
},
16+
{
17+
icon: <Download />,
18+
id: "download-certificates",
19+
href: "/certificates",
20+
textValue: "Download certificates",
21+
},
22+
];
23+
24+
const HELP_MENU_ITEMS: OptionsSchema<"menu">[] = [
25+
{
26+
textValue: "Setup",
27+
id: "setup",
28+
items: [
29+
{
30+
icon: <Continue />,
31+
id: "continue-setup",
32+
href: "/help/continue-setup",
33+
textValue: "Set up in Continue",
34+
},
35+
{
36+
icon: <Copilot />,
37+
id: "copilot-setup",
38+
href: "/help/copilot-setup",
39+
textValue: "Set up in Copilot",
40+
},
41+
],
42+
},
43+
{
44+
textValue: "Resources",
45+
id: "resources",
46+
items: [
47+
{
48+
icon: <BookOpenText />,
49+
id: "documentation",
50+
href: "https://docs.codegate.ai/",
51+
textValue: "Documentation",
52+
},
53+
{
54+
icon: <Discord />,
55+
id: "discord",
56+
href: "https://discord.gg/stacklok",
57+
textValue: "Discord",
58+
},
59+
{
60+
icon: <Github />,
61+
id: "github",
62+
href: "https://github.com/stacklok/codegate",
63+
textValue: "GitHub",
64+
},
65+
{
66+
icon: <Youtube />,
67+
id: "youtube",
68+
href: "https://www.youtube.com/@Stacklok",
69+
textValue: "YouTube",
70+
},
71+
],
72+
},
73+
];
74+
975
export function Header({ hasError }: { hasError?: boolean }) {
1076
return (
1177
<header
@@ -31,61 +97,9 @@ export function Header({ hasError }: { hasError?: boolean }) {
3197
<WorkspacesSelection />
3298
</div>
3399
<div className="flex items-center gap-4 mr-16">
34-
<HoverPopover title="Certificates">
35-
<MenuItem href="/certificates/security" icon={<ShieldCheck />}>
36-
About certificate security
37-
</MenuItem>
38-
<MenuItem icon={<Download />} href="/certificates">
39-
Download certificates
40-
</MenuItem>
41-
</HoverPopover>
42-
43-
<HoverPopover title="Help">
44-
<MenuItem href="/help/continue-setup" icon={<Continue />}>
45-
<span>
46-
Set up in <span className="font-bold">Continue</span>
47-
</span>
48-
</MenuItem>
49-
<MenuItem icon={<Copilot />} href="/help/copilot-setup">
50-
<span>
51-
Set up in <span className="font-bold">Copilot</span>
52-
</span>
53-
</MenuItem>
54-
55-
<MenuItem
56-
href="https://docs.codegate.ai/"
57-
target="_blank"
58-
icon={<BookOpenText />}
59-
>
60-
Documentation
61-
</MenuItem>
62-
63-
<Separator />
64-
65-
<MenuItem
66-
href="https://discord.gg/stacklok"
67-
target="_blank"
68-
icon={<Discord />}
69-
>
70-
Discord
71-
</MenuItem>
72-
73-
<MenuItem
74-
href="https://github.com/stacklok/codegate"
75-
target="_blank"
76-
icon={<Github />}
77-
>
78-
GitHub
79-
</MenuItem>
100+
<DropdownMenu title="Certificates" items={CERTIFICATE_MENU_ITEMS} />
80101

81-
<MenuItem
82-
href="https://www.youtube.com/@Stacklok"
83-
target="_blank"
84-
icon={<Youtube />}
85-
>
86-
YouTube
87-
</MenuItem>
88-
</HoverPopover>
102+
<DropdownMenu title="Help" items={HELP_MENU_ITEMS} />
89103

90104
<ButtonDarkMode />
91105
</div>

src/components/HoverPopover.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { Button, DropdownMenu, MenuTrigger, Popover } from "@stacklok/ui-kit";
1+
import {
2+
Button,
3+
Menu,
4+
MenuTrigger,
5+
OptionsSchema,
6+
Popover,
7+
} from "@stacklok/ui-kit";
28
import { OverlayTriggerStateContext } from "react-aria-components";
39
import { ReactNode, useContext } from "react";
410
import { ChevronDown, ChevronUp } from "lucide-react";
@@ -9,12 +15,12 @@ function PopoverIcon() {
915
return isOpen ? <ChevronUp /> : <ChevronDown />;
1016
}
1117

12-
export function HoverPopover({
13-
children,
18+
export function DropdownMenu({
19+
items,
1420
title,
1521
}: {
1622
title: ReactNode;
17-
children: ReactNode;
23+
items: OptionsSchema<"menu">[];
1824
className?: string;
1925
}) {
2026
return (
@@ -24,7 +30,7 @@ export function HoverPopover({
2430
<PopoverIcon />
2531
</Button>
2632
<Popover>
27-
<DropdownMenu>{children}</DropdownMenu>
33+
<Menu items={items} />
2834
</Popover>
2935
</MenuTrigger>
3036
);

src/features/dashboard-codegate-status/components/codegate-status-polling-control.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import { Dispatch, SetStateAction } from "react";
2-
import {
3-
Label,
4-
Select,
5-
SelectButton,
6-
TDropdownItemOrSection,
7-
} from "@stacklok/ui-kit";
2+
import { Label, Select, SelectButton, OptionsSchema } from "@stacklok/ui-kit";
83

94
// NOTE: We don't poll more than once per minute, as the server depends on
105
// Github's public API, which is rate limited to 60reqs per hour.
@@ -14,7 +9,7 @@ export const POLLING_INTERVAl = {
149
"10_MIN": { value: 600_000, name: "10 minutes" },
1510
} as const;
1611

17-
export const INTERVAL_SELECT_ITEMS: TDropdownItemOrSection[] = Object.entries(
12+
export const INTERVAL_SELECT_ITEMS: OptionsSchema<"listbox">[] = Object.entries(
1813
POLLING_INTERVAl,
1914
).map(([key, { name }]) => {
2015
return { textValue: name, id: key };

0 commit comments

Comments
 (0)