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(mobile): pair recent changes with deleted notes
Elian Doranf31da02268a2
diff --git a/apps/client/src/widgets/buttons/global_menu.spec.tsx b/apps/client/src/widgets/buttons/global_menu.spec.tsxindex 87b04bca9d..d2763f6063 100644--- a/apps/client/src/widgets/buttons/global_menu.spec.tsx+++ b/apps/client/src/widgets/buttons/global_menu.spec.tsx@@ -301,7 +301,6 @@ describe("GlobalMenu", () => {ctrl.mobile = true;const { topLevel, advanced } = await openAdvanced();- expect(topLevel).toContain("global_menu.show_deleted_notes");for (const key of [ "global_menu.open_new_window", "global_menu.show-cheatsheet", "global_menu.show_shared_notes_subtree","global_menu.show_space_usage", "global_menu.switch_to_desktop_version" ]) {expect(topLevel.some((row) => row?.startsWith(key))).toBe(false);@@ -313,20 +312,27 @@ describe("GlobalMenu", () => {expect([ ...topLevel, ...advanced ].some((row) => row?.startsWith("global_menu.show-cheatsheet"))).toBe(false);});- it("sets fullscreen and Zen mode side by side on a phone, and as rows elsewhere", async () => {- const pairOf = (scope: Element | null | undefined) => [ ...scope?.querySelectorAll(":scope > .form-list-row > .form-list-col") ?? [] ]- .map((col) => col.textContent?.trim());+ it("pairs the history views, and fullscreen with Zen mode, on a phone, and keeps them as rows elsewhere", async () => {+ const pairsOf = (scope: Element | null | undefined) => [ ...scope?.querySelectorAll(":scope > .form-list-row") ?? [] ]+ .map((row) => [ ...row.querySelectorAll(":scope > .form-list-col") ].map((col) => col.textContent?.trim()));+ const pairedKeys = [ "recent_changes.title", "global_menu.show_deleted_notes", "global_menu.toggle_fullscreen", "global_menu.toggle-zen-mode" ];const desktop = await openSubmenu("global_menu.advanced");- expect(pairOf(desktop.topLevelScroll)).toEqual([]);+ expect(pairsOf(desktop.topLevelScroll)).toEqual([]);+ expect(desktop.topLevel).toContain("global_menu.show_deleted_notes");expect(desktop.topLevel).toContain("global_menu.toggle_fullscreen");expect(desktop.topLevel.some((row) => row?.startsWith("global_menu.toggle-zen-mode"))).toBe(true);render(null, container ?? document.body);ctrl.mobile = true;const phone = await openSubmenu("global_menu.advanced");- expect(pairOf(phone.topLevelScroll)).toEqual([ "global_menu.fullscreen", "global_menu.toggle-zen-mode" ]);- expect(phone.topLevel.some((row) => row?.startsWith("global_menu.toggle_fullscreen"))).toBe(false);- expect(phone.topLevel.some((row) => row?.startsWith("global_menu.toggle-zen-mode"))).toBe(false);+ expect(phone.topLevel[0]).toBe("global_menu.search_notes");+ expect(pairsOf(phone.topLevelScroll)).toEqual([+ [ "recent_changes.title", "global_menu.show_deleted_notes" ],+ [ "global_menu.fullscreen", "global_menu.toggle-zen-mode" ]+ ]);+ for (const key of pairedKeys) {+ expect(phone.topLevel.some((row) => row?.startsWith(key))).toBe(false);+ }});});diff --git a/apps/client/src/widgets/buttons/global_menu.tsx b/apps/client/src/widgets/buttons/global_menu.tsxindex cebb5590bc..6fcd5ba9c5 100644--- a/apps/client/src/widgets/buttons/global_menu.tsx+++ b/apps/client/src/widgets/buttons/global_menu.tsx@@ -49,17 +49,24 @@ export default function GlobalMenu({ isHorizontalLayout }: { isHorizontalLayout:</>}mobileBackdrop>- {isMobile() && <>+ {isMobile() ? <><MenuItem command="searchNotes" icon="bx bx-search" text={t("global_menu.search_notes")} />- <MenuItem command="showRecentChanges" icon="bx bx-history" text={t("recent_changes.title")} />- <FormDropdownDivider />+ <MenuItemColumns>+ <MenuItem command="showRecentChanges" icon="bx bx-history" text={t("recent_changes.title")} />+ <MenuItem command="showDeletedNotes" icon="bx bx-trash-alt" text={t("global_menu.show_deleted_notes")} />+ </MenuItemColumns>+ </> : <>+ <MenuItem command="openNewWindow" icon="bx bx-window-open" text={t("global_menu.open_new_window")} />+ <MenuItem command="showDeletedNotes" icon="bx bx-trash-alt" text={t("global_menu.show_deleted_notes")} /></>}-- {!isMobile() && <MenuItem command="openNewWindow" icon="bx bx-window-open" text={t("global_menu.open_new_window")} />}- <MenuItem command="showDeletedNotes" icon="bx bx-trash-alt" text={t("global_menu.show_deleted_notes")} /><FormDropdownDivider />- {isMobile() ? <ViewModeRow /> : <>+ {isMobile() ? (+ <MenuItemColumns>+ <MenuItem command="toggleFullscreen" icon="bx bx-expand-alt" text={t("global_menu.fullscreen")} />+ <MenuItem command="toggleZenMode" icon="bx bxs-yin-yang" text={t("global_menu.toggle-zen-mode")} />+ </MenuItemColumns>+ ) : <><ZoomControls parentComponent={parentComponent} /><ToggleWindowOnTop /><KeyboardActionMenuItem command="toggleZenMode" icon="bx bxs-yin-yang" text={t("global_menu.toggle-zen-mode")} />@@ -268,16 +275,11 @@ function ZoomControls({ parentComponent }: { parentComponent?: Component | null);}-/** Fullscreen and Zen mode in two columns, as the mobile note menu sets backlinks and note paths. */-function ViewModeRow() {+/** Sets menu items side by side, one per column, as the mobile note menu sets backlinks and note paths. */+function MenuItemColumns({ children }: { children: ComponentChildren[] }) {return (<div className="form-list-row">- <div className="form-list-col">- <MenuItem command="toggleFullscreen" icon="bx bx-expand-alt" text={t("global_menu.fullscreen")} />- </div>- <div className="form-list-col">- <MenuItem command="toggleZenMode" icon="bx bxs-yin-yang" text={t("global_menu.toggle-zen-mode")} />- </div>+ {children.map((child, index) => <div key={index} className="form-list-col">{child}</div>)}</div>);}diff --git a/apps/client/src/widgets/react/FormList.css b/apps/client/src/widgets/react/FormList.cssindex a06c699b7e..45aac0e095 100644--- a/apps/client/src/widgets/react/FormList.css+++ b/apps/client/src/widgets/react/FormList.css@@ -46,6 +46,10 @@.form-list-col {flex-grow: 1;}++ .dropdown-item + & {+ margin-top: 1em;+ }}.dropdown-header.dropdown-header-with-action {