confirm archive
Massimo Melina committed
Jan 15, 2022 at 16:36 UTC
189d8060d9ad9a9734fdd027a51f807bb43a875a
2 files changed
+13
-5
frontend/src/menu.ts
+13
-4
@@ -1,7 +1,7 @@
1
import { state, useSnapState } from './state'
2
import { createElement as h, useEffect, useState } from 'react'
3
import { useDebounce } from 'use-debounce'
4
-import { promptDialog } from './dialog'
4
+import { confirmDialog, promptDialog } from './dialog'
5
import { hIcon, prefix } from './misc'
6
import { login } from './login'
7
import { showOptions } from './options'
@@ -40,7 +40,8 @@ export function MenuPanel() {
40
h(MenuLink, {
41
icon: 'archive',
42
label: 'Archive',
43
- href: '?get=zip',
43
+ href: '?get=zip', // @ts-ignore
44
+ confirm: 'Download whole folder as ZIP archive?',
45
})
46
),
47
remoteSearch && h('div', { id: 'searched' }, (stopSearch ? 'Searching' : 'Searched') + ': ' + remoteSearch + prefix(' (', stoppedSearch && 'interrupted', ')')),
@@ -95,8 +96,16 @@ export function MenuButton({ icon, label, toggled, onClick, className = '' }: Me
96
h('label', {}, label))
97
}
98
98
-export function MenuLink({ href, ...rest }: MenuButtonProps & { href: string }) {
99
- return h('a', { href }, h(MenuButton, rest))
99
+export function MenuLink({ href, confirm, ...rest }: MenuButtonProps & { href: string, confirm?: string }) {
100
+ return h('a', {
101
+ href,
102
+ async onClick(ev) {
103
+ if (!confirm) return
104
+ ev.preventDefault()
105
+ if (!await confirmDialog(confirm)) return
106
+ window.location.href = href
107
+ }
108
+ }, h(MenuButton, rest))
109
}
110
111
function LoginButton() {
todo.md
-1
@@ -1,5 +1,4 @@
1
# To do
2
-- confirm archive
2
- emoji as an alternative to icons?
3
- smaller icons file?
4
- remove seconds from time