Skip to content

Commit 9a6a53d

Browse files
committed
Merge branch 'main' into agent
2 parents e9381fa + d436993 commit 9a6a53d

File tree

9 files changed

+206
-16
lines changed

9 files changed

+206
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ require (
4545
github.com/quasilyte/go-ruleguard/dsl v0.3.17
4646
github.com/spf13/cobra v1.3.0
4747
github.com/stretchr/testify v1.7.0
48-
github.com/unrolled/secure v1.0.9
48+
github.com/unrolled/secure v1.10.0
4949
github.com/xlab/treeprint v1.1.0
5050
go.uber.org/atomic v1.9.0
5151
go.uber.org/goleak v1.1.12

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,14 +1208,12 @@ github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
12081208
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
12091209
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
12101210
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
1211-
github.com/unrolled/secure v1.0.9 h1:BWRuEb1vDrBFFDdbCnKkof3gZ35I/bnHGyt0LB0TNyQ=
1212-
github.com/unrolled/secure v1.0.9/go.mod h1:fO+mEan+FLB0CdEnHf6Q4ZZVNqG+5fuLFnP8p0BXDPI=
1211+
github.com/unrolled/secure v1.10.0 h1:TBNP42z2AB+2pW9PR6vdbqhlQuv1iTeSVzK1qHjOBzA=
1212+
github.com/unrolled/secure v1.10.0/go.mod h1:BmF5hyM6tXczk3MpQkFf1hpKSRqCyhqcbiQtiAF7+40=
12131213
github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
12141214
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
12151215
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
12161216
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
1217-
github.com/urfave/negroni v1.0.0 h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc=
1218-
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
12191217
github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
12201218
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
12211219
github.com/vishvananda/netlink v1.1.1-0.20201029203352-d40f9887b852/go.mod h1:twkDnbuQxJYemMlGd4JFIcuhgX83tXhKS2B/PRMpOho=
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { Story } from "@storybook/react"
2+
import React from "react"
3+
import { Workspace, WorkspaceProps } from "./Workspace"
4+
import { MockWorkspace } from "../../test_helpers"
5+
6+
export default {
7+
title: "Workspace",
8+
component: Workspace,
9+
argTypes: {},
10+
}
11+
12+
const Template: Story<WorkspaceProps> = (args) => <Workspace {...args} />
13+
14+
export const Example = Template.bind({})
15+
Example.args = {
16+
workspace: MockWorkspace,
17+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { render, screen } from "@testing-library/react"
2+
import React from "react"
3+
import { Workspace } from "./Workspace"
4+
import { MockWorkspace } from "../../test_helpers"
5+
6+
describe("Workspace", () => {
7+
it("renders", async () => {
8+
// When
9+
render(<Workspace workspace={MockWorkspace} />)
10+
11+
// Then
12+
const element = await screen.findByText(MockWorkspace.name)
13+
expect(element).toBeDefined()
14+
})
15+
})
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
import Box from "@material-ui/core/Box"
2+
import Paper from "@material-ui/core/Paper"
3+
import Typography from "@material-ui/core/Typography"
4+
import { makeStyles } from "@material-ui/core/styles"
5+
import CloudCircleIcon from "@material-ui/icons/CloudCircle"
6+
import Link from "next/link"
7+
import React from "react"
8+
9+
import * as API from "../../api"
10+
11+
export interface WorkspaceProps {
12+
workspace: API.Workspace
13+
}
14+
15+
namespace Constants {
16+
export const TitleIconSize = 48
17+
export const CardRadius = 8
18+
export const CardPadding = 20
19+
}
20+
21+
/**
22+
* Workspace is the top-level component for viewing an individual workspace
23+
*/
24+
export const Workspace: React.FC<WorkspaceProps> = ({ workspace }) => {
25+
const styles = useStyles()
26+
27+
return (
28+
<div className={styles.root}>
29+
<WorkspaceHeader workspace={workspace} />
30+
</div>
31+
)
32+
}
33+
34+
/**
35+
* Component for the header at the top of the workspace page
36+
*/
37+
export const WorkspaceHeader: React.FC<WorkspaceProps> = ({ workspace }) => {
38+
const styles = useStyles()
39+
40+
return (
41+
<Paper elevation={0} className={styles.section}>
42+
<div className={styles.horizontal}>
43+
<WorkspaceHeroIcon />
44+
<div className={styles.vertical}>
45+
<Typography variant="h4">{workspace.name}</Typography>
46+
<Typography variant="body2" color="textSecondary">
47+
<Link href="javascript:;">{workspace.project_id}</Link>
48+
</Typography>
49+
</div>
50+
</div>
51+
</Paper>
52+
)
53+
}
54+
55+
/**
56+
* Component to render the 'Hero Icon' in the header of a workspace
57+
*/
58+
export const WorkspaceHeroIcon: React.FC = () => {
59+
return (
60+
<Box mr="1em">
61+
<CloudCircleIcon width={Constants.TitleIconSize} height={Constants.TitleIconSize} />
62+
</Box>
63+
)
64+
}
65+
66+
export const useStyles = makeStyles((theme) => {
67+
return {
68+
root: {
69+
display: "flex",
70+
flexDirection: "column",
71+
},
72+
horizontal: {
73+
display: "flex",
74+
flexDirection: "row",
75+
},
76+
vertical: {
77+
display: "flex",
78+
flexDirection: "column",
79+
},
80+
section: {
81+
border: `1px solid ${theme.palette.divider}`,
82+
borderRadius: Constants.CardRadius,
83+
padding: Constants.CardPadding,
84+
},
85+
icon: {
86+
width: Constants.TitleIconSize,
87+
height: Constants.TitleIconSize,
88+
},
89+
}
90+
})

site/components/Workspace/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./Workspace"

site/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@storybook/addon-essentials": "6.4.19",
2727
"@storybook/addon-links": "6.4.19",
2828
"@storybook/react": "6.4.19",
29-
"@testing-library/react": "12.1.2",
29+
"@testing-library/react": "12.1.3",
3030
"@types/express": "4.17.13",
3131
"@types/jest": "27.4.0",
3232
"@types/node": "14.18.12",
@@ -41,7 +41,7 @@
4141
"eslint-import-resolver-typescript": "2.5.0",
4242
"eslint-plugin-compat": "4.0.2",
4343
"eslint-plugin-import": "2.25.4",
44-
"eslint-plugin-jest": "26.1.0",
44+
"eslint-plugin-jest": "26.1.1",
4545
"eslint-plugin-jsx-a11y": "6.5.1",
4646
"eslint-plugin-no-storage": "1.0.2",
4747
"eslint-plugin-react": "7.28.0",
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import React from "react"
2+
import useSWR from "swr"
3+
import { makeStyles } from "@material-ui/core/styles"
4+
import { useRouter } from "next/router"
5+
import { Navbar } from "../../../components/Navbar"
6+
import { Footer } from "../../../components/Page"
7+
import { useUser } from "../../../contexts/UserContext"
8+
import { firstOrItem } from "../../../util/array"
9+
import { ErrorSummary } from "../../../components/ErrorSummary"
10+
import { FullScreenLoader } from "../../../components/Loader/FullScreenLoader"
11+
import { Workspace } from "../../../components/Workspace"
12+
13+
import * as API from "../../../api"
14+
15+
const WorkspacesPage: React.FC = () => {
16+
const styles = useStyles()
17+
const router = useRouter()
18+
const { me, signOut } = useUser(true)
19+
20+
const { user: userQueryParam, workspace: workspaceQueryParam } = router.query
21+
22+
const { data: workspace, error: workspaceError } = useSWR<API.Workspace, Error>(() => {
23+
const userParam = firstOrItem(userQueryParam, null)
24+
const workspaceParam = firstOrItem(workspaceQueryParam, null)
25+
26+
// TODO(Bryan): Getting non-personal users isn't supported yet in the backend.
27+
// So if the user is the same as 'me', use 'me' as the parameter
28+
const normalizedUserParam = me && userParam === me.id ? "me" : userParam
29+
30+
// The SWR API expects us to 'throw' if the query isn't ready yet, so these casts to `any` are OK
31+
// because the API expects exceptions.
32+
return `/api/v2/workspaces/${(normalizedUserParam as any).toString()}/${(workspaceParam as any).toString()}`
33+
})
34+
35+
if (workspaceError) {
36+
return <ErrorSummary error={workspaceError} />
37+
}
38+
39+
if (!me || !workspace) {
40+
return <FullScreenLoader />
41+
}
42+
43+
return (
44+
<div className={styles.root}>
45+
<Navbar user={me} onSignOut={signOut} />
46+
47+
<div className={styles.inner}>
48+
<Workspace workspace={workspace} />
49+
</div>
50+
51+
<Footer />
52+
</div>
53+
)
54+
}
55+
56+
const useStyles = makeStyles(() => ({
57+
root: {
58+
display: "flex",
59+
flexDirection: "column",
60+
},
61+
inner: {
62+
maxWidth: "1380px",
63+
margin: "1em auto",
64+
width: "100%",
65+
},
66+
}))
67+
68+
export default WorkspacesPage

site/yarn.lock

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2720,13 +2720,14 @@
27202720
lz-string "^1.4.4"
27212721
pretty-format "^27.0.2"
27222722

2723-
"@testing-library/react@12.1.2":
2724-
version "12.1.2"
2725-
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-12.1.2.tgz#f1bc9a45943461fa2a598bb4597df1ae044cfc76"
2726-
integrity sha512-ihQiEOklNyHIpo2Y8FREkyD1QAea054U0MVbwH1m8N9TxeFz+KoJ9LkqoKqJlzx2JDm56DVwaJ1r36JYxZM05g==
2723+
"@testing-library/react@12.1.3":
2724+
version "12.1.3"
2725+
resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-12.1.3.tgz#ef26c5f122661ea9b6f672b23dc6b328cadbbf26"
2726+
integrity sha512-oCULRXWRrBtC9m6G/WohPo1GLcLesH7T4fuKzRAKn1CWVu9BzXtqLXDDTA6KhFNNtRwLtfSMr20HFl+Qrdrvmg==
27272727
dependencies:
27282728
"@babel/runtime" "^7.12.5"
27292729
"@testing-library/dom" "^8.0.0"
2730+
"@types/react-dom" "*"
27302731

27312732
"@tootallnate/once@1":
27322733
version "1.1.2"
@@ -3008,7 +3009,7 @@
30083009
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.4.tgz#cd667bcfdd025213aafb7ca5915a932590acdcdc"
30093010
integrity sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==
30103011

3011-
"@types/react-dom@17.0.11":
3012+
"@types/react-dom@*", "@types/react-dom@17.0.11":
30123013
version "17.0.11"
30133014
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.11.tgz#e1eadc3c5e86bdb5f7684e00274ae228e7bcc466"
30143015
integrity sha512-f96K3k+24RaLGVu/Y2Ng3e1EbZ8/cVJvypZWd7cy0ofCBaf2lcM46xNhycMZ2xGwbBjRql7hOlZ+e2WlJ5MH3Q==
@@ -5769,10 +5770,10 @@ eslint-plugin-import@2.25.4:
57695770
resolve "^1.20.0"
57705771
tsconfig-paths "^3.12.0"
57715772

5772-
eslint-plugin-jest@26.1.0:
5773-
version "26.1.0"
5774-
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-26.1.0.tgz#9f6c33e66f3cef3f2832c3a4d2caa21a75792dee"
5775-
integrity sha512-vjF6RvcKm4xZSJgCmXb9fXmhzTva+I9jtj9Qv5JeZQTRocU7WT1g3Kx0cZ+00SekPe2DtSWDawHtSj4RaxFhXQ==
5773+
eslint-plugin-jest@26.1.1:
5774+
version "26.1.1"
5775+
resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-26.1.1.tgz#7176dd745ef8bca3070263f62cdf112f2dfc9aa1"
5776+
integrity sha512-HRKOuPi5ADhza4ZBK5ufyNXy28bXXkib87w+pQqdvBhSTsamndh6sIAKPAUl8y0/n9jSWBdTPslrwtKWqkp8dA==
57765777
dependencies:
57775778
"@typescript-eslint/utils" "^5.10.0"
57785779

0 commit comments

Comments
 (0)