-
Notifications
You must be signed in to change notification settings - Fork 929
feat: Add deployment settings to the UI #4138
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
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5d4d7a1
Add base components for the Settings Page
BrunoQuaresma 3cb5edc
WIP OIDC page
kylecarbs c00d1f0
Merge branch 'main' of github.com:coder/coder into bq/settings-page
BrunoQuaresma af7d38b
Imrove layout
BrunoQuaresma 5d71163
Add table
BrunoQuaresma 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
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
246 changes: 246 additions & 0 deletions
246
site/src/components/DeploySettingsLayout/DeploySettingsLayout.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,246 @@ | ||
import Button from "@material-ui/core/Button" | ||
import { makeStyles } from "@material-ui/core/styles" | ||
import LaunchOutlined from "@material-ui/icons/LaunchOutlined" | ||
import VpnKeyOutlined from "@material-ui/icons/VpnKeyOutlined" | ||
import { Margins } from "components/Margins/Margins" | ||
import { Stack } from "components/Stack/Stack" | ||
import React, { ElementType, PropsWithChildren, ReactNode } from "react" | ||
import { NavLink } from "react-router-dom" | ||
import { combineClasses } from "util/combineClasses" | ||
|
||
const Sidebar: React.FC<PropsWithChildren> = ({ children }) => { | ||
const styles = useStyles() | ||
return <nav className={styles.sidebar}>{children}</nav> | ||
} | ||
|
||
const SidebarNavItem: React.FC<PropsWithChildren<{ href: string; icon: ReactNode }>> = ({ | ||
children, | ||
href, | ||
icon, | ||
}) => { | ||
const styles = useStyles() | ||
return ( | ||
<NavLink | ||
to={href} | ||
className={({ isActive }) => | ||
combineClasses([styles.sidebarNavItem, isActive ? styles.sidebarNavItemActive : undefined]) | ||
} | ||
> | ||
<Stack alignItems="center" spacing={1.5} direction="row"> | ||
{icon} | ||
{children} | ||
</Stack> | ||
</NavLink> | ||
) | ||
} | ||
|
||
const SidebarNavItemIcon: React.FC<{ icon: ElementType }> = ({ icon: Icon }) => { | ||
const styles = useStyles() | ||
return <Icon className={styles.sidebarNavItemIcon} /> | ||
} | ||
|
||
const SidebarCaption: React.FC<PropsWithChildren> = ({ children }) => { | ||
const styles = useStyles() | ||
return <span className={styles.sidebarCaption}>{children}</span> | ||
} | ||
|
||
export const SettingsHeader: React.FC<{ | ||
title: string | ||
description: string | JSX.Element | ||
docsHref: string | ||
}> = ({ title, description, docsHref }) => { | ||
const styles = useStyles() | ||
|
||
return ( | ||
<Stack alignItems="baseline" direction="row" justifyContent="space-between"> | ||
<div className={styles.headingGroup}> | ||
<h1 className={styles.title}>{title}</h1> | ||
<span className={styles.description}>{description}</span> | ||
</div> | ||
|
||
<Button | ||
size="small" | ||
startIcon={<LaunchOutlined />} | ||
component="a" | ||
href={docsHref} | ||
target="_blank" | ||
variant="outlined" | ||
> | ||
Read the docs | ||
</Button> | ||
</Stack> | ||
) | ||
} | ||
|
||
export const SettingsBadges: React.FC<{ isEnterprise?: boolean; isEnabled?: boolean }> = ({ | ||
isEnterprise, | ||
isEnabled, | ||
}) => { | ||
const styles = useStyles() | ||
|
||
return ( | ||
<Stack direction="row" alignItems="center" className={styles.badges} spacing={1}> | ||
{isEnabled ? ( | ||
<span className={styles.enabledBadge}>Enabled</span> | ||
) : ( | ||
<span className={styles.disabledBadge}>Enabled</span> | ||
)} | ||
{isEnterprise ? <span className={styles.enterpriseBadge}>Enterprise</span> : null} | ||
</Stack> | ||
) | ||
} | ||
|
||
export const DeploySettingsLayout: React.FC<PropsWithChildren> = ({ children }) => { | ||
const styles = useStyles() | ||
|
||
return ( | ||
<Margins> | ||
<Stack className={styles.wrapper} direction="row" spacing={5}> | ||
<Sidebar> | ||
<SidebarNavItem | ||
href="/settings/deployment/general" | ||
icon={<SidebarNavItemIcon icon={LaunchOutlined} />} | ||
> | ||
Deployment | ||
</SidebarNavItem> | ||
<SidebarCaption>Authentication</SidebarCaption> | ||
<SidebarNavItem | ||
href="/settings/deployment/auth" | ||
icon={<SidebarNavItemIcon icon={VpnKeyOutlined} />} | ||
> | ||
OAuth | ||
</SidebarNavItem> | ||
<SidebarNavItem | ||
href="/settings/deployment/oidc" | ||
icon={<SidebarNavItemIcon icon={VpnKeyOutlined} />} | ||
> | ||
OpenID Connect | ||
</SidebarNavItem> | ||
</Sidebar> | ||
|
||
<main className={styles.content}>{children}</main> | ||
</Stack> | ||
</Margins> | ||
) | ||
} | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
wrapper: { | ||
padding: theme.spacing(6, 0), | ||
}, | ||
|
||
sidebar: { | ||
width: 245, | ||
}, | ||
|
||
sidebarNavItem: { | ||
color: "inherit", | ||
display: "block", | ||
fontSize: 16, | ||
textDecoration: "none", | ||
padding: theme.spacing(1.5, 1.5, 1.5, 3), | ||
borderRadius: theme.shape.borderRadius / 2, | ||
transition: "background-color 0.15s ease-in-out", | ||
marginBottom: 1, | ||
position: "relative", | ||
|
||
"&:hover": { | ||
backgroundColor: theme.palette.action.hover, | ||
}, | ||
}, | ||
|
||
sidebarNavItemActive: { | ||
backgroundColor: theme.palette.action.hover, | ||
|
||
"&:before": { | ||
content: '""', | ||
display: "block", | ||
width: 3, | ||
height: "100%", | ||
position: "absolute", | ||
left: 0, | ||
top: 0, | ||
backgroundColor: theme.palette.secondary.dark, | ||
borderRadius: theme.shape.borderRadius, | ||
}, | ||
}, | ||
|
||
sidebarNavItemIcon: { | ||
width: theme.spacing(2), | ||
height: theme.spacing(2), | ||
}, | ||
|
||
sidebarCaption: { | ||
fontSize: 14, | ||
color: theme.palette.text.secondary, | ||
fontWeight: 600, | ||
margin: theme.spacing(2, 0, 1.5, 3), | ||
display: "block", | ||
}, | ||
|
||
content: { | ||
maxWidth: 800, | ||
width: "100%", | ||
}, | ||
|
||
headingGroup: { | ||
maxWidth: 420, | ||
}, | ||
|
||
title: { | ||
fontSize: 36, | ||
fontWeight: 700, | ||
display: "flex", | ||
alignItems: "center", | ||
lineHeight: "initial", | ||
margin: 0, | ||
marginBottom: theme.spacing(1), | ||
}, | ||
|
||
description: { | ||
fontSize: 14, | ||
color: theme.palette.text.secondary, | ||
lineHeight: "160%", | ||
}, | ||
|
||
badges: { | ||
marginTop: theme.spacing(3), | ||
marginBottom: theme.spacing(3), | ||
}, | ||
|
||
enterpriseBadge: { | ||
fontSize: 10, | ||
fontWeight: 600, | ||
textTransform: "uppercase", | ||
letterSpacing: "0.085em", | ||
backgroundColor: theme.palette.info.dark, | ||
padding: theme.spacing(0.5, 2), | ||
borderRadius: 9999, | ||
border: `1px solid ${theme.palette.info.light}`, | ||
lineHeight: "160%", | ||
}, | ||
|
||
enabledBadge: { | ||
fontSize: 10, | ||
fontWeight: 600, | ||
textTransform: "uppercase", | ||
letterSpacing: "0.085em", | ||
backgroundColor: theme.palette.success.dark, | ||
padding: theme.spacing(0.5, 2), | ||
borderRadius: 9999, | ||
border: `1px solid ${theme.palette.success.light}`, | ||
lineHeight: "160%", | ||
}, | ||
|
||
disabledBadge: { | ||
fontSize: 10, | ||
fontWeight: 600, | ||
textTransform: "uppercase", | ||
letterSpacing: "0.085em", | ||
backgroundColor: theme.palette.background.paper, | ||
padding: theme.spacing(0.5, 2), | ||
borderRadius: 9999, | ||
border: `1px solid ${theme.palette.divider}`, | ||
lineHeight: "160%", | ||
}, | ||
})) |
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,88 @@ | ||
import { makeStyles } from "@material-ui/core/styles" | ||
import Table from "@material-ui/core/Table" | ||
import TableBody from "@material-ui/core/TableBody" | ||
import TableCell from "@material-ui/core/TableCell" | ||
import TableContainer from "@material-ui/core/TableContainer" | ||
import TableHead from "@material-ui/core/TableHead" | ||
import TableRow from "@material-ui/core/TableRow" | ||
import { useActor } from "@xstate/react" | ||
import { | ||
DeploySettingsLayout, | ||
SettingsBadges, | ||
SettingsHeader, | ||
} from "components/DeploySettingsLayout/DeploySettingsLayout" | ||
import React, { useContext, useEffect } from "react" | ||
import { MONOSPACE_FONT_FAMILY } from "theme/constants" | ||
import { XServiceContext } from "../../xServices/StateContext" | ||
|
||
export const OIDCSettingsPage: React.FC = () => { | ||
BrunoQuaresma marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const styles = useStyles() | ||
const xServices = useContext(XServiceContext) | ||
const [authState, authSend] = useActor(xServices.authXService) | ||
useEffect(() => { | ||
authSend({ type: "GET_AUTH_METHODS" }) | ||
}, [authSend]) | ||
|
||
return ( | ||
<DeploySettingsLayout> | ||
<SettingsHeader | ||
title="OpenID Connect" | ||
description="Configure external authentication to sign in to Coder. Use the command-line options in our documentation." | ||
docsHref="https://coder.com/docs/coder-oss/latest/admin/auth#openid-connect-with-google" | ||
/> | ||
<SettingsBadges isEnabled={authState.context.methods?.oidc} /> | ||
<TableContainer> | ||
<Table> | ||
<TableHead> | ||
<TableRow> | ||
<TableCell width="50%">Option</TableCell> | ||
<TableCell width="50%">Value</TableCell> | ||
</TableRow> | ||
</TableHead> | ||
<TableBody> | ||
<TableRow> | ||
<TableCell> | ||
<span className={styles.optionName}>Address</span> | ||
<span className={styles.optionDescription}> | ||
The address to serve the API and dashboard. | ||
</span> | ||
</TableCell> | ||
|
||
<TableCell> | ||
<span className={styles.optionValue}>127.0.0.1:3000</span> | ||
</TableCell> | ||
</TableRow> | ||
<TableRow> | ||
<TableCell> | ||
<span className={styles.optionName}>Access URL</span> | ||
<span className={styles.optionDescription}> | ||
Specifies the external URL to access Coder. | ||
</span> | ||
</TableCell> | ||
|
||
<TableCell> | ||
<span className={styles.optionValue}>https://www.dev.coder.com</span> | ||
</TableCell> | ||
</TableRow> | ||
</TableBody> | ||
</Table> | ||
</TableContainer> | ||
</DeploySettingsLayout> | ||
) | ||
} | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
optionName: { | ||
display: "block", | ||
}, | ||
optionDescription: { | ||
display: "block", | ||
color: theme.palette.text.secondary, | ||
fontSize: 14, | ||
marginTop: theme.spacing(0.5), | ||
}, | ||
optionValue: { | ||
fontSize: 14, | ||
fontFamily: MONOSPACE_FONT_FAMILY, | ||
}, | ||
})) |
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.