2
0

TextInputForPageTitleAndPath.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import { FC, useCallback } from 'react';
  2. import nodePath from 'path';
  3. import { pathUtils } from '@growi/core/dist/utils';
  4. import { useTranslation } from 'next-i18next';
  5. import { apiv3Put } from '~/client/util/apiv3-client';
  6. import { ValidationTarget } from '~/client/util/input-validator';
  7. import { toastSuccess, toastError } from '~/client/util/toastr';
  8. import { useSWRMUTxCurrentPage } from '~/stores/page';
  9. import { mutatePageTree, mutatePageList } from '~/stores/page-listing';
  10. import { mutateSearching } from '~/stores/search';
  11. import ClosableTextInput from '../Common/ClosableTextInput';
  12. type Props = {
  13. currentPagePath
  14. currentPage
  15. stateHandler
  16. inputValue
  17. CustomComponent
  18. }
  19. export const TextInputForPageTitleAndPath: FC<Props> = (props) => {
  20. const {
  21. currentPagePath, currentPage, stateHandler, inputValue, CustomComponent,
  22. } = props;
  23. const { t } = useTranslation();
  24. const { isRenameInputShown, setRenameInputShown } = stateHandler;
  25. return (
  26. <>
  27. {isRenameInputShown ? (
  28. <div className="flex-fill">
  29. <ClosableTextInput
  30. value={inputValue}
  31. placeholder={t('Input page name')}
  32. onClickOutside={() => { setRenameInputShown(false) }}
  33. // onPressEnter={onPressEnterForRenameHandler}
  34. validationTarget={ValidationTarget.PAGE}
  35. />
  36. </div>
  37. ) : (
  38. <CustomComponent />
  39. )}
  40. </>
  41. );
  42. };