Shun Miyazawa пре 4 година
родитељ
комит
9f11fb284f
1 измењених фајлова са 12 додато и 0 уклоњено
  1. 12 0
      packages/app/src/components/Sidebar/PageTree/Item.tsx

+ 12 - 0
packages/app/src/components/Sidebar/PageTree/Item.tsx

@@ -123,6 +123,7 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
   const [shouldHide, setShouldHide] = useState(false);
   const [shouldHide, setShouldHide] = useState(false);
   const [isRenameInputShown, setRenameInputShown] = useState(false);
   const [isRenameInputShown, setRenameInputShown] = useState(false);
   const [isRenaming, setRenaming] = useState(false);
   const [isRenaming, setRenaming] = useState(false);
+  const [isCreating, setCreating] = useState(false);
 
 
   const { data, mutate: mutateChildren } = useSWRxPageChildren(isOpen ? page._id : null);
   const { data, mutate: mutateChildren } = useSWRxPageChildren(isOpen ? page._id : null);
 
 
@@ -336,6 +337,7 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
     }
     }
 
 
     try {
     try {
+      setCreating(true);
       await apiv3Post('/pages/', {
       await apiv3Post('/pages/', {
         path: newPagePath,
         path: newPagePath,
         body: initBody,
         body: initBody,
@@ -349,6 +351,11 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
     catch (err) {
     catch (err) {
       toastError(err);
       toastError(err);
     }
     }
+    finally {
+      setTimeout(() => {
+        setCreating(false);
+      }, 1000);
+    }
   };
   };
 
 
   const inputValidator = (title: string | null): AlertInfo | null => {
   const inputValidator = (title: string | null): AlertInfo | null => {
@@ -491,6 +498,11 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
               onClickDuplicateMenuItem={onClickDuplicateMenuItem}
               onClickDuplicateMenuItem={onClickDuplicateMenuItem}
               onClickDeleteMenuItem={onClickDeleteMenuItem}
               onClickDeleteMenuItem={onClickDeleteMenuItem}
             />
             />
+            { isCreating && (
+              <div className="text-muted text-center">
+                <i className="fa fa-spinner fa-pulse mr-1"></i>
+              </div>
+            )}
           </div>
           </div>
         ))
         ))
       }
       }