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(geomap): integrate add button to collection properties
Elian Doran1232909a3be1
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 88ed7ac752..d7d91b2443 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1977,6 +1977,7 @@},"geo-map": {"create-child-note-title": "Create a new child note and add it to the map",+ "create-child-note-text": "Add marker","create-child-note-instruction": "Click on the map to create a new note at that location or press Escape to dismiss.","unable-to-load-map": "Unable to load map."},diff --git a/apps/client/src/widgets/collections/geomap/index.tsx b/apps/client/src/widgets/collections/geomap/index.tsxindex d962c12fef..9c88d09940 100644--- a/apps/client/src/widgets/collections/geomap/index.tsx+++ b/apps/client/src/widgets/collections/geomap/index.tsx@@ -13,6 +13,7 @@ import { t } from "../../../services/i18n";import server from "../../../services/server";import toast from "../../../services/toast";import CollectionProperties from "../../note_bars/CollectionProperties";+import { ButtonOrActionButton } from "../../react/Button";import { useNoteBlob, useNoteLabel, useNoteLabelBoolean, useNoteProperty, useNoteTreeDrag, useSpacedUpdate, useTriliumEvent } from "../../react/hooks";import { ParentComponent } from "../../react/react_utils";import TouchBar, { TouchBarButton, TouchBarLabel, TouchBarSlider } from "../../react/TouchBar";@@ -133,7 +134,18 @@ export default function GeoView({ note, noteIds, viewConfig, saveConfig }: ViewMreturn (<div className={`geo-view ${state === State.NewNote ? "placing-note" : ""}`}>- <CollectionProperties note={note} />+ <CollectionProperties+ note={note}+ rightChildren={<>+ <ButtonOrActionButton+ icon="bx bx-plus"+ text={t("geo-map.create-child-note-text")}+ title={t("geo-map.create-child-note-title")}+ triggerCommand="geoMapCreateChildNote"+ disabled={isReadOnly}+ />+ </>}+ />{ coordinates !== undefined && zoom !== undefined && <MapapiRef={apiRef} containerRef={containerRef}coordinates={coordinates}diff --git a/apps/client/src/widgets/react/Button.tsx b/apps/client/src/widgets/react/Button.tsxindex 1fe7727b56..ffdc6ddd2c 100644--- a/apps/client/src/widgets/react/Button.tsx+++ b/apps/client/src/widgets/react/Button.tsx@@ -112,7 +112,7 @@ export function SplitButton({ text, icon, children, ...restProps }: {export function ButtonOrActionButton(props: {text: string;icon: string;-} & Pick<ButtonProps, "onClick" | "triggerCommand">) {+} & Pick<ButtonProps, "onClick" | "triggerCommand" | "disabled" | "title">) {if (isDesktop()) {return <Button {...props} />;}diff --git a/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx b/apps/client/src/widgets/ribbon/NoteActionsCustom.tsxindex c2925c849b..c371b4a83a 100644--- a/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx+++ b/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx@@ -247,15 +247,8 @@ function InAppHelpButton({ note }: NoteActionsCustomInnerProps) {);}-function AddChildButton({ parentComponent, noteType, viewType, ntxId, isReadOnly }: NoteActionsCustomInnerProps) {- if (noteType === "book" && viewType === "geoMap") {- return <ActionButton- icon="bx bx-plus-circle"- text={t("geo-map.create-child-note-title")}- onClick={() => parentComponent.triggerEvent("geoMapCreateChildNote", { ntxId })}- disabled={isReadOnly}- />;- } else if (noteType === "relationMap") {+function AddChildButton({ parentComponent, noteType, ntxId, isReadOnly }: NoteActionsCustomInnerProps) {+ if (noteType === "relationMap") {return <ActionButtonicon="bx bx-folder-plus"text={t("relation_map_buttons.create_child_note_title")}