mirror of
https://github.com/zadam/trilium.git
synced 2026-02-19 20:24:28 +01:00
feat(badges/content): integrate options for frontend script
This commit is contained in:
parent
bd1f0909a2
commit
2d34cdef5e
@ -2292,6 +2292,7 @@
|
||||
"active_content_badges": {
|
||||
"type_icon_pack": "Icon pack",
|
||||
"type_backend_script": "Backend script",
|
||||
"type_frontend_script": "Frontend script",
|
||||
"toggle_tooltip_enable_tooltip": "Click to enable this {{type}}.",
|
||||
"toggle_tooltip_disable_tooltip": "Click to disable this {{type}}.",
|
||||
"menu_docs": "Open documentation",
|
||||
@ -2300,6 +2301,8 @@
|
||||
"menu_run_disabled": "Manually",
|
||||
"menu_run_backend_startup": "When the backend starts up",
|
||||
"menu_run_hourly": "Hourly",
|
||||
"menu_run_daily": "Daily"
|
||||
"menu_run_daily": "Daily",
|
||||
"menu_run_frontend_startup": "When the desktop frontend starts up",
|
||||
"menu_run_mobile_startup": "When the mobile frontend starts up"
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ function ActiveContentBadge({ info, note }: { note: FNote, info: ActiveContentIn
|
||||
icon="bx bx-play"
|
||||
triggerCommand="runActiveNote"
|
||||
>{t("active_content_badges.menu_execute_now")}</FormListItem>
|
||||
<ScriptRunOptions note={note} />
|
||||
<ScriptRunOptions note={note} info={info} />
|
||||
<FormDropdownDivider />
|
||||
</>
|
||||
)}
|
||||
@ -82,18 +82,18 @@ function ActiveContentBadge({ info, note }: { note: FNote, info: ActiveContentIn
|
||||
);
|
||||
}
|
||||
|
||||
function ScriptRunOptions({ note }: { note: FNote }) {
|
||||
function ScriptRunOptions({ info, note }: { note: FNote, info: ActiveContentInfo }) {
|
||||
const [ run, setRun ] = useNoteLabel(note, "run");
|
||||
|
||||
const options: {
|
||||
title: string;
|
||||
value: string | null;
|
||||
type: "backendScript" | "frontendScript";
|
||||
}[] = [
|
||||
type: "both" | "backendScript" | "frontendScript";
|
||||
}[] = ([
|
||||
{
|
||||
title: t("active_content_badges.menu_run_disabled"),
|
||||
value: null,
|
||||
type: "backendScript"
|
||||
type: "both"
|
||||
},
|
||||
{
|
||||
title: t("active_content_badges.menu_run_backend_startup"),
|
||||
@ -110,7 +110,17 @@ function ScriptRunOptions({ note }: { note: FNote }) {
|
||||
value: "hourly",
|
||||
type: "backendScript"
|
||||
},
|
||||
];
|
||||
{
|
||||
title: t("active_content_badges.menu_run_frontend_startup"),
|
||||
value: "frontendStartup",
|
||||
type: "frontendScript"
|
||||
},
|
||||
{
|
||||
title: t("active_content_badges.menu_run_mobile_startup"),
|
||||
value: "mobileStartup",
|
||||
type: "frontendScript"
|
||||
}
|
||||
] as const).filter(option => option.type === "both" || option.type === info.type);
|
||||
|
||||
return (
|
||||
<FormDropdownSubmenu title={t("active_content_badges.menu_run")} icon="bx bx-rss" dropStart>
|
||||
@ -131,6 +141,8 @@ function getTranslationForType(type: ActiveContentInfo["type"]) {
|
||||
return t("active_content_badges.type_icon_pack");
|
||||
case "backendScript":
|
||||
return t("active_content_badges.type_backend_script");
|
||||
case "frontendScript":
|
||||
return t("active_content_badges.type_frontend_script");
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,6 +198,8 @@ function useActiveContentInfo(note: FNote | null | undefined) {
|
||||
|
||||
if (note.type === "code" && note.mime === "application/javascript;env=backend") {
|
||||
type = "backendScript";
|
||||
} else if (note.type === "code" && note.mime === "application/javascript;env=frontend") {
|
||||
type = "frontendScript";
|
||||
}
|
||||
|
||||
for (const labelToCheck of activeContentLabels ) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user