From 24286c2a6c382ef41c162cb37a813ca50f3612b9 Mon Sep 17 00:00:00 2001 From: zadam Date: Wed, 24 Aug 2022 23:20:05 +0200 Subject: [PATCH] remove all alert() usages, fixes #3086 --- src/public/app/services/branches.js | 18 +++++++++--------- src/public/app/services/entrypoints.js | 2 +- src/public/app/services/ws.js | 2 +- src/public/app/widgets/buttons/calendar.js | 3 ++- src/public/app/widgets/dialogs/export.js | 2 +- .../app/widgets/dialogs/options/etapi.js | 3 ++- .../app/widgets/dialogs/options/password.js | 6 +++--- src/public/app/widgets/note_tree.js | 2 -- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/public/app/services/branches.js b/src/public/app/services/branches.js index c96c46cd3..ef04344b9 100644 --- a/src/public/app/services/branches.js +++ b/src/public/app/services/branches.js @@ -11,7 +11,7 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) { branchIdsToMove = filterSearchBranches(branchIdsToMove); if (beforeBranchId === 'root') { - alert('Cannot move notes before root note.'); + toastService.showError('Cannot move notes before root note.'); return; } @@ -19,7 +19,7 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) { const resp = await server.put(`branches/${branchIdToMove}/move-before/${beforeBranchId}`); if (!resp.success) { - alert(resp.message); + toastService.showError(resp.message); return; } } @@ -32,7 +32,7 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) { const afterNote = await froca.getBranch(afterBranchId).getNote(); if (afterNote.noteId === 'root' || afterNote.noteId === hoistedNoteService.getHoistedNoteId()) { - alert('Cannot move notes after root note.'); + toastService.showError('Cannot move notes after root note.'); return; } @@ -42,7 +42,7 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) { const resp = await server.put(`branches/${branchIdToMove}/move-after/${afterBranchId}`); if (!resp.success) { - alert(resp.message); + toastService.showError(resp.message); return; } } @@ -62,7 +62,7 @@ async function moveToParentNote(branchIdsToMove, newParentBranchId) { const resp = await server.put(`branches/${branchIdToMove}/move-to/${newParentBranchId}`); if (!resp.success) { - alert(resp.message); + toastService.showError(resp.message); return; } } @@ -127,7 +127,7 @@ async function moveNodeUpInHierarchy(node) { const resp = await server.put('branches/' + node.data.branchId + '/move-after/' + node.getParent().data.branchId); if (!resp.success) { - alert(resp.message); + toastService.showError(resp.message); return; } @@ -203,7 +203,7 @@ async function cloneNoteToBranch(childNoteId, parentBranchId, prefix) { }); if (!resp.success) { - alert(resp.message); + toastService.showError(resp.message); } } @@ -213,7 +213,7 @@ async function cloneNoteToNote(childNoteId, parentNoteId, prefix) { }); if (!resp.success) { - alert(resp.message); + toastService.showError(resp.message); } } @@ -222,7 +222,7 @@ async function cloneNoteAfter(noteId, afterBranchId) { const resp = await server.put('notes/' + noteId + '/clone-after/' + afterBranchId); if (!resp.success) { - alert(resp.message); + toastService.showError(resp.message); } } diff --git a/src/public/app/services/entrypoints.js b/src/public/app/services/entrypoints.js index 44033f766..116877976 100644 --- a/src/public/app/services/entrypoints.js +++ b/src/public/app/services/entrypoints.js @@ -179,7 +179,7 @@ export default class Entrypoints extends Component { const resp = await server.post("sql/execute/" + note.noteId); if (!resp.success) { - alert("Error occurred while executing SQL query: " + resp.message); + toastService.showError("Error occurred while executing SQL query: " + resp.message); } await appContext.triggerEvent('sqlQueryResults', {ntxId: ntxId, results: resp.results}); diff --git a/src/public/app/services/ws.js b/src/public/app/services/ws.js index 512096a02..113d1f0ad 100644 --- a/src/public/app/services/ws.js +++ b/src/public/app/services/ws.js @@ -175,7 +175,7 @@ async function consumeFrontendUpdateData() { else { console.log("nonProcessedEntityChanges causing the timeout", nonProcessedEntityChanges); - alert(`Encountered error "${e.message}", check out the console.`); + toastService.showError(`Encountered error "${e.message}", check out the console.`); } } diff --git a/src/public/app/widgets/buttons/calendar.js b/src/public/app/widgets/buttons/calendar.js index d7a396a8e..3c60ec132 100644 --- a/src/public/app/widgets/buttons/calendar.js +++ b/src/public/app/widgets/buttons/calendar.js @@ -4,6 +4,7 @@ import dateNoteService from "../../services/date_notes.js"; import server from "../../services/server.js"; import appContext from "../../services/app_context.js"; import RightDropdownButtonWidget from "./right_dropdown_button.js"; +import toastService from "../../services/toast.js"; const DROPDOWN_TPL = `
@@ -62,7 +63,7 @@ export default class CalendarWidget extends RightDropdownButtonWidget { this.hideDropdown(); } else { - alert("Cannot find day note"); + toastService.showError("Cannot find day note"); } }); } diff --git a/src/public/app/widgets/dialogs/export.js b/src/public/app/widgets/dialogs/export.js index 5727aa5e2..075182300 100644 --- a/src/public/app/widgets/dialogs/export.js +++ b/src/public/app/widgets/dialogs/export.js @@ -142,7 +142,7 @@ export default class ExportDialog extends BasicWidget { if (!exportType) { // this shouldn't happen as we always choose default export type - alert("Choose export type first please"); + toastService.showError("Choose export type first please"); return; } diff --git a/src/public/app/widgets/dialogs/options/etapi.js b/src/public/app/widgets/dialogs/options/etapi.js index 8709a5721..b0034709d 100644 --- a/src/public/app/widgets/dialogs/options/etapi.js +++ b/src/public/app/widgets/dialogs/options/etapi.js @@ -1,5 +1,6 @@ import server from "../../../services/server.js"; import dialogService from "../../dialog.js"; +import toastService from "../../../services/toast.js"; const TPL = `

ETAPI

@@ -56,7 +57,7 @@ export default class EtapiOptions { }); if (!tokenName.trim()) { - alert("Token name can't be empty"); + toastService.showError("Token name can't be empty"); return; } diff --git a/src/public/app/widgets/dialogs/options/password.js b/src/public/app/widgets/dialogs/options/password.js index 1560ae3ad..9b5829994 100644 --- a/src/public/app/widgets/dialogs/options/password.js +++ b/src/public/app/widgets/dialogs/options/password.js @@ -49,7 +49,7 @@ export default class ChangePasswordOptions { const options = await server.get('options'); this.optionsLoaded(options); - alert("Password has been reset. Please set new password"); + toastService.showError("Password has been reset. Please set new password"); } }); @@ -74,7 +74,7 @@ export default class ChangePasswordOptions { this.$newPassword2.val(''); if (newPassword1 !== newPassword2) { - alert("New passwords are not the same."); + toastService.showError("New passwords are not the same."); return false; } @@ -83,7 +83,7 @@ export default class ChangePasswordOptions { 'new_password': newPassword1 }).then(result => { if (result.success) { - alert("Password has been changed. Trilium will be reloaded after you press OK."); + toastService.showError("Password has been changed. Trilium will be reloaded after you press OK."); // password changed so current protected session is invalid and needs to be cleared protectedSessionHolder.resetProtectedSession(); diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index 9224d67d4..41394751e 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -513,8 +513,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { if (isHoistedNote) { const $unhoistButton = $(''); - $unhoistButton.on('click', () => alert("bebe")); - $span.append($unhoistButton); }