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
refactor(client): show the new layout's note actions on both layouts
Elian Doran50a24336453a
diff --git a/apps/client/src/layouts/desktop_layout.tsx b/apps/client/src/layouts/desktop_layout.tsxindex 7307edcaa7..4b1a77fcca 100644--- a/apps/client/src/layouts/desktop_layout.tsx+++ b/apps/client/src/layouts/desktop_layout.tsx@@ -1,6 +1,5 @@import type { AppContext } from "../components/app_context.js";import type { WidgetsByParent } from "../services/bundle.js";-import { isExperimentalFeatureEnabled } from "../services/experimental_features.js";import options from "../services/options.js";import utils from "../services/utils.js";import ApiLog from "../widgets/api_log.jsx";@@ -17,8 +16,6 @@ import SplitNoteContainer from "../widgets/containers/split_note_container.js";import PasswordNoteSetDialog from "../widgets/dialogs/password_not_set.js";import UploadAttachmentsDialog from "../widgets/dialogs/upload_attachments.js";import FindWidget from "../widgets/find.js";-import FloatingButtons from "../widgets/FloatingButtons.jsx";-import { DESKTOP_FLOATING_BUTTONS } from "../widgets/FloatingButtonsDefinitions.jsx";import LauncherContainer from "../widgets/launch_bar/LauncherContainer.jsx";import SpacerWidget from "../widgets/launch_bar/SpacerWidget.jsx";import { FixedFormattingToolbar } from "../widgets/layout/FormattingToolbar.jsx";@@ -64,7 +61,6 @@ export default class DesktopLayout {* cannot give those controls room, and they end up drawn over the launcher pane instead.*/const fullWidthTabBar = launcherPaneIsHorizontal || (isElectron && !hasNativeTitleBar && utils.areWindowControlsOnLeft());- const isNewLayout = isExperimentalFeatureEnabled("new-layout");const rootContainer = new RootContainer(true).setParent(appContext)@@ -130,7 +126,6 @@ export default class DesktopLayout {.child(<SpacerWidget baseSize={0} growthFactor={1} />).child(<NoteActions />)).child(new WatchedFileUpdateStatusWidget())- .optChild(!isNewLayout, <FloatingButtons items={DESKTOP_FLOATING_BUTTONS} />).child(new ScrollingContainer().filling()diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex 6b087ac8a4..4ecffce494 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1193,9 +1193,6 @@"active": "Protected session is active. Click to leave protected session.","inactive": "Click to enter protected session"},- "revisions_button": {- "note_revisions": "Note Revisions"- },"update_available": {"update_available": "Update available"},diff --git a/apps/client/src/widgets/layout/NoteActions.tsx b/apps/client/src/widgets/layout/NoteActions.tsxindex 9fe79eef38..87a9fc4ba3 100644--- a/apps/client/src/widgets/layout/NoteActions.tsx+++ b/apps/client/src/widgets/layout/NoteActions.tsx@@ -10,7 +10,6 @@ import NoteContext from "../../components/note_context";import FNote from "../../entities/fnote";import branches from "../../services/branches";import dialog from "../../services/dialog";-import { isExperimentalFeatureEnabled } from "../../services/experimental_features";import { t } from "../../services/i18n";import protected_session from "../../services/protected_session";import server from "../../services/server";@@ -22,7 +21,6 @@ import CreatePaneButton from "../buttons/create_pane_button";import MovePaneButton from "../buttons/move_pane_button";import { showImageCompressionDialog } from "../dialogs/image_compression/image_compression_dialog";import { isAlwaysFullWidthByType } from "../note_wrapper";-import ActionButton from "../react/ActionButton";import Dropdown, { type DropdownHandle } from "../react/Dropdown";import { FormDropdownDivider, FormDropdownSubmenu, FormListHeader, FormListItem, FormListToggleableItem } from "../react/FormList";import { useIsNoteReadOnly, useNoteContext, useNoteLabel, useNoteLabelBoolean, useNoteLabelOptionalBool, useNoteProperty, useSyncedRef, useTriliumEvent, useTriliumOption } from "../react/hooks";@@ -31,14 +29,11 @@ import NoteActionsCustom from "./NoteActionsCustom";import { useShareState } from "./NoteBadges";import { NoteTypeDropdownContent } from "./NoteTypeSwitcher";-const isNewLayout = isExperimentalFeatureEnabled("new-layout");-export default function NoteActions() {const { note, ntxId, noteContext } = useNoteContext();return (<div className="note-actions-bar" style={{ contain: "none" }}>- {note && ntxId && noteContext && <NoteActionsCustom note={note} ntxId={ntxId} noteContext={noteContext} typeActionsOnly={!isNewLayout} />}- {note && !isNewLayout && <RevisionsButton note={note} />}+ {note && ntxId && noteContext && <NoteActionsCustom note={note} ntxId={ntxId} noteContext={noteContext} />}<MovePaneButton direction="left" /><MovePaneButton direction="right" /><ClosePaneButton />@@ -48,19 +43,6 @@ export default function NoteActions() {);}-function RevisionsButton({ note }: { note: FNote }) {- const isEnabled = !["launcher", "doc"].includes(note?.type ?? "");-- return (isEnabled &&- <ActionButton- icon="bx bx-history"- text={t("revisions_button.note_revisions")}- triggerCommand="showRevisions"- titlePosition="bottom"- />- );-}-type ItemToFocus = "basic-properties";export function NoteContextMenu({ note, noteContext, itemsAtStart, itemsNearNoteSettings, dropdownRef: externalDropdownRef }: {@@ -102,7 +84,6 @@ export function NoteContextMenu({ note, noteContext, itemsAtStart, itemsNearNoteconst itemToFocusRef = useRef<ItemToFocus>(null);// Keyboard shortcuts.useTriliumEvent("toggleRibbonTabBasicProperties", () => {- if (!isNewLayout) return;itemToFocusRef.current = "basic-properties";dropdownRef.current?.toggle();});@@ -111,7 +92,7 @@ export function NoteContextMenu({ note, noteContext, itemsAtStart, itemsNearNote<><DropdowndropdownRef={dropdownRef}- buttonClassName={ isNewLayout ? "bx bx-dots-horizontal-rounded" : "bx bx-dots-vertical-rounded" }+ buttonClassName="bx bx-dots-horizontal-rounded"className="note-actions"mobileBottomSheethideToggleArrow@@ -138,7 +119,7 @@ export function NoteContextMenu({ note, noteContext, itemsAtStart, itemsNearNote<FormDropdownDivider />- {isNewLayout && isNormalViewMode && !isHelpPage && <>+ {isNormalViewMode && !isHelpPage && <><NoteBasicProperties note={note} focus={itemToFocusRef} /><FormDropdownDivider /></>}diff --git a/apps/client/src/widgets/layout/NoteActionsCustom.tsx b/apps/client/src/widgets/layout/NoteActionsCustom.tsxindex db4684ca00..f0ce3d9485 100644--- a/apps/client/src/widgets/layout/NoteActionsCustom.tsx+++ b/apps/client/src/widgets/layout/NoteActionsCustom.tsx@@ -28,11 +28,9 @@ interface NoteActionsCustomProps {note: FNote;ntxId: string;noteContext: NoteContext;- /** Renders only the note type's own actions, leaving out those `FloatingButtons` shows on the old layout. */- typeActionsOnly?: boolean;}-interface NoteActionsCustomInnerProps extends Omit<NoteActionsCustomProps, "typeActionsOnly"> {+interface NoteActionsCustomInnerProps extends NoteActionsCustomProps {noteMime: string;noteType: NoteType;isReadOnly: boolean;@@ -47,7 +45,7 @@ const cachedIsMobile = isMobile();* Part of {@link NoteActions}, but are rendered with a slight spacing* from the rest of the note items and the buttons differ based on the note type.*/-export default function NoteActionsCustom({ typeActionsOnly, ...props }: NoteActionsCustomProps) {+export default function NoteActionsCustom(props: NoteActionsCustomProps) {const { note } = props;const containerRef = useRef<HTMLDivElement>(null);const noteType = useNoteProperty(note, "type");@@ -74,16 +72,14 @@ export default function NoteActionsCustom({ typeActionsOnly, ...props }: NoteActref={containerRef}className="note-actions-custom">- {!typeActionsOnly && <>- <RunActiveNoteButton {...innerProps } />- <SwitchSplitOrientationButton {...innerProps} />- <DisplayModeSwitcher {...innerProps} />- <SaveToNoteButton {...innerProps} />- <RefreshButton {...innerProps} />- {innerProps.note.noteId === "_backendLog" && <DownloadFileButton {...innerProps} />}- <CopyReferenceToClipboardButton {...innerProps} />- <InAppHelpButton {...innerProps} />- </>}+ <RunActiveNoteButton {...innerProps } />+ <SwitchSplitOrientationButton {...innerProps} />+ <DisplayModeSwitcher {...innerProps} />+ <SaveToNoteButton {...innerProps} />+ <RefreshButton {...innerProps} />+ {innerProps.note.noteId === "_backendLog" && <DownloadFileButton {...innerProps} />}+ <CopyReferenceToClipboardButton {...innerProps} />+ <InAppHelpButton {...innerProps} /><NoteActionsCustomInner {...innerProps} /></div>);