security-section.tsx 3.9 KB

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