|
@@ -109,7 +109,6 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
const [isNewPageInputShown, setNewPageInputShown] = useState(false);
|
|
const [isNewPageInputShown, setNewPageInputShown] = useState(false);
|
|
|
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 [isCreating, setCreating] = 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);
|
|
@@ -271,7 +270,6 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
setRenameInputShown(false);
|
|
setRenameInputShown(false);
|
|
|
- setRenaming(true);
|
|
|
|
|
await apiv3Put('/pages/rename', {
|
|
await apiv3Put('/pages/rename', {
|
|
|
pageId: page._id,
|
|
pageId: page._id,
|
|
|
revisionId: page.revision,
|
|
revisionId: page.revision,
|
|
@@ -288,11 +286,6 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
setRenameInputShown(true);
|
|
setRenameInputShown(true);
|
|
|
toastError(err);
|
|
toastError(err);
|
|
|
}
|
|
}
|
|
|
- finally {
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
|
- setRenaming(false);
|
|
|
|
|
- }, 1000);
|
|
|
|
|
- }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
const deleteMenuItemClickHandler = useCallback(async(_pageId: string, pageInfo: IPageInfoAll | undefined): Promise<void> => {
|
|
const deleteMenuItemClickHandler = useCallback(async(_pageId: string, pageInfo: IPageInfoAll | undefined): Promise<void> => {
|
|
@@ -377,7 +370,6 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
*/
|
|
*/
|
|
|
const pathRecoveryMenuItemClickHandler = async(pageId: string): Promise<void> => {
|
|
const pathRecoveryMenuItemClickHandler = async(pageId: string): Promise<void> => {
|
|
|
try {
|
|
try {
|
|
|
- setRenaming(true);
|
|
|
|
|
await resumeRenameOperation(pageId);
|
|
await resumeRenameOperation(pageId);
|
|
|
|
|
|
|
|
if (onRenamed != null) {
|
|
if (onRenamed != null) {
|
|
@@ -417,6 +409,10 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
}
|
|
}
|
|
|
}, [data, isOpen, targetPathOrId]);
|
|
}, [data, isOpen, targetPathOrId]);
|
|
|
|
|
|
|
|
|
|
+ // Rename process
|
|
|
|
|
+ // Icon that draw attention from users for some actions
|
|
|
|
|
+ const shouldShowAttentionIcon = !!page.processData?.Rename?.isProcessable;
|
|
|
|
|
+
|
|
|
return (
|
|
return (
|
|
|
<div
|
|
<div
|
|
|
id={`pagetree-item-${page._id}`}
|
|
id={`pagetree-item-${page._id}`}
|
|
@@ -454,8 +450,8 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
)
|
|
)
|
|
|
: (
|
|
: (
|
|
|
<>
|
|
<>
|
|
|
- { isRenaming && (
|
|
|
|
|
- <i className="fa fa-spinner fa-pulse mr-2 text-muted"></i>
|
|
|
|
|
|
|
+ { shouldShowAttentionIcon && (
|
|
|
|
|
+ <i className="fa fa-warning mr-2 text-warning"></i>
|
|
|
)}
|
|
)}
|
|
|
<a href={`/${page._id}`} className="grw-pagetree-title-anchor flex-grow-1">
|
|
<a href={`/${page._id}`} className="grw-pagetree-title-anchor flex-grow-1">
|
|
|
<p className={`text-truncate m-auto ${page.isEmpty && 'grw-sidebar-text-muted'}`}>{nodePath.basename(page.path ?? '') || '/'}</p>
|
|
<p className={`text-truncate m-auto ${page.isEmpty && 'grw-sidebar-text-muted'}`}>{nodePath.basename(page.path ?? '') || '/'}</p>
|
|
@@ -477,6 +473,7 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
onClickDeleteMenuItem={deleteMenuItemClickHandler}
|
|
onClickDeleteMenuItem={deleteMenuItemClickHandler}
|
|
|
onClickPathRecoveryMenuItem={pathRecoveryMenuItemClickHandler}
|
|
onClickPathRecoveryMenuItem={pathRecoveryMenuItemClickHandler}
|
|
|
isInstantRename
|
|
isInstantRename
|
|
|
|
|
+ // Todo: It is wanted to find a better way to pass operationProcessData to PageItemControl
|
|
|
operationProcessData={page.processData}
|
|
operationProcessData={page.processData}
|
|
|
>
|
|
>
|
|
|
{/* pass the color property to reactstrap dropdownToggle props. https://6-4-0--reactstrap.netlify.app/components/dropdowns/ */}
|
|
{/* pass the color property to reactstrap dropdownToggle props. https://6-4-0--reactstrap.netlify.app/components/dropdowns/ */}
|