PageItemControl.tsx 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 text-danger" type="button" onClick={deleteButtonHandler}>
  44. <i className="icon-fw icon-fire"></i>{t('Delete')}
  45. </button>
  46. <button className="dropdown-item" type="button" onClick={() => toastr.warning(t('search_result.currently_not_implemented'))}>
  47. <i className="icon-fw icon-star"></i>{t('Add to bookmark')}
  48. </button>
  49. <button className="dropdown-item" type="button" onClick={() => toastr.warning(t('search_result.currently_not_implemented'))}>
  50. <i className="icon-fw icon-docs"></i>{t('Duplicate')}
  51. </button>
  52. <button className="dropdown-item" type="button" onClick={() => toastr.warning(t('search_result.currently_not_implemented'))}>
  53. <i className="icon-fw icon-action-redo"></i>{t('Move/Rename')}
  54. </button>
  55. </div>
  56. </>
  57. );
  58. };
  59. export default PageItemControl;