Skip to content

Build your personal knowledge base with Trilium Notes

feat(layout/note_actions): integrate geo map add button

Elian Doran4b80eec000e9
diff --git a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx
index 72cd37f5d2..ec5db379c8 100644
--- a/apps/client/src/widgets/FloatingButtonsDefinitions.tsx
+++ b/apps/client/src/widgets/FloatingButtonsDefinitions.tsx
@@ -103,7 +103,7 @@ function SwitchSplitOrientationButton({ note, isReadOnly, isDefaultViewMode }: F
function ToggleReadOnlyButton({ note, viewType, isDefaultViewMode }: FloatingButtonContext) {
const [ isReadOnly, setReadOnly ] = useNoteLabelBoolean(note, "readOnly");
- const isEnabled = ([ "mermaid", "mindMap", "canvas" ].includes(note.type) || viewType === "geoMap")
+ const isEnabled = !isNewLayout && ([ "mermaid", "mindMap", "canvas" ].includes(note.type) || viewType === "geoMap")
&& note.isContentAvailable() && isDefaultViewMode;
return isEnabled && <FloatingButton
@@ -246,7 +246,7 @@ function RelationMapButtons({ note, isDefaultViewMode, triggerEvent }: FloatingB
}
function GeoMapButtons({ triggerEvent, viewType, isReadOnly }: FloatingButtonContext) {
- const isEnabled = viewType === "geoMap" && !isReadOnly;
+ const isEnabled = !isNewLayout && viewType === "geoMap" && !isReadOnly;
return isEnabled && (
<FloatingButton
icon="bx bx-plus-circle"
diff --git a/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx b/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx
index 497e1ae148..81d36e3d7c 100644
--- a/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx
+++ b/apps/client/src/widgets/ribbon/NoteActionsCustom.tsx
@@ -42,7 +42,7 @@ export default function NoteActionsCustom(props: NoteActionsCustomProps) {
const [ viewType ] = useNoteLabel(note, "viewType");
const parentComponent = useContext(ParentComponent);
const [ isReadOnly ] = useNoteLabelBoolean(note, "readOnly");
- const innerProps: NoteActionsCustomInnerProps | false = !!noteType && !!noteMime && !!parentComponent && {
+ const innerProps: NoteActionsCustomInnerProps | false = !!noteType && noteMime !== undefined && !!parentComponent && {
...props,
noteType,
noteMime,
@@ -223,12 +223,21 @@ function OpenTriliumApiDocsButton({ noteMime }: NoteActionsCustomInnerProps) {
/>;
}
-function AddChildButton({ parentComponent, noteType, ntxId }: NoteActionsCustomInnerProps) {
- const isEnabled = noteType === "relationMap";
- return isEnabled && <ActionButton
- icon="bx bx-folder-plus"
- text={t("relation_map_buttons.create_child_note_title")}
- onClick={() => parentComponent.triggerEvent("relationMapCreateChildNote", { ntxId })}
- />;
+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") {
+ return <ActionButton
+ icon="bx bx-folder-plus"
+ text={t("relation_map_buttons.create_child_note_title")}
+ onClick={() => parentComponent.triggerEvent("relationMapCreateChildNote", { ntxId })}
+ disabled={isReadOnly}
+ />;
+ }
}
//#endregion