PageItemControl.tsx 2.4 KB

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