1
1
import { create } from '@dstack-js/ipfs' ;
2
2
import { Stack , Shard , ShardKind } from '@dstack-js/lib' ;
3
+ import Box from '@mui/material/Box' ;
4
+ import LoadingButton from '@mui/lab/LoadingButton' ;
5
+ import TextField from '@mui/material/TextField' ;
3
6
import React , { useState } from 'react' ;
4
7
import { Dashboard } from './dashboard' ;
5
8
6
9
export const App : React . FunctionComponent < { } > = ( ) => {
7
10
const [ stack , setStack ] = useState < Stack | null > ( null ) ;
8
- const [ fillInfo , setFillInfo ] = useState ( true ) ;
11
+ const [ loading , setLoading ] = useState ( false ) ;
9
12
const [ namespace , setNamespace ] = useState ( 'dstack' ) ;
10
13
11
14
const init = async ( ) : Promise < void > => {
12
- setFillInfo ( false ) ;
15
+ setLoading ( true ) ;
13
16
localStorage . setItem ( 'debug' , '*' ) ;
14
17
15
18
const ipfs = await create ( ) ;
@@ -22,21 +25,32 @@ export const App: React.FunctionComponent<{}> = () => {
22
25
// @ts -expect-error
23
26
window . ShardKind = ShardKind ;
24
27
28
+ setLoading ( false ) ;
25
29
setStack ( stack ) ;
26
30
} ;
27
31
28
- if ( fillInfo ) {
32
+ if ( ! stack ) {
29
33
return (
30
- < div >
31
- < input
32
- type = "text"
33
- value = { namespace }
34
+ < Box
35
+ component = "form"
36
+ sx = { {
37
+ '& > :not(style)' : { m : 1 , width : '25ch' } ,
38
+ } }
39
+ noValidate
40
+ autoComplete = "off"
41
+ >
42
+ < TextField
43
+ label = "Stack namespace"
34
44
onChange = { ( e ) => setNamespace ( e . target . value ) }
35
- > </ input >
36
- < button onClick = { init } > Start</ button >
37
- </ div >
45
+ value = { namespace }
46
+ focused
47
+ />
48
+ < LoadingButton loading = { loading } onClick = { init } >
49
+ Create
50
+ </ LoadingButton >
51
+ </ Box >
38
52
) ;
39
53
}
40
54
41
- return stack ? < Dashboard stack = { stack } /> : < h3 > Initializing </ h3 > ;
55
+ return < Dashboard stack = { stack } /> ;
42
56
} ;
0 commit comments