|
|
@@ -11,18 +11,18 @@ import { EditorMode, useEditorMode } from '~/stores/ui';
|
|
|
import { PagePathNav } from '../Common/PagePathNav';
|
|
|
import { PageSelectModal } from '../PageSelectModal/PageSelectModal';
|
|
|
|
|
|
-import type { editedPagePathState } from './TextInputForPageTitleAndPath';
|
|
|
import { TextInputForPageTitleAndPath } from './TextInputForPageTitleAndPath';
|
|
|
import { usePagePathRenameHandler } from './page-header-utils';
|
|
|
|
|
|
|
|
|
export type Props = {
|
|
|
currentPage: IPagePopulatedToShowRevision
|
|
|
- editedPagePathState: editedPagePathState
|
|
|
+ inputValue: string
|
|
|
+ onInputChange?: (inputText: string) => void
|
|
|
}
|
|
|
|
|
|
export const PagePathHeader: FC<Props> = (props) => {
|
|
|
- const { currentPage, editedPagePathState } = props;
|
|
|
+ const { currentPage } = props;
|
|
|
|
|
|
const currentPagePath = currentPage.path;
|
|
|
|
|
|
@@ -32,8 +32,6 @@ export const PagePathHeader: FC<Props> = (props) => {
|
|
|
const { data: editorMode } = useEditorMode();
|
|
|
const { data: PageSelectModalData, open: openPageSelectModal } = usePageSelectModal();
|
|
|
|
|
|
- const { editedPagePath, setEditedPagePath } = editedPagePathState;
|
|
|
-
|
|
|
const onRenameFinish = () => {
|
|
|
setRenameInputShown(false);
|
|
|
};
|
|
|
@@ -59,18 +57,14 @@ export const PagePathHeader: FC<Props> = (props) => {
|
|
|
/>
|
|
|
), [currentPage._id, currentPagePath, isEditorMode]);
|
|
|
|
|
|
- const handleInputChange = (inputText: string) => {
|
|
|
- setEditedPagePath(inputText);
|
|
|
- };
|
|
|
-
|
|
|
- const handleEditButtonClick = useCallback(() => {
|
|
|
+ const onClickEditButton = useCallback(() => {
|
|
|
if (isRenameInputShown) {
|
|
|
- pagePathRenameHandler(editedPagePath);
|
|
|
+ pagePathRenameHandler(props.inputValue);
|
|
|
}
|
|
|
else {
|
|
|
setRenameInputShown(true);
|
|
|
}
|
|
|
- }, [editedPagePath, isRenameInputShown, pagePathRenameHandler]);
|
|
|
+ }, [isRenameInputShown, pagePathRenameHandler, props.inputValue]);
|
|
|
|
|
|
const buttonStyle = isButtonsShown ? '' : 'd-none';
|
|
|
|
|
|
@@ -103,15 +97,14 @@ export const PagePathHeader: FC<Props> = (props) => {
|
|
|
<TextInputForPageTitleAndPath
|
|
|
currentPage={currentPage}
|
|
|
stateHandler={stateHandler}
|
|
|
- editedPagePathState={editedPagePathState}
|
|
|
- inputValue={editedPagePath}
|
|
|
+ inputValue={props.inputValue}
|
|
|
CustomComponent={PagePath}
|
|
|
- handleInputChange={handleInputChange}
|
|
|
+ onInputChange={props.onInputChange}
|
|
|
/>
|
|
|
</div>
|
|
|
<div className={`${buttonStyle} col-4 row`}>
|
|
|
<div className="col-4">
|
|
|
- <button type="button" onClick={handleEditButtonClick}>
|
|
|
+ <button type="button" onClick={onClickEditButton}>
|
|
|
{isRenameInputShown ? <span className="material-symbols-outlined">check_circle</span> : <span className="material-symbols-outlined">edit</span>}
|
|
|
</button>
|
|
|
</div>
|