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
7 changes: 5 additions & 2 deletions packages/app/src/app/overmind/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import {
NotificationType,
convertTypeToStatus,
} from '@codesandbox/common/lib/utils/notifications';
import { Action, AsyncAction } from '.';
import * as internalActions from './internalActions';

import { withLoadApp } from './factories';
import * as internalActions from './internalActions';
import { Action, AsyncAction } from '.';

export const internal = internalActions;

Expand All @@ -16,6 +17,8 @@ export const sandboxPageMounted: AsyncAction = withLoadApp();

export const searchMounted: AsyncAction = withLoadApp();

export const codesadboxMounted: AsyncAction = withLoadApp();

export const cliMounted: AsyncAction = withLoadApp(
async ({ state, actions }) => {
if (state.user) {
Expand Down
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> = ({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think using FunctionComponent would make the type a bit more clear.

Suggested change
export const CodeSadbox: React.FC<IFallbackComponentProps> = ({
export const CodeSadbox: React.FunctionComponent<IFallbackComponentProps> = ({

Copy link
Contributor

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 for FC due 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 😄

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>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,49 @@ export const buildCrashReport = ({
error,
trace,
}: IbuildCrashReport): string => {
const url = new URL(
`https://github.com/codesandbox/codesandbox-client/issues/new`
);
const { name, version, os } = browser();

const title = `💥 Crash Report: <Please Add a Short Description of Crash Circumstances>`;
url.searchParams.set(
`body`,
`<h1>💥 Crash Report</h1>

const body = `<h1>💥 Crash Report</h1>
<h2>What were you trying to accomplish when the crash occurred?</h2>

<h2>What were you trying to accomplish when the crash occurred?</h2>
> Please use this issue template to describe what you were doing when you encountered this crash. While we are able to fill in some details automatically, it's not always enough to reproduce!

> Please use this issue template to describe what you were doing when you encountered this crash. While we are able to fill in some details automatically, it's not always enough to reproduce!
<h3>Link to sandbox: [link]() (optional)</h3>

<h3>Link to sandbox: [link]() (optional)</h3>
<h3>Crash Details</h3>

<h3>Crash Details</h3>
<details>
<summary>Environment</summary>

<details>
<summary>Environment</summary>
| Browser | Version | Operating System |
| ------- | --------- | ---------------- |
| ${name} | ${version} | ${os} |

| Browser | Version | Operating System |
| ------- | --------- | ---------------- |
| ${name} | ${version} | ${os} |
**Route:**
${window.location.href}

**Route:**
${window.location.href}
</details>

</details>
<details>
<summary>Error Message</summary>

<details>
<summary>Error Message</summary>
${'```'}bash
${error}
${error.stack}
${trace}
${'```'}

${'```'}bash
${error}
${error.stack}
${trace}
${'```'}
</details>
`
);

</details>
`;
url.searchParams.set(`labels`, `💥 Crash Report`);

return `https://github.com/codesandbox/codesandbox-client/issues/new?title=${encodeURI(
title
)}&body=${encodeURI(body)}`;
return url.toString();
};