Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.
Go dockerfossgomarkdownmemomicroblognote-takingnotesopen-sourceown-your-datareactself-hostedsqlitetimeline
chore: tweak action orders in memo action menu
boojackb1fa9aefcc22
diff --git a/web/src/components/MemoActionMenu/MemoActionMenu.tsx b/web/src/components/MemoActionMenu/MemoActionMenu.tsxindex f48aa5d04..5edfda510 100644--- a/web/src/components/MemoActionMenu/MemoActionMenu.tsx+++ b/web/src/components/MemoActionMenu/MemoActionMenu.tsx@@ -35,8 +35,9 @@ import { useMemoActionHandlers } from "./hooks";import type { MemoActionMenuProps } from "./types";/**- * The memo's action menu, in order of how often each action is reached for:- * open, edit and pin first; then archive, tasks and the Copy submenu; Delete last.+ * The memo's action menu, grouped by what each action does to the card:+ * write on it (Edit, the task action), place it (Pin, Archive), reach it beyond+ * the feed (Open its page, Copy its link or content), then Delete last.* A memo's Space is changed in the editor, not here. An archived memo offers* only Restore and Delete, and a viewer only Open and Copy.*/@@ -136,25 +137,10 @@ const MemoActionMenu = (props: MemoActionMenuProps) => {return (<>- {openItem}<DropdownMenuItem onClick={handleEditMemoClick}><Edit3Icon />{t("common.edit")}</DropdownMenuItem>- {!isComment && (- <DropdownMenuItem onClick={handleTogglePinMemoBtnClick}>- {memo.pinned ? <BookmarkMinusIcon /> : <BookmarkPlusIcon />}- {memo.pinned ? t("common.unpin") : t("common.pin")}- </DropdownMenuItem>- )}-- <DropdownMenuSeparator />- {!isComment && (- <DropdownMenuItem onClick={handleToggleMemoStatusClick}>- <ArchiveIcon />- {t("common.archive")}- </DropdownMenuItem>- )}{/* One task action at a time: finish the open tasks, or reset a finished list. */}{hasTaskList &&(hasOpenTasks ? (@@ -168,6 +154,24 @@ const MemoActionMenu = (props: MemoActionMenuProps) => {{t("memo.task-actions.uncheck-all")}</DropdownMenuItem>))}++ {/* A comment has no place of its own to pin or archive; it lives under its parent. */}+ {!isComment && (+ <>+ <DropdownMenuSeparator />+ <DropdownMenuItem onClick={handleTogglePinMemoBtnClick}>+ {memo.pinned ? <BookmarkMinusIcon /> : <BookmarkPlusIcon />}+ {memo.pinned ? t("common.unpin") : t("common.pin")}+ </DropdownMenuItem>+ <DropdownMenuItem onClick={handleToggleMemoStatusClick}>+ <ArchiveIcon />+ {t("common.archive")}+ </DropdownMenuItem>+ </>+ )}++ <DropdownMenuSeparator />+ {openItem}{copySubmenu}<DropdownMenuSeparator />diff --git a/web/src/components/MemoMetadata/MetadataSection.tsx b/web/src/components/MemoMetadata/MetadataSection.tsxindex a7f94bf4a..b8809e072 100644--- a/web/src/components/MemoMetadata/MetadataSection.tsx+++ b/web/src/components/MemoMetadata/MetadataSection.tsx@@ -18,6 +18,11 @@ export const METADATA_ROW_CLASSES = cn("aria-pressed:bg-accent aria-pressed:text-accent-foreground data-popup-open:bg-accent data-popup-open:text-accent-foreground",FOCUS_VISIBLE_OUTLINE_CLASSES,);+/**+ * The compact row: 24px instead of 28px, for a list that previews rather than edits (the+ * comment strip under a feed card). It packs rows into one block of lines.+ */+export const METADATA_COMPACT_ROW_CLASSES = cn(METADATA_ROW_CLASSES, "h-6");/** The focusable body of a split row; its gap must equal the box's `gap-1`. */export const METADATA_ROW_LABEL_CLASSES = `flex h-full min-w-0 flex-1 items-center gap-1 text-start ${FOCUS_VISIBLE_OUTLINE_CLASSES}`;export const METADATA_ROW_SLOT_CLASSES = "flex size-5 shrink-0 items-center justify-center";@@ -107,23 +112,25 @@ interface MetadataSectionProps extends PropsWithChildren {count?: number;/** A control on the header's trailing end; it pulls out by its own padding to end on the text edge. */action?: ReactNode;+ /** `compact` sets a 20px header over gapless rows, to pair with `METADATA_COMPACT_ROW_CLASSES`. */+ density?: "default" | "compact";}/**- * A quiet titled list: a 24px header with an uppercase title on the text edge, then+ * A quiet titled list: a 24px header (20px when compact) with an uppercase title on the text edge, then* rows whose leading glyph lands on that same edge. No box or band, so the list recedes* behind the memo's own content.*/-const MetadataSection = ({ title, count, action, children }: MetadataSectionProps) => (+const MetadataSection = ({ title, count, action, density = "default", children }: MetadataSectionProps) => (<section className="w-full" aria-label={title}>- <div className="mb-0.5 flex h-6 min-w-0 items-center justify-between gap-2">+ <div className={cn("flex min-w-0 items-center justify-between gap-2", density === "compact" ? "h-5" : "mb-0.5 h-6")}><h3 className="flex min-w-0 items-center gap-1.5 text-2xs font-normal uppercase tracking-wide text-muted-foreground/55 select-none"><span className="truncate">{title}</span>{count != null && <span className="tabular-nums text-muted-foreground/60">{count}</span>}</h3>{action && <div className="-me-2 shrink-0">{action}</div>}</div>- <div className={METADATA_ROW_LIST_CLASSES}>{children}</div>+ <div className={cn(METADATA_ROW_LIST_CLASSES, density === "compact" && "gap-0")}>{children}</div></section>);diff --git a/web/src/components/MemoPreview/MemoPreview.tsx b/web/src/components/MemoPreview/MemoPreview.tsxindex 3d80e6b0c..3f5a5cdae 100644--- a/web/src/components/MemoPreview/MemoPreview.tsx+++ b/web/src/components/MemoPreview/MemoPreview.tsx@@ -142,14 +142,9 @@ const MemoPreview = ({return (<MemoViewContext.Provider value={STUB_CONTEXT}><div- className={cn(- "pointer-events-none",- truncate ? "flex items-center gap-1.5 min-w-0 leading-tight" : "flex flex-col gap-1",- className,- )}+ className={cn("pointer-events-none", truncate ? "flex items-center gap-2 min-w-0 leading-tight" : "flex flex-col gap-1", className)}>{showMeta && meta}- {showMeta && truncate && (hasContent || hasAttachments) && <div className="text-muted-foreground/50 shrink-0">·</div>}{contentNode}{hasAttachments &&(truncate ? (diff --git a/web/src/components/MemoView/components/MemoCommentListView.tsx b/web/src/components/MemoView/components/MemoCommentListView.tsxindex 8ea58a084..53b621dc8 100644--- a/web/src/components/MemoView/components/MemoCommentListView.tsx+++ b/web/src/components/MemoView/components/MemoCommentListView.tsx@@ -1,23 +1,31 @@-import { ArrowUpRightIcon } from "lucide-react";+import { ChevronRightIcon } from "lucide-react";import { Link } from "react-router-dom";-import MetadataSection, { METADATA_ROW_CLASSES, METADATA_ROW_SLOT_CLASSES } from "@/components/MemoMetadata/MetadataSection";+import MetadataSection, { METADATA_COMPACT_ROW_CLASSES, METADATA_ROW_SLOT_CLASSES } from "@/components/MemoMetadata/MetadataSection";import { MemoPreview } from "@/components/MemoPreview";-import { buttonVariants } from "@/components/ui/button";+import { FOCUS_VISIBLE_OUTLINE_CLASSES } from "@/components/ui/focus";import { useMemoComments } from "@/hooks/useMemoQueries";import { useNearViewport } from "@/hooks/useNearViewport";import { useUsersByNames } from "@/hooks/useUserQueries";import { MEMO_COMMENTS_ANCHOR_ID } from "@/lib/memo-comments";import { extractMemoIdFromName } from "@/lib/resource-names";+import { cn } from "@/lib/utils";import { useTranslate } from "@/utils/i18n";import UserAvatar from "../../UserAvatar";import { useMemoViewContext, useMemoViewDerived } from "../MemoViewContext";import { createMemoNavigationState } from "../navigation";-const VIEW_ALL_CLASSES = buttonVariants({ variant: "quiet", size: "sm" });+/**+ * "View all" speaks at the header's scale: 11px muted ink in a box as tall as the compact+ * header, so it sits on the title's line instead of stretching it.+ */+const VIEW_ALL_CLASSES = cn(+ "inline-flex h-5 items-center gap-0.5 rounded-md px-2 text-2xs text-muted-foreground/60 transition-colors hover:bg-muted/60 hover:text-foreground",+ FOCUS_VISIBLE_OUTLINE_CLASSES,+);/**- * The comment strip hangs off the card's bottom edge: a titled list of up to three- * comments, each a row whose avatar sits in the leading slot on the card's text edge.+ * The comment strip hangs off the card's bottom edge: a compact titled list of up to three+ * comments, each a 24px row whose avatar sits in the leading slot on the card's text edge.*/const MemoCommentListView: React.FC = () => {const t = useTranslate();@@ -38,14 +46,15 @@ const MemoCommentListView: React.FC = () => {}return (- <div ref={viewportRef} className="rounded-b-lg border border-t-0 border-border/70 px-4 pb-2 pt-1.5">+ <div ref={viewportRef} className="rounded-b-lg border border-t-0 border-border/70 px-4 py-1"><MetadataSectiontitle={t("memo.comment.self")}count={commentAmount}+ density="compact"action={<Link to={`/${memo.name}#${MEMO_COMMENTS_ANCHOR_ID}`} state={createMemoNavigationState(parentPage)} className={VIEW_ALL_CLASSES}>{t("common.view-all")}- <ArrowUpRightIcon className="size-3" strokeWidth={1.8} />+ <ChevronRightIcon className="-me-0.5 size-3" strokeWidth={2} /></Link>}>@@ -58,7 +67,7 @@ const MemoCommentListView: React.FC = () => {to={`/${memo.name}#${uid}`}state={createMemoNavigationState(parentPage)}viewTransition- className={METADATA_ROW_CLASSES}+ className={METADATA_COMPACT_ROW_CLASSES}><span className={METADATA_ROW_SLOT_CLASSES} aria-hidden="true"><UserAvatar className="size-4" avatarUrl={creator?.avatarUrl} name={creator?.displayName || creator?.username} />diff --git a/web/tests/memo-action-menu.test.tsx b/web/tests/memo-action-menu.test.tsxindex 79e8254a3..fb10ec321 100644--- a/web/tests/memo-action-menu.test.tsx+++ b/web/tests/memo-action-menu.test.tsx@@ -62,9 +62,9 @@ describe("MemoActionMenu", () => {handlers.isInMemoDetailPage = false;});- it("orders an owner's memo actions and puts Delete last, with no Move entry", async () => {+ it("groups an owner's memo actions by what they do to the card and puts Delete last, with no Move entry", async () => {await openMenu(memoOf({ space: "spaces/work" }));- expect(menuItemLabels()).toEqual(["common.open", "common.edit", "common.pin", "common.archive", "common.copy", "common.delete"]);+ expect(menuItemLabels()).toEqual(["common.edit", "common.pin", "common.archive", "common.open", "common.copy", "common.delete"]);const separators = screen.getAllByRole("separator");expect(separators[separators.length - 1].nextElementSibling).toBe(screen.getByRole("menuitem", { name: "common.delete" }));});@@ -88,15 +88,15 @@ describe("MemoActionMenu", () => {it("hides Open on the memo's own page", async () => {handlers.isInMemoDetailPage = true;await openMenu(memoOf());- expect(menuItemLabels()[0]).toBe("common.edit");+ expect(menuItemLabels()).toEqual(["common.edit", "common.pin", "common.archive", "common.copy", "common.delete"]);});it.each([[true, "memo.task-actions.check-all", "handleCheckAllTaskListItemsClick"],[false, "memo.task-actions.uncheck-all", "handleUncheckAllTaskListItemsClick"],- ] as const)("shows one task action after Archive (open tasks: %s)", async (hasIncompleteTasks, label, handler) => {+ ] as const)("shows one task action right after Edit (open tasks: %s)", async (hasIncompleteTasks, label, handler) => {await openMenu(memoOf({ property: { hasTaskList: true, hasIncompleteTasks } }));- expect(menuItemLabels().slice(3, 5)).toEqual(["common.archive", label]);+ expect(menuItemLabels().slice(0, 3)).toEqual(["common.edit", label, "common.pin"]);fireEvent.click(screen.getByRole("menuitem", { name: label }));expect(handlers[handler]).toHaveBeenCalledOnce();});