diff --git a/apps/client/src/widgets/note_map.ts b/apps/client/src/widgets/note_map.ts index 2aa7a94d1..0811c7515 100644 --- a/apps/client/src/widgets/note_map.ts +++ b/apps/client/src/widgets/note_map.ts @@ -13,11 +13,6 @@ import type FNote from "../entities/fnote.js"; const esc = utils.escapeHtml; const TPL = /*html*/`
-
- - -
-
@@ -63,12 +58,6 @@ export default class NoteMapWidget extends NoteContextAwareWidget { new ResizeObserver(() => this.setDimensions()).observe(this.$container[0]); - this.$widget.find(".map-type-switcher button").on("click", async (e) => { - const type = $(e.target).closest("button").attr("data-type"); - - await attributeService.setLabel(this.noteId ?? "", "mapType", type); - }); - // Reading the status of the Drag nodes Ui element. Changing it´s color when activated. // Reading Force value of the link distance. this.$fixNodesButton.on("click", async (event) => { diff --git a/apps/client/src/widgets/note_map/NoteMap.tsx b/apps/client/src/widgets/note_map/NoteMap.tsx index b4dc6fef3..ce062be20 100644 --- a/apps/client/src/widgets/note_map/NoteMap.tsx +++ b/apps/client/src/widgets/note_map/NoteMap.tsx @@ -7,6 +7,8 @@ import { useElementSize, useNoteContext, useNoteLabel } from "../react/hooks"; import ForceGraph, { LinkObject, NodeObject } from "force-graph"; import { loadNotesAndRelations, NotesAndRelationsData } from "./data"; import { CssData, setupRendering } from "./rendering"; +import ActionButton from "../react/ActionButton"; +import { t } from "../../services/i18n"; interface NoteMapProps { note: FNote; @@ -19,8 +21,7 @@ type MapType = "tree" | "link"; export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) { const containerRef = useRef(null); const styleResolverRef = useRef(null); - const [ cssData, setCssData ] = useState(); - const [ mapTypeRaw ] = useNoteLabel(note, "mapType"); + const [ mapTypeRaw, setMapType ] = useNoteLabel(note, "mapType"); const mapType: MapType = mapTypeRaw === "tree" ? "tree" : "link"; const graphRef = useRef>>(); @@ -35,7 +36,6 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) { graphRef.current = graph; const mapRootId = getMapRootNoteId(note.noteId, note, widgetMode); - console.log("Map root ID ", mapRootId); if (!mapRootId) return; const labelValues = (name: string) => note.getLabels(name).map(l => l.value) ?? []; @@ -56,7 +56,7 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) { }); return () => container.replaceChildren(); - }, [ note ]); + }, [ note, mapType ]); // React to container size useEffect(() => { @@ -66,6 +66,24 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) { return (
+
+ setMapType("link")} + frame + /> + + setMapType("tree")} + frame + /> +
+
diff --git a/apps/client/src/widgets/react/ActionButton.tsx b/apps/client/src/widgets/react/ActionButton.tsx index e9753a7e2..bb5f58eb3 100644 --- a/apps/client/src/widgets/react/ActionButton.tsx +++ b/apps/client/src/widgets/react/ActionButton.tsx @@ -12,9 +12,10 @@ export interface ActionButtonProps { triggerCommand?: CommandNames; noIconActionClass?: boolean; frame?: boolean; + disabled?: boolean; } -export default function ActionButton({ text, icon, className, onClick, triggerCommand, titlePosition, noIconActionClass, frame }: ActionButtonProps) { +export default function ActionButton({ text, icon, className, onClick, triggerCommand, titlePosition, noIconActionClass, frame, disabled }: ActionButtonProps) { const buttonRef = useRef(null); const [ keyboardShortcut, setKeyboardShortcut ] = useState(); @@ -32,8 +33,9 @@ export default function ActionButton({ text, icon, className, onClick, triggerCo return