feat(badges/content): add toggle for widget

This commit is contained in:
Elian Doran 2026-02-14 11:47:42 +02:00
parent 2d34cdef5e
commit 3107bc8840
No known key found for this signature in database
2 changed files with 18 additions and 3 deletions

View File

@ -2303,6 +2303,7 @@
"menu_run_hourly": "Hourly",
"menu_run_daily": "Daily",
"menu_run_frontend_startup": "When the desktop frontend starts up",
"menu_run_mobile_startup": "When the mobile frontend starts up"
"menu_run_mobile_startup": "When the mobile frontend starts up",
"menu_toggle_widget": "Widget"
}
}

View File

@ -7,9 +7,9 @@ import attributes from "../../services/attributes";
import { t } from "../../services/i18n";
import { openInAppHelpFromUrl } from "../../services/utils";
import { BadgeWithDropdown } from "../react/Badge";
import { FormDropdownDivider, FormDropdownSubmenu, FormListItem } from "../react/FormList";
import { FormDropdownDivider, FormDropdownSubmenu, FormListItem, FormListToggleableItem } from "../react/FormList";
import FormToggle from "../react/FormToggle";
import { useNoteContext, useNoteLabel, useTriliumEvent, useTriliumOption } from "../react/hooks";
import { useNoteContext, useNoteLabel, useNoteLabelBoolean, useTriliumEvent, useTriliumOption } from "../react/hooks";
const DANGEROUS_ATTRIBUTES = BUILTIN_ATTRIBUTES.filter(a => a.isDangerous);
const activeContentLabels = [ "iconPack" ] as const;
@ -65,6 +65,7 @@ function ActiveContentBadge({ info, note }: { note: FNote, info: ActiveContentIn
triggerCommand="runActiveNote"
>{t("active_content_badges.menu_execute_now")}</FormListItem>
<ScriptRunOptions note={note} info={info} />
{info.type === "frontendScript" && <WidgetSwitcher note={note} />}
<FormDropdownDivider />
</>
)}
@ -135,6 +136,19 @@ function ScriptRunOptions({ info, note }: { note: FNote, info: ActiveContentInfo
);
}
function WidgetSwitcher({ note }: { note: FNote }) {
const [ widget, setWidget ] = useNoteLabelBoolean(note, "widget");
return (
<FormListToggleableItem
title={t("active_content_badges.menu_toggle_widget")}
icon="bx bxs-widget"
currentValue={widget}
onChange={newValue => setWidget(newValue)}
/>
);
}
function getTranslationForType(type: ActiveContentInfo["type"]) {
switch (type) {
case "iconPack":