/* eslint-disable react/no-danger */ import React from 'react'; import PropTypes from 'prop-types'; import { useTranslation } from 'react-i18next'; import AdminGeneralSecurityContainer from '~/client/services/AdminGeneralSecurityContainer'; import AdminGoogleSecurityContainer from '~/client/services/AdminGoogleSecurityContainer'; import { toastSuccess, toastError } from '~/client/util/apiNotification'; import { withUnstatedContainers } from '../../UnstatedUtils'; class GoogleSecurityManagementContents extends React.Component { constructor(props) { super(props); this.onClickSubmit = this.onClickSubmit.bind(this); } async onClickSubmit() { const { t, adminGoogleSecurityContainer, adminGeneralSecurityContainer } = this.props; try { await adminGoogleSecurityContainer.updateGoogleSetting(); await adminGeneralSecurityContainer.retrieveSetupStratedies(); toastSuccess(t('security_setting.OAuth.Google.updated_google')); } catch (err) { toastError(err); } } render() { const { t, adminGeneralSecurityContainer, adminGoogleSecurityContainer } = this.props; const { isGoogleEnabled } = adminGeneralSecurityContainer.state; return ( {t('security_setting.OAuth.Google.name')} {adminGoogleSecurityContainer.state.retrieveError != null && ( {t('Error occurred')} : {adminGoogleSecurityContainer.state.retrieveError} )} { adminGeneralSecurityContainer.switchIsGoogleOAuthEnabled() }} /> {t('security_setting.OAuth.Google.enable_google')} {(!adminGeneralSecurityContainer.state.setupStrategies.includes('google') && isGoogleEnabled) && {t('security_setting.setup_is_not_yet_complete')}} {t('security_setting.callback_URL')} {t('security_setting.desc_of_callback_URL', { AuthName: 'OAuth' })} {!adminGeneralSecurityContainer.state.appSiteUrl && ( ${t('App Settings')}` }) }} /> )} {isGoogleEnabled && ( {t('security_setting.configuration')} {t('security_setting.clientID')} adminGoogleSecurityContainer.changeGoogleClientId(e.target.value)} /> {t('security_setting.client_secret')} adminGoogleSecurityContainer.changeGoogleClientSecret(e.target.value)} /> { adminGoogleSecurityContainer.switchIsSameEmailTreatedAsIdenticalUser() }} /> {t('Update')} )} {t('security_setting.OAuth.how_to.google')} {/* eslint-disable-next-line max-len */} Google Cloud Platform API Manager' }) }} /> ); } } const GoogleSecurityManagementContentsFc = (props) => { const { t } = useTranslation(); return ; }; GoogleSecurityManagementContents.propTypes = { t: PropTypes.func.isRequired, // i18next adminGeneralSecurityContainer: PropTypes.instanceOf(AdminGeneralSecurityContainer).isRequired, adminGoogleSecurityContainer: PropTypes.instanceOf(AdminGoogleSecurityContainer).isRequired, }; const GoogleSecurityManagementContentsWrapper = withUnstatedContainers(GoogleSecurityManagementContentsFc, [ AdminGeneralSecurityContainer, AdminGoogleSecurityContainer, ]); export default GoogleSecurityManagementContentsWrapper;
{t('Error occurred')} : {adminGoogleSecurityContainer.state.retrieveError}
{t('security_setting.desc_of_callback_URL', { AuthName: 'OAuth' })}