better code: define icon 'delete'
Massimo Melina committed
Sep 24, 2023 at 17:33 UTC
2c8a70131abb0cb9853ad58404ffe44e03f26d3c
6 files changed
+8
-7
frontend/src/BrowseFiles.ts
+1
@@ -205,6 +205,7 @@ const Entry = memo(({ entry, midnight, separator }: EntryProps) => {
205
h('span', { className: 'link-wrapper' }, // container to handle mouse over for both children
206
isFolder ? h(Fragment, {},
207
h(Link, { to: uri }, ico, entry.n.slice(0,-1)),
208
+ // popup button is here to be able to detect link-wrapper:hover
209
menuOnLink && !showingButton && h('button', { className: 'popup-menu-button', onClick: fileMenu }, hIcon('menu'), t`Menu`)
210
)
211
: containerDir ? h(Fragment, {},
frontend/src/fileMenu.ts
+1
-1
@@ -35,7 +35,7 @@ export function openFileMenu(entry: DirEntry, ev: MouseEvent, addToMenu: (FileMe
35
return (state.can_delete || entry.p?.includes('d')) && {
36
id: 'delete',
37
label: t`Delete`,
38
- icon: 'trash',
38
+ icon: 'delete',
39
onClick: () => deleteFiles([entry.uri])
40
}
41
if (x === 'show')
frontend/src/icons.ts
+1
@@ -35,6 +35,7 @@ const SYS_ICONS: Record<string, [string] | [string, string]> = {
35
pause: ['⏸'],
36
edit: ['✏️'],
37
zoom: ['↔'],
38
+ delete: ['🗑️', 'trash'],
39
}
40
41
document.fonts.ready.then(async ()=> {
frontend/src/menu.ts
+1
-1
@@ -64,7 +64,7 @@ export function MenuPanel() {
64
}),
65
h(MenuButton, changingButton === 'delete' ? {
66
id: 'delete-button',
67
- icon: 'trash',
67
+ icon: 'delete',
68
label: t`Delete`,
69
className: 'show-sliding',
70
onClick: () => deleteFiles(Object.keys(selected))
frontend/src/upload.ts
+2
-2
@@ -146,7 +146,7 @@ export function showUpload() {
146
qs.length > 0 && h('div', {},
147
h(Flex, { alignItems: 'center', justifyContent: 'center', borderTop: '1px dashed', padding: '.5em' },
148
[queueStr, etaStr].filter(Boolean).join(', '),
149
- inQ > 0 && iconBtn('trash', ()=> {
149
+ inQ > 0 && iconBtn('delete', ()=> {
150
uploadState.qs = []
151
abortCurrentUpload()
152
}),
@@ -196,7 +196,7 @@ function FilesList({ files, remove }: { files: File[], remove: (f:File) => any }
196
files.map((f,i) => {
197
const working = f === uploading
198
return h('tr', { key: i },
199
- h('td', {}, iconBtn('trash', () => remove(f))),
199
+ h('td', {}, iconBtn('delete', () => remove(f))),
200
h('td', {}, formatBytes(f.size)),
201
h('td', { className: working ? 'ani-working' : undefined },
202
path(f),
src/serveFile.ts
+2
-3
@@ -27,11 +27,10 @@ export function serveFileNode(ctx: Koa.Context, node: VfsNode) {
27
const name = getNodeName(node)
28
const mimeString = typeof mime === 'string' ? mime
29
: _.find(mime, (val,mask) => matches(name, mask))
30
- const allowed = allowedReferer.get()
31
- if (allowed) {
30
+ if (allowedReferer.get()) {
31
const ref = /\/\/([^:/]+)/.exec(ctx.get('referer'))?.[1] // extract host from url
32
if (ref && ref !== host() // automatic accept if referer is basically the hosting domain
34
- && !matches(ref, allowed))
33
+ && !matches(ref, allowedReferer.get()))
34
return ctx.status = HTTP_FORBIDDEN
35
}
36