diff --git a/packages/toolpad-app/src/components/AppEditor/HierarchyExplorer/index.tsx b/packages/toolpad-app/src/components/AppEditor/HierarchyExplorer/index.tsx index 7a8183ecbe..0d2fbbdb94 100644 --- a/packages/toolpad-app/src/components/AppEditor/HierarchyExplorer/index.tsx +++ b/packages/toolpad-app/src/components/AppEditor/HierarchyExplorer/index.tsx @@ -21,7 +21,6 @@ import * as appDom from '../../../appDom'; import { useDom, useDomApi } from '../../DomLoader'; import CreatePageNodeDialog from './CreatePageNodeDialog'; import CreateCodeComponentNodeDialog from './CreateCodeComponentNodeDialog'; -import CreateApiNodeDialog from './CreateApiNodeDialog'; import CreateConnectionNodeDialog from './CreateConnectionNodeDialog'; import useLocalStorageState from '../../../utils/useLocalStorageState'; import useLatest from '../../../utils/useLatest'; @@ -85,7 +84,7 @@ export default function HierarchyExplorer({ appId, className }: HierarchyExplore const [expanded, setExpanded] = useLocalStorageState( `editor/${app.id}/hierarchy-expansion`, - [':connections', ':pages', ':apis', ':codeComponents'], + [':connections', ':pages', ':codeComponents'], ); const location = useLocation(); @@ -155,13 +154,6 @@ export default function HierarchyExplorer({ appId, className }: HierarchyExplore [], ); - const [createApiDialogOpen, setCreateApiDialogOpen] = React.useState(0); - const handleCreateApiDialogOpen = React.useCallback((event: React.MouseEvent) => { - event.stopPropagation(); - setCreateApiDialogOpen(Math.random()); - }, []); - const handleCreateApiDialogClose = React.useCallback(() => setCreateApiDialogOpen(0), []); - const [createPageDialogOpen, setCreatePageDialogOpen] = React.useState(0); const handleCreatePageDialogOpen = React.useCallback((event: React.MouseEvent) => { event.stopPropagation(); @@ -226,16 +218,18 @@ export default function HierarchyExplorer({ appId, className }: HierarchyExplore /> ))} - - {apis.map((apiNode) => ( - - ))} - + {apis.length > 0 ? ( + + {apis.map((apiNode) => ( + + ))} + + ) : null} - { - const stateNode = appDom.createNode(dom, 'queryState', { - params: {}, - attributes: { api: appDom.createConst(null) }, - }); - domApi.addNode(stateNode, page, 'queryStates'); - setEditedState(stateNode.id); - }, [dom, domApi, page]); - - // To keep it around during closing animation + // To keep dialog content around during closing animation const lastEditedStateNode = useLatest(editedStateNode); const handleRemove = React.useCallback(() => { @@ -242,11 +232,8 @@ export default function QueryStateEditor() { handleEditStateDialogClose(); }, [editedStateNode, handleEditStateDialogClose, domApi]); - return ( + return queryStates.length > 0 ? ( - {queryStates.map((stateNode) => { return ( @@ -277,5 +264,5 @@ export default function QueryStateEditor() { ) : null} - ); + ) : null; }