Skip to content

feat: Redesign workspaces page #1450

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 24 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"typegen": "xstate typegen 'src/**/*.ts'"
},
"dependencies": {
"@fontsource/fira-code": "4.5.9",
"@fontsource/ibm-plex-mono": "^4.5.9",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Can you pin this dependency to 4.5.9? You run the upgrade command to do it:

cd site
yarn upgrade @fontsource/ibm-plex-mono@4.5.9

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vapurrmaid I notice we have yarn.lock - what's the thought process behind pinning dependencies?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll answer those two questions separately:

  • Why do we want them pinned

vs

  • Why pin in package.json

For the former: We have a RFC and guide covering, but the TL:DR is more incremental upgrades w depend-a-bot
For the latter: I don't know if having them unpinned interferes with depend-a-bot or any other tool, but simply for precision. I shouldn't have to hunt down the actual version in yarn.lock to answer what version of X we're on.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will look at the guide!

"@fontsource/inter": "4.5.7",
"@material-ui/core": "4.9.4",
"@material-ui/icons": "4.5.1",
Expand Down
9 changes: 9 additions & 0 deletions site/src/AppRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { TemplatesPage } from "./pages/TemplatesPages/TemplatesPage"
import { CreateUserPage } from "./pages/UsersPage/CreateUserPage/CreateUserPage"
import { UsersPage } from "./pages/UsersPage/UsersPage"
import { WorkspacePage } from "./pages/WorkspacePage/WorkspacePage"
import { WorkspacesPage } from "./pages/WorkspacesPage/WorkspacesPage"

const TerminalPage = React.lazy(() => import("./pages/TerminalPage/TerminalPage"))

Expand Down Expand Up @@ -75,6 +76,14 @@ export const AppRouter: React.FC = () => (
</Route>

<Route path="workspaces">
<Route
index
element={
<AuthAndFrame>
<WorkspacesPage />
</AuthAndFrame>
}
/>
<Route
path=":workspace"
element={
Expand Down
5 changes: 5 additions & 0 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ export const getWorkspace = async (workspaceId: string): Promise<TypesGen.Worksp
return response.data
}

export const getWorkspaces = async (userID = "me"): Promise<TypesGen.Workspace[]> => {
const response = await axios.get<TypesGen.Workspace[]>(`/api/v2/users/${userID}/workspaces`)
return response.data
}

export const getWorkspaceByOwnerAndName = async (
organizationID: string,
username = "me",
Expand Down
4 changes: 2 additions & 2 deletions site/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BrowserRouter as Router } from "react-router-dom"
import { SWRConfig } from "swr"
import { AppRouter } from "./AppRouter"
import { GlobalSnackbar } from "./components/GlobalSnackbar/GlobalSnackbar"
import { light } from "./theme"
import { dark } from "./theme"
import "./theme/globalFonts"
import { XServiceProvider } from "./xServices/StateContext"

Expand All @@ -31,7 +31,7 @@ export const App: React.FC = () => {
}}
>
<XServiceProvider>
<ThemeProvider theme={light}>
<ThemeProvider theme={dark}>
<CssBaseline />
<AppRouter />
<GlobalSnackbar />
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/AdminDropdown/AdminDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const AdminDropdown: React.FC = () => {
<>
<div className={styles.link}>
<ListItem selected={Boolean(anchorEl)} button onClick={onOpenAdminMenu}>
<ListItemText className="no-brace" color="primary" primary={Language.menuTitle} />
<ListItemText className="no-brace" primary={Language.menuTitle} />
{anchorEl ? <CloseDropdown /> : <OpenDropdown />}
</ListItem>
</div>
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/CodeBlock/CodeBlock.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const useStyles = makeStyles((theme) => ({
root: {
minHeight: 156,
background: theme.palette.background.default,
color: theme.palette.codeBlock.contrastText,
color: theme.palette.text.primary,
fontFamily: MONOSPACE_FONT_FAMILY,
fontSize: 13,
wordBreak: "break-all",
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/CodeExample/CodeExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const useStyles = makeStyles((theme) => ({
justifyContent: "space-between",
alignItems: "center",
background: theme.palette.background.default,
color: theme.palette.codeBlock.contrastText,
color: theme.palette.primary.contrastText,
fontFamily: MONOSPACE_FONT_FAMILY,
fontSize: 13,
padding: theme.spacing(2),
Expand Down
4 changes: 2 additions & 2 deletions site/src/components/ConfirmDialog/ConfirmDialog.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import ThemeProvider from "@material-ui/styles/ThemeProvider"
import { fireEvent, render } from "@testing-library/react"
import React from "react"
import { act } from "react-dom/test-utils"
import { light } from "../../theme"
import { dark } from "../../theme"
import { ConfirmDialog, ConfirmDialogProps } from "./ConfirmDialog"

namespace Helpers {
export const Component: React.FC<ConfirmDialogProps> = (props: ConfirmDialogProps) => {
return (
<ThemeProvider theme={light}>
<ThemeProvider theme={dark}>
<ConfirmDialog {...props} />
</ThemeProvider>
)
Expand Down
15 changes: 6 additions & 9 deletions site/src/components/ConfirmDialog/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,11 @@ interface StyleProps {
const useStyles = makeStyles((theme) => ({
dialogWrapper: (props: StyleProps) => ({
"& .MuiPaper-root": {
background:
props.type === "info"
? theme.palette.confirmDialog.info.background
: theme.palette.confirmDialog.error.background,
background: props.type === "info" ? theme.palette.primary.main : theme.palette.error.dark,
},
}),
dialogContent: (props: StyleProps) => ({
color: props.type === "info" ? theme.palette.confirmDialog.info.text : theme.palette.confirmDialog.error.text,
color: props.type === "info" ? theme.palette.primary.contrastText : theme.palette.error.contrastText,
padding: theme.spacing(6),
textAlign: "center",
}),
Expand All @@ -65,15 +62,15 @@ const useStyles = makeStyles((theme) => ({
description: (props: StyleProps) => ({
color:
props.type === "info"
? fade(theme.palette.confirmDialog.info.text, 0.75)
: fade(theme.palette.confirmDialog.error.text, 0.75),
? fade(theme.palette.primary.contrastText, 0.75)
: fade(theme.palette.error.contrastText, 0.75),
lineHeight: "160%",

"& strong": {
color:
props.type === "info"
? fade(theme.palette.confirmDialog.info.text, 0.95)
: fade(theme.palette.confirmDialog.error.text, 0.95),
? fade(theme.palette.primary.contrastText, 0.95)
: fade(theme.palette.error.contrastText, 0.95),
},
}),
}))
Expand Down
6 changes: 3 additions & 3 deletions site/src/components/CopyButton/CopyButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ const useStyles = makeStyles((theme) => ({
},
copyButton: {
borderRadius: 7,
background: theme.palette.codeBlock.button.main,
color: theme.palette.codeBlock.button.contrastText,
background: theme.palette.background.default,
color: theme.palette.primary.contrastText,
padding: theme.spacing(0.85),
minWidth: 32,

"&:hover": {
background: theme.palette.codeBlock.button.hover,
background: theme.palette.background.paper,
},
},
fileCopyIcon: {
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const useButtonStyles = makeStyles((theme) => ({
},
},
confirmDialogCancelButton: (props: StyleProps) => {
const color = props.type === "info" ? theme.palette.confirmDialog.info.text : theme.palette.confirmDialog.error.text
const color = props.type === "info" ? theme.palette.primary.contrastText : theme.palette.error.contrastText
return {
background: fade(color, 0.15),
color,
Expand Down
2 changes: 1 addition & 1 deletion site/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const useStyles = makeStyles((theme) => ({
display: "flex",
alignItems: "center",
height: 126,
background: theme.palette.hero.main,
background: theme.palette.background.default,
boxShadow: theme.shadows[3],
},
topInner: {
Expand Down
6 changes: 2 additions & 4 deletions site/src/components/HeaderButton/HeaderButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Button from "@material-ui/core/Button"
import { lighten, makeStyles } from "@material-ui/core/styles"
import { makeStyles } from "@material-ui/core/styles"
import React from "react"

export interface HeaderButtonProps {
Expand Down Expand Up @@ -28,10 +28,8 @@ export const HeaderButton: React.FC<HeaderButtonProps> = (props) => {
)
}

const useStyles = makeStyles((theme) => ({
const useStyles = makeStyles(() => ({
pageButton: {
whiteSpace: "nowrap",
backgroundColor: lighten(theme.palette.hero.main, 0.1),
color: "#B5BFD2",
},
}))
7 changes: 2 additions & 5 deletions site/src/components/Margins/Margins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ const useStyles = makeStyles(() => ({
maxWidth,
padding: `0 ${sidePadding}`,
flex: 1,
width: "100%",
},
}))

export const Margins: React.FC = ({ children }) => {
const styles = useStyles()
return (
<div>
<div className={styles.margins}>{children}</div>
</div>
)
return <div className={styles.margins}>{children}</div>
}
30 changes: 17 additions & 13 deletions site/src/components/NavbarView/NavbarView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,15 @@ export const NavbarView: React.FC<NavbarViewProps> = ({ user, onSignOut, display
<nav className={styles.root}>
<List className={styles.fixed}>
<ListItem className={styles.item}>
<NavLink className={styles.logo} to="/">
<NavLink className={styles.logo} to="/workspaces">
<Logo fill="white" opacity={1} width={125} />
</NavLink>
</ListItem>
<ListItem button className={styles.item}>
<NavLink className={styles.link} to="/workspaces">
Workspaces
</NavLink>
</ListItem>
<ListItem button className={styles.item}>
<NavLink className={styles.link} to="/templates">
Templates
Expand All @@ -47,13 +52,13 @@ const useStyles = makeStyles((theme) => ({
justifyContent: "center",
alignItems: "center",
height: navHeight,
background: theme.palette.navbar.main,
background: theme.palette.background.paper,
marginTop: 0,
transition: "margin 150ms ease",
"@media (display-mode: standalone)": {
borderTop: `1px solid ${theme.palette.divider}`,
},
borderBottom: `1px solid #383838`,
borderBottom: `1px solid ${theme.palette.divider}`,
},
fixed: {
flex: 0,
Expand All @@ -68,9 +73,9 @@ const useStyles = makeStyles((theme) => ({
display: "flex",
height: navHeight,
paddingLeft: theme.spacing(4),
paddingRight: theme.spacing(2),
paddingRight: theme.spacing(4),
"& svg": {
width: 125,
width: 109,
},
},
title: {
Expand Down Expand Up @@ -98,17 +103,16 @@ const useStyles = makeStyles((theme) => ({
"&.active": {
position: "relative",
color: theme.palette.primary.contrastText,
fontWeight: "bold",

"&::before": {
content: `"{"`,
left: 10,
position: "absolute",
},

"&::after": {
content: `"}"`,
content: `" "`,
bottom: 0,
left: theme.spacing(3),
background: "#C16800",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a good theme color that could go here in place of the hardcoded color? Like secondary or something maybe.

right: theme.spacing(3),
height: 2,
position: "absolute",
right: 10,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const AccountForm: React.FC<AccountFormProps> = ({
{error && <FormHelperText error>{error}</FormHelperText>}

<div>
<LoadingButton color="primary" loading={isLoading} type="submit" variant="contained">
<LoadingButton loading={isLoading} type="submit" variant="contained">
{isLoading ? "" : Language.updatePreferences}
</LoadingButton>
</div>
Expand Down
4 changes: 2 additions & 2 deletions site/src/components/SignInForm/SignInForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ export const SignInForm: React.FC<SignInFormProps> = ({
{authErrorMessage && <FormHelperText error>{Language.authErrorMessage}</FormHelperText>}
{methodsErrorMessage && <FormHelperText error>{Language.methodsErrorMessage}</FormHelperText>}
<div className={styles.submitBtn}>
<LoadingButton color="primary" loading={isLoading} fullWidth type="submit" variant="contained">
<LoadingButton loading={isLoading} fullWidth type="submit" variant="contained">
{isLoading ? "" : Language.passwordSignIn}
</LoadingButton>
</div>
</form>
{authMethods?.github && (
<div className={styles.submitBtn}>
<Link href={`/api/v2/users/oauth2/github/callback?redirect=${encodeURIComponent(redirectTo)}`}>
<Button color="primary" disabled={isLoading} fullWidth type="submit" variant="contained">
<Button disabled={isLoading} fullWidth type="submit" variant="contained">
{Language.githubSignIn}
</Button>
</Link>
Expand Down
15 changes: 14 additions & 1 deletion site/src/components/UserAvatar/UserAvatar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Avatar from "@material-ui/core/Avatar"
import { makeStyles } from "@material-ui/core/styles"
import React from "react"
import { firstLetter } from "../../util/firstLetter"

Expand All @@ -8,5 +9,17 @@ export interface UserAvatarProps {
}

export const UserAvatar: React.FC<UserAvatarProps> = ({ username, className }) => {
return <Avatar className={className}>{firstLetter(username)}</Avatar>
const styles = useStyles()
return (
<Avatar variant="square" className={`${styles.avatar} ${className || ""}`}>
{firstLetter(username)}
</Avatar>
)
}

const useStyles = makeStyles((theme) => ({
avatar: {
borderRadius: 2,
border: `1px solid ${theme.palette.divider}`,
},
}))
Loading