frontend: let access upload queue if not empty while browsing folders with no upload permission

Massimo Melina committed Jan 24, 2023 at 19:00 UTC 362d3ad094df5457fc739070eaf72dc6fa9520e9
2 files changed +6 -4
frontend/src/menu.ts
+2 -2
@@ -16,7 +16,7 @@ import { useSnapshot } from 'valtio'
16
17 export function MenuPanel() {
18 const { showFilter, remoteSearch, stopSearch, stoppedSearch, patternFilter, selected, can_upload } = useSnapState()
19 - const { uploading } = useSnapshot(uploadState)
19 + const { uploading, qs } = useSnapshot(uploadState)
20 const [filter, setFilter] = useState(patternFilter)
21 ;[state.patternFilter] = useDebounce(showFilter ? filter : '', 300)
22 useEffect(() => {
@@ -74,7 +74,7 @@ export function MenuPanel() {
74 }
75 }
76 }),
77 - can_upload && h(MenuButton, {
77 + (can_upload || qs.length > 0) && h(MenuButton, {
78 icon: 'upload',
79 label: 'Upload',
80 className: uploading && 'ani-working',
frontend/src/upload.ts
+4 -2
@@ -8,6 +8,7 @@ import { proxy, ref, subscribe, useSnapshot } from 'valtio'
8 import { alertDialog, confirmDialog } from './dialog'
9 import { reloadList } from './useFetchList'
10 import { getNotification } from './api'
11 +import { useSnapState } from './state'
12
13 export const uploadState = proxy<{
14 done: number
@@ -75,12 +76,13 @@ export function showUpload() {
76 function Content(){
77 const [files, setFiles] = useState([] as File[])
78 const { qs, done, doneByte, paused, errors, eta } = useSnapshot(uploadState)
79 + const { can_upload } = useSnapState()
80 const etaStr = useMemo(() => !eta ? '' : formatTime(eta*1000, 0, 2), [eta])
81
82 return h(FlexV, {},
83 h(Flex, { gap: '.5em', flexWrap: 'wrap', justifyContent: 'center', position: 'sticky', top: -4, background: 'var(--bg)', boxShadow: '0 3px 3px #000' },
82 - h('button',{ onClick: () => selectFiles() }, "Add file(s)"),
83 - h('button',{ onClick: () => selectFiles(true) }, "Add folder"),
84 + can_upload && h('button',{ onClick: () => selectFiles() }, "Add file(s)"),
85 + can_upload && h('button',{ onClick: () => selectFiles(true) }, "Add folder"),
86 files.length > 1 && h('button', { onClick() { setFiles([]) } }, "Clear"),
87 files.length > 0 && h('button', {
88 onClick() {