PageItemControl.tsx 3.0 KB

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