Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(note_actions): protect note switch
Elian Doran77f5770bff5c
diff --git a/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx b/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsxindex 94aa6b3143..d42617dae1 100644--- a/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx+++ b/apps/client/src/widgets/ribbon/BasicPropertiesTab.tsx@@ -29,7 +29,7 @@ export default function BasicPropertiesTab({ note }: TabContext) {return (<div className="basic-properties-widget"><NoteTypeWidget note={note} />- <ProtectedNoteSwitch note={note} />+ {!isNewLayout && <ProtectedNoteSwitch note={note} />}{!isNewLayout && <EditabilitySelect note={note} />}{!isNewLayout && <BookmarkSwitch note={note} />}{!isNewLayout && <SharedSwitch note={note} />}diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsxindex d4b5e235a1..282bb6b9c1 100644--- a/apps/client/src/widgets/ribbon/NoteActions.tsx+++ b/apps/client/src/widgets/ribbon/NoteActions.tsx@@ -18,6 +18,7 @@ import { useIsNoteReadOnly, useNoteContext, useNoteLabel, useNoteLabelBoolean, uimport { ParentComponent } from "../react/react_utils";import { isExperimentalFeatureEnabled } from "../../services/experimental_features";import { useNoteBookmarkState, useShareState } from "./BasicPropertiesTab";+import protected_session from "../../services/protected_session";const isNewLayout = isExperimentalFeatureEnabled("new-layout");@@ -120,6 +121,7 @@ function NoteBasicProperties({ note }: { note: FNote }) {const [ isBookmarked, setIsBookmarked ] = useNoteBookmarkState(note);const [ isShared, switchShareState ] = useShareState(note);const [ isTemplate, setIsTemplate ] = useNoteLabelBoolean(note, "template");+ const isProtected = useNoteProperty(note, "isProtected");return <><FormListToggleableItem@@ -141,6 +143,11 @@ function NoteBasicProperties({ note }: { note: FNote }) {disabled={["root", "_share", "_hidden"].includes(note?.noteId ?? "") || note?.noteId.startsWith("_options")}/><EditabilityDropdown note={note} />+ <FormListToggleableItem+ icon="bx bx-lock-alt"+ title={t("protect_note.toggle-on")}+ currentValue={!!isProtected} onChange={shouldProtect => protected_session.protectNote(note.noteId, shouldProtect, false)}+ /></>;}@@ -154,7 +161,7 @@ function EditabilityDropdown({ note }: { note: FNote }) {}return (- <FormDropdownSubmenu title={t("basic_properties.editable")} icon="bx bx-lock-alt" dropStart>+ <FormDropdownSubmenu title={t("basic_properties.editable")} icon="bx bx-edit-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>