mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 15:09:14 +00:00
45
frontend/src/components/dialog/confirm-disconnect-weixin.js
Normal file
45
frontend/src/components/dialog/confirm-disconnect-weixin.js
Normal file
@@ -0,0 +1,45 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
|
||||
import { gettext } from '../../utils/constants';
|
||||
|
||||
const propTypes = {
|
||||
formActionURL: PropTypes.string.isRequired,
|
||||
csrfToken: PropTypes.string.isRequired,
|
||||
toggle: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
class ConfirmDisconnectWeixin extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.form = React.createRef();
|
||||
}
|
||||
|
||||
disconnect = () => {
|
||||
this.form.current.submit();
|
||||
};
|
||||
|
||||
render() {
|
||||
const { formActionURL, csrfToken, toggle } = this.props;
|
||||
return (
|
||||
<Modal centered={true} isOpen={true} toggle={toggle}>
|
||||
<ModalHeader toggle={toggle}>{gettext('Disconnect')}</ModalHeader>
|
||||
<ModalBody>
|
||||
<p>{gettext('Are you sure you want to disconnect?')}</p>
|
||||
<form ref={this.form} className="d-none" method="post" action={formActionURL}>
|
||||
<input type="hidden" name="csrfmiddlewaretoken" value={csrfToken} />
|
||||
</form>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="secondary" onClick={toggle}>{gettext('Cancel')}</Button>
|
||||
<Button color="primary" onClick={this.disconnect}>{gettext('Disconnect')}</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ConfirmDisconnectWeixin.propTypes = propTypes;
|
||||
|
||||
export default ConfirmDisconnectWeixin;
|
59
frontend/src/components/user-settings/social-login-weixin.js
Normal file
59
frontend/src/components/user-settings/social-login-weixin.js
Normal file
@@ -0,0 +1,59 @@
|
||||
import React from 'react';
|
||||
import { gettext, siteRoot } from '../../utils/constants';
|
||||
import ModalPortal from '../modal-portal';
|
||||
import ConfirmDisconnectWeixin from '../dialog/confirm-disconnect-weixin';
|
||||
|
||||
const {
|
||||
csrfToken,
|
||||
langCode,
|
||||
socialConnectedWeixin,
|
||||
socialNextPage
|
||||
} = window.app.pageOptions;
|
||||
|
||||
class SocialLoginWeixin extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
isConfirmDialogOpen: false
|
||||
};
|
||||
}
|
||||
|
||||
confirmDisconnect = () => {
|
||||
this.setState({
|
||||
isConfirmDialogOpen: true
|
||||
});
|
||||
};
|
||||
|
||||
toggleDialog = () => {
|
||||
this.setState({
|
||||
isConfirmDialogOpen: !this.state.isConfirmDialogOpen
|
||||
});
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="setting-item" id="social-auth">
|
||||
<h3 className="setting-item-heading">{gettext('Social Login')}</h3>
|
||||
<p className="mb-2">{langCode == 'zh-cn' ? '微信' : 'Weixin'}</p>
|
||||
{socialConnectedWeixin ?
|
||||
<button className="btn btn-outline-primary" onClick={this.confirmDisconnect}>{gettext('Disconnect')}</button> :
|
||||
<a href={`${siteRoot}weixin/oauth-connect/?next=${encodeURIComponent(socialNextPage)}`} className="btn btn-outline-primary">{gettext('Connect')}</a>
|
||||
}
|
||||
</div>
|
||||
{this.state.isConfirmDialogOpen && (
|
||||
<ModalPortal>
|
||||
<ConfirmDisconnectWeixin
|
||||
formActionURL={`${siteRoot}weixin/oauth-disconnect/?next=${encodeURIComponent(socialNextPage)}`}
|
||||
csrfToken={csrfToken}
|
||||
toggle={this.toggleDialog}
|
||||
/>
|
||||
</ModalPortal>
|
||||
)}
|
||||
</React.Fragment>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default SocialLoginWeixin;
|
@@ -19,6 +19,7 @@ import EmailNotice from './components/user-settings/email-notice';
|
||||
import TwoFactorAuthentication from './components/user-settings/two-factor-auth';
|
||||
import SocialLogin from './components/user-settings/social-login';
|
||||
import SocialLoginDingtalk from './components/user-settings/social-login-dingtalk';
|
||||
import SocialLoginWeixin from './components/user-settings/social-login-weixin';
|
||||
import SocialLoginSAML from './components/user-settings/social-login-saml';
|
||||
import LinkedDevices from './components/user-settings/linked-devices';
|
||||
import DeleteAccount from './components/user-settings/delete-account';
|
||||
@@ -39,6 +40,7 @@ const {
|
||||
twoFactorAuthEnabled,
|
||||
enableWechatWork,
|
||||
enableDingtalk,
|
||||
enableWeixin,
|
||||
isOrgContext,
|
||||
enableADFS,
|
||||
enableMultiADFS,
|
||||
@@ -59,7 +61,7 @@ class Settings extends React.Component {
|
||||
{ show: true, href: '#lang-setting', text: gettext('Language') },
|
||||
{ show: isPro, href: '#email-notice', text: gettext('Email Notification') },
|
||||
{ show: twoFactorAuthEnabled, href: '#two-factor-auth', text: gettext('Two-Factor Authentication') },
|
||||
{ show: (enableWechatWork || enableDingtalk || enableADFS || (enableMultiADFS || isOrgContext)), href: '#social-auth', text: gettext('Social Login') },
|
||||
{ show: (enableWechatWork || enableDingtalk || enableWeixin || enableADFS || (enableMultiADFS || isOrgContext)), href: '#social-auth', text: gettext('Social Login') },
|
||||
{ show: true, href: '#linked-devices', text: gettext('Linked Devices') },
|
||||
{ show: enableDeleteAccount, href: '#del-account', text: gettext('Delete Account') },
|
||||
];
|
||||
@@ -180,6 +182,7 @@ class Settings extends React.Component {
|
||||
{twoFactorAuthEnabled && <TwoFactorAuthentication />}
|
||||
{enableWechatWork && <SocialLogin />}
|
||||
{enableDingtalk && <SocialLoginDingtalk />}
|
||||
{enableWeixin && <SocialLoginWeixin />}
|
||||
{(enableADFS || (enableMultiADFS && isOrgContext)) && <SocialLoginSAML />}
|
||||
<LinkedDevices />
|
||||
{enableDeleteAccount && <DeleteAccount />}
|
||||
|
Reference in New Issue
Block a user