CommentManageRightsSettings.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import React from 'react';
  2. import type AdminGeneralSecurityContainer from '~/client/services/AdminGeneralSecurityContainer';
  3. type Props = {
  4. adminGeneralSecurityContainer: AdminGeneralSecurityContainer;
  5. t: (key: string) => string;
  6. };
  7. export const CommentManageRightsSettings: React.FC<Props> = ({ adminGeneralSecurityContainer, t }) => {
  8. const { isRomUserAllowedToComment } = adminGeneralSecurityContainer.state;
  9. return (
  10. <>
  11. <h4 className="mb-3">{t('security_settings.comment_manage_rights')}</h4>
  12. <div className="row mb-4">
  13. <div className="col-md-4 text-md-end py-2">
  14. <strong>{t('security_settings.readonly_users_access')}</strong>
  15. </div>
  16. <div className="col-md-8">
  17. <div className="dropdown">
  18. <button
  19. className={`btn btn-outline-secondary dropdown-toggle text-end col-12 col-md-auto ${
  20. adminGeneralSecurityContainer.isWikiModeForced && 'disabled'
  21. }`}
  22. type="button"
  23. id="dropdownMenuButton"
  24. data-bs-toggle="dropdown"
  25. aria-haspopup="true"
  26. aria-expanded="true"
  27. >
  28. <span className="float-start">
  29. {isRomUserAllowedToComment === true && t('security_settings.read_only_users_comment.accept')}
  30. {isRomUserAllowedToComment === false && t('security_settings.read_only_users_comment.deny')}
  31. </span>
  32. </button>
  33. <div className="dropdown-menu" aria-labelledby="dropdownMenuButton">
  34. <button
  35. className="dropdown-item"
  36. type="button"
  37. onClick={() => { adminGeneralSecurityContainer.switchIsRomUserAllowedToComment(false) }}
  38. >
  39. {t('security_settings.read_only_users_comment.deny')}
  40. </button>
  41. <button
  42. className="dropdown-item"
  43. type="button"
  44. onClick={() => { adminGeneralSecurityContainer.switchIsRomUserAllowedToComment(true) }}
  45. >
  46. {t('security_settings.read_only_users_comment.accept')}
  47. </button>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </>
  53. );
  54. };