feat(layout/note_actions): integrate refresh backend log

This commit is contained in:
Elian Doran
2025-12-15 08:00:03 +02:00
parent ca39282269
commit 3e19a163c2
3 changed files with 26 additions and 7 deletions

View File

@@ -81,7 +81,7 @@ export const POPUP_HIDDEN_FLOATING_BUTTONS: FloatingButtonsList = [
const isNewLayout = isExperimentalFeatureEnabled("new-layout"); const isNewLayout = isExperimentalFeatureEnabled("new-layout");
function RefreshBackendLogButton({ note, parentComponent, noteContext, isDefaultViewMode }: FloatingButtonContext) { 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 && <FloatingButton return isEnabled && <FloatingButton
text={t("backend_log.refresh")} text={t("backend_log.refresh")}
icon="bx bx-refresh" icon="bx bx-refresh"

View File

@@ -32,7 +32,7 @@ export default function NoteActions() {
<div className="ribbon-button-container" style={{ contain: "none" }}> <div className="ribbon-button-container" style={{ contain: "none" }}>
{isNewLayout && ( {isNewLayout && (
<> <>
{note && ntxId && <NoteActionsCustom note={note} ntxId={ntxId} />} {note && ntxId && noteContext && <NoteActionsCustom note={note} ntxId={ntxId} noteContext={noteContext} />}
<MovePaneButton direction="left" /> <MovePaneButton direction="left" />
<MovePaneButton direction="right" /> <MovePaneButton direction="right" />
<ClosePaneButton /> <ClosePaneButton />

View File

@@ -1,6 +1,8 @@
import { NoteType } from "@triliumnext/commons"; import { NoteType } from "@triliumnext/commons";
import { useContext } from "preact/hooks"; import { useContext } from "preact/hooks";
import Component from "../../components/component";
import NoteContext from "../../components/note_context";
import FNote from "../../entities/fnote"; import FNote from "../../entities/fnote";
import { t } from "../../services/i18n"; import { t } from "../../services/i18n";
import { downloadFileNote, openNoteExternally } from "../../services/open"; import { downloadFileNote, openNoteExternally } from "../../services/open";
@@ -14,10 +16,13 @@ import { buildUploadNewImageRevisionListener } from "./ImagePropertiesTab";
interface NoteActionsCustomProps { interface NoteActionsCustomProps {
note: FNote; note: FNote;
ntxId: string; ntxId: string;
noteContext: NoteContext;
} }
interface NoteActionsCustomInnerProps extends NoteActionsCustomProps { interface NoteActionsCustomInnerProps extends NoteActionsCustomProps {
noteType: NoteType; noteType: NoteType;
isDefaultViewMode: boolean;
parentComponent: Component;
} }
/** /**
@@ -26,13 +31,17 @@ interface NoteActionsCustomInnerProps extends NoteActionsCustomProps {
*/ */
export default function NoteActionsCustom(props: NoteActionsCustomProps) { export default function NoteActionsCustom(props: NoteActionsCustomProps) {
const noteType = useNoteProperty(props.note, "type"); const noteType = useNoteProperty(props.note, "type");
const innerProps: NoteActionsCustomInnerProps | undefined = noteType && { const parentComponent = useContext(ParentComponent);
const innerProps: NoteActionsCustomInnerProps | null | undefined = noteType && parentComponent && {
...props, ...props,
noteType noteType,
isDefaultViewMode: props.noteContext.viewScope?.viewMode === "default",
parentComponent
}; };
return (innerProps && return (innerProps &&
<div className="note-actions-custom"> <div className="note-actions-custom">
<RefreshButton {...innerProps} />
<CopyReferenceToClipboardButton {...innerProps} /> <CopyReferenceToClipboardButton {...innerProps} />
<NoteActionsCustomInner {...innerProps} /> <NoteActionsCustomInner {...innerProps} />
</div> </div>
@@ -108,9 +117,7 @@ function DownloadFileButton({ note }: NoteActionsCustomInnerProps) {
); );
} }
function CopyReferenceToClipboardButton({ ntxId, noteType }: NoteActionsCustomInnerProps) { function CopyReferenceToClipboardButton({ ntxId, noteType, parentComponent }: NoteActionsCustomInnerProps) {
const parentComponent = useContext(ParentComponent);
return (["mermaid", "canvas", "mindMap", "image"].includes(noteType) && return (["mermaid", "canvas", "mindMap", "image"].includes(noteType) &&
<ActionButton <ActionButton
text={t("image_properties.copy_reference_to_clipboard")} text={t("image_properties.copy_reference_to_clipboard")}
@@ -120,3 +127,15 @@ function CopyReferenceToClipboardButton({ ntxId, noteType }: NoteActionsCustomIn
); );
} }
//#endregion //#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 })}
/>
);
}