@samitouri / QOSami-HFS / commits / 7c75cfe4

ux: admin/shared: transformed 2 confirmations into notifications (as we have undo, now)

Massimo Melina committed Feb 19, 2026 at 20:02 UTC 7c75cfe4cb2f3804d66b7ca8af55592e2bded590
3 files changed +14 -13
admin/src/FileForm.ts
+1 -1
@@ -114,7 +114,7 @@ export default function FileForm({ file, addToBar, statusApi, accounts, saved, i
114 || file.id === movingFile.replace(/[^/]+\/?$/,''), // can't move to the same parent
115 title: movingFile,
116 async onClick() {
117 - if (await moveVfs(movingFile, file.id))
117 + if (moveVfs(movingFile, file.id))
118 state.movingFile = ''
119 },
120 }),
admin/src/VfsPage.ts
+2 -2
@@ -14,7 +14,7 @@ import _ from 'lodash'
14 import apiAccounts from '../../src/api.accounts'
15 import FileForm from './FileForm'
16 import { Add, Delete } from '@mui/icons-material'
17 -import { alertDialog, confirmDialog } from './dialog'
17 +import { toast } from './dialog'
18 import { PageProps } from './App'
19
20 let selectOnReload: string[] | undefined
@@ -202,8 +202,8 @@ export function reloadVfs(pleaseSelect?: string[]) {
202 async function deleteFiles() {
203 const f = state.selectedFiles
204 if (!f.length) return
205 - if (!await confirmDialog(`Delete ${f.length} item(s)?`)) return
205 deleteVfs(f.map(x => x.id))
206 + toast(`${f.length} item(s) deleted`, 'success')
207 }
208
209 export function deleteVfs(uris: string[]) {
admin/src/VfsTree.ts
+11 -10
@@ -13,7 +13,7 @@ import { onlyTruthy, pathEncode, prefix, toMutable, wantArray, Who, with_ } from
13 import { Flex, iconTooltip, useToggleButton } from './mui'
14 import VfsMenuBar from './VfsMenuBar'
15 import { ApiObject } from './api'
16 -import { alertDialog, confirmDialog } from './dialog'
16 +import { alertDialog, toast } from './dialog'
17 import _ from 'lodash'
18
19 export const FolderIcon = Folder
@@ -51,8 +51,9 @@ export default function VfsTree({ statusApi }:{ statusApi: ApiObject }) {
51 async onDrop() {
52 const from = dragging.current
53 if (!from) return
54 - if (await confirmDialog(`Moving ${from} under ${id}`))
55 - await moveVfs(from, id)
54 + const fromName = id2node.get(from)?.name // won't work after moving
55 + if (moveVfs(from, id))
56 + toast(`Moved "${fromName}" under "${id2node.get(id)?.name}"`, 'success')
57 },
58 sx: {
59 display: 'flex',
@@ -149,19 +150,19 @@ export default function VfsTree({ statusApi }:{ statusApi: ApiObject }) {
150 export function moveVfs(from: string, to: string) {
151 const fromNode = id2node.get(from)
152 if (!fromNode)
152 - return alertDialog("Item to move not found", 'error').then(() => false)
153 + return !alertDialog("Item to move not found", 'error')
154 if (fromNode.isRoot)
154 - return alertDialog("Cannot move root", 'error').then(() => false)
155 + return !alertDialog("Cannot move root", 'error')
156 const toNode = id2node.get(to)
157 if (!toNode || toNode.type !== 'folder')
157 - return alertDialog("Destination folder not found", 'error').then(() => false)
158 + return !alertDialog("Destination folder not found", 'error')
159 if (isDescendantUri(to, from))
159 - return alertDialog("Cannot move inside itself", 'error').then(() => false)
160 + return !alertDialog("Cannot move inside itself", 'error')
161 if (toNode.children?.find(x => x.name === fromNode.name))
161 - return alertDialog("Item with same name already present in destination", 'error').then(() => false)
162 + return !alertDialog("Item with same name already present in destination", 'error')
163 const oldSiblings = fromNode.parent?.children
164 if (!oldSiblings)
164 - return alertDialog("Source parent not found", 'error').then(() => false)
165 + return !alertDialog("Source parent not found", 'error')
166 const fromParent = fromNode.parent
167 const movedName = fromNode.name
168 const movedIsFolder = fromNode.type === 'folder'
@@ -174,7 +175,7 @@ export function moveVfs(from: string, to: string) {
175 const movedId = prefix(to, pathEncode(movedName), movedIsFolder ? '/' : '')
176 reindexVfs({ select: [movedId] })
177 state.expanded = _.uniq([...state.expanded, ...destinationAncestors])
177 - return Promise.resolve(true)
178 + return true
179
180 function getAncestorIds(node: VfsNodeAdmin) {
181 const ret: string[] = []