security-section.tsx 4.0 KB

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