Skip to content

Commit 07ce677

Browse files
committed
Apply PR review suggestions
1 parent 7e11d46 commit 07ce677

File tree

6 files changed

+32
-33
lines changed

6 files changed

+32
-33
lines changed

site/src/components/Button/Button.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55
import { Slot } from "@radix-ui/react-slot";
66
import { type VariantProps, cva } from "class-variance-authority";
7-
import { type FC, forwardRef } from "react";
7+
import { forwardRef } from "react";
88
import { cn } from "utils/cn";
99

1010
export const buttonVariants = cva(
@@ -62,4 +62,3 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
6262
);
6363
},
6464
);
65-
Button.displayName = "Button";

site/src/index.css

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,14 @@
7171
@apply border-border;
7272
}
7373

74-
/** Related to https://github.com/radix-ui/primitives/issues/3251 */
74+
/*
75+
By default, Radix adds a margin to the `body` element when a dropdown is displayed,
76+
causing some shifting when the dropdown has a full-width size, as is the case with the mobile menu.
77+
To prevent this, we need to apply the styles below.
78+
79+
There’s a related issue on GitHub: Radix UI Primitives Issue #3251
80+
https://github.com/radix-ui/primitives/issues/3251
81+
*/
7582
html body[data-scroll-locked] {
7683
--removed-body-scroll-bar-size: 0 !important;
7784
margin-right: 0 !important;

site/src/modules/dashboard/Navbar/MobileMenu.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ const itemStyles = {
3434
open: "text-content-primary",
3535
};
3636

37+
type MobileMenuPermissions = {
38+
canViewDeployment: boolean;
39+
canViewOrganizations: boolean;
40+
canViewAuditLog: boolean;
41+
canViewHealth: boolean;
42+
};
43+
3744
type MobileMenuProps = MobileMenuPermissions & {
3845
proxyContextValue?: ProxyContextValue;
3946
user?: TypesGen.User;
@@ -43,13 +50,6 @@ type MobileMenuProps = MobileMenuPermissions & {
4350
isDefaultOpen?: boolean; // Useful for storybook
4451
};
4552

46-
type MobileMenuPermissions = {
47-
canViewDeployment: boolean;
48-
canViewOrganizations: boolean;
49-
canViewAuditLog: boolean;
50-
canViewHealth: boolean;
51-
};
52-
5353
export const MobileMenu: FC<MobileMenuProps> = ({
5454
isDefaultOpen,
5555
proxyContextValue,
@@ -136,7 +136,7 @@ const ProxySettingsSub: FC<ProxySettingsSubProps> = ({ proxyContextValue }) => {
136136
}}
137137
>
138138
Workspace proxy settings:
139-
<span className="leading-[0px] flex items-center gap-1">
139+
<span className="leading-none flex items-center gap-1">
140140
<img
141141
className="w-4 h-4"
142142
src={selectedProxy.icon_url}

site/src/modules/dashboard/Navbar/Navbar.test.tsx

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ describe("Navbar", () => {
2323
render(<App />);
2424
const deploymentMenu = await screen.findByText("Admin settings");
2525
await userEvent.click(deploymentMenu);
26-
await waitFor(
27-
() => {
28-
const link = screen.getByText("Audit Logs");
29-
expect(link).toBeDefined();
30-
},
31-
{ timeout: 2000 },
32-
);
26+
await screen.findByText("Audit Logs");
3327
});
3428

3529
it("does not show Audit Log link when not entitled", async () => {
@@ -40,8 +34,7 @@ describe("Navbar", () => {
4034
await userEvent.click(deploymentMenu);
4135
await waitFor(
4236
() => {
43-
const link = screen.queryByText("Audit Logs");
44-
expect(link).toBe(null);
37+
expect(screen.queryByText("Audit Logs")).not.toBeInTheDocument();
4538
},
4639
{ timeout: 2000 },
4740
);
@@ -63,8 +56,7 @@ describe("Navbar", () => {
6356
render(<App />);
6457
await waitFor(
6558
() => {
66-
const link = screen.queryByText("Deployment");
67-
expect(link).toBe(null);
59+
expect(screen.queryByText("Deployment")).not.toBeInTheDocument();
6860
},
6961
{ timeout: 2000 },
7062
);

site/src/modules/dashboard/Navbar/NavbarView.test.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ describe("NavbarView", () => {
3535
canViewAuditLog
3636
/>,
3737
);
38-
const workspacesLink = await screen.findByText("Workspaces");
39-
expect((workspacesLink as HTMLAnchorElement).href).toContain("/workspaces");
38+
const workspacesLink =
39+
await screen.findByText<HTMLAnchorElement>(/workspaces/i);
40+
expect(workspacesLink.href).toContain("/workspaces");
4041
});
4142

4243
it("templates nav link has the correct href", async () => {
@@ -52,8 +53,9 @@ describe("NavbarView", () => {
5253
canViewAuditLog
5354
/>,
5455
);
55-
const templatesLink = await screen.findByText("Templates");
56-
expect((templatesLink as HTMLAnchorElement).href).toContain("/templates");
56+
const templatesLink =
57+
await screen.findByText<HTMLAnchorElement>(/templates/i);
58+
expect(templatesLink.href).toContain("/templates");
5759
});
5860

5961
it("audit nav link has the correct href", async () => {
@@ -71,8 +73,8 @@ describe("NavbarView", () => {
7173
);
7274
const deploymentMenu = await screen.findByText("Admin settings");
7375
await userEvent.click(deploymentMenu);
74-
const auditLink = await screen.findByText("Audit Logs");
75-
expect((auditLink as HTMLAnchorElement).href).toContain("/audit");
76+
const auditLink = await screen.findByText<HTMLAnchorElement>(/audit logs/i);
77+
expect(auditLink.href).toContain("/audit");
7678
});
7779

7880
it("deployment nav link has the correct href", async () => {
@@ -90,9 +92,8 @@ describe("NavbarView", () => {
9092
);
9193
const deploymentMenu = await screen.findByText("Admin settings");
9294
await userEvent.click(deploymentMenu);
93-
const deploymentSettingsLink = await screen.findByText("Deployment");
94-
expect((deploymentSettingsLink as HTMLAnchorElement).href).toContain(
95-
"/deployment/general",
96-
);
95+
const deploymentSettingsLink =
96+
await screen.findByText<HTMLAnchorElement>(/deployment/i);
97+
expect(deploymentSettingsLink.href).toContain("/deployment/general");
9798
});
9899
});

site/src/modules/dashboard/Navbar/proxyUtils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export function sortProxiesByLatency(
44
proxies: Proxies,
55
latencies: ProxyLatencies,
66
) {
7-
return [...proxies].sort((a, b) => {
7+
return proxies.toSorted((a, b) => {
88
const latencyA = latencies?.[a.id]?.latencyMS ?? Number.POSITIVE_INFINITY;
99
const latencyB = latencies?.[b.id]?.latencyMS ?? Number.POSITIVE_INFINITY;
1010
return latencyA - latencyB;

0 commit comments

Comments
 (0)