chore(note_actions): reintroduce disabled logic for toggles

This commit is contained in:
Elian Doran 2025-12-10 20:20:21 +02:00
parent 01978dabf0
commit efb2f9a048
No known key found for this signature in database
2 changed files with 21 additions and 4 deletions

View File

@ -141,7 +141,9 @@ export function FormListToggleableItem({ title, currentValue, onChange, ...props
return ( return (
<FormListItem {...props} onClick={(e) => { <FormListItem {...props} onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
onChange(!currentValue); if (!props.disabled) {
onChange(!currentValue);
}
}}> }}>
<FormToggle <FormToggle
switchOnName={title} switchOffName={title} switchOnName={title} switchOffName={title}

View File

@ -122,9 +122,24 @@ function NoteBasicProperties({ note }: { note: FNote }) {
const [ isTemplate, setIsTemplate ] = useNoteLabelBoolean(note, "template"); const [ isTemplate, setIsTemplate ] = useNoteLabelBoolean(note, "template");
return <> return <>
<FormListToggleableItem icon="bx bx-bookmark" title={t("bookmark_switch.bookmark")} currentValue={isBookmarked} onChange={setIsBookmarked} /> <FormListToggleableItem
<FormListToggleableItem icon="bx bx-share-alt" title={t("shared_switch.shared")} currentValue={isShared} onChange={switchShareState} /> icon="bx bx-bookmark"
<FormListToggleableItem icon="bx bx-copy-alt" title={t("template_switch.template")} currentValue={isTemplate} onChange={setIsTemplate} /> title={t("bookmark_switch.bookmark")}
currentValue={isBookmarked} onChange={setIsBookmarked}
disabled={["root", "_hidden"].includes(note?.noteId ?? "")}
/>
<FormListToggleableItem
icon="bx bx-copy-alt"
title={t("template_switch.template")}
currentValue={isTemplate} onChange={setIsTemplate}
disabled={note?.noteId.startsWith("_options")}
/>
<FormListToggleableItem
icon="bx bx-share-alt"
title={t("shared_switch.shared")}
currentValue={isShared} onChange={switchShareState}
disabled={["root", "_share", "_hidden"].includes(note?.noteId ?? "") || note?.noteId.startsWith("_options")}
/>
<EditabilityDropdown note={note} /> <EditabilityDropdown note={note} />
</>; </>;
} }