fix: inconsistent permissions in file-menu
Massimo Melina committed
Apr 7, 2023 at 13:12 UTC
b697c6d12b38fb4c4bf086c948ca555c60baeabd
1 file changed
+7
-6
frontend/src/BrowseFiles.ts
+7
-6
@@ -227,12 +227,13 @@ const Entry = memo((entry: DirEntry & { midnight: Date, separator?: string }) =>
227
ev.preventDefault()
228
const OPEN_ICON = 'play'
229
const OPEN_LABEL = t('file_open', "Open")
230
- const couldRead = entry.p !== (isFolder ? 'l' : 'r')
230
+ const couldOpen = !entry.p?.includes(isFolder ? 'l' : 'r') // to open we need list for folders and read for files
231
+ const couldDownload = !entry.p?.includes('r') && (!isFolder || !entry.p?.includes('l')) // folders needs list as well
232
const menu = [
232
- couldRead && menuOnLink
233
- && (isFolder ? h(Link, { to: base + uri, onClick: () => close() }, hIcon(OPEN_ICON), OPEN_LABEL)
233
+ menuOnLink && couldOpen && (
234
+ isFolder ? h(Link, { to: base + uri, onClick: () => close() }, hIcon(OPEN_ICON), OPEN_LABEL)
235
: { label: OPEN_LABEL, href: uri, target: isFolder ? undefined : '_blank', icon: OPEN_ICON }),
235
- couldRead && { label: t`Download`, href: uri + (isFolder ? '?get=zip' : '?dl'), icon: 'download' },
236
+ couldDownload && { label: t`Download`, href: uri + (isFolder ? '?get=zip' : '?dl'), icon: 'download' },
237
can_delete && { label: t`Delete`, icon: 'trash', onClick: () => deleteFiles([uri], base) }
238
]
239
const props = [
@@ -256,7 +257,7 @@ const Entry = memo((entry: DirEntry & { midnight: Date, separator?: string }) =>
257
: null
258
))
259
),
259
- entry.p && h(Fragment, {}, hIcon('password', { style: { marginRight: '.5em' } }), t(MISSING_PERM)),
260
+ !couldOpen && h(Fragment, {}, hIcon('password', { style: { marginRight: '.5em' } }), t(MISSING_PERM)),
261
h('div', { className: 'file-menu' },
262
dontBotherWithKeys(menu.map((e: any, i) =>
263
isValidElement(e) ? e
@@ -286,7 +287,7 @@ const EntryProps = memo((entry: DirEntry & { midnight: Date }) => {
287
const dd = '2-digit'
288
return h('div', { className: 'entry-props' },
289
h(CustomCode, { name: 'additionalEntryProps', props: { entry } }),
289
- entry.p && hIcon('password', { className: 'miss-perm', title: t(MISSING_PERM) }),
290
+ entry.p?.match(entry.isFolder ? /l/i : /r/i) && hIcon('password', { className: 'miss-perm', title: t(MISSING_PERM) }),
291
h(EntrySize, { s }),
292
time && h('span', {
293
className: 'entry-ts',