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(badges/content): indicate enabled/disabled state
Elian Doranccff210b4c98
diff --git a/apps/client/src/widgets/layout/ActiveContentBadges.tsx b/apps/client/src/widgets/layout/ActiveContentBadges.tsxindex 62eb528898..c2eab4a68a 100644--- a/apps/client/src/widgets/layout/ActiveContentBadges.tsx+++ b/apps/client/src/widgets/layout/ActiveContentBadges.tsx@@ -11,10 +11,10 @@ export function ActiveContentBadges() {const info = useActiveContentInfo(note);console.log("Got inf ", info);- return (+ return (info &&<>- {info?.type === "iconPack" && <IconPackBadge />}- <ActiveContentToggle />+ {info.type === "iconPack" && <IconPackBadge />}+ <ActiveContentToggle info={info} /></>);}@@ -29,11 +29,11 @@ function IconPackBadge() {);}-function ActiveContentToggle() {- return <FormToggle+function ActiveContentToggle({ info }: { info: ActiveContentInfo }) {+ return info && <FormToggleswitchOnName="Enabled"switchOffName="Enabled"- currentValue={true}+ currentValue={info.isEnabled}/>;}@@ -41,6 +41,7 @@ const activeContentLabels = [ "iconPack" ] as const;interface ActiveContentInfo {type: "iconPack";+ isEnabled: boolean;}function useActiveContentInfo(note: FNote | null | undefined) {@@ -48,6 +49,7 @@ function useActiveContentInfo(note: FNote | null | undefined) {function refresh() {let type: ActiveContentInfo["type"] | null = null;+ let isEnabled = true;if (!note) {setInfo(null);@@ -57,11 +59,16 @@ function useActiveContentInfo(note: FNote | null | undefined) {for (const labelToCheck of activeContentLabels ) {if (note.hasLabel(labelToCheck)) {type = labelToCheck;+ break;+ } else if (note.hasLabel(`disabled:${labelToCheck}`)) {+ type = labelToCheck;+ isEnabled = false;+ break;}}if (type) {- setInfo({ type });+ setInfo({ type, isEnabled });} else {setInfo(null);}