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): option to execute now
Elian Doranef75de63fe0f
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 8145a74231..c8ded0fbb4 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -2294,6 +2294,7 @@"type_backend_script": "Backend script","toggle_tooltip_enable_tooltip": "Click to enable this {{type}}.","toggle_tooltip_disable_tooltip": "Click to disable this {{type}}.",- "menu_docs": "Open documentation"+ "menu_docs": "Open documentation",+ "menu_execute_now": "Execute script now"}}diff --git a/apps/client/src/widgets/layout/ActiveContentBadges.tsx b/apps/client/src/widgets/layout/ActiveContentBadges.tsxindex daa787b927..936c6da7a6 100644--- a/apps/client/src/widgets/layout/ActiveContentBadges.tsx+++ b/apps/client/src/widgets/layout/ActiveContentBadges.tsx@@ -6,7 +6,7 @@ import attributes from "../../services/attributes";import { t } from "../../services/i18n";import { openInAppHelpFromUrl } from "../../services/utils";import { BadgeWithDropdown } from "../react/Badge";-import { FormListItem } from "../react/FormList";+import { FormDropdownDivider, FormListItem } from "../react/FormList";import FormToggle from "../react/FormToggle";import { useNoteContext, useTriliumEvent } from "../react/hooks";@@ -17,6 +17,7 @@ const typeMappings: Record<ActiveContentInfo["type"], {icon: string;helpPage: string;apiDocsPage?: string;+ isExecutable?: boolean}> = {iconPack: {icon: "bx bx-package",@@ -25,12 +26,14 @@ const typeMappings: Record<ActiveContentInfo["type"], {backendScript: {icon: "bx bx-server",helpPage: "SPirpZypehBG",- apiDocsPage: "MEtfsqa5VwNi"+ apiDocsPage: "MEtfsqa5VwNi",+ isExecutable: true,},frontendScript: {icon: "bx bx-window",helpPage: "yIhgI5H7A2Sm",- apiDocsPage: "Q2z6av6JZVWm"+ apiDocsPage: "Q2z6av6JZVWm",+ isExecutable: true}};@@ -47,13 +50,23 @@ export function ActiveContentBadges() {}function ActiveContentBadge({ info }: { note: FNote, info: ActiveContentInfo }) {- const { icon, helpPage, apiDocsPage } = typeMappings[info.type];+ const { icon, helpPage, apiDocsPage, isExecutable } = typeMappings[info.type];return (<BadgeWithDropdownclassName="icon-pack-badge"icon={icon}text={getTranslationForType(info.type)}>+ {isExecutable && (+ <>+ <FormListItem+ icon="bx bx-play"+ triggerCommand="runActiveNote"+ >{t("active_content_badges.menu_execute_now")}</FormListItem>+ <FormDropdownDivider />+ </>+ )}+<FormListItemicon="bx bx-help-circle"onClick={() => openInAppHelpFromUrl(helpPage)}