@@ -6,8 +6,11 @@ import {
6
6
Stack ,
7
7
IStackTokens ,
8
8
} from 'office-ui-fabric-react' ;
9
+ import { remote } from 'electron' ;
9
10
import routes from '../constants/routes.json' ;
10
11
12
+ const { dialog } = remote ;
13
+
11
14
export interface IButtonExampleProps {
12
15
// These are set based on the toggles shown above the examples (not needed in real code)
13
16
disabled ?: boolean ;
@@ -18,12 +21,19 @@ export interface IButtonExampleProps {
18
21
const stackTokens : IStackTokens = { childrenGap : 40 } ;
19
22
20
23
export default function Home ( ) : JSX . Element {
21
- const [ state ] = useState < string > ( 'Hi' ) ;
24
+ const [ state ] = useState < string > ( 'Please select backup directory' ) ;
25
+ const [ directory , setDirectory ] = useState < string > ( 't' ) ;
22
26
23
27
const alertClicked = ( ) : void => {
24
28
alert ( 'Clicked' ) ;
25
29
} ;
26
-
30
+ const onButtonClick = ( ) => {
31
+ const path = dialog . showOpenDialog ( {
32
+ properties : [ 'openDirectory' ] ,
33
+ } ) ;
34
+ // eslint-disable-next-line promise/catch-or-return
35
+ path . then ( ( res ) => setDirectory ( res . filePaths [ 0 ] ) ) ;
36
+ } ;
27
37
useEffect ( ( ) => {
28
38
// axios
29
39
// .get('http://localhost:5000')
@@ -36,16 +46,17 @@ export default function Home(): JSX.Element {
36
46
< h2 > { state } </ h2 >
37
47
< Stack horizontal tokens = { stackTokens } >
38
48
< DefaultButton
39
- text = "Standard "
40
- onClick = { alertClicked }
49
+ text = "Directory "
50
+ onClick = { onButtonClick }
41
51
allowDisabledFocus
42
52
/>
43
53
< PrimaryButton
44
- text = "Primary "
54
+ text = "BACKUP "
45
55
onClick = { alertClicked }
46
56
allowDisabledFocus
47
57
/>
48
58
</ Stack >
59
+ < div > { directory } </ div >
49
60
< Link to = { routes . COUNTER } > counter</ Link >
50
61
</ div >
51
62
) ;
0 commit comments