Skip to content

Build your personal knowledge base with Trilium Notes

feat(note_actions): integrate editability menu into new layout

Elian Dorancfbd2bf53ac8
diff --git a/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx b/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx
index 0f186998b9..94aa6b3143 100644
--- a/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx
+++ b/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx
@@ -30,7 +30,7 @@ export default function BasicPropertiesTab({ note }: TabContext) {
<div className="basic-properties-widget">
<NoteTypeWidget note={note} />
<ProtectedNoteSwitch note={note} />
- <EditabilitySelect note={note} />
+ {!isNewLayout && <EditabilitySelect note={note} />}
{!isNewLayout && <BookmarkSwitch note={note} />}
{!isNewLayout && <SharedSwitch note={note} />}
{!isNewLayout && <TemplateSwitch note={note} />}
@@ -190,7 +190,7 @@ function EditabilitySelect({ note }: { note?: FNote | null }) {
}}
/>
</div>
- )
+ );
}
function BookmarkSwitch({ note }: { note?: FNote | null }) {
diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsx
index 321ccda894..22e913b16d 100644
--- a/apps/client/src/widgets/ribbon/NoteActions.tsx
+++ b/apps/client/src/widgets/ribbon/NoteActions.tsx
@@ -125,9 +125,28 @@ function NoteBasicProperties({ note }: { note: FNote }) {
<FormListToggleableItem icon="bx bx-bookmark" title={t("bookmark_switch.bookmark")} currentValue={isBookmarked} onChange={setIsBookmarked} />
<FormListToggleableItem icon="bx bx-share-alt" title={t("shared_switch.shared")} currentValue={isShared} onChange={switchShareState} />
<FormListToggleableItem icon="bx bx-copy-alt" title={t("template_switch.template")} currentValue={isTemplate} onChange={setIsTemplate} />
+ <EditabilityDropdown note={note} />
</>;
}
+function EditabilityDropdown({ note }: { note: FNote }) {
+ const [ readOnly, setReadOnly ] = useNoteLabelBoolean(note, "readOnly");
+ const [ autoReadOnlyDisabled, setAutoReadOnlyDisabled ] = useNoteLabelBoolean(note, "autoReadOnlyDisabled");
+
+ function setState(readOnly: boolean, autoReadOnlyDisabled: boolean) {
+ setReadOnly(readOnly);
+ setAutoReadOnlyDisabled(autoReadOnlyDisabled);
+ }
+
+ return (
+ <FormDropdownSubmenu title={t("basic_properties.editable")} icon="bx bx-lock-alt" dropStart>
+ <FormListItem checked={!readOnly && !autoReadOnlyDisabled} onClick={() => setState(false, false)} description={t("editability_select.note_is_editable")}>{t("editability_select.auto")}</FormListItem>
+ <FormListItem checked={readOnly && !autoReadOnlyDisabled} onClick={() => setState(true, false)} description={t("editability_select.note_is_read_only")}>{t("editability_select.read_only")}</FormListItem>
+ <FormListItem checked={!readOnly && autoReadOnlyDisabled} onClick={() => setState(false, true)} description={t("editability_select.note_is_always_editable")}>{t("editability_select.always_editable")}</FormListItem>
+ </FormDropdownSubmenu>
+ );
+}
+
function DevelopmentActions({ note, noteContext }: { note: FNote, noteContext?: NoteContext }) {
return (
<FormDropdownSubmenu title="Development Actions" icon="bx bx-wrench" dropStart>