mirror of
https://github.com/zadam/trilium.git
synced 2025-12-22 15:24:24 +01:00
feat(client/bundle): use new toast for script errors with known note ID
This commit is contained in:
parent
2c25786fa2
commit
f8bf301d12
@ -67,7 +67,8 @@ function showErrorTitleAndMessage(title: string, message: string, timeout = 1000
|
|||||||
export async function showErrorForScriptNote(noteId: string, message: string) {
|
export async function showErrorForScriptNote(noteId: string, message: string) {
|
||||||
const note = await froca.getNote(noteId, true);
|
const note = await froca.getNote(noteId, true);
|
||||||
|
|
||||||
addToast({
|
showPersistent({
|
||||||
|
id: `custom-widget-failure-${noteId}`,
|
||||||
title: note?.title ?? "",
|
title: note?.title ?? "",
|
||||||
icon: note?.getIcon() ?? "bx bx-error-circle",
|
icon: note?.getIcon() ?? "bx bx-error-circle",
|
||||||
message,
|
message,
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import { isValidElement, VNode } from "preact";
|
import { isValidElement, VNode } from "preact";
|
||||||
|
|
||||||
import Component, { TypedComponent } from "../components/component.js";
|
import Component, { TypedComponent } from "../components/component.js";
|
||||||
import froca from "../services/froca.js";
|
import froca from "../services/froca.js";
|
||||||
import { t } from "../services/i18n.js";
|
import { t } from "../services/i18n.js";
|
||||||
import toastService from "../services/toast.js";
|
import toastService, { showErrorForScriptNote } from "../services/toast.js";
|
||||||
import { renderReactWidget } from "./react/react_utils.jsx";
|
import { renderReactWidget } from "./react/react_utils.jsx";
|
||||||
|
|
||||||
export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedComponent<T> {
|
export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedComponent<T> {
|
||||||
@ -56,9 +57,9 @@ export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedCompon
|
|||||||
optChild(condition: boolean, ...components: (T | VNode)[]) {
|
optChild(condition: boolean, ...components: (T | VNode)[]) {
|
||||||
if (condition) {
|
if (condition) {
|
||||||
return this.child(...components);
|
return this.child(...components);
|
||||||
} else {
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
return this;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
id(id: string) {
|
id(id: string) {
|
||||||
@ -172,16 +173,11 @@ export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedCompon
|
|||||||
const noteId = this._noteId;
|
const noteId = this._noteId;
|
||||||
if (this._noteId) {
|
if (this._noteId) {
|
||||||
froca.getNote(noteId, true).then((note) => {
|
froca.getNote(noteId, true).then((note) => {
|
||||||
toastService.showPersistent({
|
showErrorForScriptNote(noteId, t("toast.widget-error.message-custom", {
|
||||||
id: `custom-widget-failure-${noteId}`,
|
id: noteId,
|
||||||
title: t("toast.widget-error.title"),
|
title: note?.title,
|
||||||
icon: "bx bx-error-circle",
|
message: e.message || e.toString()
|
||||||
message: t("toast.widget-error.message-custom", {
|
}));
|
||||||
id: noteId,
|
|
||||||
title: note?.title,
|
|
||||||
message: e.message || e.toString()
|
|
||||||
})
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
toastService.showPersistent({
|
toastService.showPersistent({
|
||||||
@ -213,7 +209,7 @@ export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedCompon
|
|||||||
|
|
||||||
toggleInt(show: boolean | null | undefined) {
|
toggleInt(show: boolean | null | undefined) {
|
||||||
this.$widget.toggleClass("hidden-int", !show)
|
this.$widget.toggleClass("hidden-int", !show)
|
||||||
.toggleClass("visible", !!show);
|
.toggleClass("visible", !!show);
|
||||||
}
|
}
|
||||||
|
|
||||||
isHiddenInt() {
|
isHiddenInt() {
|
||||||
@ -222,7 +218,7 @@ export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedCompon
|
|||||||
|
|
||||||
toggleExt(show: boolean | null | "" | undefined) {
|
toggleExt(show: boolean | null | "" | undefined) {
|
||||||
this.$widget.toggleClass("hidden-ext", !show)
|
this.$widget.toggleClass("hidden-ext", !show)
|
||||||
.toggleClass("visible", !!show);
|
.toggleClass("visible", !!show);
|
||||||
}
|
}
|
||||||
|
|
||||||
isHiddenExt() {
|
isHiddenExt() {
|
||||||
@ -250,9 +246,9 @@ export class TypedBasicWidget<T extends TypedComponent<any>> extends TypedCompon
|
|||||||
getClosestNtxId() {
|
getClosestNtxId() {
|
||||||
if (this.$widget) {
|
if (this.$widget) {
|
||||||
return this.$widget.closest("[data-ntx-id]").attr("data-ntx-id");
|
return this.$widget.closest("[data-ntx-id]").attr("data-ntx-id");
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup() {}
|
cleanup() {}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user