|
@@ -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);
|
|
|
|
|
|
|
@@ -242,7 +243,11 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
|
|
|
|
|
const onClickPlusButton = useCallback(() => {
|
|
const onClickPlusButton = useCallback(() => {
|
|
|
setNewPageInputShown(true);
|
|
setNewPageInputShown(true);
|
|
|
- }, []);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (hasDescendants) {
|
|
|
|
|
+ setIsOpen(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ }, [hasDescendants]);
|
|
|
|
|
|
|
|
const duplicateMenuItemClickHandler = useCallback((): void => {
|
|
const duplicateMenuItemClickHandler = useCallback((): void => {
|
|
|
if (onClickDuplicateMenuItem == null) {
|
|
if (onClickDuplicateMenuItem == null) {
|
|
@@ -338,6 +343,8 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
|
+ setCreating(true);
|
|
|
|
|
+
|
|
|
await apiv3Post('/pages/', {
|
|
await apiv3Post('/pages/', {
|
|
|
path: newPagePath,
|
|
path: newPagePath,
|
|
|
body: initBody,
|
|
body: initBody,
|
|
@@ -345,7 +352,15 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
grantUserGroupId: page.grantedGroup,
|
|
grantUserGroupId: page.grantedGroup,
|
|
|
createFromPageTree: true,
|
|
createFromPageTree: true,
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ setCreating(false);
|
|
|
|
|
+
|
|
|
mutateChildren();
|
|
mutateChildren();
|
|
|
|
|
+
|
|
|
|
|
+ if (!hasDescendants) {
|
|
|
|
|
+ setIsOpen(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
toastSuccess(t('successfully_saved_the_page'));
|
|
toastSuccess(t('successfully_saved_the_page'));
|
|
|
}
|
|
}
|
|
|
catch (err) {
|
|
catch (err) {
|
|
@@ -484,7 +499,7 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
/>
|
|
/>
|
|
|
)}
|
|
)}
|
|
|
{
|
|
{
|
|
|
- isOpen && hasChildren() && currentChildren.map(node => (
|
|
|
|
|
|
|
+ isOpen && hasChildren() && currentChildren.map((node, index) => (
|
|
|
<div key={node.page._id} className="grw-pagetree-item-children">
|
|
<div key={node.page._id} className="grw-pagetree-item-children">
|
|
|
<Item
|
|
<Item
|
|
|
isEnableActions={isEnableActions}
|
|
isEnableActions={isEnableActions}
|
|
@@ -496,6 +511,11 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
onClickDuplicateMenuItem={onClickDuplicateMenuItem}
|
|
onClickDuplicateMenuItem={onClickDuplicateMenuItem}
|
|
|
onClickDeleteMenuItem={onClickDeleteMenuItem}
|
|
onClickDeleteMenuItem={onClickDeleteMenuItem}
|
|
|
/>
|
|
/>
|
|
|
|
|
+ { isCreating && (currentChildren.length - 1 === index) && (
|
|
|
|
|
+ <div className="text-muted text-center">
|
|
|
|
|
+ <i className="fa fa-spinner fa-pulse mr-1"></i>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
</div>
|
|
</div>
|
|
|
))
|
|
))
|
|
|
}
|
|
}
|