mirror of
https://github.com/zadam/trilium.git
synced 2025-12-16 21:29:56 +01:00
feat(layout/note_actions): integrate geo map add button
This commit is contained in:
@@ -103,7 +103,7 @@ function SwitchSplitOrientationButton({ note, isReadOnly, isDefaultViewMode }: F
|
|||||||
|
|
||||||
function ToggleReadOnlyButton({ note, viewType, isDefaultViewMode }: FloatingButtonContext) {
|
function ToggleReadOnlyButton({ note, viewType, isDefaultViewMode }: FloatingButtonContext) {
|
||||||
const [ isReadOnly, setReadOnly ] = useNoteLabelBoolean(note, "readOnly");
|
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;
|
&& note.isContentAvailable() && isDefaultViewMode;
|
||||||
|
|
||||||
return isEnabled && <FloatingButton
|
return isEnabled && <FloatingButton
|
||||||
@@ -246,7 +246,7 @@ function RelationMapButtons({ note, isDefaultViewMode, triggerEvent }: FloatingB
|
|||||||
}
|
}
|
||||||
|
|
||||||
function GeoMapButtons({ triggerEvent, viewType, isReadOnly }: FloatingButtonContext) {
|
function GeoMapButtons({ triggerEvent, viewType, isReadOnly }: FloatingButtonContext) {
|
||||||
const isEnabled = viewType === "geoMap" && !isReadOnly;
|
const isEnabled = !isNewLayout && viewType === "geoMap" && !isReadOnly;
|
||||||
return isEnabled && (
|
return isEnabled && (
|
||||||
<FloatingButton
|
<FloatingButton
|
||||||
icon="bx bx-plus-circle"
|
icon="bx bx-plus-circle"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ export default function NoteActionsCustom(props: NoteActionsCustomProps) {
|
|||||||
const [ viewType ] = useNoteLabel(note, "viewType");
|
const [ viewType ] = useNoteLabel(note, "viewType");
|
||||||
const parentComponent = useContext(ParentComponent);
|
const parentComponent = useContext(ParentComponent);
|
||||||
const [ isReadOnly ] = useNoteLabelBoolean(note, "readOnly");
|
const [ isReadOnly ] = useNoteLabelBoolean(note, "readOnly");
|
||||||
const innerProps: NoteActionsCustomInnerProps | false = !!noteType && !!noteMime && !!parentComponent && {
|
const innerProps: NoteActionsCustomInnerProps | false = !!noteType && noteMime !== undefined && !!parentComponent && {
|
||||||
...props,
|
...props,
|
||||||
noteType,
|
noteType,
|
||||||
noteMime,
|
noteMime,
|
||||||
@@ -223,12 +223,21 @@ function OpenTriliumApiDocsButton({ noteMime }: NoteActionsCustomInnerProps) {
|
|||||||
/>;
|
/>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function AddChildButton({ parentComponent, noteType, ntxId }: NoteActionsCustomInnerProps) {
|
function AddChildButton({ parentComponent, noteType, viewType, ntxId, isReadOnly }: NoteActionsCustomInnerProps) {
|
||||||
const isEnabled = noteType === "relationMap";
|
if (noteType === "book" && viewType === "geoMap") {
|
||||||
return isEnabled && <ActionButton
|
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"
|
icon="bx bx-folder-plus"
|
||||||
text={t("relation_map_buttons.create_child_note_title")}
|
text={t("relation_map_buttons.create_child_note_title")}
|
||||||
onClick={() => parentComponent.triggerEvent("relationMapCreateChildNote", { ntxId })}
|
onClick={() => parentComponent.triggerEvent("relationMapCreateChildNote", { ntxId })}
|
||||||
|
disabled={isReadOnly}
|
||||||
/>;
|
/>;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user