Skip to content

Build your personal knowledge base with Trilium Notes

feat(mobile/note_actions): basic integration of note paths

Elian Doran171d948a0065
diff --git a/apps/client/src/widgets/layout/StatusBar.tsx b/apps/client/src/widgets/layout/StatusBar.tsx
index d05fa113df..bfc9b02648 100644
--- a/apps/client/src/widgets/layout/StatusBar.tsx
+++ b/apps/client/src/widgets/layout/StatusBar.tsx
@@ -56,7 +56,7 @@ export default function StatusBar() {
similarNotesShown: activePane === "similar-notes",
setSimilarNotesShown: (shown) => setActivePane(shown && "similar-notes")
};
- const isHiddenNote = note?.isInHiddenSubtree();
+ const isHiddenNote = note?.isHiddenCompletely();
return (
<div className="status-bar">
diff --git a/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx b/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx
index af4a6cabc1..8116eceb6e 100644
--- a/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx
+++ b/apps/client/src/widgets/mobile_widgets/mobile_detail_menu.tsx
@@ -1,6 +1,6 @@
import { createPortal, useState } from "preact/compat";
-import FNote from "../../entities/fnote";
+import FNote, { NotePathRecord } from "../../entities/fnote";
import { t } from "../../services/i18n";
import { ViewScope } from "../../services/link";
import note_create from "../../services/note_create";
@@ -11,12 +11,15 @@ import { useNoteContext } from "../react/hooks";
import Modal from "../react/Modal";
import { NoteContextMenu } from "../ribbon/NoteActions";
import NoteActionsCustom from "../ribbon/NoteActionsCustom";
+import { NotePathsWidget, useSortedNotePaths } from "../ribbon/NotePathsTab";
export default function MobileDetailMenu() {
- const { note, noteContext, parentComponent, ntxId, viewScope } = useNoteContext();
+ const { note, noteContext, parentComponent, ntxId, viewScope, hoistedNoteId } = useNoteContext();
const subContexts = noteContext?.getMainContext().getSubContexts() ?? [];
const isMainContext = noteContext?.isMainContext();
- const [ modalShown, setModalShown ] = useState(false);
+ const [ backlinksModalShown, setBacklinksModalShown ] = useState(false);
+ const [ notePathsModalShown, setNotePathsModalShown ] = useState(false);
+ const sortedNotePaths = useSortedNotePaths(note, hoistedNoteId);
function closePane() {
// Wait first for the context menu to be dismissed, otherwise the backdrop stays on.
@@ -31,7 +34,14 @@ export default function MobileDetailMenu() {
<NoteContextMenu
note={note} noteContext={noteContext}
extraItems={<>
- <Backlinks note={note} viewScope={viewScope} setModalShown={setModalShown} />
+ <Backlinks note={note} viewScope={viewScope} setModalShown={setBacklinksModalShown} />
+ <FormDropdownDivider />
+ <FormListItem
+ icon="bx bx-directions"
+ onClick={() => setNotePathsModalShown(true)}
+ disabled={(sortedNotePaths?.length ?? 0) <= 1}
+ >{t("status_bar.note_paths", { count: sortedNotePaths?.length })}</FormListItem>
+ <FormDropdownDivider />
{noteContext && ntxId && <NoteActionsCustom note={note} noteContext={noteContext} ntxId={ntxId} />}
<FormListItem
@@ -64,7 +74,10 @@ export default function MobileDetailMenu() {
)}
{createPortal((
- <BacklinksModal note={note} modalShown={modalShown} setModalShown={setModalShown} />
+ <>
+ <BacklinksModal note={note} modalShown={backlinksModalShown} setModalShown={setBacklinksModalShown} />
+ <NotePathsModal note={note} modalShown={notePathsModalShown} notePath={noteContext?.notePath} sortedNotePaths={sortedNotePaths} setModalShown={setNotePathsModalShown} />
+ </>
), document.body)}
</div>
);
@@ -74,14 +87,11 @@ function Backlinks({ note, viewScope, setModalShown }: { note: FNote, viewScope?
const count = useBacklinkCount(note, viewScope?.viewMode === "default");
return (
- <>
- <FormListItem
- icon="bx bx-link"
- onClick={() => setModalShown(true)}
- disabled={count === 0}
- >{t("status_bar.backlinks", { count })}</FormListItem>
- <FormDropdownDivider />
- </>
+ <FormListItem
+ icon="bx bx-link"
+ onClick={() => setModalShown(true)}
+ disabled={count === 0}
+ >{t("status_bar.backlinks", { count })}</FormListItem>
);
}
@@ -100,3 +110,24 @@ function BacklinksModal({ note, modalShown, setModalShown }: { note: FNote | nul
</Modal>
);
}
+
+function NotePathsModal({ note, modalShown, notePath, sortedNotePaths, setModalShown }: { note: FNote | null | undefined, modalShown: boolean, sortedNotePaths: NotePathRecord[] | undefined, notePath: string | null | undefined, setModalShown: (shown: boolean) => void }) {
+ return (
+ <Modal
+ className="note-paths-modal"
+ size="md"
+ title={t("note_paths.title")}
+ show={modalShown}
+ onHidden={() => setModalShown(false)}
+ >
+ <ul className="note-paths-items">
+ {note && (
+ <NotePathsWidget
+ sortedNotePaths={sortedNotePaths}
+ currentNotePath={notePath}
+ />
+ )}
+ </ul>
+ </Modal>
+ );
+}