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(client): the attributes panel offers the way to the sidebar's own
Elian Doran786fe56ac91b
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 0223c0078c..d3cb03c2fa 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -3555,7 +3555,8 @@"tab_width_style_tabs": "Tabs"},"attributes_panel": {- "title": "Note Attributes"+ "title": "Note Attributes",+ "edit_in_sidebar": "Edit in the sidebar"},"right_pane": {"empty_message": "Nothing to show for this note",diff --git a/apps/client/src/widgets/layout/StatusBar.css b/apps/client/src/widgets/layout/StatusBar.cssindex 7203830bcb..a5dd41d231 100644--- a/apps/client/src/widgets/layout/StatusBar.css+++ b/apps/client/src/widgets/layout/StatusBar.css@@ -181,6 +181,17 @@ body.experimental-feature-new-layout .note-info-content {font-size: .85em;}+ .status-bar-sidebar-link {+ display: flex;+ align-items: center;+ gap: 4px;+ font-size: .85em;++ .tn-icon {+ font-size: 1.2em;+ }+ }+.icon-action {--icon-button-size: 24px;--icon-button-icon-ratio: 0.8;diff --git a/apps/client/src/widgets/layout/StatusBar.spec.tsx b/apps/client/src/widgets/layout/StatusBar.spec.tsxindex 8e8e03d5c6..4b75066b63 100644--- a/apps/client/src/widgets/layout/StatusBar.spec.tsx+++ b/apps/client/src/widgets/layout/StatusBar.spec.tsx@@ -75,6 +75,20 @@ describe("StatusBar panels", () => {expect(isShown(".attribute-list")).toBe(false);});+ it("offers the attributes panel a way to the sidebar's own, and steps aside once taken", () => {+ const triggerEvent = vi.spyOn(appContext, "triggerEvent").mockResolvedValue(undefined);+ renderBar();+ fire("toggleRibbonTabOwnedAttributes");++ const sidebarLink = container.querySelector<HTMLElement>(".attribute-list .bottom-panel-title-bar .status-bar-sidebar-link");+ expect(sidebarLink).not.toBeNull();++ act(() => sidebarLink?.click());+ expect(triggerEvent).toHaveBeenCalledWith("selectRightPaneTab", { tabId: "attributes", peek: true });+ // Two attribute editors over the one note is what the way across is for the reader to avoid.+ expect(isShown(".attribute-list")).toBe(false);+ });+it("closes the similar notes panel from its own title bar", () => {renderBar();fire("toggleRibbonTabSimilarNotes");diff --git a/apps/client/src/widgets/layout/StatusBar.tsx b/apps/client/src/widgets/layout/StatusBar.tsxindex 5263f47cac..6aa977f2bc 100644--- a/apps/client/src/widgets/layout/StatusBar.tsx+++ b/apps/client/src/widgets/layout/StatusBar.tsx@@ -7,7 +7,7 @@ import { type ComponentChildren, RefObject } from "preact";import { createPortal } from "preact/compat";import { useCallback, useContext, useEffect, useMemo, useRef, useState } from "preact/hooks";-import { CommandNames } from "../../components/app_context";+import appContext, { CommandNames } from "../../components/app_context";import NoteContext from "../../components/note_context";import FNote from "../../entities/fnote";import attributes from "../../services/attributes";@@ -33,6 +33,7 @@ import InheritedAttributesTab from "../ribbon/InheritedAttributesTab";import { NoteSizeWidget, useNoteMetadata } from "../ribbon/NoteInfoTab";import { NotePathsWidget, useSortedNotePaths } from "../ribbon/NotePathsTab";import SimilarNotesTab from "../ribbon/SimilarNotesTab";+import type { RightPaneTabId } from "../sidebar/RightPaneTabs";import { useAttachments } from "../type_widgets/Attachment";import { useProcessedLocales } from "../type_widgets/options/components/LocaleSelector";import Breadcrumb from "./Breadcrumb";@@ -166,6 +167,28 @@ function StatusBarButton({ className, icon, text, title, active, ...restProps }:);}+/**+ * The way from a panel of the status bar to the sidebar tab holding the fuller version of the same+ * thing: the attributes panel edits a note's attributes as a line of text, the sidebar's card as a+ * list with a control apiece. Worded as what is found there rather than as the pane it opens, and+ * shown in the panel's title bar beside its `?`.+ *+ * A pane the user keeps closed is peeked rather than docked — a glance asked for from the status bar+ * is no reason to reflow the content the note is read in.+ */+function SidebarLink({ text, tabId, onOpened }: { text: string; tabId: RightPaneTabId; onOpened?: () => void }) {+ return (+ <LinkButton+ className="status-bar-sidebar-link"+ text={<><Icon icon="bx bx-sidebar" className="bx-flip-horizontal" />{text}</>}+ onClick={() => {+ void appContext.triggerEvent("selectRightPaneTab", { tabId, peek: true });+ onOpened?.();+ }}+ />+ );+}+//#region Language Switcherfunction LanguageSwitcher({ note }: StatusBarContext) {const [ modalShown, setModalShown ] = useState(false);@@ -419,6 +442,11 @@ function AttributesPane({ note, noteContext, attributesShown, setAttributesShownclassName="attribute-list"visible={attributesShown}setVisible={setAttributesShown}+ buttons={<SidebarLink+ text={t("attributes_panel.edit_in_sidebar")}+ tabId="attributes"+ onOpened={() => setAttributesShown(false)}+ />}helpPage={ATTRIBUTE_HELP_PAGE}helpContent={<AttributeHelp />}>@@ -605,15 +633,21 @@ interface BottomPanelParams {visible: boolean;setVisible?: (visible: boolean) => void;className?: string;+ /**+ * What the panel offers besides being read and closed, shown in its title bar ahead of the `?`+ * and the `×` — the same place, and the same name, as a sidebar card's own (see RightPanelWidget).+ */+ buttons?: ComponentChildren;helpPage?: string;/** Inline help shown by the title bar's `?`; without it the `?` opens {@link helpPage} directly. */helpContent?: ComponentChildren;}-function BottomPanel({ children, title, visible, setVisible, className, helpPage, helpContent }: BottomPanelParams) {+function BottomPanel({ children, title, visible, setVisible, className, buttons, helpPage, helpContent }: BottomPanelParams) {return <div className={clsx("bottom-panel", className, {"hidden-ext": !visible})}><div className="bottom-panel-title-bar"><span className="bottom-panel-title-bar-caption">{title}</span>+ {buttons}{helpContent? <HelpDropdown helpPage={helpPage}>{helpContent}</HelpDropdown>: helpPage && <button class="icon-action bx bx-help-circle" onClick={() => openInAppHelpFromUrl(helpPage)} title={t("open-help-page")} />}diff --git a/apps/client/src/widgets/react/LinkButton.tsx b/apps/client/src/widgets/react/LinkButton.tsxindex e9feefacc6..ffa248fb7c 100644--- a/apps/client/src/widgets/react/LinkButton.tsx+++ b/apps/client/src/widgets/react/LinkButton.tsx@@ -1,3 +1,4 @@+import clsx from "clsx";import { ComponentChild } from "preact";import { CommandNames } from "../../components/app_context";@@ -5,11 +6,12 @@ interface LinkButtonProps {onClick?: () => void;text: ComponentChild;triggerCommand?: CommandNames;+ className?: string;}-export default function LinkButton({ onClick, text, triggerCommand }: LinkButtonProps) {+export default function LinkButton({ onClick, text, triggerCommand, className }: LinkButtonProps) {return (- <a class="tn-link" href="#"+ <a class={clsx("tn-link", className)} href="#"data-trigger-command={triggerCommand}role="button"onKeyDown={(e)=> {