|
@@ -197,21 +197,27 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
|
|
|
}, []);
|
|
}, []);
|
|
|
|
|
|
|
|
const onPressEnterForRenameHandler = async(inputText: string) => {
|
|
const onPressEnterForRenameHandler = async(inputText: string) => {
|
|
|
|
|
+ if (inputText == null || inputText === '' || inputText.trim() === '' || inputText.includes('/')) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
const parentPath = nodePath.dirname(page.path as string);
|
|
const parentPath = nodePath.dirname(page.path as string);
|
|
|
const newPagePath = `${parentPath}/${inputText}`;
|
|
const newPagePath = `${parentPath}/${inputText}`;
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
- await apiv3Put('pages/rename', { newPagePath, pageId: page._id, revisionId: page.revision });
|
|
|
|
|
setPageTitle(inputText);
|
|
setPageTitle(inputText);
|
|
|
|
|
+ setRenameInputShown(false);
|
|
|
|
|
+ await apiv3Put('/pages/rename', { newPagePath, pageId: page._id, revisionId: page.revision });
|
|
|
}
|
|
}
|
|
|
catch (err) {
|
|
catch (err) {
|
|
|
|
|
+ // open ClosableInput and set pageTitle back to the previous title
|
|
|
|
|
+ setPageTitle(nodePath.basename(pageTitle as string));
|
|
|
|
|
+ setRenameInputShown(true);
|
|
|
toastError(err);
|
|
toastError(err);
|
|
|
}
|
|
}
|
|
|
- finally {
|
|
|
|
|
- setRenameInputShown(false);
|
|
|
|
|
- }
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// TODO: go to create page page
|
|
// TODO: go to create page page
|
|
|
const onPressEnterForCreateHandler = () => {
|
|
const onPressEnterForCreateHandler = () => {
|
|
|
toastWarning(t('search_result.currently_not_implemented'));
|
|
toastWarning(t('search_result.currently_not_implemented'));
|