|
1 | 1 | import { dashboardUrl } from '@codesandbox/common/lib/utils/url-generator'; |
2 | | -import { inject, hooksObserver } from 'app/componentConnectors'; |
| 2 | +import { useOvermind } from 'app/overmind'; |
3 | 3 | import React from 'react'; |
4 | 4 |
|
5 | 5 | import { UserMenu } from 'app/pages/common/UserMenu'; |
@@ -29,50 +29,59 @@ import { |
29 | 29 | import { Logo } from './Logo'; |
30 | 30 | import { MenuBar } from './MenuBar'; |
31 | 31 | import { SandboxName } from './SandboxName'; |
32 | | -import { HeaderProps } from './types'; |
| 32 | +import { IHeaderProps } from './types'; |
33 | 33 |
|
34 | | -export const Header = inject('store')( |
35 | | - hooksObserver(({ zenMode, store }: HeaderProps & { store: any }) => { |
36 | | - const vscode = store.preferences.settings.experimentVSCode; |
| 34 | +export const Header: React.FC<IHeaderProps> = ({ zenMode }) => { |
| 35 | + const { |
| 36 | + state: { |
| 37 | + preferences: { |
| 38 | + settings: { experimentVSCode: vscode }, |
| 39 | + }, |
| 40 | + isPatron, |
| 41 | + updateStatus, |
| 42 | + hasLogIn, |
| 43 | + isLoggedIn, |
| 44 | + user, |
| 45 | + }, |
| 46 | + } = useOvermind(); |
37 | 47 |
|
38 | | - return ( |
39 | | - <Container zenMode={zenMode}> |
40 | | - <Left> |
41 | | - {store.hasLogIn ? ( |
42 | | - <DashboardLink to={dashboardUrl()}> |
43 | | - <DashboardIcon /> |
44 | | - </DashboardLink> |
45 | | - ) : ( |
46 | | - <Logo /> |
47 | | - )} |
| 48 | + return ( |
| 49 | + <Container zenMode={zenMode}> |
| 50 | + <Left> |
| 51 | + {hasLogIn ? ( |
| 52 | + <DashboardLink to={dashboardUrl()}> |
| 53 | + <DashboardIcon /> |
| 54 | + </DashboardLink> |
| 55 | + ) : ( |
| 56 | + <Logo /> |
| 57 | + )} |
48 | 58 |
|
49 | | - {vscode ? <MenuBar /> : <SaveAllButton />} |
50 | | - </Left> |
| 59 | + {vscode ? <MenuBar /> : <SaveAllButton />} |
| 60 | + </Left> |
51 | 61 |
|
52 | | - <Centered> |
53 | | - <SandboxName /> |
54 | | - </Centered> |
| 62 | + <Centered> |
| 63 | + <SandboxName /> |
| 64 | + </Centered> |
55 | 65 |
|
56 | | - <Right> |
57 | | - {store.updateStatus === 'available' && <RefreshButton />} |
58 | | - {!store.isLoggedIn || (!store.isPatron && <PatronButton />)} |
59 | | - {!store.isLoggedIn && <PreferencesButton />} |
60 | | - <NewSandboxButton /> |
61 | | - {store.isLoggedIn && <LikeButton />} |
62 | | - {store.user && store.user.curatorAt && <PickButton />} |
63 | | - <ShareButton /> |
64 | | - <ForkButton /> |
65 | | - <AccountContainer> |
66 | | - {store.isLoggedIn ? ( |
67 | | - <UserMenuContainer> |
68 | | - <UserMenu /> |
69 | | - </UserMenuContainer> |
70 | | - ) : ( |
71 | | - <SignInButton /> |
72 | | - )} |
73 | | - </AccountContainer> |
74 | | - </Right> |
75 | | - </Container> |
76 | | - ); |
77 | | - }) |
78 | | -); |
| 66 | + <Right> |
| 67 | + {updateStatus === 'available' && <RefreshButton />} |
| 68 | + {!isLoggedIn || (!isPatron && <PatronButton />)} |
| 69 | + {!isLoggedIn && <PreferencesButton />} |
| 70 | + <NewSandboxButton /> |
| 71 | + {isLoggedIn && <LikeButton />} |
| 72 | + {user && user.curatorAt && <PickButton />} |
| 73 | + <ShareButton /> |
| 74 | + <ForkButton /> |
| 75 | + <AccountContainer> |
| 76 | + {isLoggedIn ? ( |
| 77 | + <UserMenuContainer> |
| 78 | + <UserMenu /> |
| 79 | + </UserMenuContainer> |
| 80 | + ) : ( |
| 81 | + <SignInButton /> |
| 82 | + )} |
| 83 | + </AccountContainer> |
| 84 | + </Right> |
| 85 | + </Container> |
| 86 | + ); |
| 87 | +}; |
0 commit comments