remove all alert() usages, fixes #3086

This commit is contained in:
zadam 2022-08-24 23:20:05 +02:00
parent e70a7bad1a
commit 24286c2a6c
8 changed files with 19 additions and 19 deletions

View File

@ -11,7 +11,7 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) {
branchIdsToMove = filterSearchBranches(branchIdsToMove); branchIdsToMove = filterSearchBranches(branchIdsToMove);
if (beforeBranchId === 'root') { if (beforeBranchId === 'root') {
alert('Cannot move notes before root note.'); toastService.showError('Cannot move notes before root note.');
return; return;
} }
@ -19,7 +19,7 @@ async function moveBeforeBranch(branchIdsToMove, beforeBranchId) {
const resp = await server.put(`branches/${branchIdToMove}/move-before/${beforeBranchId}`); const resp = await server.put(`branches/${branchIdToMove}/move-before/${beforeBranchId}`);
if (!resp.success) { if (!resp.success) {
alert(resp.message); toastService.showError(resp.message);
return; return;
} }
} }
@ -32,7 +32,7 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) {
const afterNote = await froca.getBranch(afterBranchId).getNote(); const afterNote = await froca.getBranch(afterBranchId).getNote();
if (afterNote.noteId === 'root' || afterNote.noteId === hoistedNoteService.getHoistedNoteId()) { if (afterNote.noteId === 'root' || afterNote.noteId === hoistedNoteService.getHoistedNoteId()) {
alert('Cannot move notes after root note.'); toastService.showError('Cannot move notes after root note.');
return; return;
} }
@ -42,7 +42,7 @@ async function moveAfterBranch(branchIdsToMove, afterBranchId) {
const resp = await server.put(`branches/${branchIdToMove}/move-after/${afterBranchId}`); const resp = await server.put(`branches/${branchIdToMove}/move-after/${afterBranchId}`);
if (!resp.success) { if (!resp.success) {
alert(resp.message); toastService.showError(resp.message);
return; return;
} }
} }
@ -62,7 +62,7 @@ async function moveToParentNote(branchIdsToMove, newParentBranchId) {
const resp = await server.put(`branches/${branchIdToMove}/move-to/${newParentBranchId}`); const resp = await server.put(`branches/${branchIdToMove}/move-to/${newParentBranchId}`);
if (!resp.success) { if (!resp.success) {
alert(resp.message); toastService.showError(resp.message);
return; return;
} }
} }
@ -127,7 +127,7 @@ async function moveNodeUpInHierarchy(node) {
const resp = await server.put('branches/' + node.data.branchId + '/move-after/' + node.getParent().data.branchId); const resp = await server.put('branches/' + node.data.branchId + '/move-after/' + node.getParent().data.branchId);
if (!resp.success) { if (!resp.success) {
alert(resp.message); toastService.showError(resp.message);
return; return;
} }
@ -203,7 +203,7 @@ async function cloneNoteToBranch(childNoteId, parentBranchId, prefix) {
}); });
if (!resp.success) { if (!resp.success) {
alert(resp.message); toastService.showError(resp.message);
} }
} }
@ -213,7 +213,7 @@ async function cloneNoteToNote(childNoteId, parentNoteId, prefix) {
}); });
if (!resp.success) { 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); const resp = await server.put('notes/' + noteId + '/clone-after/' + afterBranchId);
if (!resp.success) { if (!resp.success) {
alert(resp.message); toastService.showError(resp.message);
} }
} }

View File

@ -179,7 +179,7 @@ export default class Entrypoints extends Component {
const resp = await server.post("sql/execute/" + note.noteId); const resp = await server.post("sql/execute/" + note.noteId);
if (!resp.success) { 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}); await appContext.triggerEvent('sqlQueryResults', {ntxId: ntxId, results: resp.results});

View File

@ -175,7 +175,7 @@ async function consumeFrontendUpdateData() {
else { else {
console.log("nonProcessedEntityChanges causing the timeout", nonProcessedEntityChanges); 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.`);
} }
} }

View File

@ -4,6 +4,7 @@ import dateNoteService from "../../services/date_notes.js";
import server from "../../services/server.js"; import server from "../../services/server.js";
import appContext from "../../services/app_context.js"; import appContext from "../../services/app_context.js";
import RightDropdownButtonWidget from "./right_dropdown_button.js"; import RightDropdownButtonWidget from "./right_dropdown_button.js";
import toastService from "../../services/toast.js";
const DROPDOWN_TPL = ` const DROPDOWN_TPL = `
<div class="calendar-dropdown-widget"> <div class="calendar-dropdown-widget">
@ -62,7 +63,7 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
this.hideDropdown(); this.hideDropdown();
} }
else { else {
alert("Cannot find day note"); toastService.showError("Cannot find day note");
} }
}); });
} }

View File

@ -142,7 +142,7 @@ export default class ExportDialog extends BasicWidget {
if (!exportType) { if (!exportType) {
// this shouldn't happen as we always choose default export type // 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; return;
} }

View File

@ -1,5 +1,6 @@
import server from "../../../services/server.js"; import server from "../../../services/server.js";
import dialogService from "../../dialog.js"; import dialogService from "../../dialog.js";
import toastService from "../../../services/toast.js";
const TPL = ` const TPL = `
<h4>ETAPI</h4> <h4>ETAPI</h4>
@ -56,7 +57,7 @@ export default class EtapiOptions {
}); });
if (!tokenName.trim()) { if (!tokenName.trim()) {
alert("Token name can't be empty"); toastService.showError("Token name can't be empty");
return; return;
} }

View File

@ -49,7 +49,7 @@ export default class ChangePasswordOptions {
const options = await server.get('options'); const options = await server.get('options');
this.optionsLoaded(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(''); this.$newPassword2.val('');
if (newPassword1 !== newPassword2) { if (newPassword1 !== newPassword2) {
alert("New passwords are not the same."); toastService.showError("New passwords are not the same.");
return false; return false;
} }
@ -83,7 +83,7 @@ export default class ChangePasswordOptions {
'new_password': newPassword1 'new_password': newPassword1
}).then(result => { }).then(result => {
if (result.success) { 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 // password changed so current protected session is invalid and needs to be cleared
protectedSessionHolder.resetProtectedSession(); protectedSessionHolder.resetProtectedSession();

View File

@ -513,8 +513,6 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
if (isHoistedNote) { if (isHoistedNote) {
const $unhoistButton = $('<span class="tree-item-button unhoist-button bx bx-door-open" title="Unhoist"></span>'); const $unhoistButton = $('<span class="tree-item-button unhoist-button bx bx-door-open" title="Unhoist"></span>');
$unhoistButton.on('click', () => alert("bebe"));
$span.append($unhoistButton); $span.append($unhoistButton);
} }