-
Notifications
You must be signed in to change notification settings - Fork 976
feat: split management settings sidebar into deployment/organization sidebars #15388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
8eae1d2
wip
jaaydenh 212918a
fix
jaaydenh 8b9417a
wip
jaaydenh 8c5458f
revert css
jaaydenh ed22bea
feat: changes for premium page
jaaydenh d65a965
feat: implement Premium page with Tailwind and shadcn button
jaaydenh d7f71ed
chore: updates to button styles
jaaydenh 312eef0
chore: update variant
jaaydenh 18286d7
chore: move CacheProvider to ThemeProvider
jaaydenh 739f95f
chore: update paths for shadcn
jaaydenh c4bf0c1
feat: show premium tab if no premium license
jaaydenh 547914a
fix: fix format
jaaydenh f5f355e
fix: remove fontSize
jaaydenh a1f1b0e
feat: split management settings sidebar into deployment and organizat…
jaaydenh f176dab
fix: fix format
jaaydenh 406e328
fix: update permissions
jaaydenh 7307273
fix: format
jaaydenh ac71d6c
chore: remove unused stories
jaaydenh 73a3c74
chore: indent sidebar subitems
jaaydenh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: split management settings sidebar into deployment and organizat…
…ion settings
- Loading branch information
commit a1f1b0ec68a3c17a7cac71da0e8cf70687c1a8e6
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Loader } from "components/Loader/Loader"; | ||
import { useAuthenticated } from "contexts/auth/RequireAuth"; | ||
import { RequirePermission } from "contexts/auth/RequirePermission"; | ||
import { type FC, Suspense } from "react"; | ||
import { Outlet } from "react-router-dom"; | ||
import { DeploymentSidebar } from "./DeploymentSidebar"; | ||
|
||
const DeploymentSettingsLayout: FC = () => { | ||
const { permissions } = useAuthenticated(); | ||
|
||
// The deployment settings page also contains users, audit logs, and groups | ||
// so this page must be visible if you can see any of these. | ||
const canViewDeploymentSettingsPage = | ||
permissions.viewDeploymentValues || | ||
permissions.viewAllUsers || | ||
permissions.viewAnyAuditLog; | ||
|
||
return ( | ||
<RequirePermission isFeatureVisible={canViewDeploymentSettingsPage}> | ||
<div className="px-10 max-w-screen-2xl"> | ||
<div className="flex flex-row gap-12 py-10"> | ||
<DeploymentSidebar /> | ||
<main css={{ flexGrow: 1 }}> | ||
<Suspense fallback={<Loader />}> | ||
<Outlet /> | ||
</Suspense> | ||
</main> | ||
</div> | ||
</div> | ||
</RequirePermission> | ||
); | ||
}; | ||
|
||
export default DeploymentSettingsLayout; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { useAuthenticated } from "contexts/auth/RequireAuth"; | ||
import type { FC } from "react"; | ||
import { DeploymentSidebarView } from "./DeploymentSidebarView"; | ||
|
||
/** | ||
* A sidebar for deployment settings. | ||
*/ | ||
export const DeploymentSidebar: FC = () => { | ||
const { permissions } = useAuthenticated(); | ||
|
||
return <DeploymentSidebarView permissions={permissions} />; | ||
}; |
69 changes: 69 additions & 0 deletions
69
site/src/modules/management/DeploymentSidebarView.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { MockNoPermissions, MockPermissions } from "testHelpers/entities"; | ||
import { withDashboardProvider } from "testHelpers/storybook"; | ||
import { DeploymentSidebarView } from "./DeploymentSidebarView"; | ||
|
||
const meta: Meta<typeof DeploymentSidebarView> = { | ||
title: "modules/management/SidebarView", | ||
component: DeploymentSidebarView, | ||
decorators: [withDashboardProvider], | ||
parameters: { showOrganizations: true }, | ||
args: { | ||
permissions: MockPermissions, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof DeploymentSidebarView>; | ||
|
||
export const NoCreateOrg: Story = { | ||
args: { | ||
permissions: { | ||
...MockPermissions, | ||
createOrganization: false, | ||
}, | ||
}, | ||
}; | ||
|
||
export const NoViewUsers: Story = { | ||
args: { | ||
permissions: { | ||
...MockPermissions, | ||
viewAllUsers: false, | ||
}, | ||
}, | ||
}; | ||
|
||
export const NoAuditLog: Story = { | ||
args: { | ||
permissions: { | ||
...MockPermissions, | ||
viewAnyAuditLog: false, | ||
}, | ||
}, | ||
}; | ||
|
||
export const NoLicenses: Story = { | ||
args: { | ||
permissions: { | ||
...MockPermissions, | ||
viewAllLicenses: false, | ||
}, | ||
}, | ||
}; | ||
|
||
export const NoDeploymentValues: Story = { | ||
args: { | ||
permissions: { | ||
...MockPermissions, | ||
viewDeploymentValues: false, | ||
editDeploymentValues: false, | ||
}, | ||
}, | ||
}; | ||
|
||
export const NoPermissions: Story = { | ||
args: { | ||
permissions: MockNoPermissions, | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import type { AuthorizationResponse, Organization } from "api/typesGenerated"; | ||
import { FeatureStageBadge } from "components/FeatureStageBadge/FeatureStageBadge"; | ||
import { | ||
Sidebar as BaseSidebar, | ||
SettingsSidebarNavItem as SidebarNavItem, | ||
} from "components/Sidebar/Sidebar"; | ||
import type { Permissions } from "contexts/auth/permissions"; | ||
import { useFeatureVisibility } from "modules/dashboard/useFeatureVisibility"; | ||
import type { FC } from "react"; | ||
|
||
export interface OrganizationWithPermissions extends Organization { | ||
permissions: AuthorizationResponse; | ||
} | ||
|
||
interface DeploymentSidebarProps { | ||
/** Site-wide permissions. */ | ||
permissions: Permissions; | ||
} | ||
|
||
/** | ||
* A combined deployment settings and organization menu. | ||
*/ | ||
export const DeploymentSidebarView: FC<DeploymentSidebarProps> = ({ | ||
permissions, | ||
}) => { | ||
const { multiple_organizations: hasPremiumLicense } = useFeatureVisibility(); | ||
|
||
return ( | ||
<BaseSidebar> | ||
<DeploymentSettingsNavigation | ||
permissions={permissions} | ||
isPremium={hasPremiumLicense} | ||
/> | ||
</BaseSidebar> | ||
); | ||
}; | ||
|
||
interface DeploymentSettingsNavigationProps { | ||
/** Site-wide permissions. */ | ||
permissions: Permissions; | ||
isPremium: boolean; | ||
} | ||
|
||
/** | ||
* Displays navigation for deployment settings. If active, highlight the main | ||
* menu heading. | ||
* | ||
* Menu items are shown based on the permissions. If organizations can be | ||
* viewed, groups are skipped since they will show under each org instead. | ||
*/ | ||
const DeploymentSettingsNavigation: FC<DeploymentSettingsNavigationProps> = ({ | ||
permissions, | ||
isPremium, | ||
}) => { | ||
return ( | ||
<div> | ||
<div className="flex flex-col gap-1"> | ||
{permissions.viewDeploymentValues && ( | ||
<SidebarNavItem href="general">General</SidebarNavItem> | ||
)} | ||
{permissions.viewAllLicenses && ( | ||
<SidebarNavItem href="licenses">Licenses</SidebarNavItem> | ||
)} | ||
{permissions.editDeploymentValues && ( | ||
<SidebarNavItem href="appearance">Appearance</SidebarNavItem> | ||
)} | ||
{permissions.viewDeploymentValues && ( | ||
<SidebarNavItem href="userauth">User Authentication</SidebarNavItem> | ||
)} | ||
{permissions.viewDeploymentValues && ( | ||
<SidebarNavItem href="external-auth"> | ||
External Authentication | ||
</SidebarNavItem> | ||
)} | ||
{/* Not exposing this yet since token exchange is not finished yet. | ||
<SidebarNavItem href="oauth2-provider/ap> | ||
OAuth2 Applications | ||
</SidebarNavItem>*/} | ||
{permissions.viewDeploymentValues && ( | ||
<SidebarNavItem href="network">Network</SidebarNavItem> | ||
)} | ||
{permissions.readWorkspaceProxies && ( | ||
<SidebarNavItem href="workspace-proxies"> | ||
Workspace Proxies | ||
</SidebarNavItem> | ||
)} | ||
{permissions.viewDeploymentValues && ( | ||
<SidebarNavItem href="security">Security</SidebarNavItem> | ||
)} | ||
{permissions.viewDeploymentValues && ( | ||
<SidebarNavItem href="observability">Observability</SidebarNavItem> | ||
)} | ||
{permissions.viewAllUsers && ( | ||
<SidebarNavItem href="users">Users</SidebarNavItem> | ||
)} | ||
{permissions.viewNotificationTemplate && ( | ||
<SidebarNavItem href="notifications"> | ||
<div className="flex flex-row items-center gap-2"> | ||
<span>Notifications</span> | ||
<FeatureStageBadge contentType="beta" size="sm" /> | ||
</div> | ||
</SidebarNavItem> | ||
)} | ||
{!isPremium && <SidebarNavItem href="premium">Premium</SidebarNavItem>} | ||
</div> | ||
</div> | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.