Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(layout/note_actions): integrate refresh backend log
Elian Doran3e19a163c2b5
diff --git a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx b/apps/client/src/widgets/FloatingButtonsDefinitions.tsxindex 5cbb6f10f5..ce650aa701 100644--- a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx+++ b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx@@ -81,7 +81,7 @@ export const POPUP_HIDDEN_FLOATING_BUTTONS: FloatingButtonsList = [const isNewLayout = isExperimentalFeatureEnabled("new-layout");function RefreshBackendLogButton({ note, parentComponent, noteContext, isDefaultViewMode }: FloatingButtonContext) {- const isEnabled = (note.noteId === "_backendLog" || note.type === "render") && isDefaultViewMode;+ const isEnabled = !isNewLayout && (note.noteId === "_backendLog" || note.type === "render") && isDefaultViewMode;return isEnabled && <FloatingButtontext={t("backend_log.refresh")}icon="bx bx-refresh"diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsxindex 698945d8d5..cf2af8e09b 100644--- a/apps/client/src/widgets/ribbon/NoteActions.tsx+++ b/apps/client/src/widgets/ribbon/NoteActions.tsx@@ -32,7 +32,7 @@ export default function NoteActions() {<div className="ribbon-button-container" style={{ contain: "none" }}>{isNewLayout && (<>- {note && ntxId && <NoteActionsCustom note={note} ntxId={ntxId} />}+ {note && ntxId && noteContext && <NoteActionsCustom note={note} ntxId={ntxId} noteContext={noteContext} />}<MovePaneButton direction="left" /><MovePaneButton direction="right" /><ClosePaneButton />diff --git a/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx b/apps/client/src/widgets/ribbon/NoteActionsCustom.tsxindex 113d2ed149..dadfe9a3b3 100644--- a/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx+++ b/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx@@ -1,6 +1,8 @@import { NoteType } from "@triliumnext/commons";import { useContext } from "preact/hooks";+import Component from "../../components/component";+import NoteContext from "../../components/note_context";import FNote from "../../entities/fnote";import { t } from "../../services/i18n";import { downloadFileNote, openNoteExternally } from "../../services/open";@@ -14,10 +16,13 @@ import { buildUploadNewImageRevisionListener } from "./ImagePropertiesTab";interface NoteActionsCustomProps {note: FNote;ntxId: string;+ noteContext: NoteContext;}interface NoteActionsCustomInnerProps extends NoteActionsCustomProps {noteType: NoteType;+ isDefaultViewMode: boolean;+ parentComponent: Component;}/**@@ -26,13 +31,17 @@ interface NoteActionsCustomInnerProps extends NoteActionsCustomProps {*/export default function NoteActionsCustom(props: NoteActionsCustomProps) {const noteType = useNoteProperty(props.note, "type");- const innerProps: NoteActionsCustomInnerProps | undefined = noteType && {+ const parentComponent = useContext(ParentComponent);+ const innerProps: NoteActionsCustomInnerProps | null | undefined = noteType && parentComponent && {...props,- noteType+ noteType,+ isDefaultViewMode: props.noteContext.viewScope?.viewMode === "default",+ parentComponent};return (innerProps &&<div className="note-actions-custom">+ <RefreshButton {...innerProps} /><CopyReferenceToClipboardButton {...innerProps} /><NoteActionsCustomInner {...innerProps} /></div>@@ -108,9 +117,7 @@ function DownloadFileButton({ note }: NoteActionsCustomInnerProps) {);}-function CopyReferenceToClipboardButton({ ntxId, noteType }: NoteActionsCustomInnerProps) {- const parentComponent = useContext(ParentComponent);-+function CopyReferenceToClipboardButton({ ntxId, noteType, parentComponent }: NoteActionsCustomInnerProps) {return (["mermaid", "canvas", "mindMap", "image"].includes(noteType) &&<ActionButtontext={t("image_properties.copy_reference_to_clipboard")}@@ -120,3 +127,15 @@ function CopyReferenceToClipboardButton({ ntxId, noteType }: NoteActionsCustomIn);}//#endregion++function RefreshButton({ note, noteType, isDefaultViewMode, parentComponent, noteContext }: NoteActionsCustomInnerProps) {+ const isEnabled = (note.noteId === "_backendLog" || noteType === "render") && isDefaultViewMode;++ return (isEnabled &&+ <ActionButton+ text={t("backend_log.refresh")}+ icon="bx bx-refresh"+ onClick={() => parentComponent.triggerEvent("refreshData", { ntxId: noteContext.ntxId })}+ />+ );+}