Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Action, AsyncAction } from 'app/overmind';
import { withLoadApp } from 'app/overmind/factories';
import { OrderBy } from './state';

export const dashboardMounted = withLoadApp();
export const dashboardMounted: AsyncAction = withLoadApp();

export const sandboxesSelected: Action<{
sandboxIds: string[];
Expand Down
110 changes: 0 additions & 110 deletions packages/app/src/app/pages/Dashboard/index.js

This file was deleted.

105 changes: 105 additions & 0 deletions packages/app/src/app/pages/Dashboard/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import React, { useState, useEffect } from 'react';
import { useOvermind } from 'app/overmind';
import RightIcon from 'react-icons/lib/md/keyboard-arrow-right';
import LeftIcon from 'react-icons/lib/md/keyboard-arrow-left';
import { withRouter } from 'react-router-dom';
import { Navigation } from 'app/pages/common/Navigation';
import { SignInButton } from 'app/pages/common/SignInButton';
import { client } from 'app/graphql/client';

import SidebarContents from './Sidebar';
import Content from './Content';
import {
Container,
Centered,
Content as ContentContainer,
LoggedInContainer,
LoggedInTitle,
Sidebar,
NavigationContainer,
ShowSidebarButton,
OffsettedLogo,
} from './elements';

const Dashboard = props => {
const [showSidebar, setShowSidebar] = useState(false);

const {
state: { hasLogIn },
actions: { dashboard },
} = useOvermind();

useEffect(() => {
dashboard.dashboardMounted();
return () => {
// Reset store so new visits get fresh data
client.resetStore();
};
}, [dashboard]);

const onRouteChange = () => {
setShowSidebar(false);
};

const toggleSidebar = () => {
setShowSidebar(!showSidebar);
};

const { history } = props;

history.listen(({ state }) => {
if (!!state && state.from === 'sandboxSearchFocused') {
return;
}

onRouteChange();
});

let DashboardContent = (
<>
<Sidebar active={showSidebar}>
<SidebarContents />
<ShowSidebarButton onClick={toggleSidebar}>
{showSidebar ? (
<LeftIcon style={{ color: 'white' }} />
) : (
<RightIcon style={{ color: 'white' }} />
)}
</ShowSidebarButton>
</Sidebar>

<ContentContainer>
<Content />
</ContentContainer>
</>
);

if (!hasLogIn) {
DashboardContent = (
<Container>
<Centered>
<LoggedInContainer>
<OffsettedLogo />
<LoggedInTitle>Sign in to CodeSandbox</LoggedInTitle>

<SignInButton big style={{ fontSize: '1rem' }} />
</LoggedInContainer>
</Centered>
</Container>
);
}

return (
<Container>
<NavigationContainer>
<Navigation searchNoInput title="Dashboard" />
</NavigationContainer>

<div style={{ display: 'flex', overflow: 'hidden' }}>
{DashboardContent}
</div>
</Container>
);
};

export default withRouter(Dashboard);
1 change: 1 addition & 0 deletions packages/common/src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { LinkButton, AButton, Button } from './elements';
export type Props = {
to?: string;
href?: string;
big?: boolean;
small?: boolean;
style?: React.CSSProperties;
block?: boolean;
Expand Down