Skip to content

fix: Use /projects as the landing page #72

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 2 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add Redirect component; use on Index page
  • Loading branch information
bryphe-coder committed Jan 26, 2022
commit 0d7ec7176913ac81b56c0610cd7aeff07b77f660
16 changes: 16 additions & 0 deletions site/components/Redirect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { useEffect } from "react"
import { useRouter } from "next/router"

export interface RedirectProps {
to: string
}

export const Redirect: React.FC<RedirectProps> = ({ to }) => {
const router = useRouter()

useEffect(() => {
void router.replace(to)
}, [])

return null
}
1 change: 1 addition & 0 deletions site/components/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./Button"
export * from "./EmptyState"
export * from "./Page"
export * from "./Redirect"
79 changes: 10 additions & 69 deletions site/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,78 +1,19 @@
import React from "react"
import Box from "@material-ui/core/Box"
import { makeStyles } from "@material-ui/core/styles"
import Paper from "@material-ui/core/Paper"
import AddWorkspaceIcon from "@material-ui/icons/AddToQueue"

import { EmptyState, SplitButton } from "../components"
import { Navbar } from "../components/Navbar"
import { Footer } from "../components/Page"
import { useUser } from "../contexts/UserContext"
import { Redirect } from "../components"
import { ErrorSummary } from "../components/ErrorSummary"
import { FullScreenLoader } from "../components/Loader/FullScreenLoader"
import { useUser } from "../contexts/UserContext"

const WorkspacesPage: React.FC = () => {
const styles = useStyles()
const { me, signOut } = useUser(true)

if (!me) {
return <FullScreenLoader />
}

const createWorkspace = () => {
alert("create")
}
const IndexPage: React.FC = () => {
const { me } = useUser(/* redirectOnError */ true)

const button = {
children: "New Workspace",
onClick: createWorkspace,
if (me) {
// Once the user is logged in, just redirect them to /projects as the landing page
return <Redirect to="/projects" />
}

return (
<div className={styles.root}>
<Navbar user={me} onSignOut={signOut} />
<div className={styles.header}>
<SplitButton<string>
color="primary"
onClick={createWorkspace}
options={[
{
label: "New workspace",
value: "custom",
},
{
label: "New workspace from template",
value: "template",
},
]}
startIcon={<AddWorkspaceIcon />}
textTransform="none"
/>
</div>

<Paper style={{ maxWidth: "1380px", margin: "1em auto", width: "100%" }}>
<Box pt={4} pb={4}>
<EmptyState message="No workspaces available." button={button} />
</Box>
</Paper>
<Footer />
</div>
)
return <FullScreenLoader />
}

const useStyles = makeStyles((theme) => ({
root: {
display: "flex",
flexDirection: "column",
},
header: {
display: "flex",
flexDirection: "row-reverse",
justifyContent: "space-between",
margin: "1em auto",
maxWidth: "1380px",
padding: theme.spacing(2, 6.25, 0),
width: "100%",
},
}))

export default WorkspacesPage
export default IndexPage