Skip to content

Commit 5020497

Browse files
committed
Extract Git
1 parent 7877af9 commit 5020497

File tree

2 files changed

+33
-13
lines changed

2 files changed

+33
-13
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import GithubBadge from '@codesandbox/common/lib/components/GithubBadge';
2+
import { githubRepoUrl } from '@codesandbox/common/lib/utils/url-generator';
3+
import React, { FunctionComponent } from 'react';
4+
import { useOvermind } from 'app/overmind';
5+
6+
import { Item } from './elements';
7+
8+
export const Git: FunctionComponent = () => {
9+
const {
10+
state: {
11+
editor: {
12+
currentSandbox: {
13+
git,
14+
git: { branch, commitSha, repo, username },
15+
},
16+
},
17+
},
18+
} = useOvermind();
19+
20+
return (
21+
<Item>
22+
<GithubBadge
23+
branch={branch}
24+
commitSha={commitSha}
25+
repo={repo}
26+
url={githubRepoUrl(git)}
27+
username={username}
28+
/>
29+
</Item>
30+
);
31+
};

packages/app/src/app/pages/Sandbox/Editor/Workspace/Project/index.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import GithubBadge from '@codesandbox/common/lib/components/GithubBadge';
21
import Tooltip from '@codesandbox/common/lib/components/Tooltip';
32
import getTemplateDefinition from '@codesandbox/common/lib/templates';
43
import { getSandboxName } from '@codesandbox/common/lib/utils/get-sandbox-name';
54
import {
6-
githubRepoUrl,
75
patronUrl,
86
sandboxUrl,
97
} from '@codesandbox/common/lib/utils/url-generator';
@@ -31,6 +29,7 @@ import {
3129
TemplateStyledLink,
3230
} from './elements';
3331
import { Frozen } from './Frozen';
32+
import { Git } from './Git';
3433
import { Keywords } from './Keywords';
3534
import { SandboxConfig } from './SandboxConfig';
3635
import { Team } from './Team';
@@ -76,17 +75,7 @@ export const Project: FunctionComponent<Props> = ({ editable = false }) => {
7675

7776
{team && <Team />}
7877

79-
{git && (
80-
<Item>
81-
<GithubBadge
82-
branch={git.branch}
83-
commitSha={git.commitSha}
84-
repo={git.repo}
85-
url={githubRepoUrl(git)}
86-
username={git.username}
87-
/>
88-
</Item>
89-
)}
78+
{git && <Git />}
9079

9180
<StatsContainer>
9281
<Stats sandbox={currentSandbox} />

0 commit comments

Comments
 (0)