@@ -2,67 +2,62 @@ import { Button } from '@codesandbox/common/lib/components/Button';
22import Input from '@codesandbox/common/lib/components/Input' ;
33import Margin from '@codesandbox/common/lib/components/spacing/Margin' ;
44import track from '@codesandbox/common/lib/utils/analytics' ;
5- import { inject , hooksObserver } from 'app/componentConnectors ' ;
5+ import { useOvermind } from 'app/overmind ' ;
66import React from 'react' ;
7-
87import {
98 WorkspaceSubtitle ,
109 WorkspaceInputContainer ,
1110} from 'app/pages/Sandbox/Editor/Workspace/elements' ;
12-
1311import { Error } from './elements' ;
1412
15- type Props = {
13+ interface ICreateRepoProps {
1614 style ?: React . CSSProperties ;
17- store : any ;
18- signals : any ;
15+ }
16+
17+ export const CreateRepo : React . FC < ICreateRepoProps > = ( { style } ) => {
18+ const {
19+ state : {
20+ editor : { isAllModulesSynced } ,
21+ git : { repoTitle, error } ,
22+ } ,
23+ actions : {
24+ git : { repoTitleChanged, createRepoClicked } ,
25+ } ,
26+ } = useOvermind ( ) ;
27+
28+ const updateRepoTitle = ( {
29+ target : { value : title } ,
30+ } : React . ChangeEvent < HTMLInputElement > ) => repoTitleChanged ( { title } ) ;
31+
32+ const createRepo = ( ) => {
33+ track ( 'Export to GitHub Clicked' ) ;
34+ createRepoClicked ( ) ;
35+ } ;
36+
37+ return (
38+ < div style = { style } >
39+ { ! isAllModulesSynced && (
40+ < Error > Save your files first before exporting.</ Error >
41+ ) }
42+
43+ { error && < Error > { error } </ Error > }
44+
45+ < WorkspaceSubtitle > Repository Name</ WorkspaceSubtitle >
46+
47+ < WorkspaceInputContainer >
48+ < Input onChange = { updateRepoTitle } value = { repoTitle } />
49+ </ WorkspaceInputContainer >
50+
51+ < Margin horizontal = { 1 } bottom = { 1 } >
52+ < Button
53+ block
54+ disabled = { Boolean ( error || ! repoTitle || ! isAllModulesSynced ) }
55+ onClick = { createRepo }
56+ small
57+ >
58+ Create Repository
59+ </ Button >
60+ </ Margin >
61+ </ div >
62+ ) ;
1963} ;
20- export const CreateRepo = inject ( 'store' , 'signals' ) (
21- hooksObserver (
22- ( {
23- style,
24- signals : {
25- git : { repoTitleChanged, createRepoClicked } ,
26- } ,
27- store : {
28- editor : { isAllModulesSynced } ,
29- git : { repoTitle, error } ,
30- } ,
31- } : Props ) => {
32- const updateRepoTitle = ( {
33- target : { value : title } ,
34- } : React . ChangeEvent < HTMLInputElement > ) => repoTitleChanged ( { title } ) ;
35- const createRepo = ( ) => {
36- track ( 'Export to GitHub Clicked' ) ;
37- createRepoClicked ( ) ;
38- } ;
39-
40- return (
41- < div style = { style } >
42- { ! isAllModulesSynced && (
43- < Error > Save your files first before exporting.</ Error >
44- ) }
45-
46- { error && < Error > { error } </ Error > }
47-
48- < WorkspaceSubtitle > Repository Name</ WorkspaceSubtitle >
49-
50- < WorkspaceInputContainer >
51- < Input onChange = { updateRepoTitle } value = { repoTitle } />
52- </ WorkspaceInputContainer >
53-
54- < Margin horizontal = { 1 } bottom = { 1 } >
55- < Button
56- block
57- disabled = { error || ! repoTitle || ! isAllModulesSynced }
58- onClick = { createRepo }
59- small
60- >
61- Create Repository
62- </ Button >
63- </ Margin >
64- </ div >
65- ) ;
66- }
67- )
68- ) ;
0 commit comments