security-section.tsx 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import MaterialIcon from '@/shared/components/material-icon'
  2. import { Trans, useTranslation } from 'react-i18next'
  3. import { GroupSSOLinkingStatus } from '../../../../../types/subscription/sso'
  4. import getMeta from '../../../utils/meta'
  5. function SecuritySection() {
  6. const { t } = useTranslation()
  7. const memberOfSSOEnabledGroups = getMeta(
  8. 'ol-memberOfSSOEnabledGroups',
  9. []
  10. ) as GroupSSOLinkingStatus[]
  11. return (
  12. <>
  13. {memberOfSSOEnabledGroups?.length > 0 ? (
  14. <>
  15. <h3>{t('security')}</h3>
  16. {memberOfSSOEnabledGroups.map(
  17. ({
  18. groupId,
  19. linked,
  20. groupName,
  21. adminEmail,
  22. }: GroupSSOLinkingStatus) => (
  23. <div key={groupId} className="security-row">
  24. <span className="icon">
  25. <MaterialIcon type="key" />
  26. </span>
  27. <div className="text">
  28. <span className="line-header">
  29. <b>{t('single_sign_on_sso')}</b>{' '}
  30. {linked ? (
  31. <span className="status-label status-label-configured">
  32. {t('active')}
  33. </span>
  34. ) : (
  35. <span className="status-label status-label-ready">
  36. {t('ready_to_set_up')}
  37. </span>
  38. )}
  39. </span>
  40. <div>
  41. {linked ? (
  42. groupName ? (
  43. <Trans
  44. i18nKey="sso_user_explanation_enabled_with_group_name"
  45. // eslint-disable-next-line react/jsx-key
  46. components={[<b />]}
  47. values={{ groupName }}
  48. shouldUnescape
  49. tOptions={{ interpolation: { escapeValue: true } }}
  50. />
  51. ) : (
  52. <Trans
  53. i18nKey="sso_user_explanation_enabled_with_admin_email"
  54. // eslint-disable-next-line react/jsx-key
  55. components={[<b />]}
  56. values={{ adminEmail }}
  57. shouldUnescape
  58. tOptions={{ interpolation: { escapeValue: true } }}
  59. />
  60. )
  61. ) : groupName ? (
  62. <Trans
  63. i18nKey="sso_user_explanation_ready_with_group_name"
  64. // eslint-disable-next-line react/jsx-key
  65. components={[<b />, <b />]}
  66. values={{ groupName, buttonText: t('set_up_sso') }}
  67. shouldUnescape
  68. tOptions={{ interpolation: { escapeValue: true } }}
  69. />
  70. ) : (
  71. <Trans
  72. i18nKey="sso_user_explanation_ready_with_admin_email"
  73. // eslint-disable-next-line react/jsx-key
  74. components={[<b />, <b />]}
  75. values={{ adminEmail, buttonText: t('set_up_sso') }}
  76. shouldUnescape
  77. tOptions={{ interpolation: { escapeValue: true } }}
  78. />
  79. )}
  80. </div>
  81. </div>
  82. {linked ? null : (
  83. <div className="button-column">
  84. <a
  85. className="btn btn-primary"
  86. href={`/subscription/${groupId}/sso_enrollment`}
  87. >
  88. {t('set_up_sso')}
  89. </a>
  90. </div>
  91. )}
  92. </div>
  93. )
  94. )}
  95. <hr />
  96. </>
  97. ) : null}
  98. </>
  99. )
  100. }
  101. export default SecuritySection