Skip to content

Commit 87adcec

Browse files
feat(files_sharing): confirm share deletion
in order to prevent accidental share deletion Signed-off-by: Misha M.-Kupriyanov <kupriyanov@strato.de>
1 parent 0df3a46 commit 87adcec

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

apps/files_sharing/src/mixins/SharesMixin.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { emit } from '@nextcloud/event-bus'
77
import { fetchNode } from '../services/WebdavClient.ts'
8-
import { showError, showSuccess } from '@nextcloud/dialogs'
8+
import { DialogBuilder, showError, showSuccess } from '@nextcloud/dialogs'
99
import { getCurrentUser } from '@nextcloud/auth'
1010
// eslint-disable-next-line import/no-unresolved, n/no-missing-import
1111
import PQueue from 'p-queue'
@@ -253,10 +253,45 @@ export default {
253253
}
254254
},
255255

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+
},
256282
/**
257283
* Delete share button handler
258284
*/
259285
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+
260295
try {
261296
this.loading = true
262297
this.open = false

0 commit comments

Comments
 (0)