Browse Source

remove dragabble judgement from page-path-util

kaori 4 years ago
parent
commit
61523dcde6

+ 4 - 3
packages/app/src/components/Sidebar/PageTree/Item.tsx

@@ -113,7 +113,6 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
     itemNode, targetPathOrId, isOpen: _isOpen = false, isEnabledAttachTitleHeader,
     onClickDuplicateMenuItem, onClickRenameMenuItem, onClickDeleteMenuItem, isEnableActions,
   } = props;
-  const [canDragItem, setCanDragItem] = useState(false);
 
   const { page, children } = itemNode;
 
@@ -122,7 +121,7 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
   const [isOpen, setIsOpen] = useState(_isOpen);
   const [isNewPageInputShown, setNewPageInputShown] = useState(false);
   const [shouldHide, setShouldHide] = useState(false);
-  // const [isRenameInputShown, setRenameInputShown] = useState(false);
+  const [canDragItem, setCanDragItem] = useState(false);
 
   const { data, mutate: mutateChildren } = useSWRxPageChildren(isOpen ? page._id : null);
 
@@ -374,8 +373,10 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
     return null;
   };
 
+
   useEffect(() => {
-    setCanDragItem(pagePathUtils.canDragByPath(page.path || '/'));
+    const isDraggable = !pagePathUtils.isUserPage(page.path || '/');
+    setCanDragItem(isDraggable);
   }, [page.path]);
 
   useEffect(() => {

+ 0 - 9
packages/core/src/utils/page-path-utils.ts

@@ -265,12 +265,3 @@ export const isPathAreaOverlap = (pathToTest: string, pathToBeTested: string): b
 export const canMoveByPath = (fromPath: string, toPath: string): boolean => {
   return !isPathAreaOverlap(fromPath, toPath);
 };
-
-/**
- * Determine whether can drag by path
- * @param path string
- * @returns boolean
- */
-export const canDragByPath = (path: string): boolean => {
-  return !isUserPage(path);
-};