improve: add setting button to pathnode
This commit is contained in:
@@ -5,8 +5,10 @@ import "./PathNode.css";
|
|||||||
import {useDeletePath, useMovePath, useUpdatePath} from "../../utils/path-queries";
|
import {useDeletePath, useMovePath, useUpdatePath} from "../../utils/path-queries";
|
||||||
import {useIndexMarkdown, useMoveMarkdown} from "../../utils/markdown-queries";
|
import {useIndexMarkdown, useMoveMarkdown} from "../../utils/markdown-queries";
|
||||||
import MarkdownNode from "./MarkdownNode";
|
import MarkdownNode from "./MarkdownNode";
|
||||||
|
import PathSettingModal from "../Modals/PathSettingModal";
|
||||||
|
|
||||||
const PathNode = ({ path, isRoot = false }) => {
|
const PathNode = ({ path, isRoot = false }) => {
|
||||||
|
const [isPathSettingModalOpen, setIsPathSettingModalOpen] = useState(false);
|
||||||
const [isExpanded, setIsExpanded] = useState(isRoot);
|
const [isExpanded, setIsExpanded] = useState(isRoot);
|
||||||
const [isEditing, setIsEditing] = useState(false);
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
const [newName, setNewName] = useState(path.name);
|
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))
|
? markdowns.filter(md => md.title !== "index").sort((a, b) => a.order.localeCompare(b.order))
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
/* if(childError || markdownError){
|
|
||||||
return <li>Error...</li>;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
if(isRoot)
|
if(isRoot)
|
||||||
return (
|
return (
|
||||||
@@ -127,6 +126,21 @@ const PathNode = ({ path, isRoot = false }) => {
|
|||||||
|
|
||||||
<PermissionGuard rolesRequired={["admin"]}>
|
<PermissionGuard rolesRequired={["admin"]}>
|
||||||
<div className="field has-addons actions control is-justify-content-flex-end">
|
<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 ? (
|
{isEditing ? (
|
||||||
<p className="control">
|
<p className="control">
|
||||||
<button
|
<button
|
||||||
@@ -182,6 +196,11 @@ const PathNode = ({ path, isRoot = false }) => {
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<PathSettingModal
|
||||||
|
isOpen={isPathSettingModalOpen}
|
||||||
|
path={path}
|
||||||
|
onClose={() => setIsPathSettingModalOpen(false)}
|
||||||
|
/>
|
||||||
</PermissionGuard>
|
</PermissionGuard>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -9,9 +9,7 @@ const SideNavigation = () => {
|
|||||||
const {data: tree, isLoading, error} = useTree();
|
const {data: tree, isLoading, error} = useTree();
|
||||||
const deletePath = useDeletePath();
|
const deletePath = useDeletePath();
|
||||||
const updatePath = useUpdatePath();
|
const updatePath = useUpdatePath();
|
||||||
const [searchTerm, setSearchTerm] = React.useState("");
|
|
||||||
const [keyword, setKeyword] = React.useState("");
|
const [keyword, setKeyword] = React.useState("");
|
||||||
const [searchMode, setSearchMode] = React.useState(false);
|
|
||||||
const handleDelete = (id) => {
|
const handleDelete = (id) => {
|
||||||
if (window.confirm("Are you sure you want to delete this path?")){
|
if (window.confirm("Are you sure you want to delete this path?")){
|
||||||
deletePath.mutate(id, {
|
deletePath.mutate(id, {
|
||||||
|
|||||||
@@ -108,4 +108,5 @@ export const useSearchMarkdown = (keyword) => {
|
|||||||
export const useLinks = () => {
|
export const useLinks = () => {
|
||||||
const config = useConfig();
|
const config = useConfig();
|
||||||
return useQuery(["links"], () => fetch_(`${config.BACKEND_HOST}/api/markdown/links`));
|
return useQuery(["links"], () => fetch_(`${config.BACKEND_HOST}/api/markdown/links`));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user