-
Notifications
You must be signed in to change notification settings - Fork 2.4k
🔨 Switch CodeSadbox to useOvermind, Remove title, add label to Report #2498
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 65 additions & 54 deletions
119
packages/app/src/app/pages/common/ErrorBoundary/CodeSadbox/CodeSadbox.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,71 +1,82 @@ | ||
| import React from 'react'; | ||
| import GoHome from 'react-icons/lib/go/home'; | ||
| import GoIssueOpened from 'react-icons/lib/go/issue-opened'; | ||
| import { inject, hooksObserver } from 'app/componentConnectors'; | ||
| import { Button } from '@codesandbox/common/lib/components/Button'; | ||
| import { dashboardUrl } from '@codesandbox/common/lib/utils/url-generator'; | ||
| import { useOvermind } from 'app/overmind'; | ||
| import { Navigation } from 'app/pages/common/Navigation'; | ||
| import React, { useEffect } from 'react'; | ||
| import GoHome from 'react-icons/lib/go/home'; | ||
| import GoIssueOpened from 'react-icons/lib/go/issue-opened'; | ||
| // @ts-ignore | ||
| import Dashboard from '-!svg-react-loader!@codesandbox/common/lib/icons/dashboard.svg'; | ||
| import { Sadbox } from './Sadbox'; | ||
|
|
||
| import { IFallbackComponentProps } from '../types'; | ||
| import { buildCrashReport } from './buildCrashReport'; | ||
| import { | ||
| Actions, | ||
| ButtonIcon, | ||
| Container, | ||
| Content, | ||
| Header, | ||
| Nav, | ||
| Content, | ||
| Title, | ||
| Subtitle, | ||
| Actions, | ||
| ButtonIcon, | ||
| Title, | ||
| } from './elements'; | ||
| import { Sadbox } from './Sadbox'; | ||
|
|
||
| export const CodeSadbox = inject('store')( | ||
| hooksObserver( | ||
| ({ error, trace, store }: IFallbackComponentProps & { store: any }) => ( | ||
| <Container> | ||
| <Header> | ||
| <Nav> | ||
| <Navigation title="CodeSadbox" /> | ||
| </Nav> | ||
| </Header> | ||
| <Content> | ||
| <Title>Oh no! Something broke!</Title> | ||
| <Sadbox scale={3} /> | ||
| <Subtitle>CodeSadbox</Subtitle> | ||
| <Actions> | ||
| {store.isLoggedIn ? ( | ||
| <Button small secondary href={dashboardUrl()}> | ||
| <ButtonIcon> | ||
| <Dashboard /> | ||
| </ButtonIcon> | ||
| Go to Dashboard | ||
| </Button> | ||
| ) : ( | ||
| <Button small secondary href="/"> | ||
| <ButtonIcon> | ||
| <GoHome /> | ||
| </ButtonIcon> | ||
| Back to Home | ||
| </Button> | ||
| )} | ||
| {/* | ||
| // @ts-ignore */} | ||
| <Button | ||
| small | ||
| target="_blank" | ||
| rel="noopener" | ||
| href={buildCrashReport({ error, trace })} | ||
| > | ||
| export const CodeSadbox: React.FC<IFallbackComponentProps> = ({ | ||
| error, | ||
| trace, | ||
| }) => { | ||
| const { | ||
| actions: { codesadboxMounted }, | ||
| state: { isLoggedIn }, | ||
| } = useOvermind(); | ||
|
|
||
| useEffect(() => { | ||
| codesadboxMounted(); | ||
| }, [codesadboxMounted]); | ||
|
|
||
| return ( | ||
| <Container> | ||
| <Header> | ||
| <Nav> | ||
| <Navigation title="CodeSadbox" /> | ||
| </Nav> | ||
| </Header> | ||
| <Content> | ||
| <Title>Oh no! Something broke!</Title> | ||
| <Sadbox scale={3} /> | ||
| <Subtitle>CodeSadbox</Subtitle> | ||
| <Actions> | ||
| {isLoggedIn ? ( | ||
| <Button small secondary href={dashboardUrl()}> | ||
| <ButtonIcon> | ||
| <Dashboard /> | ||
| </ButtonIcon> | ||
| Go to Dashboard | ||
| </Button> | ||
| ) : ( | ||
| <Button small secondary href="/"> | ||
| <ButtonIcon> | ||
| <GoIssueOpened /> | ||
| <GoHome /> | ||
| </ButtonIcon> | ||
| Report Crash | ||
| Back to Home | ||
| </Button> | ||
| </Actions> | ||
| </Content> | ||
| </Container> | ||
| ) | ||
| ) | ||
| ); | ||
| )} | ||
| {/* | ||
| // @ts-ignore */} | ||
| <Button | ||
| small | ||
| target="_blank" | ||
| rel="noopener" | ||
| href={buildCrashReport({ error, trace })} | ||
| > | ||
| <ButtonIcon> | ||
| <GoIssueOpened /> | ||
| </ButtonIcon> | ||
| Report Crash | ||
| </Button> | ||
| </Actions> | ||
| </Content> | ||
| </Container> | ||
| ); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using
FunctionComponentwould make the type a bit more clear.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I am a bit split on this. I started using
FunctionComponent, but went forFCdue to lazyness. Totally agree it is more explicit, though this type is not really what tells us this is a component. It is the folder name, file name and not at least the JSX in the file. We would never like... "what is this thing? Oh, let me check the type... hm React.FC... hmmmm... oh, it is a component", you know long before you look at the type that it is a component 😄