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");
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
text={t("backend_log.refresh")}
icon="bx bx-refresh"

View File

@@ -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 />

View File

@@ -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) &&
<ActionButton
text={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 })}
/>
);
}