8000 Move audit page to /deployment/audit with multi-org · coder/coder@2c49c58 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2c49c58

Browse files
committed
Move audit page to /deployment/audit with multi-org
The existing link remains but will redirect to the new URL.
1 parent 6c2336b commit 2c49c58

File tree

6 files changed

+36
-11
lines changed

6 files changed

+36
-11
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
PopoverTrigger,
1111
usePopover,
1212
} from "components/Popover/Popover";
13-
import { USERS_LINK } from "modules/navigation";
13+
import { AUDIT_LINK, USERS_LINK } from "modules/navigation";
1414

1515
interface DeploymentDropdownProps {
1616
canViewDeployment: boolean;
@@ -114,7 +114,7 @@ const DeploymentDropdownContent: FC<DeploymentDropdownProps> = ({
114114
{canViewAllUsers && (
115115
<MenuItem
116116
component={NavLink}
117-
to={USERS_LINK}
117+
to={canViewOrganizations ? `/deployment${USERS_LINK}` : USERS_LINK}
118118
css={styles.menuItem}
119119
onClick={onPopoverClose}
120120
>
@@ -124,7 +124,7 @@ const DeploymentDropdownContent: FC<DeploymentDropdownProps> = ({
124124
{canViewAuditLog && (
125125
<MenuItem
126126
component={NavLink}
127-
to="/audit"
127+
to={canViewOrganizations ? `/deployment${AUDIT_LINK}` : AUDIT_LINK}
128128
css={styles.menuItem}
129129
onClick={onPopoverClose}
130130
>

site/src/modules/navigation.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
* @fileoverview TODO: centralize navigation code here! URL constants, URL formatting, all of it
33
*/
44

5+
export const AUDIT_LINK = "/audit";
6+
57
export const USERS_LINK = `/users?filter=${encodeURIComponent(
68
"status:active",
79
)}`;

site/src/pages/AuditPage/AuditPage.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { FC } from "react";
22
import { Helmet } from "react-helmet-async";
3-
import { useSearchParams } from "react-router-dom";
3+
import { useSearchParams, Navigate, useLocation } from "react-router-dom";
44
import { paginatedAudits } from "api/queries/audits";
55
import { useFilter } from "components/Filter/filter";
66
import { useUserFilterMenu } from "components/Filter/UserFilter";
@@ -19,6 +19,8 @@ import { AuditPageView } from "./AuditPageView";
1919
const AuditPage: FC = () => {
2020
const { audit_log: isAuditLogVisible } = useFeatureVisibility();
2121
const { experiments } = useDashboard();
22+
const location = useLocation();
23+
const isMultiOrg = experiments.includes("multi-organization");
2224

2325
/**
2426
* There is an implicit link between auditsQuery and filter via the
@@ -70,6 +72,13 @@ const AuditPage: FC = () => {
7072
}),
7173
});
7274

75+
// TODO: Once multi-org is stable, we can could place this redirect into the
76+
// router directly, if we still need to maintain it (for users who are
77+
// typing the old URL manually or have it bookmarked).
78+
if (isMultiOrg && location.pathname !== "/deployment/audit") {
79+
return <Navigate to={`/deployment/audit${location.search}`} replace />;
80+
}
81+
7382
return (
7483
<>
7584
<Helmet>
@@ -82,17 +91,15 @@ const AuditPage: FC = () => {
8291
isAuditLogVisible={isAuditLogVisible}
8392
auditsQuery={auditsQuery}
8493
error={auditsQuery.error}
85-
showOrgDetails={experiments.includes("multi-organization")}
94+
showOrgDetails={isMultiOrg}
8695
filterProps={{
8796
filter,
8897
error: auditsQuery.error,
8998
menus: {
9099
user: userMenu,
91100
action: actionMenu,
92101
resourceType: resourceTypeMenu,
93-
organization: experiments.includes("multi-organization")
94-
? organizationsMenu
95-
: undefined,
102+
organization: isMultiOrg ? organizationsMenu : undefined,
96103
},
97104
}}
98105
/>

site/src/pages/AuditPage/AuditPageView.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,20 @@ export const AuditPageView: FC<AuditPageViewProps> = ({
5757
const isEmpty = !isLoading && auditLogs?.length === 0;
5858

5959
return (
60-
<Margins>
61-
<PageHeader>
60+
<Margins
61+
css={{
62+
// When acting as a deployment settings page, there is already padding.
63+
// TODO: When multi-org is stable we should move this to the deployment
64+
// settings dir, use the standard header, and remove these margins.
65+
padding: showOrgDetails ? 0 : undefined,
66+
}}
67+
>
68+
<PageHeader
69+
css={{
70+
// When acting as a deployment settings page, there is already padding.
71+
paddingTop: showOrgDetails ? 0 : undefined,
72+
}}
73+
>
6274
<PageHeaderTitle>
6375
<Stack direction="row" spacing={1} alignItems="center">
6476
<span>{Language.title}</span>

site/src/pages/ManagementSettingsPage/Sidebar.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Sidebar as BaseSidebar } from "components/Sidebar/Sidebar";
99
import { Stack } from "components/Stack/Stack";
1010
import { UserAvatar } from "components/UserAvatar/UserAvatar";
1111
import { type ClassName, useClassName } from "hooks/useClassName";
12-
import { USERS_LINK } from "modules/navigation";
12+
import { AUDIT_LINK, USERS_LINK } from "modules/navigation";
1313
import { useOrganizationSettings } from "./ManagementSettingsLayout";
1414

1515
export const Sidebar: FC = () => {
@@ -81,6 +81,9 @@ const DeploymentSettingsNavigation: FC = () => {
8181
<SidebarNavSubItem href={USERS_LINK.slice(1)}>
8282
Users
8383
</SidebarNavSubItem>
84+
<SidebarNavSubItem href={AUDIT_LINK.slice(1)}>
85+
Auditing
86+
</SidebarNavSubItem>
8487
</Stack>
8588
)}
8689
</div>

site/src/router.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ export const router = createBrowserRouter(
409409
<Route path="workspace-proxies" element={<WorkspaceProxyPage />} />
410410
<Route path="users" element={<UsersPage />} />
411411
<Route path="users/create" element={<CreateUserPage />} />
412+
<Route path="audit" element={<AuditPage />} />
412413
</Route>
413414

414415
<Route path="/settings" element={<UserSettingsLayout />}>

0 commit comments

Comments
 (0)
0