|
@@ -15,9 +15,11 @@ import ApiErrorMessage from './PageManagement/ApiErrorMessage';
|
|
|
|
|
|
|
|
const PageRenameModal = (props) => {
|
|
const PageRenameModal = (props) => {
|
|
|
const {
|
|
const {
|
|
|
- t, appContainer, pageContainer, path,
|
|
|
|
|
|
|
+ t, appContainer, pageContainer,
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
|
|
+ const { path } = pageContainer.state;
|
|
|
|
|
+
|
|
|
const { crowi } = appContainer.config;
|
|
const { crowi } = appContainer.config;
|
|
|
|
|
|
|
|
const [pageNameInput, setPageNameInput] = useState(path);
|
|
const [pageNameInput, setPageNameInput] = useState(path);
|
|
@@ -25,8 +27,8 @@ const PageRenameModal = (props) => {
|
|
|
const [errorMessage, setErrorMessage] = useState(null);
|
|
const [errorMessage, setErrorMessage] = useState(null);
|
|
|
|
|
|
|
|
const [isRenameRecursively, SetIsRenameRecursively] = useState(true);
|
|
const [isRenameRecursively, SetIsRenameRecursively] = useState(true);
|
|
|
- const [isRenameRedirect, SetIsRenameRedirect] = useState(false);
|
|
|
|
|
- const [isRenameMetadata, SetIsRenameMetadata] = useState(false);
|
|
|
|
|
|
|
+ const [isRenameRedirect, SetIsRenameRedirect] = useState(true);
|
|
|
|
|
+ const [isRenameMetadata, SetIsRenameMetadata] = useState(true);
|
|
|
|
|
|
|
|
function changeIsRenameRecursivelyHandler() {
|
|
function changeIsRenameRecursivelyHandler() {
|
|
|
SetIsRenameRecursively(!isRenameRecursively);
|
|
SetIsRenameRecursively(!isRenameRecursively);
|
|
@@ -45,12 +47,12 @@ const PageRenameModal = (props) => {
|
|
|
setErrorCode(null);
|
|
setErrorCode(null);
|
|
|
setErrorMessage(null);
|
|
setErrorMessage(null);
|
|
|
|
|
|
|
|
- const response = await appContainer.apiPost('/pages.rename', {
|
|
|
|
|
- new_path: pageNameInput,
|
|
|
|
|
- create_redirect: isRenameRedirect,
|
|
|
|
|
- remain_metadata: isRenameMetadata,
|
|
|
|
|
- recursively: isRenameRecursively,
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ const response = await pageContainer.rename(
|
|
|
|
|
+ pageNameInput,
|
|
|
|
|
+ isRenameRedirect,
|
|
|
|
|
+ isRenameMetadata,
|
|
|
|
|
+ isRenameRecursively,
|
|
|
|
|
+ );
|
|
|
const { page } = response;
|
|
const { page } = response;
|
|
|
window.location.href = encodeURI(`${page.path}?rename=${path}`);
|
|
window.location.href = encodeURI(`${page.path}?rename=${path}`);
|
|
|
}
|
|
}
|
|
@@ -68,7 +70,7 @@ const PageRenameModal = (props) => {
|
|
|
<ModalBody>
|
|
<ModalBody>
|
|
|
<div className="form-group">
|
|
<div className="form-group">
|
|
|
<label>{ t('modal_rename.label.Current page name') }</label><br />
|
|
<label>{ t('modal_rename.label.Current page name') }</label><br />
|
|
|
- <code>{path}</code>
|
|
|
|
|
|
|
+ <code>{ path }</code>
|
|
|
</div>
|
|
</div>
|
|
|
<div className="form-group">
|
|
<div className="form-group">
|
|
|
<label htmlFor="newPageName">{ t('modal_rename.label.New page name') }</label><br />
|
|
<label htmlFor="newPageName">{ t('modal_rename.label.New page name') }</label><br />
|