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
chore(client): address requested changes
Elian Doran15e569dcea32
diff --git a/apps/client/src/entities/fnote.ts b/apps/client/src/entities/fnote.tsindex fbe9493128..2b515f2412 100644--- a/apps/client/src/entities/fnote.ts+++ b/apps/client/src/entities/fnote.ts@@ -700,6 +700,11 @@ export default class FNote {return this.hasAttribute(LABEL, name);}+ /**+ * Returns `true` if the note has a label with the given name (same as {@link hasOwnedLabel}), or it has a label with the `disabled:` prefix (for example due to a safe import).+ * @param name the name of the label to look for.+ * @returns `true` if the label exists, or its version with the `disabled:` prefix.+ */hasLabelOrDisabled(name: string) {return this.hasLabel(name) || this.hasLabel(`disabled:${name}`);}diff --git a/apps/client/src/widgets/layout/ActiveContentBadges.tsx b/apps/client/src/widgets/layout/ActiveContentBadges.tsxindex ff94f19f04..80b37ec291 100644--- a/apps/client/src/widgets/layout/ActiveContentBadges.tsx+++ b/apps/client/src/widgets/layout/ActiveContentBadges.tsx@@ -76,7 +76,7 @@ function ActiveContentBadge({ info, note }: { note: FNote, info: ActiveContentInconst { icon, helpPage, apiDocsPage, isExecutable } = typeMappings[info.type];return (<BadgeWithDropdown- className={clsx("active-content-badge", !!info.isEnabled && "disabled")}+ className={clsx("active-content-badge", info.canToggleEnabled && !info.isEnabled && "disabled")}icon={icon}text={getTranslationForType(info.type)}>@@ -200,7 +200,7 @@ function getTranslationForType(type: ActiveContentInfo["type"]) {case "renderNote":return t("active_content_badges.type_render_note");case "webView":- return t("note_types.web-view");+ return t("active_content_badges.type_web_view");}}@@ -210,8 +210,8 @@ function ActiveContentToggle({ note, info }: { note: FNote, info: ActiveContentIreturn info && <FormToggleswitchOnName="" switchOffName=""currentValue={info.isEnabled}- switchOnTooltip={t("active_content_badges.toggle_tooltip_disable_tooltip", { type: typeTranslation })}- switchOffTooltip={t("active_content_badges.toggle_tooltip_enable_tooltip", { type: typeTranslation })}+ switchOffTooltip={t("active_content_badges.toggle_tooltip_disable_tooltip", { type: typeTranslation })}+ switchOnTooltip={t("active_content_badges.toggle_tooltip_enable_tooltip", { type: typeTranslation })}onChange={async (willEnable) => {const attrs = note.getOwnedAttributes().filter(attr => {@@ -227,7 +227,7 @@ function ActiveContentToggle({ note, info }: { note: FNote, info: ActiveContentI// We are adding and removing afterwards to avoid a flicker (because for a moment there would be no active content attribute anymore) because the operations are done in sequence and not atomically.if (attr.type === "label") {- await attributes.addLabel(note.noteId, newName, attr.value);+ await attributes.setLabel(note.noteId, newName, attr.value);} else {await attributes.setRelation(note.noteId, newName, attr.value);}@@ -246,7 +246,7 @@ function useActiveContentInfo(note: FNote | null | undefined) {function refresh() {let type: ActiveContentInfo["type"] | null = null;- let isEnabled = true;+ let isEnabled = false;let canToggleEnabled = false;if (!note) {