1- import { inject , hooksObserver } from 'app/componentConnectors' ;
2- import React from 'react' ;
1+ import React , { FunctionComponent } from 'react' ;
32
3+ import { useOvermind } from 'app/overmind' ;
44import { GithubIntegration } from 'app/pages/common/GithubIntegration' ;
55
66import { Description } from '../../elements' ;
@@ -10,61 +10,59 @@ import { CreateRepo } from './CreateRepo';
1010import { Git } from './Git' ;
1111import { More } from '../More' ;
1212
13- export const GitHub = inject ( 'store' ) (
14- hooksObserver ( ( { store } ) => {
15- const showPlaceHolder =
16- ! store . editor . currentSandbox . owned || ! store . isLoggedIn ;
17-
18- if ( showPlaceHolder ) {
19- const message = store . isLoggedIn ? (
20- < >
21- You need to own this sandbox to export this sandbox to GitHub and make
22- commits and pull requests to it.{ ' ' }
23- < p > Make a fork to own the sandbox.</ p >
24- </ >
25- ) : (
26- `You need to be signed in to export this sandbox to GitHub and make commits and pull requests to it.`
27- ) ;
28-
29- return < More message = { message } id = "github" /> ;
30- }
31-
32- const {
13+ export const GitHub : FunctionComponent = ( ) => {
14+ const {
15+ state : {
3316 editor : {
34- currentSandbox : { originalGit } ,
17+ currentSandbox : { originalGit, owned } ,
3518 } ,
19+ isLoggedIn,
3620 user : {
3721 integrations : { github } ,
3822 } ,
39- } = store ;
23+ } ,
24+ } = useOvermind ( ) ;
25+ const showPlaceHolder = ! owned || ! isLoggedIn ;
26+
27+ if ( showPlaceHolder ) {
28+ const message = isLoggedIn ? (
29+ < >
30+ You need to own this sandbox to export this sandbox to GitHub and make
31+ commits and pull requests to it. < p > Make a fork to own the sandbox.</ p >
32+ </ >
33+ ) : (
34+ `You need to be signed in to export this sandbox to GitHub and make commits and pull requests to it.`
35+ ) ;
4036
41- return github ? ( // eslint-disable-line
42- originalGit ? (
43- < >
44- < Git />
37+ return < More message = { message } id = "github" /> ;
38+ }
4539
46- < WorkspaceItem title = "Export to GitHub" >
47- < CreateRepo />
48- </ WorkspaceItem >
49- </ >
50- ) : (
51- < >
52- < Description > Export your sandbox to GitHub.</ Description >
40+ return github ? ( // eslint-disable-line
41+ originalGit ? (
42+ < >
43+ < Git />
5344
45+ < WorkspaceItem title = "Export to GitHub" >
5446 < CreateRepo />
55- </ >
56- )
47+ </ WorkspaceItem >
48+ </ >
5749 ) : (
5850 < >
59- < Description >
60- You can create commits and open pull requests if you add GitHub to
61- your integrations.
62- </ Description >
51+ < Description > Export your sandbox to GitHub.</ Description >
6352
64- < div style = { { margin : '1rem' } } >
65- < GithubIntegration small />
66- </ div >
53+ < CreateRepo />
6754 </ >
68- ) ;
69- } )
70- ) ;
55+ )
56+ ) : (
57+ < >
58+ < Description >
59+ You can create commits and open pull requests if you add GitHub to your
60+ integrations.
61+ </ Description >
62+
63+ < div style = { { margin : '1rem' } } >
64+ < GithubIntegration small />
65+ </ div >
66+ </ >
67+ ) ;
68+ } ;
0 commit comments