File tree 3 files changed +24
-5
lines changed
3 files changed +24
-5
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react'
2
2
3
+ import { File , DeviceType } from '../main.type.ts'
4
+
3
5
type FileManagementParams = ( ) => {
4
6
upload : ( ) => void
5
7
download : ( ) => void
6
8
remove : ( ) => void
7
9
refresh : ( ) => void
10
+ canDownload : Boolean ,
11
+ canUpload : Boolean ,
12
+ selectedFiles : File [ ]
8
13
}
9
14
10
15
const FileManagementView : React . FC = ( { logic } ) => {
11
- const { refresh } : FileManagementParams = logic ( )
16
+ const {
17
+ refresh,
18
+ download,
19
+ upload,
20
+ remove,
21
+ canUpload,
22
+ canDownload,
23
+ selectedFiles = [ ]
24
+ } : FileManagementParams = logic ( )
12
25
return (
13
26
< div className = "file-management column align-center justify-center" >
14
27
< button onClick = { refresh } > ↺</ button >
15
- < button > ←</ button >
16
- < button > →</ button >
17
- < button > ×</ button >
28
+ < button disabled = { ! canUpload } onClick = { upload } > ←</ button >
29
+ < button disabled = { ! canDownload } onClick = { download } > →</ button >
30
+ < button onClick = { remove } > ×</ button >
18
31
</ div >
19
32
)
20
33
}
Original file line number Diff line number Diff line change @@ -144,6 +144,8 @@ export const useMainLogic = function() {
144
144
navigate : navigateDisk
145
145
} )
146
146
const fileManagementLogic = ( ) => ( {
147
+ canUpload : selectedFiles . find ( f => f . device === DeviceType . disk ) && serialPath ,
148
+ canDownload : selectedFiles . find ( f => f . device === DeviceType . serial ) && diskPath ,
147
149
upload : async ( ) => {
148
150
setWaiting ( true )
149
151
try {
@@ -180,7 +182,7 @@ export const useMainLogic = function() {
180
182
await BridgeDisk . removeFile ( diskPath , filename )
181
183
}
182
184
if ( f . device === DeviceType . serial ) {
183
- await BridgeSerial . removeFile ( f . path )
185
+ await BridgeSerial . removeFile ( serialPath + '/' + f . path )
184
186
}
185
187
}
186
188
refresh ( )
Original file line number Diff line number Diff line change @@ -139,6 +139,10 @@ button {
139
139
padding : 5px 30px ;
140
140
cursor : pointer ;
141
141
}
142
+ button [disabled ] {
143
+ opacity : 0.5 ;
144
+ cursor : not-allowed ;
145
+ }
142
146
143
147
.window-overlay {
144
148
width : 100vw ;
You can’t perform that action at this time.
0 commit comments