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(collections): improve display of no children
Elian Dorancffcfeb734ad
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex f434ffeddd..2de9813275 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1010,7 +1010,7 @@"no_attachments": "This note has no attachments."},"book": {- "no_children_help": "This collection doesn't have any child notes so there's nothing to display. See <a href=\"https://triliumnext.github.io/Docs/Wiki/book-note.html\">wiki</a> for details.",+ "no_children_help": "This collection doesn't have any child notes so there's nothing to display.","drag_locked_title": "Locked for editing","drag_locked_message": "Dragging not allowed since the collection is locked for editing."},diff --git a/apps/client/src/widgets/NoteDetail.tsx b/apps/client/src/widgets/NoteDetail.tsxindex c49802a7a4..1b2cc8f8cc 100644--- a/apps/client/src/widgets/NoteDetail.tsx+++ b/apps/client/src/widgets/NoteDetail.tsx@@ -1,6 +1,7 @@import "./NoteDetail.css";import clsx from "clsx";+import { note } from "mermaid/dist/rendering-util/rendering-elements/shapes/note.js";import { isValidElement, VNode } from "preact";import { useEffect, useRef, useState } from "preact/hooks";@@ -355,6 +356,14 @@ export function checkFullHeight(noteContext: NoteContext | undefined, type: Exte// https://github.com/zadam/trilium/issues/2522const isBackendNote = noteContext?.noteId === "_backendLog";const isFullHeightNoteType = type && TYPE_MAPPINGS[type].isFullHeight;++ // Allow vertical centering when there are no results.+ if (type === "book" &&+ [ "grid", "list" ].includes(noteContext.note?.getLabelValue("viewType") ?? "grid") &&+ !noteContext.note?.hasChildren()) {+ return true;+ }+return (!noteContext?.hasNoteList() && isFullHeightNoteType)|| noteContext?.viewScope?.viewMode === "attachments"|| isBackendNote;diff --git a/apps/client/src/widgets/type_widgets/Book.tsx b/apps/client/src/widgets/type_widgets/Book.tsxindex 6d07f5fbe3..05a1e2f058 100644--- a/apps/client/src/widgets/type_widgets/Book.tsx+++ b/apps/client/src/widgets/type_widgets/Book.tsx@@ -5,9 +5,8 @@ import { useEffect, useState } from "preact/hooks";import { t } from "../../services/i18n";import { ViewTypeOptions } from "../collections/interface";import CollectionProperties from "../note_bars/CollectionProperties";-import Alert from "../react/Alert";import { useNoteLabelWithDefault, useTriliumEvent } from "../react/hooks";-import RawHtml from "../react/RawHtml";+import NoItems from "../react/NoItems";import { TypeWidgetProps } from "./type_widget";const VIEW_TYPES: ViewTypeOptions[] = [ "list", "grid", "presentation" ];@@ -33,9 +32,7 @@ export default function Book({ note }: TypeWidgetProps) {<><CollectionProperties note={note} />- <Alert type="warning" className="note-detail-book-empty-help">- <RawHtml html={t("book.no_children_help")} />- </Alert>+ <NoItems icon="bx bx-collection" text={t("book.no_children_help")} /></>)}</>