Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): remove the ribbon's edited notes tab

Elian Doran2d05900ad6e8
diff --git a/apps/client/src/stylesheets/theme-next/ribbon.css b/apps/client/src/stylesheets/theme-next/ribbon.css
index 5d71aee649..905891d486 100644
--- a/apps/client/src/stylesheets/theme-next/ribbon.css
+++ b/apps/client/src/stylesheets/theme-next/ribbon.css
@@ -64,25 +64,6 @@ div.promoted-attributes-container {
gap: 10px 40px;
}
-/*
- * Edited notes (for calendar notes)
- */
-
-/* The path of the note */
-.edited-notes-list small {
- margin-inline-start: 4px;
- font-size: inherit;
- color: var(--muted-text-color);
-}
-
-.edited-notes-list small::before {
- content: "(";
-}
-
-.edited-notes-list small::after {
- content: ")";
-}
-
/*
* Owned attributes
*/
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index ef9ff35b44..eff1970730 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1312,9 +1312,7 @@
"open_all_limit_exceeded": "Too many notes to open at once ({{count}}). The maximum is {{max}}, try narrowing the results first."
},
"edited_notes": {
- "no_edited_notes_found": "No edited notes on this day yet...",
- "title": "Edited Notes",
- "deleted": "(deleted)"
+ "no_edited_notes_found": "No edited notes on this day yet..."
},
"file_properties": {
"original_file_name": "Original file name",
@@ -1877,9 +1875,6 @@
"enabled": "enabled",
"disabled": "disabled"
},
- "ribbon": {
- "edited_notes_message": "Edited Notes ribbon tab will automatically open on day notes"
- },
"theme": {
"title": "User Interface",
"theme_label": "Application theme",
@@ -1908,7 +1903,8 @@
"layout-vertical-title": "Vertical",
"layout-horizontal-title": "Horizontal",
"layout-vertical-description": "launcher bar is on the left (default)",
- "layout-horizontal-description": "launcher bar is underneath the tab bar, the tab bar is now full width."
+ "layout-horizontal-description": "launcher bar is underneath the tab bar, the tab bar is now full width.",
+ "edited_notes_expanded": "Expand \"Notes edited on this day\" on day notes"
},
"ui-performance": {
"title": "Performance",
diff --git a/apps/client/src/widgets/layout/NoteTitleActions.tsx b/apps/client/src/widgets/layout/NoteTitleActions.tsx
index 1a64873a4c..34f49d0ed9 100644
--- a/apps/client/src/widgets/layout/NoteTitleActions.tsx
+++ b/apps/client/src/widgets/layout/NoteTitleActions.tsx
@@ -1,16 +1,18 @@
import "./NoteTitleActions.css";
+import { EditedNotesResponse } from "@triliumnext/commons";
import { useEffect, useState } from "preact/hooks";
import NoteContext from "../../components/note_context";
import FNote from "../../entities/fnote";
+import froca from "../../services/froca";
import { t } from "../../services/i18n";
+import server from "../../services/server";
import { checkFullHeight, getExtendedWidgetType } from "../NoteDetail";
import { PromotedAttributesContent, usePromotedAttributeData } from "../PromotedAttributes";
import Collapsible, { ExternallyControlledCollapsible } from "../react/Collapsible";
import { useNoteContext, useNoteLabel, useNoteProperty, useTriliumEvent, useTriliumOptionBool } from "../react/hooks";
import { NewNoteLink } from "../react/NoteLink";
-import { useEditedNotes } from "../ribbon/EditedNotesTab";
import SearchDefinition from "../search/SearchDefinition";
import NoteTypeSwitcher from "./NoteTypeSwitcher";
@@ -100,4 +102,19 @@ function EditedNotesContent({ note }: { note: FNote }) {
<div className="no-edited-notes-found">{t("edited_notes.no_edited_notes_found")}</div>
)));
}
+
+function useEditedNotes(note: FNote) {
+ const [ editedNotes, setEditedNotes ] = useState<EditedNotesResponse>();
+
+ useEffect(() => {
+ server.get<EditedNotesResponse>(`edited-notes/${note.getLabelValue("dateNote")}`).then(async editedNotes => {
+ editedNotes = editedNotes.filter((n) => n.noteId !== note.noteId);
+ const noteIds = editedNotes.flatMap((n) => n.noteId);
+ await froca.getNotes(noteIds, true); // preload all at once
+ setEditedNotes(editedNotes);
+ });
+ }, [ note ]);
+
+ return editedNotes;
+}
//#endregion
diff --git a/apps/client/src/widgets/ribbon/EditedNotesTab.tsx b/apps/client/src/widgets/ribbon/EditedNotesTab.tsx
deleted file mode 100644
index 8e5d625b19..0000000000
--- a/apps/client/src/widgets/ribbon/EditedNotesTab.tsx
+++ /dev/null
@@ -1,59 +0,0 @@
-import { EditedNotesResponse } from "@triliumnext/commons";
-import { useEffect, useState } from "preact/hooks";
-
-import FNote from "../../entities/fnote";
-import froca from "../../services/froca";
-import { t } from "../../services/i18n";
-import server from "../../services/server";
-import NoteLink from "../react/NoteLink";
-import { joinElements } from "../react/react_utils";
-import { TabContext } from "./ribbon-interface";
-
-export default function EditedNotesTab({ note }: TabContext) {
- const editedNotes = useEditedNotes(note);
-
- return (
- <div className="edited-notes-widget" style={{
- padding: "12px",
- maxHeight: "200px",
- width: "100%",
- overflow: "auto"
- }}>
- {editedNotes?.length ? (
- <div className="edited-notes-list use-tn-links">
- {joinElements(editedNotes.map(editedNote => {
- return (
- <span key={editedNote.noteId} className="edited-note-line">
- {editedNote.isDeleted ? (
- <i>{`${editedNote.title} ${t("edited_notes.deleted")}`}</i>
- ) : (
- <>
- {editedNote.notePath ? <NoteLink notePath={editedNote.notePath} showNotePath /> : <span>{editedNote.title}</span> }
- </>
- )}
- </span>
- );
- }), " ")}
- </div>
- ) : (
- <div className="no-edited-notes-found">{t("edited_notes.no_edited_notes_found")}</div>
- )}
- </div>
- );
-}
-
-export function useEditedNotes(note: FNote | null | undefined) {
- const [ editedNotes, setEditedNotes ] = useState<EditedNotesResponse>();
-
- useEffect(() => {
- if (!note) return;
- server.get<EditedNotesResponse>(`edited-notes/${note.getLabelValue("dateNote")}`).then(async editedNotes => {
- editedNotes = editedNotes.filter((n) => n.noteId !== note.noteId);
- const noteIds = editedNotes.flatMap((n) => n.noteId);
- await froca.getNotes(noteIds, true); // preload all at once
- setEditedNotes(editedNotes);
- });
- }, [ note ]);
-
- return editedNotes;
-}
diff --git a/apps/client/src/widgets/ribbon/RibbonDefinition.ts b/apps/client/src/widgets/ribbon/RibbonDefinition.ts
index 6bdd22c54e..39b6e0eb8b 100644
--- a/apps/client/src/widgets/ribbon/RibbonDefinition.ts
+++ b/apps/client/src/widgets/ribbon/RibbonDefinition.ts
@@ -1,18 +1,9 @@
import { t } from "../../services/i18n";
-import options from "../../services/options";
-import EditedNotesTab from "./EditedNotesTab";
import ImagePropertiesTab from "./ImagePropertiesTab";
import NotePropertiesTab from "./NotePropertiesTab";
import { TabConfiguration } from "./ribbon-interface";
export const RIBBON_TAB_DEFINITIONS: TabConfiguration[] = [
- {
- title: t("edited_notes.title"),
- icon: "bx bx-calendar-edit",
- content: EditedNotesTab,
- show: ({ note }) => note?.hasOwnedLabel("dateNote"),
- activate: () => options.is("editedNotesOpenInRibbon")
- },
{
title: t("note_properties.info"),
icon: "bx bx-info-square",
diff --git a/apps/client/src/widgets/type_widgets/options/appearance.spec.tsx b/apps/client/src/widgets/type_widgets/options/appearance.spec.tsx
index 8fabd51d93..fb8fe86e11 100644
--- a/apps/client/src/widgets/type_widgets/options/appearance.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/options/appearance.spec.tsx
@@ -87,13 +87,13 @@ describe("the layout choices", () => {
expect(host.querySelector(".appearance-layout-choices")).toBeNull();
});
- it("offers the ribbon setting only on the old layout, which is the only one that has one", () => {
+ it("offers the edited notes setting on both layouts", () => {
open();
expect(host.querySelector("input.switch-toggle[id^='edited-notes-open-in-ribbon-']")).not.toBeNull();
mocks.stored = { newLayout: true };
open();
- expect(host.querySelector("input.switch-toggle[id^='edited-notes-open-in-ribbon-']")).toBeNull();
+ expect(host.querySelector("input.switch-toggle[id^='edited-notes-open-in-ribbon-']")).not.toBeNull();
});
});
diff --git a/apps/client/src/widgets/type_widgets/options/appearance.tsx b/apps/client/src/widgets/type_widgets/options/appearance.tsx
index 79f1f43d6f..a41606b910 100644
--- a/apps/client/src/widgets/type_widgets/options/appearance.tsx
+++ b/apps/client/src/widgets/type_widgets/options/appearance.tsx
@@ -94,7 +94,6 @@ export default function AppearanceSettings() {
function UserInterface() {
const [ theme, setTheme ] = useTriliumOption("theme");
const [ customThemes, setCustomThemes ] = useState<CustomTheme[]>([]);
- const [ newLayout ] = useTriliumOptionBool("newLayout");
const [ editedNotesOpenInRibbon, setEditedNotesOpenInRibbon ] = useTriliumOptionBool("editedNotesOpenInRibbon");
useEffect(() => {
@@ -180,10 +179,10 @@ function UserInterface() {
/>
</OptionCardSection>
- {!isMobile() && !newLayout && (
+ {!isMobile() && (
<OptionCardSection
name="edited-notes-open-in-ribbon"
- label={t("ribbon.edited_notes_message")}
+ label={t("theme.edited_notes_expanded")}
>
<FormToggle
currentValue={editedNotesOpenInRibbon}