From cd5467bf5c0775293cc21d725a1f2ede8ce62ac1 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 9 Aug 2025 23:12:27 +0300 Subject: [PATCH] refactor(react/bulk_actions): set up way to self-enable modal --- .../src/widgets/dialogs/branch_prefix.tsx | 95 +++++++++---------- apps/client/src/widgets/react/Modal.tsx | 14 ++- 2 files changed, 58 insertions(+), 51 deletions(-) diff --git a/apps/client/src/widgets/dialogs/branch_prefix.tsx b/apps/client/src/widgets/dialogs/branch_prefix.tsx index e4b7d3e59..fb3b24294 100644 --- a/apps/client/src/widgets/dialogs/branch_prefix.tsx +++ b/apps/client/src/widgets/dialogs/branch_prefix.tsx @@ -1,6 +1,6 @@ import { useRef, useState } from "preact/hooks"; import appContext from "../../components/app_context.js"; -import { closeActiveDialog, openDialog } from "../../services/dialog.js"; +import { closeActiveDialog } from "../../services/dialog.js"; import { t } from "../../services/i18n.js"; import server from "../../services/server.js"; import toast from "../../services/toast.js"; @@ -8,56 +8,18 @@ import Modal from "../react/Modal.jsx"; import ReactBasicWidget from "../react/ReactBasicWidget.js"; import froca from "../../services/froca.js"; import tree from "../../services/tree.js"; -import FBranch from "../../entities/fbranch.js"; import Button from "../react/Button.jsx"; import FormGroup from "../react/FormGroup.js"; +import useTriliumEvent from "../react/hooks.jsx"; +import FBranch from "../../entities/fbranch.js"; -interface BranchPrefixDialogProps { - branch?: FBranch; -} - -function BranchPrefixDialogComponent({ branch }: BranchPrefixDialogProps) { +function BranchPrefixDialogComponent() { + const [ shown, setShown ] = useState(false); + const [ branch, setBranch ] = useState(); const [ prefix, setPrefix ] = useState(branch?.prefix ?? ""); const branchInput = useRef(null); - async function onSubmit() { - if (!branch) { - return; - } - - savePrefix(branch.branchId, prefix); - closeActiveDialog(); - } - - return ( - branchInput.current?.focus()} - onSubmit={onSubmit} - helpPageId="TBwsyfadTA18" - footer={