|
|
@@ -2,25 +2,25 @@ import React, {
|
|
|
useState, useEffect, useCallback, useMemo,
|
|
|
} from 'react';
|
|
|
|
|
|
+
|
|
|
+import { pagePathUtils } from '@growi/core';
|
|
|
+import { useTranslation } from 'react-i18next';
|
|
|
import {
|
|
|
Collapse, Modal, ModalHeader, ModalBody, ModalFooter,
|
|
|
} from 'reactstrap';
|
|
|
-
|
|
|
-import { useTranslation } from 'react-i18next';
|
|
|
-
|
|
|
import { debounce } from 'throttle-debounce';
|
|
|
-import { pagePathUtils } from '@growi/core';
|
|
|
-import { usePageRenameModal } from '~/stores/modal';
|
|
|
-import { toastError } from '~/client/util/apiNotification';
|
|
|
|
|
|
+import { toastError } from '~/client/util/apiNotification';
|
|
|
import { apiv3Get, apiv3Put } from '~/client/util/apiv3-client';
|
|
|
-
|
|
|
-import ApiErrorMessageList from './PageManagement/ApiErrorMessageList';
|
|
|
-import DuplicatedPathsTable from './DuplicatedPathsTable';
|
|
|
-import { useSiteUrl } from '~/stores/context';
|
|
|
import { isIPageInfoForEntity } from '~/interfaces/page';
|
|
|
+import { useSiteUrl, useIsSearchServiceReachable } from '~/stores/context';
|
|
|
+import { usePageRenameModal } from '~/stores/modal';
|
|
|
import { useSWRxPageInfo } from '~/stores/page';
|
|
|
|
|
|
+import DuplicatedPathsTable from './DuplicatedPathsTable';
|
|
|
+import ApiErrorMessageList from './PageManagement/ApiErrorMessageList';
|
|
|
+import PagePathAutoComplete from './PagePathAutoComplete';
|
|
|
+
|
|
|
|
|
|
const isV5Compatible = (meta: unknown): boolean => {
|
|
|
return isIPageInfoForEntity(meta) ? meta.isV5Compatible : true;
|
|
|
@@ -33,6 +33,7 @@ const PageRenameModal = (): JSX.Element => {
|
|
|
const { isUsersHomePage } = pagePathUtils;
|
|
|
const { data: siteUrl } = useSiteUrl();
|
|
|
const { data: renameModalData, close: closeRenameModal } = usePageRenameModal();
|
|
|
+ const { data: isReachable } = useIsSearchServiceReachable();
|
|
|
|
|
|
const isOpened = renameModalData?.isOpened ?? false;
|
|
|
const page = renameModalData?.page;
|
|
|
@@ -154,6 +155,11 @@ const PageRenameModal = (): JSX.Element => {
|
|
|
}, [pageNameInput, subordinatedPages, checkExistPathsDebounce, page, checkIsUsersHomePageDebounce]);
|
|
|
|
|
|
|
|
|
+ function ppacInputChangeHandler(value) {
|
|
|
+ setErrs(null);
|
|
|
+ setPageNameInput(value);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* change pageNameInput
|
|
|
* @param {string} value
|
|
|
@@ -219,14 +225,25 @@ const PageRenameModal = (): JSX.Element => {
|
|
|
<span className="input-group-text">{siteUrl}</span>
|
|
|
</div>
|
|
|
<form className="flex-fill" onSubmit={(e) => { e.preventDefault(); rename() }}>
|
|
|
- <input
|
|
|
- type="text"
|
|
|
- value={pageNameInput}
|
|
|
- className="form-control"
|
|
|
- onChange={e => inputChangeHandler(e.target.value)}
|
|
|
- required
|
|
|
- autoFocus
|
|
|
- />
|
|
|
+ {isReachable
|
|
|
+ ? (
|
|
|
+ <PagePathAutoComplete
|
|
|
+ initializedPath={path}
|
|
|
+ onSubmit={rename}
|
|
|
+ onInputChange={ppacInputChangeHandler}
|
|
|
+ autoFocus
|
|
|
+ />
|
|
|
+ )
|
|
|
+ : (
|
|
|
+ <input
|
|
|
+ type="text"
|
|
|
+ value={pageNameInput}
|
|
|
+ className="form-control"
|
|
|
+ onChange={e => inputChangeHandler(e.target.value)}
|
|
|
+ required
|
|
|
+ autoFocus
|
|
|
+ />
|
|
|
+ )}
|
|
|
</form>
|
|
|
</div>
|
|
|
</div>
|