|
1 | 1 | import React from "react"
|
2 |
| -import Box from "@material-ui/core/Box" |
3 |
| -import { makeStyles } from "@material-ui/core/styles" |
4 |
| -import Paper from "@material-ui/core/Paper" |
5 |
| -import AddWorkspaceIcon from "@material-ui/icons/AddToQueue" |
6 | 2 |
|
7 |
| -import { EmptyState, SplitButton } from "../components" |
8 |
| -import { Navbar } from "../components/Navbar" |
9 |
| -import { Footer } from "../components/Page" |
10 |
| -import { useUser } from "../contexts/UserContext" |
| 3 | +import { Redirect } from "../components" |
11 | 4 | import { FullScreenLoader } from "../components/Loader/FullScreenLoader"
|
| 5 | +import { useUser } from "../contexts/UserContext" |
12 | 6 |
|
13 |
| -const WorkspacesPage: React.FC = () => { |
14 |
| - const styles = useStyles() |
15 |
| - const { me, signOut } = useUser(true) |
16 |
| - |
17 |
| - if (!me) { |
18 |
| - return <FullScreenLoader /> |
19 |
| - } |
20 |
| - |
21 |
| - const createWorkspace = () => { |
22 |
| - alert("create") |
23 |
| - } |
| 7 | +const IndexPage: React.FC = () => { |
| 8 | + const { me } = useUser(/* redirectOnError */ true) |
24 | 9 |
|
25 |
| - const button = { |
26 |
| - children: "New Workspace", |
27 |
| - onClick: createWorkspace, |
| 10 | + if (me) { |
| 11 | + // Once the user is logged in, just redirect them to /projects as the landing page |
| 12 | + return <Redirect to="/projects" /> |
28 | 13 | }
|
29 | 14 |
|
30 |
| - return ( |
31 |
| - <div className={styles.root}> |
32 |
| - <Navbar user={me} onSignOut={signOut} /> |
33 |
| - <div className={styles.header}> |
34 |
| - <SplitButton<string> |
35 |
| - color="primary" |
36 |
| - onClick={createWorkspace} |
37 |
| - options={[ |
38 |
| - { |
39 |
| - label: "New workspace", |
40 |
| - value: "custom", |
41 |
| - }, |
42 |
| - { |
43 |
| - label: "New workspace from template", |
44 |
| - value: "template", |
45 |
| - }, |
46 |
| - ]} |
47 |
| - startIcon={<AddWorkspaceIcon />} |
48 |
| - textTransform="none" |
49 |
| - /> |
50 |
| - </div> |
51 |
| - |
52 |
| - <Paper style={{ maxWidth: "1380px", margin: "1em auto", width: "100%" }}> |
53 |
| - <Box pt={4} pb={4}> |
54 |
| - <EmptyState message="No workspaces available." button={button} /> |
55 |
| - </Box> |
56 |
| - </Paper> |
57 |
| - <Footer /> |
58 |
| - </div> |
59 |
| - ) |
| 15 | + return <FullScreenLoader /> |
60 | 16 | }
|
61 | 17 |
|
62 |
| -const useStyles = makeStyles((theme) => ({ |
63 |
| - root: { |
64 |
| - display: "flex", |
65 |
| - flexDirection: "column", |
66 |
| - }, |
67 |
| - header: { |
68 |
| - display: "flex", |
69 |
| - flexDirection: "row-reverse", |
70 |
| - justifyContent: "space-between", |
71 |
| - margin: "1em auto", |
72 |
| - maxWidth: "1380px", |
73 |
| - padding: theme.spacing(2, 6.25, 0), |
74 |
| - width: "100%", |
75 |
| - }, |
76 |
| -})) |
77 |
| - |
78 |
| -export default WorkspacesPage |
| 18 | +export default IndexPage |
0 commit comments