Skip to content

Commit 6e5f289

Browse files
yeion7CompuIves
authored andcommitted
GitHub integration prevent crash (codesandbox#2676)
* update type * prevent crash
1 parent 2acdfce commit 6e5f289

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

packages/app/src/app/overmind/state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type State = {
1919
authToken: string;
2020
error: string;
2121
contributors: string[];
22-
user: CurrentUser;
22+
user: CurrentUser | null;
2323
connected: boolean;
2424
notifications: Notification[];
2525
isLoadingCLI: boolean;

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/GitHub/GitHub.tsx

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ export const GitHub: FunctionComponent = () => {
1717
currentSandbox: { originalGit, owned },
1818
},
1919
isLoggedIn,
20-
user: {
21-
integrations: { github },
22-
},
20+
user,
2321
},
2422
} = useOvermind();
2523
const showPlaceHolder = !owned || !isLoggedIn;
@@ -37,32 +35,33 @@ export const GitHub: FunctionComponent = () => {
3735
return <More message={message} id="github" />;
3836
}
3937

40-
return github ? ( // eslint-disable-line
41-
originalGit ? (
38+
if (!user.integrations.github) {
39+
return (
4240
<>
43-
<Git />
41+
<Description>
42+
You can create commits and open pull requests if you add GitHub to
43+
your integrations.
44+
</Description>
4445

45-
<WorkspaceItem title="Export to GitHub">
46-
<CreateRepo />
47-
</WorkspaceItem>
46+
<div style={{ margin: '1rem' }}>
47+
<GithubIntegration small />
48+
</div>
4849
</>
49-
) : (
50-
<>
51-
<Description>Export your sandbox to GitHub.</Description>
50+
);
51+
}
52+
return originalGit ? (
53+
<>
54+
<Git />
5255

56+
<WorkspaceItem title="Export to GitHub">
5357
<CreateRepo />
54-
</>
55-
)
58+
</WorkspaceItem>
59+
</>
5660
) : (
5761
<>
58-
<Description>
59-
You can create commits and open pull requests if you add GitHub to your
60-
integrations.
61-
</Description>
62+
<Description>Export your sandbox to GitHub.</Description>
6263

63-
<div style={{ margin: '1rem' }}>
64-
<GithubIntegration small />
65-
</div>
64+
<CreateRepo />
6665
</>
6766
);
6867
};

0 commit comments

Comments
 (0)