mirror of
https://github.com/zadam/trilium.git
synced 2026-05-07 11:06:20 +02:00
refactor(client): deduplicate checks for title/icon editability
This commit is contained in:
@@ -236,6 +236,16 @@ export default class FNote {
|
||||
return this.hasAttribute("label", "archived");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the note's metadata (title, icon) should not be editable.
|
||||
* This applies to system notes like options, help, and launch bar configuration.
|
||||
*/
|
||||
get isMetadataReadOnly() {
|
||||
return utils.isLaunchBarConfig(this.noteId)
|
||||
|| this.noteId.startsWith("_help_")
|
||||
|| this.noteId.startsWith("_options");
|
||||
}
|
||||
|
||||
getChildNoteIds() {
|
||||
return this.children;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { CellComponentProps, Grid } from "react-window";
|
||||
import FNote from "../entities/fnote";
|
||||
import attributes from "../services/attributes";
|
||||
import server from "../services/server";
|
||||
import { isDesktop, isLaunchBarConfig, isMobile } from "../services/utils";
|
||||
import { isDesktop, isMobile } from "../services/utils";
|
||||
import ActionButton from "./react/ActionButton";
|
||||
import Dropdown from "./react/Dropdown";
|
||||
import { FormDropdownDivider, FormListItem } from "./react/FormList";
|
||||
@@ -43,9 +43,7 @@ export default function NoteIcon() {
|
||||
}, [ note, iconClass, workspaceIconClass ]);
|
||||
|
||||
const isDisabled = viewScope?.viewMode !== "default"
|
||||
|| (note?.noteId && isLaunchBarConfig(note.noteId))
|
||||
|| note?.noteId?.startsWith("_help_")
|
||||
|| note?.noteId?.startsWith("_options");
|
||||
|| note?.isMetadataReadOnly;
|
||||
|
||||
if (isMobile()) {
|
||||
return <MobileNoteIconSwitcher note={note} icon={icon} disabled={isDisabled} />;
|
||||
|
||||
@@ -9,7 +9,6 @@ import { t } from "../services/i18n";
|
||||
import protected_session_holder from "../services/protected_session_holder";
|
||||
import server from "../services/server";
|
||||
import { isIMEComposing } from "../services/shortcuts";
|
||||
import { isLaunchBarConfig } from "../services/utils";
|
||||
import FormTextBox from "./react/FormTextBox";
|
||||
import { useNoteContext, useNoteProperty, useSpacedUpdate, useTriliumEvent, useTriliumEvents } from "./react/hooks";
|
||||
|
||||
@@ -27,9 +26,7 @@ export default function NoteTitleWidget(props: {className?: string}) {
|
||||
const isReadOnly = note === null
|
||||
|| note === undefined
|
||||
|| (note.isProtected && !protected_session_holder.isProtectedSessionAvailable())
|
||||
|| isLaunchBarConfig(note.noteId)
|
||||
|| note.noteId.startsWith("_help_")
|
||||
|| note.noteId.startsWith("_options")
|
||||
|| note.isMetadataReadOnly
|
||||
|| viewScope?.viewMode !== "default";
|
||||
setReadOnly(isReadOnly);
|
||||
}, [ note, note?.noteId, note?.isProtected, viewScope?.viewMode ]);
|
||||
|
||||
Reference in New Issue
Block a user