|
5 | 5 |
|
6 | 6 | import { emit } from '@nextcloud/event-bus' |
7 | 7 | import { fetchNode } from '../services/WebdavClient.ts' |
8 | | -import { showError, showSuccess } from '@nextcloud/dialogs' |
| 8 | +import { DialogBuilder, showError, showSuccess } from '@nextcloud/dialogs' |
9 | 9 | import { getCurrentUser } from '@nextcloud/auth' |
10 | 10 | // eslint-disable-next-line import/no-unresolved, n/no-missing-import |
11 | 11 | import PQueue from 'p-queue' |
@@ -253,10 +253,45 @@ export default { |
253 | 253 | } |
254 | 254 | }, |
255 | 255 |
|
| 256 | + /** |
| 257 | + * Display delete share confirmation dialog |
| 258 | + * @returns {Promise<boolean>} |
| 259 | + */ |
| 260 | + async askDeleteConfirmation() { |
| 261 | + let confirmed = false |
| 262 | + await new DialogBuilder() |
| 263 | + .setName(t('files_sharing', 'Delete share')) |
| 264 | + .setText(t('files_sharing', 'You are about to delete this share')) |
| 265 | + .setButtons([ |
| 266 | + { |
| 267 | + label: t('core', 'Cancel'), |
| 268 | + }, |
| 269 | + { |
| 270 | + label: t('files_sharing', 'Delete share'), |
| 271 | + type: 'error', |
| 272 | + callback: () => { |
| 273 | + confirmed = true |
| 274 | + }, |
| 275 | + }, |
| 276 | + ]) |
| 277 | + .build() |
| 278 | + .show() |
| 279 | + |
| 280 | + return confirmed |
| 281 | + }, |
256 | 282 | /** |
257 | 283 | * Delete share button handler |
258 | 284 | */ |
259 | 285 | async onDelete() { |
| 286 | + console.debug('Deleting share', this.share.id) |
| 287 | + this.open = false |
| 288 | + const deletionConfirmed = await this.askDeleteConfirmation() |
| 289 | + |
| 290 | + if (!deletionConfirmed) { |
| 291 | + console.debug('Deletion aborted', this.share.id) |
| 292 | + return |
| 293 | + } |
| 294 | + |
260 | 295 | try { |
261 | 296 | this.loading = true |
262 | 297 | this.open = false |
|
0 commit comments