PageItemControl.tsx 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import React, { FC } from 'react';
  2. import toastr from 'toastr';
  3. import { useTranslation } from 'react-i18next';
  4. import { IPageHasId } from '~/interfaces/page';
  5. type PageItemControlProps = {
  6. page: Partial<IPageHasId>
  7. isEnableActions: boolean
  8. onClickDeleteButton?: (pageId: string) => void
  9. }
  10. const PageItemControl: FC<PageItemControlProps> = (props: PageItemControlProps) => {
  11. const { page, isEnableActions, onClickDeleteButton } = props;
  12. const { t } = useTranslation('');
  13. const deleteButtonHandler = () => {
  14. if (onClickDeleteButton != null && page._id != null) {
  15. onClickDeleteButton(page._id);
  16. }
  17. };
  18. return (
  19. <>
  20. <button
  21. type="button"
  22. className="btn-link nav-link dropdown-toggle dropdown-toggle-no-caret border-0 rounded grw-btn-page-management py-0"
  23. data-toggle="dropdown"
  24. >
  25. <i className="fa fa-ellipsis-v text-muted"></i>
  26. </button>
  27. <div className="dropdown-menu dropdown-menu-right">
  28. {/* TODO: if there is the following button in XD add it here
  29. <button
  30. type="button"
  31. className="btn btn-link p-0"
  32. value={page.path}
  33. onClick={(e) => {
  34. window.location.href = e.currentTarget.value;
  35. }}
  36. >
  37. <i className="icon-login" />
  38. </button>
  39. */}
  40. {/*
  41. TODO: add function to the following buttons like using modal or others
  42. ref: https://estoc.weseek.co.jp/redmine/issues/79026
  43. */}
  44. {/* TODO: show dropdown when permalink section is implemented */}
  45. {!isEnableActions && (
  46. <p className="dropdown-item">
  47. {t('search_result.currently_not_implemented')}
  48. </p>
  49. )}
  50. {isEnableActions && (
  51. <button className="dropdown-item" type="button" onClick={() => toastr.warning(t('search_result.currently_not_implemented'))}>
  52. <i className="icon-fw icon-star"></i>
  53. {t('Add to bookmark')}
  54. </button>
  55. )}
  56. {isEnableActions && (
  57. <button className="dropdown-item" type="button" onClick={() => toastr.warning(t('search_result.currently_not_implemented'))}>
  58. <i className="icon-fw icon-docs"></i>
  59. {t('Duplicate')}
  60. </button>
  61. )}
  62. {isEnableActions && (
  63. <button className="dropdown-item" type="button" onClick={() => toastr.warning(t('search_result.currently_not_implemented'))}>
  64. <i className="icon-fw icon-action-redo"></i>
  65. {t('Move/Rename')}
  66. </button>
  67. )}
  68. {isEnableActions && (
  69. <>
  70. <div className="dropdown-divider"></div>
  71. <button className="dropdown-item text-danger pt-2" type="button" onClick={deleteButtonHandler}>
  72. <i className="icon-fw icon-trash"></i>
  73. {t('Delete')}
  74. </button>
  75. </>
  76. )}
  77. </div>
  78. </>
  79. );
  80. };
  81. export default PageItemControl;