Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): remove the ribbon's note info tab

Elian Doran50977daf5b0c
diff --git a/apps/client/src/stylesheets/theme-next/ribbon.css b/apps/client/src/stylesheets/theme-next/ribbon.css
index 52b090dfe2..20744d2c13 100644
--- a/apps/client/src/stylesheets/theme-next/ribbon.css
+++ b/apps/client/src/stylesheets/theme-next/ribbon.css
@@ -42,7 +42,6 @@ div.promoted-attributes-container {
*/
/* The property label */
-.note-info-item > span:first-child,
.file-properties-widget .file-table th,
.image-properties > div:first-child > span > strong {
opacity: 0.65;
@@ -138,12 +137,3 @@ div.promoted-attributes-container {
color: var(--cmd-button-hover-text-color);
background: var(--cmd-button-hover-background-color);
}
-
-/*
- * Note info
- */
-
-/* Narrow width layout */
-.note-info-widget {
- container: info-section / inline-size;
-}
diff --git a/apps/client/src/widgets/layout/InlineTitle.tsx b/apps/client/src/widgets/layout/InlineTitle.tsx
index 9f211cb75c..b8324aa0f5 100644
--- a/apps/client/src/widgets/layout/InlineTitle.tsx
+++ b/apps/client/src/widgets/layout/InlineTitle.tsx
@@ -15,7 +15,7 @@ import NoteIcon from "../note_icon";
import NoteTitleWidget from "../note_title";
import { useNoteContext, useNoteProperty, useStaticTooltip } from "../react/hooks";
import { joinElements } from "../react/react_utils";
-import { useNoteMetadata } from "../ribbon/NoteInfoTab";
+import { useNoteMetadata } from "./note_metadata";
export default function InlineTitle() {
const { note, parentComponent, viewScope } = useNoteContext();
diff --git a/apps/client/src/widgets/layout/StatusBar.tsx b/apps/client/src/widgets/layout/StatusBar.tsx
index 6c3e62428e..c078a329fc 100644
--- a/apps/client/src/widgets/layout/StatusBar.tsx
+++ b/apps/client/src/widgets/layout/StatusBar.tsx
@@ -31,11 +31,11 @@ import LinkButton from "../react/LinkButton";
import NoItems from "../react/NoItems";
import NoteLink from "../react/NoteLink";
import { ParentComponent } from "../react/react_utils";
-import { NoteSizeWidget, useNoteMetadata } from "../ribbon/NoteInfoTab";
import { NotePathsWidget, useSortedNotePaths } from "../sidebar/NotePaths";
import type { RightPaneTabId } from "../sidebar/RightPaneTabs";
import { useProcessedLocales } from "../type_widgets/options/components/LocaleSelector";
import Breadcrumb from "./Breadcrumb";
+import { NoteSizeWidget, useNoteMetadata } from "./note_metadata";
import { codeLanguageItems, NoteTypeOptionsModal, useMimeTypes } from "./NoteTypeSwitcher";
import { convertIndentation } from "./reindentation";
diff --git a/apps/client/src/widgets/ribbon/NoteInfoTab.spec.tsx b/apps/client/src/widgets/layout/note_metadata.spec.tsx
similarity index 98%
rename from apps/client/src/widgets/ribbon/NoteInfoTab.spec.tsx
rename to apps/client/src/widgets/layout/note_metadata.spec.tsx
index f1faedd2d3..cfa0efc0fe 100644
--- a/apps/client/src/widgets/ribbon/NoteInfoTab.spec.tsx
+++ b/apps/client/src/widgets/layout/note_metadata.spec.tsx
@@ -28,7 +28,7 @@ vi.mock("../react/hooks", () => ({
import type FNote from "../../entities/fnote";
import froca from "../../services/froca";
import { buildNote } from "../../test/easy-froca";
-import { useNoteMetadata } from "./NoteInfoTab";
+import { useNoteMetadata } from "./note_metadata";
/** A reload touching this note, which is what a deletion looks like to the hook. */
const NOTE_RELOADED = { loadResults: { isNoteReloaded: () => true, isNoteContentReloaded: () => false } };
diff --git a/apps/client/src/widgets/ribbon/NoteInfoTab.tsx b/apps/client/src/widgets/layout/note_metadata.tsx
similarity index 64%
rename from apps/client/src/widgets/ribbon/NoteInfoTab.tsx
rename to apps/client/src/widgets/layout/note_metadata.tsx
index 79716eebe1..eb749ff3b7 100644
--- a/apps/client/src/widgets/ribbon/NoteInfoTab.tsx
+++ b/apps/client/src/widgets/layout/note_metadata.tsx
@@ -1,80 +1,16 @@
-import "./NoteInfoTab.css";
-
import { MetadataResponse, NoteSizeResponse, SubtreeSizeResponse } from "@triliumnext/commons";
import { useCallback, useEffect, useMemo, useState } from "preact/hooks";
import FNote from "../../entities/fnote";
import debounce from "../../services/debounce";
-import { isExperimentalFeatureEnabled } from "../../services/experimental_features";
import froca from "../../services/froca";
import { t } from "../../services/i18n";
import server from "../../services/server";
import { formatSize } from "../../services/utils";
-import { formatDateTime } from "../../utils/formatters";
import { useTriliumEvent } from "../react/hooks";
import LinkButton from "../react/LinkButton";
import LoadingSpinner from "../react/LoadingSpinner";
-const isNewLayout = isExperimentalFeatureEnabled("new-layout");
-
-export default function NoteInfoTab({ note }: { note: FNote | null | undefined }) {
- const { metadata, ...sizeProps } = useNoteMetadata(note);
-
- return (
- <div className="note-info-widget">
- {note && (
- <>
- <div className="note-info-item">
- <span>{t("note_info_widget.note_id")}:</span>
- <span className="note-info-id selectable-text">{note.noteId}</span>
- </div>
- {!isNewLayout && <div className="note-info-item">
- <span>{t("note_info_widget.created")}:</span>
- <span className="selectable-text">{formatDateTime(metadata?.dateCreated)}</span>
- </div>}
- {!isNewLayout && <div className="note-info-item">
- <span>{t("note_info_widget.modified")}:</span>
- <span className="selectable-text">{formatDateTime(metadata?.dateModified)}</span>
- </div>}
- <div className="note-info-item">
- <span>{t("note_info_widget.type")}:</span>
- <span>
- <span className="note-info-type">{note.type}</span>{' '}
- {note.mime && <span className="note-info-mime selectable-text">({note.mime})</span>}
- </span>
- </div>
- <div className="note-info-item">
- <span title={t("note_info_widget.note_size_info")}>{t("note_info_widget.note_size")}:</span>
- <span className="note-info-size-col-span">
- <NoteSizeWidget {...sizeProps} />
- </span>
- </div>
- </>
- )}
- </div>
- );
-}
-
-export function NoteSizeWidget({ isLoading, noteSizeResponse, subtreeSizeResponse, requestSizeInfo }: Omit<ReturnType<typeof useNoteMetadata>, "metadata">) {
- return <>
- {!isLoading && !noteSizeResponse && !subtreeSizeResponse && (
- <LinkButton
- text={t("note_info_widget.calculate")}
- onClick={requestSizeInfo}
- />
- )}
-
- <span className="note-sizes-wrapper selectable-text">
- <span className="note-size">{formatSize(noteSizeResponse?.noteSize)}</span>
- {" "}
- {subtreeSizeResponse && subtreeSizeResponse.subTreeNoteCount > 1 &&
- <span className="subtree-size">{t("note_info_widget.subtree_size", { size: formatSize(subtreeSizeResponse.subTreeSize), count: subtreeSizeResponse.subTreeNoteCount })}</span>
- }
- {isLoading && <LoadingSpinner />}
- </span>
- </>;
-}
-
export function useNoteMetadata(note: FNote | null | undefined, debounceTime = 10_000) {
const [ isLoading, setIsLoading ] = useState(false);
const [ noteSizeResponse, setNoteSizeResponse ] = useState<NoteSizeResponse>();
@@ -123,3 +59,23 @@ export function useNoteMetadata(note: FNote | null | undefined, debounceTime = 1
return { isLoading, metadata, noteSizeResponse, subtreeSizeResponse, requestSizeInfo };
}
+
+export function NoteSizeWidget({ isLoading, noteSizeResponse, subtreeSizeResponse, requestSizeInfo }: Omit<ReturnType<typeof useNoteMetadata>, "metadata">) {
+ return <>
+ {!isLoading && !noteSizeResponse && !subtreeSizeResponse && (
+ <LinkButton
+ text={t("note_info_widget.calculate")}
+ onClick={requestSizeInfo}
+ />
+ )}
+
+ <span className="note-sizes-wrapper selectable-text">
+ <span className="note-size">{formatSize(noteSizeResponse?.noteSize)}</span>
+ {" "}
+ {subtreeSizeResponse && subtreeSizeResponse.subTreeNoteCount > 1 &&
+ <span className="subtree-size">{t("note_info_widget.subtree_size", { size: formatSize(subtreeSizeResponse.subTreeSize), count: subtreeSizeResponse.subTreeNoteCount })}</span>
+ }
+ {isLoading && <LoadingSpinner />}
+ </span>
+ </>;
+}
diff --git a/apps/client/src/widgets/ribbon/NoteInfoTab.css b/apps/client/src/widgets/ribbon/NoteInfoTab.css
deleted file mode 100644
index 7f927b8018..0000000000
--- a/apps/client/src/widgets/ribbon/NoteInfoTab.css
+++ /dev/null
@@ -1,31 +0,0 @@
-.note-info-widget {
- padding: 12px;
- display: flex;
- flex-wrap: wrap;
- align-items: baseline;
-}
-
-.note-info-item {
- display: flex;
- align-items: baseline;
- padding-inline-end: 15px;
- padding-block: 5px;
-}
-
-.note-info-item > span:first-child {
- padding-inline-end: 5px;
-}
-
-.note-info-mime {
- max-width: 13em;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.note-info-id {
- font-variant: none;
- font-family: var(--monospace-font-family);
- font-size: 0.8em;
- vertical-align: middle !important;
-}
diff --git a/apps/client/src/widgets/ribbon/RibbonDefinition.ts b/apps/client/src/widgets/ribbon/RibbonDefinition.ts
index 4ea9157777..a71f588bf1 100644
--- a/apps/client/src/widgets/ribbon/RibbonDefinition.ts
+++ b/apps/client/src/widgets/ribbon/RibbonDefinition.ts
@@ -3,7 +3,6 @@ import options from "../../services/options";
import EditedNotesTab from "./EditedNotesTab";
import FilePropertiesTab from "./FilePropertiesTab";
import ImagePropertiesTab from "./ImagePropertiesTab";
-import NoteInfoTab from "./NoteInfoTab";
import NotePropertiesTab from "./NotePropertiesTab";
import { TabConfiguration } from "./ribbon-interface";
import ScriptTab from "./ScriptTab";
@@ -56,11 +55,4 @@ export const RIBBON_TAB_DEFINITIONS: TabConfiguration[] = [
toggleCommand: "toggleRibbonTabImageProperties",
activate: true,
},
- {
- title: t("note_info_widget.title"),
- icon: "bx bx-info-circle",
- show: ({ note }) => !!note,
- content: NoteInfoTab,
- toggleCommand: "toggleRibbonTabNoteInfo"
- }
];