8000 File management plugged · arduino/lab-micropython-editor@f05c5bb · GitHub
[go: up one dir, main page]

Skip to content

Commit f05c5bb

Browse files
committed
File management plugged
1 parent ce9c5dc commit f05c5bb

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

ui/ftp/components/fileManagementView.tsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,33 @@
11
import React from 'react'
22

3+
import { File, DeviceType } from '../main.type.ts'
4+
35
type FileManagementParams = () => {
46
upload: () => void
57
download: () => void
68
remove: () => void
79
refresh: () => void
10+
canDownload: Boolean,
11+
canUpload: Boolean,
12+
selectedFiles: File[]
813
}
914

1015
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()
1225
return (
1326
<div className="file-management column align-center justify-center">
1427
<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>
1831
</div>
1932
)
2033
}

ui/ftp/main.logic.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@ export const useMainLogic = function() {
144144
navigate: navigateDisk
145145
})
146146
const fileManagementLogic = () => ({
147+
canUpload: selectedFiles.find(f => f.device === DeviceType.disk) && serialPath,
148+
canDownload: selectedFiles.find(f => f.device === DeviceType.serial) && diskPath,
147149
upload: async () => {
148150
setWaiting(true)
149151
try {
@@ -180,7 +182,7 @@ export const useMainLogic = function() {
180182
await BridgeDisk.removeFile(diskPath, filename)
181183
}
182184
if (f.device === DeviceType.serial) {
183-
await BridgeSerial.removeFile(f.path)
185+
await BridgeSerial.removeFile(serialPath + '/' + f.path)
184186
}
185187
}
186188
refresh()

ui/ftp/main.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ button {
139139
padding: 5px 30px;
140140
cursor: pointer;
141141
}
142+
button[disabled] {
143+
opacity: 0.5;
144+
cursor: not-allowed;
145+
}
142146

143147
.window-overlay {
144148
width: 100vw;

0 commit comments

Comments
 (0)
0