Skip to content

Commit cbc1015

Browse files
committed
Add empty view
1 parent 190b7d1 commit cbc1015

File tree

4 files changed

+40
-7
lines changed

4 files changed

+40
-7
lines changed

site/src/pages/WorkspacesPage/WorkspacesPage.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import { useMachine } from "@xstate/react"
2-
import dayjs from "dayjs"
3-
import relativeTime from "dayjs/plugin/relativeTime"
42
import React from "react"
53
import { workspacesMachine } from "../../xServices/workspaces/workspacesXService"
64
import { WorkspacesPageView } from "./WorkspacesPageView"
75

8-
dayjs.extend(relativeTime)
9-
106
export const WorkspacesPage: React.FC = () => {
117
const [workspacesState] = useMachine(workspacesMachine)
128

site/src/pages/WorkspacesPage/WorkspacesPageView.stories.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ AllStates.args = {
4545
createWorkspaceWithStatus("running", "delete"),
4646
],
4747
}
48+
49+
export const Empty = Template.bind({})
50+
Empty.args = {}

site/src/pages/WorkspacesPage/WorkspacesPageView.tsx

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { Link } from "@material-ui/core"
12
import Avatar from "@material-ui/core/Avatar"
23
import Button from "@material-ui/core/Button"
34
import { makeStyles, Theme } from "@material-ui/core/styles"
@@ -11,7 +12,7 @@ import useTheme from "@material-ui/styles/useTheme"
1112
import dayjs from "dayjs"
1213
import relativeTime from "dayjs/plugin/relativeTime"
1314
import React from "react"
14-
import { Link } from "react-router-dom"
15+
import { Link as RouterLink } from "react-router-dom"
1516
import * as TypesGen from "../../api/typesGenerated"
1617
import { WorkspaceBuild } from "../../api/typesGenerated"
1718
import { Margins } from "../../components/Margins/Margins"
@@ -50,14 +51,28 @@ export const WorkspacesPageView: React.FC<WorkspacesPageViewProps> = (props) =>
5051
</TableRow>
5152
</TableHead>
5253
<TableBody>
54+
{!props.workspaces && (
55+
<TableRow>
56+
<TableCell colSpan={999}>
57+
<div className={styles.welcome}>
58+
<span>
59+
<Link component={RouterLink} to="/workspaces/new">
60+
Create a workspace
61+
</Link>
62+
&nbsp;so you can check out your repositories, edit your source code, and build and test your software.
63+
</span>
64+
</div>
65+
</TableCell>
66+
</TableRow>
67+
)}
5368
{props.workspaces?.map((workspace) => (
5469
<TableRow key={workspace.id} className={styles.workspaceRow}>
5570
<TableCell>
5671
<div className={styles.workspaceName}>
5772
<Avatar variant="square" className={styles.workspaceAvatar}>
5873
{firstLetter(workspace.name)}
5974
</Avatar>
60-
<Link to={`/workspaces/${workspace.id}`} className={styles.workspaceLink}>
75+
<Link component={RouterLink} to={`/workspaces/${workspace.id}`} className={styles.workspaceLink}>
6176
<b>{workspace.name}</b>
6277
<span>{workspace.owner_name}</span>
6378
</Link>
@@ -139,6 +154,20 @@ const useStyles = makeStyles((theme) => ({
139154
marginLeft: "auto",
140155
},
141156
},
157+
welcome: {
158+
paddingTop: theme.spacing(12),
159+
paddingBottom: theme.spacing(12),
160+
display: "flex",
161+
flexDirection: "column",
162+
alignItems: "center",
163+
justifyContent: "center",
164+
"& span": {
165+
maxWidth: 600,
166+
textAlign: "center",
167+
fontSize: theme.spacing(2),
168+
lineHeight: `${theme.spacing(3)}px`,
169+
},
170+
},
142171
workspaceRow: {
143172
"& > td": {
144173
paddingTop: theme.spacing(2),

site/src/theme/overrides.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PaletteOptions } from "@material-ui/core/styles/createPalette"
1+
import { PaletteOptions, SimplePaletteColorOptions } from "@material-ui/core/styles/createPalette"
22
import { MONOSPACE_FONT_FAMILY } from "./constants"
33

44
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
@@ -74,5 +74,10 @@ export const getOverrides = (palette: PaletteOptions) => {
7474
},
7575
},
7676
},
77+
MuiLink: {
78+
root: {
79+
color: (palette.primary as SimplePaletteColorOptions).light,
80+
},
81+
},
7782
}
7883
}

0 commit comments

Comments
 (0)