improve: add setting button to pathnode

This commit is contained in:
h z
2025-03-20 18:37:13 +00:00
parent dc0ff3b406
commit 09338a2683
3 changed files with 24 additions and 6 deletions

View File

@@ -5,8 +5,10 @@ import "./PathNode.css";
import {useDeletePath, useMovePath, useUpdatePath} from "../../utils/path-queries";
import {useIndexMarkdown, useMoveMarkdown} from "../../utils/markdown-queries";
import MarkdownNode from "./MarkdownNode";
import PathSettingModal from "../Modals/PathSettingModal";
const PathNode = ({ path, isRoot = false }) => {
const [isPathSettingModalOpen, setIsPathSettingModalOpen] = useState(false);
const [isExpanded, setIsExpanded] = useState(isRoot);
const [isEditing, setIsEditing] = useState(false);
const [newName, setNewName] = useState(path.name);
@@ -68,9 +70,6 @@ const PathNode = ({ path, isRoot = false }) => {
? markdowns.filter(md => md.title !== "index").sort((a, b) => a.order.localeCompare(b.order))
: [];
/* if(childError || markdownError){
return <li>Error...</li>;
}*/
if(isRoot)
return (
@@ -127,6 +126,21 @@ const PathNode = ({ path, isRoot = false }) => {
<PermissionGuard rolesRequired={["admin"]}>
<div className="field has-addons actions control is-justify-content-flex-end">
<p className="control">
<button
className="button is-small is-success"
onClick={() => {
console.log("path", path);
setIsPathSettingModalOpen(true);
}}
type="button"
>
<span className="icon">
<i className="fas fa-cog"></i>
</span>
</button>
</p>
{isEditing ? (
<p className="control">
<button
@@ -182,6 +196,11 @@ const PathNode = ({ path, isRoot = false }) => {
</button>
</div>
</div>
<PathSettingModal
isOpen={isPathSettingModalOpen}
path={path}
onClose={() => setIsPathSettingModalOpen(false)}
/>
</PermissionGuard>
</div>

View File

@@ -9,9 +9,7 @@ const SideNavigation = () => {
const {data: tree, isLoading, error} = useTree();
const deletePath = useDeletePath();
const updatePath = useUpdatePath();
const [searchTerm, setSearchTerm] = React.useState("");
const [keyword, setKeyword] = React.useState("");
const [searchMode, setSearchMode] = React.useState(false);
const handleDelete = (id) => {
if (window.confirm("Are you sure you want to delete this path?")){
deletePath.mutate(id, {

View File

@@ -108,4 +108,5 @@ export const useSearchMarkdown = (keyword) => {
export const useLinks = () => {
const config = useConfig();
return useQuery(["links"], () => fetch_(`${config.BACKEND_HOST}/api/markdown/links`));
}
}