From 6b78bfecb4d7b0c0d7bff1639c09e4aab7f6dcde Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 15 Feb 2026 13:34:48 +0200 Subject: [PATCH] refactor(badges/content): integrate run options using additional options --- .../widgets/layout/ActiveContentBadges.tsx | 85 +++++++------------ .../src/widgets/react/NotePropertyMenu.tsx | 7 +- 2 files changed, 34 insertions(+), 58 deletions(-) diff --git a/apps/client/src/widgets/layout/ActiveContentBadges.tsx b/apps/client/src/widgets/layout/ActiveContentBadges.tsx index 781f827553..473cae9a85 100644 --- a/apps/client/src/widgets/layout/ActiveContentBadges.tsx +++ b/apps/client/src/widgets/layout/ActiveContentBadges.tsx @@ -38,12 +38,41 @@ const typeMappings: Record{t("active_content_badges.menu_execute_now")} - )} @@ -143,59 +171,6 @@ function ActiveContentBadge({ info, note }: { note: FNote, info: ActiveContentIn ); } -function ScriptRunOptions({ info, note }: { note: FNote, info: ActiveContentInfo }) { - const [ run, setRun ] = useNoteLabel(note, "run"); - - const options: { - title: string; - value: string | null; - type: "both" | "backendScript" | "frontendScript"; - }[] = ([ - { - title: t("active_content_badges.menu_run_disabled"), - value: null, - type: "both" - }, - { - title: t("active_content_badges.menu_run_backend_startup"), - value: "backendStartup", - type: "backendScript" - }, - { - title: t("active_content_badges.menu_run_daily"), - value: "daily", - type: "backendScript" - }, - { - title: t("active_content_badges.menu_run_hourly"), - 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 ( - - {options.map(({ title, value }) => ( - setRun(value)} - checked={run ? run === value : value === null } - >{title} - ))} - - ); -} - function WidgetSwitcher({ note }: { note: FNote }) { const [ widget, setWidget ] = useNoteLabelBoolean(note, "widget"); const [ disabledWidget, setDisabledWidget ] = useNoteLabelBoolean(note, "disabled:widget"); diff --git a/apps/client/src/widgets/react/NotePropertyMenu.tsx b/apps/client/src/widgets/react/NotePropertyMenu.tsx index 5384c400a4..6a5bba1bf8 100644 --- a/apps/client/src/widgets/react/NotePropertyMenu.tsx +++ b/apps/client/src/widgets/react/NotePropertyMenu.tsx @@ -7,7 +7,7 @@ import FNote from "../../entities/fnote"; import NoteContextAwareWidget from "../note_context_aware_widget"; import { FormDropdownDivider, FormDropdownSubmenu, FormListItem, FormListToggleableItem } from "./FormList"; import FormTextBox from "./FormTextBox"; -import { useNoteLabelBoolean, useNoteLabelWithDefault } from "./hooks"; +import { useNoteLabel, useNoteLabelBoolean, useNoteLabelWithDefault } from "./hooks"; import { ParentComponent } from "./react_utils"; export interface ClickContext { @@ -153,13 +153,14 @@ function NumberPropertyView({ note, property }: { note: FNote, property: NumberP } function ComboBoxPropertyView({ note, property }: { note: FNote, property: ComboBoxProperty }) { - const [ value, setValue ] = useNoteLabelWithDefault(note, property.bindToLabel, property.defaultValue ?? ""); + const [ value, setValue ] = useNoteLabel(note, property.bindToLabel); + const valueWithDefault = value ?? property.defaultValue ?? null; function renderItem(option: ComboBoxItem) { return ( setValue(option.value)} > {option.label}