PageItemControl.tsx 3.0 KB

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