Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the option to show a delete confirmation modal #200

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions app/controller.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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();
});

Expand Down
36 changes: 36 additions & 0 deletions app/ui/confirmDeleteDialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const html = require('choo/html');

module.exports = function(archive) {
return function(state, emit, close) {
return html`
<send-ok-dialog class="flex flex-col max-w-sm p-4 m-auto">
<h2 class="text-center text-xl font-bold m-8 leading-normal">
${state.translate('deleteConfirmation')}
</h2>
<div class="grid grid-cols-2 gap-4">
<button
class="border-2 border-primary cursor-pointer py-4 px-6 font-semibold rounded-lg w-full flex-shrink-0"
onclick="${close}"
title="${state.translate('cancelButton')}"
>
${state.translate('cancelButton')}
</button>
<button
class="btn rounded-lg w-full flex-shrink-0"
onclick="${confirm}"
title="${state.translate('continueButton')}"
>
${state.translate('continueButton')}
</button>
</div>
</send-ok-dialog>
`;

function confirm(event) {
console.log(state);
event.stopPropagation();
emit('confirmedDelete', archive);
close();
}
};
};
3 changes: 3 additions & 0 deletions public/locales/de/send.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = Stornieren
deleteConfirmation = Sind Sie sicher, dass Sie diesen Datei löschen möchten?
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
Expand Down
3 changes: 3 additions & 0 deletions public/locales/en-CA/send.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions public/locales/en-GB/send.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions public/locales/en-US/send.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions public/locales/nl/send.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion server/clientConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 7 additions & 1 deletion server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: '',
Expand Down