Skip to content

Build your personal knowledge base with Trilium Notes

client/content manager/space usage/browse view: tweak UI

Adorian Doran37391f1d85a9
diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.spec.tsx b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.spec.tsx
index 1b5d2cd0a9..b14bd56a4a 100644
--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.spec.tsx
@@ -97,7 +97,7 @@ describe("SpaceUsage section", () => {
}) ?? "");
});
- it("switches to Browse and back, keeping the status line up", async () => {
+ it("switches to Browse and back, leaving the whole-database totals behind", async () => {
mocks.overview = OVERVIEW;
const probe = renderSection();
@@ -110,11 +110,13 @@ describe("SpaceUsage section", () => {
await flushRender();
expect(probe.querySelector(".browse-stub")).not.toBeNull();
expect(probe.querySelector(".overview-stub")).toBeNull();
- expect(probe.querySelector(".space-usage-status")).not.toBeNull();
+ // Browse is about one note; database-wide totals under it would read as that note's.
+ expect(probe.querySelector(".space-usage-status")).toBeNull();
inactiveViewButton()?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
await flushRender();
expect(probe.querySelector(".overview-stub")).not.toBeNull();
expect(probe.querySelector(".browse-stub")).toBeNull();
+ expect(probe.querySelector(".space-usage-status")).not.toBeNull();
});
});
diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.tsx b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.tsx
index 4565974fff..c0b5646a2b 100644
--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.tsx
+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/index.tsx
@@ -27,9 +27,9 @@ export default function SpaceUsage({ sectionSwitcher }: ContentManagerSectionPro
setBrowsePath(notePath);
setView("browse");
}, []);
- // Fetched in both views: the treemap consumes it, and the status line is view-independent.
- // Revisions stay out of the ranking so it shares the basis of the areas the treemap draws —
- // asking for one basis and drawing the other would rank in notes the cells then shrink away.
+ // Kept fetched across both views so returning to the treemap draws immediately rather than
+ // blanking. Revisions stay out of the ranking so it shares the basis of the areas the treemap
+ // draws — asking for one basis and drawing the other would rank in notes the cells then shrink.
const overview = useSpaceUsageFetch<SpaceUsageOverviewResponse>(
`space-usage/overview?limit=${OVERVIEW_LIMIT}`);
@@ -51,7 +51,9 @@ export default function SpaceUsage({ sectionSwitcher }: ContentManagerSectionPro
? <Overview overview={overview} onShowDetails={showDetails} />
: <p className="space-usage-loading">{t("space_usage.loading")}</p>)}
- {overview && (
+ {/* Overview only: these are whole-database totals, and beside a single note's donut
+ they would read as being about that note. */}
+ {view === "overview" && overview && (
<footer className="space-usage-status">
<StatusEntry
// Revisions are left out: they carry their own cell on the map, which names
diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/note_usage_donut.css b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/note_usage_donut.css
index 6b41dd17a1..cca08f168c 100644
--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/note_usage_donut.css
+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/note_usage_donut.css
@@ -70,7 +70,7 @@
.note-usage-donut-size {
opacity: 0.7;
font-size: 0.85em;
- line-height: 1;
+ line-height: 1.15;
}
.note-usage-donut-size-value {
diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/note_usage_donut.spec.tsx b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/note_usage_donut.spec.tsx
index 990acfd566..a48690d86b 100644
--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/note_usage_donut.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/note_usage_donut.spec.tsx
@@ -6,15 +6,13 @@ import { t } from "../../../../../services/i18n";
import { formatSize } from "../../../../../services/utils";
const mocks = vi.hoisted(() => ({
- openContextWithNote: vi.fn()
+ triggerCommand: vi.fn()
}));
vi.mock("../../../../../components/app_context", () => ({
default: {
- tabManager: {
- openContextWithNote: mocks.openContextWithNote,
- getActiveContext: () => ({ hoistedNoteId: "hoistedNote" })
- }
+ triggerCommand: mocks.triggerCommand,
+ tabManager: { getActiveContext: () => ({ hoistedNoteId: "hoistedNote" }) }
}
}));
@@ -73,7 +71,7 @@ afterEach(() => {
container.remove();
container = undefined;
}
- mocks.openContextWithNote.mockClear();
+ mocks.triggerCommand.mockClear();
});
describe("NoteUsageDonut", () => {
@@ -118,21 +116,21 @@ describe("NoteUsageDonut", () => {
expect(pattern?.namespaceURI).toBe("http://www.w3.org/2000/svg");
});
- it("links the center title to the note and opens it in a new tab instead of navigating", () => {
+ it("quick-edits the note from the center title rather than navigating away", () => {
const probe = renderDonut();
const title = probe.querySelector<HTMLAnchorElement>(".note-usage-donut-title");
expect(title?.textContent).toBe("My note");
- expect(title?.getAttribute("href")).toBe("#root/n1");
+ // The app's own quick-edit link form, so the markup says what the click does.
+ expect(title?.getAttribute("href")).toBe("#root/n1?popup");
const click = new MouseEvent("click", { bubbles: true, cancelable: true });
title?.dispatchEvent(click);
+ // Handled here rather than let through: the hash would otherwise swap the settings page
+ // itself, and the popup must stack over the dialog instead of replacing it.
expect(click.defaultPrevented).toBe(true);
- expect(mocks.openContextWithNote).toHaveBeenCalledWith("n1", {
- activate: true,
- hoistedNoteId: "hoistedNote"
- });
+ expect(mocks.triggerCommand).toHaveBeenCalledWith("openInPopup", { noteIdOrPath: "root/n1" });
});
it("totals each ring in the hole, with the actions above the title", () => {
diff --git a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/note_usage_donut.tsx b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/note_usage_donut.tsx
index 74ea94c1a9..86c9ebccf8 100644
--- a/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/note_usage_donut.tsx
+++ b/apps/client/src/widgets/type_widgets/options/content_manager/space_usage/note_usage_donut.tsx
@@ -11,7 +11,7 @@ import { t } from "../../../../../services/i18n";
import { formatSize } from "../../../../../services/utils";
import DonutChart, { type DonutRing } from "../../../../react/charts/DonutChart";
import { useStaticTooltip } from "../../../../react/hooks";
-import { openNoteInNewTab } from "./context_menu";
+import { quickEditNote } from "./context_menu";
import {
buildCompositionSegments,
noteWeight,
@@ -47,10 +47,11 @@ interface NoteUsageDonutProps {
}
/**
- * The composition donut of a single note — body (blue), each attachment (yellow) and revisions
- * (gray) as ring segments, the note's name and total size in the hole. The name is a live note
- * link: it opens the note and carries the note preview tooltip. Reusable wherever one note's usage
- * needs breaking down; Browse wraps it with its children ring via {@link outerRings}.
+ * The composition donut of a single note — its body (blue) and each attachment (yellow) as ring
+ * segments, the note's name and the totals in the hole. The name is a live note link: it opens the
+ * note in the quick-edit popup, which stacks over the settings page rather than replacing what the
+ * user was reading. Reusable wherever one note's usage needs breaking down; Browse wraps it with
+ * its children ring via {@link outerRings}, which is also where history is drawn.
*/
export default function NoteUsageDonut({ usage, title, notePath, outerRings = [], centerActions, onTitleContextMenu, className }: NoteUsageDonutProps) {
const compositionRing: DonutRing<UsageSegmentData> = useMemo(() => ({
@@ -75,13 +76,15 @@ export default function NoteUsageDonut({ usage, title, notePath, outerRings = []
{centerActions}
<a
className="note-usage-donut-title"
- href={`#${notePath.join("/")}`}
+ // `?popup` is the app's own quick-edit link form, so the markup advertises what the
+ // click does — and a copied link opens the same way anywhere else.
+ href={`#${notePath.join("/")}?popup`}
onClick={(event) => {
// Handled here: default hash navigation would swap the settings page itself,
// and the dialog's link interception must not double-handle it.
event.preventDefault();
event.stopPropagation();
- openNoteInNewTab(usage.noteId);
+ quickEditNote(notePath);
}}
onContextMenu={onTitleContextMenu}
>{title}</a>