/* eslint-disable react/no-danger */ import React from 'react'; import PropTypes from 'prop-types'; import { withTranslation } from 'react-i18next'; import loggerFactory from '@alias/logger'; import { createSubscribedElement } from '../../UnstatedUtils'; import { toastError } from '../../../util/apiNotification'; import AppContainer from '../../../services/AppContainer'; import AdminGeneralSecurityContainer from '../../../services/AdminGeneralSecurityContainer'; import AdminGoogleSecurityContainer from '../../../services/AdminGoogleSecurityContainer'; const logger = loggerFactory('growi:security:AdminTwitterSecurityContainer'); class GoogleSecurityManagement extends React.Component { constructor(props) { super(props); this.state = { retrieveError: null, }; this.onClickSubmit = this.onClickSubmit.bind(this); } async componentDidMount() { const { adminGoogleSecurityContainer } = this.props; try { await adminGoogleSecurityContainer.retrieveSecurityData(); } catch (err) { toastError(err); this.setState({ retrieveError: err }); logger.error(err); } } render() { const { t, adminGeneralSecurityContainer, adminGoogleSecurityContainer } = this.props; return (

{ t('security_setting.OAuth.Google.name') } { t('security_setting.configuration') }

{this.state.retrieveError != null && (

{t('Error occurred')} : {this.state.err}

)}
{ t('security_setting.OAuth.Google.name') }
{ adminGeneralSecurityContainer.switchIsGoogleOAuthEnabled() }} />

{ t('security_setting.desc_of_callback_URL', { AuthName: 'OAuth' }) }

{!adminGeneralSecurityContainer.state.appSiteUrl && (
${t('App settings')}` }) }} />
)}
{adminGeneralSecurityContainer.state.isGoogleOAuthEnabled && (
adminGoogleSecurityContainer.changeGoogleClientId(e.target.value)} />

adminGoogleSecurityContainer.changeGoogleClientSecret(e.target.value)} />

{ adminGoogleSecurityContainer.switchIsSameUsernameTreatedAsIdenticalUser() }} />

)}

{ t('security_setting.OAuth.how_to.google') }

    {/* eslint-disable-next-line max-len */}
  1. Google Cloud Platform API Manager' }) }} />
); } } GoogleSecurityManagement.propTypes = { t: PropTypes.func.isRequired, // i18next appContainer: PropTypes.instanceOf(AppContainer).isRequired, adminGeneralSecurityContainer: PropTypes.instanceOf(AdminGeneralSecurityContainer).isRequired, adminGoogleSecurityContainer: PropTypes.instanceOf(AdminGoogleSecurityContainer).isRequired, }; const GoogleSecurityManagementWrapper = (props) => { return createSubscribedElement(GoogleSecurityManagement, props, [AppContainer, AdminGeneralSecurityContainer, AdminGoogleSecurityContainer]); }; export default withTranslation()(GoogleSecurityManagementWrapper);