add: template editor

This commit is contained in:
h z
2025-04-14 17:02:22 +01:00
parent 09338a2683
commit 947b59e3ea
29 changed files with 1277 additions and 166 deletions

View File

@@ -1,15 +1,12 @@
import React, {useEffect, useState, useRef, useContext} from "react";
import {useCreatePath, usePath, usePaths} from "../utils/path-queries";
import {useCreatePath, usePaths} from "../utils/queries/path-queries";
import { useQueryClient } from "react-query";
import "./PathManager.css";
import {fetch_} from "../utils/request-utils";
import {ConfigContext} from "../ConfigProvider";
import PathSettingModal from "./Modals/PathSettingModal";
const PathManager = ({ currentPathId = 1, onPathChange }) => {
const { data: currentPath } = usePath(currentPathId);
const [currentFullPath, setCurrentFullPath] = useState([{ name: "Root", id: 1 }]);
const [searchTerm, setSearchTerm] = useState("");
const [dropdownActive, setDropdownActive] = useState(false);
@@ -20,11 +17,7 @@ const PathManager = ({ currentPathId = 1, onPathChange }) => {
const { data: subPaths, isLoading: isSubPathsLoading, error: subPathsError } = usePaths(currentPathId);
const createPath = useCreatePath();
const config = useContext(ConfigContext).config;
const [isPathSettingModalOpen, setIsPathSettingModalModalOpen] = useState(false);
const handleSettingClick = () => {
setIsPathSettingModalModalOpen(true);
}
const buildFullPath = async (pathId) => {
const path = [];
@@ -117,31 +110,16 @@ const PathManager = ({ currentPathId = 1, onPathChange }) => {
{currentFullPath.map((path, index) => (
<span
key={path.id}
className="breadcrumb-item is-clickable"
className="tag is-clickable is-link is-light"
onClick={() => handlePathClick(path.id, index)}
>
{path.name}
{index < currentFullPath.length - 1 && " / "}
{path.name + "/"}
</span>
))}
</div>
<div className="control">
<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
</div>
<div className="control">
<button
className="button is-small is-primary"
type="button"
onClick={handleSettingClick}
>
Settings
</button>
<PathSettingModal
isOpen={isPathSettingModalOpen}
path={currentPath}
onClose={() => setIsPathSettingModalModalOpen(false)}
/>
</div>
</div>
<div className="path-manager-body">