Skip to content

Commit

Permalink
Add confirmation dialog before deleting label
Browse files Browse the repository at this point in the history
Close #7934
  • Loading branch information
wrdhub authored and charlag committed Nov 21, 2024
1 parent d72d321 commit 38600c8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/common/misc/TranslationKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1803,3 +1803,4 @@ export type TranslationKeyType =
| "editLabel_action"
| "importantLabel_label"
| "labelLimitExceeded_msg"
| "confirmDeleteLabel_msg"
12 changes: 11 additions & 1 deletion src/mail-app/mail/view/MailView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,16 @@ export class MailView extends BaseTopLevelView implements TopLevelView<MailViewA
await showEditLabelDialog(null, this.mailViewModel, label)
}

private async showLabelDeleteDialog(label: MailFolder) {
const confirmed = await Dialog.confirm(() =>
lang.get("confirmDeleteLabel_msg", {
"{1}": label.name,
}),
)
if (!confirmed) return
await this.mailViewModel.deleteLabel(label)
}

private renderMailboxLabelItems(mailboxDetail: MailboxDetail, inEditMode: boolean, onEditMailbox: () => void): Children {
return [
m(
Expand Down Expand Up @@ -842,7 +852,7 @@ export class MailView extends BaseTopLevelView implements TopLevelView<MailViewA
label: "delete_action",
icon: Icons.Trash,
click: () => {
this.mailViewModel.deleteLabel(label)
this.showLabelDeleteDialog(label)
},
},
],
Expand Down
3 changes: 2 additions & 1 deletion src/mail-app/translations/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,7 @@ export default {
"yourCalendars_label": "Deine Kalender",
"yourFolders_action": "DEINE ORDNER",
"yourMessage_label": "Deine Nachricht",
"you_label": "Du"
"you_label": "Du",
"confirmDeleteLabel_msg": "Möchtest du wirklich das Label \"{1}\" löschen?"
}
}
3 changes: 2 additions & 1 deletion src/mail-app/translations/de_sie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,7 @@ export default {
"yourCalendars_label": "Deine Kalender",
"yourFolders_action": "Ihre ORDNER",
"yourMessage_label": "Ihre Nachricht",
"you_label": "Sie"
"you_label": "Sie",
"confirmDeleteLabel_msg": "Möchten Sie wirklich das Label \"{1}\" löschen?"
}
}
3 changes: 2 additions & 1 deletion src/mail-app/translations/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1815,6 +1815,7 @@ export default {
"yourCalendars_label": "Your calendars",
"yourFolders_action": "YOUR FOLDERS",
"yourMessage_label": "Your message",
"you_label": "You"
"you_label": "You",
"confirmDeleteLabel_msg": "Are you sure that you want to delete the label \"{1}\"?"
}
}

0 comments on commit 38600c8

Please sign in to comment.