feat(badges/content): option to execute now

This commit is contained in:
Elian Doran
2026-02-14 11:15:08 +02:00
parent a739d28563
commit ef75de63fe
2 changed files with 19 additions and 5 deletions

View File

@@ -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"
}
}

View File

@@ -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 (
<BadgeWithDropdown
className="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 />
</>
)}
<FormListItem
icon="bx bx-help-circle"
onClick={() => openInAppHelpFromUrl(helpPage)}