diff --git a/app/controller.js b/app/controller.js index 8c6945acc..412ae2e48 100644 --- a/app/controller.js +++ b/app/controller.js @@ -1,5 +1,6 @@ import FileReceiver from './fileReceiver'; import FileSender from './fileSender'; +import confirmDeleteDialog from './ui/confirmDeleteDialog'; import copyDialog from './ui/copyDialog'; import faviconProgressbar from './ui/faviconProgressbar'; import okDialog from './ui/okDialog'; @@ -33,6 +34,15 @@ export default function(state, emitter) { render(); } + async function deleteFile(ownedFile) { + try { + state.storage.remove(ownedFile.id); + await ownedFile.del(); + } catch (e) { + state.sentry.captureException(e); + } + } + emitter.on('DOMContentLoaded', () => { document.addEventListener('blur', () => (updateTitle = true)); document.addEventListener('focus', () => { @@ -65,12 +75,17 @@ export default function(state, emitter) { }); emitter.on('delete', async ownedFile => { - try { - state.storage.remove(ownedFile.id); - await ownedFile.del(); - } catch (e) { - state.sentry.captureException(e); + if (state.WEB_UI.SHOW_DELETE_CONFIRM) { + state.modal = confirmDeleteDialog(ownedFile); + } else { + await deleteFile(ownedFile); } + + render(); + }); + + emitter.on('confirmedDelete', async ownedFile => { + await deleteFile(ownedFile); render(); }); diff --git a/app/ui/confirmDeleteDialog.js b/app/ui/confirmDeleteDialog.js new file mode 100644 index 000000000..a610277ce --- /dev/null +++ b/app/ui/confirmDeleteDialog.js @@ -0,0 +1,36 @@ +const html = require('choo/html'); + +module.exports = function(archive) { + return function(state, emit, close) { + return html` + +

+ ${state.translate('deleteConfirmation')} +

+
+ + +
+
+ `; + + function confirm(event) { + console.log(state); + event.stopPropagation(); + emit('confirmedDelete', archive); + close(); + } + }; +}; diff --git a/public/locales/de/send.ftl b/public/locales/de/send.ftl index 44e001777..d15b45528 100644 --- a/public/locales/de/send.ftl +++ b/public/locales/de/send.ftl @@ -134,6 +134,9 @@ accountBenefitSync = Geteilte Dateien von anderen Geräten aus verwalten accountBenefitMoz = Erfahre mehr über andere { -mozilla }-Dienste signOut = Abmelden okButton = OK +continueButton = Fortsetzen +cancelButton = Abbrechen +deleteConfirmation = Bist du dir sicher, dass du diese Datei löschen möchtest? downloadingTitle = Wird heruntergeladen… noStreamsWarning = Dieser Browser kann eine so große Datei möglicherweise nicht entschlüsseln. noStreamsOptionCopy = Kopiere den Link, um ihn in einem anderen Browser zu öffnen diff --git a/public/locales/en-CA/send.ftl b/public/locales/en-CA/send.ftl index 35fd7ba75..2f7453039 100644 --- a/public/locales/en-CA/send.ftl +++ b/public/locales/en-CA/send.ftl @@ -134,6 +134,9 @@ accountBenefitSync = Manage shared files from any device accountBenefitMoz = Learn about other { -mozilla } services signOut = Sign out okButton = OK +continueButton = Continue +cancelButton = Cancel +deleteConfirmation = Are you sure you want to delete this file? downloadingTitle = Downloading noStreamsWarning = This browser might not be able to decrypt a file this big. noStreamsOptionCopy = Copy the link to open in another browser diff --git a/public/locales/en-GB/send.ftl b/public/locales/en-GB/send.ftl index 1fb7a3f88..822351c65 100644 --- a/public/locales/en-GB/send.ftl +++ b/public/locales/en-GB/send.ftl @@ -139,6 +139,9 @@ accountBenefitSync = Manage shared files from any device accountBenefitMoz = Learn about other { -mozilla } services signOut = Sign out okButton = OK +continueButton = Continue +cancelButton = Cancel +deleteConfirmation = Are you sure you want to delete this file? downloadingTitle = Downloading noStreamsWarning = This browser might not be able to decrypt a file this big. noStreamsOptionCopy = Copy the link to open in another browser diff --git a/public/locales/en-US/send.ftl b/public/locales/en-US/send.ftl index 36e482f4f..b7b6ac9dd 100644 --- a/public/locales/en-US/send.ftl +++ b/public/locales/en-US/send.ftl @@ -131,6 +131,9 @@ accountBenefitSync = Manage shared files from any device accountBenefitMoz = Learn about other { -mozilla } services signOut = Sign out okButton = OK +continueButton = Continue +cancelButton = Cancel +deleteConfirmation = Are you sure you want to delete this file? downloadingTitle = Downloading noStreamsWarning = This browser might not be able to decrypt a file this big. noStreamsOptionCopy = Copy the link to open in another browser diff --git a/public/locales/nl/send.ftl b/public/locales/nl/send.ftl index ba7388021..f5d9cbcf6 100644 --- a/public/locales/nl/send.ftl +++ b/public/locales/nl/send.ftl @@ -139,6 +139,9 @@ accountBenefitSync = Gedeelde bestanden vanaf andere apparaten beheren accountBenefitMoz = Info over andere services van { -mozilla } signOut = Afmelden okButton = OK +continueButton = Doorgaan +cancelButton = Annuleren +deleteConfirmation = Weet je zeker dat je dit bestand wilt verwijderen? downloadingTitle = Downloaden noStreamsWarning = Deze browser kan een bestand van deze omvang mogelijk niet ontcijferen. noStreamsOptionCopy = Koppeling kopiëren om in een andere browser te openen diff --git a/server/clientConstants.js b/server/clientConstants.js index 37c69be96..913ea47ca 100644 --- a/server/clientConstants.js +++ b/server/clientConstants.js @@ -19,7 +19,8 @@ module.exports = { PRIMARY: config.ui_color_primary, ACCENT: config.ui_color_accent }, - CUSTOM_ASSETS: config.ui_custom_assets + CUSTOM_ASSETS: config.ui_custom_assets, + SHOW_DELETE_CONFIRM: config.show_delete_confirm }, DEFAULTS: { DOWNLOADS: config.default_downloads, diff --git a/server/config.js b/server/config.js index 7c0f43ccf..199dcd78c 100644 --- a/server/config.js +++ b/server/config.js @@ -175,7 +175,8 @@ const conf = convict({ }, custom_description: { format: String, - default: 'Encrypt and send files with a link that automatically expires to ensure your important documents don’t stay online forever.', + default: + 'Encrypt and send files with a link that automatically expires to ensure your important documents don’t stay online forever.', env: 'CUSTOM_DESCRIPTION' }, detect_base_url: { @@ -223,6 +224,11 @@ const conf = convict({ default: '', env: 'FXA_CSP_PROFILEIMAGE_URL' }, + show_delete_confirm: { + format: Boolean, + default: false, + env: 'SHOW_DELETE_CONFIRM' + }, survey_url: { format: String, default: '',