mirror of
https://github.com/wassname/talk.git
synced 2026-09-09 11:38:08 +08:00
Merge branch 'master' into restore-links
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Slot } from 'plugin-api/beta/client/components';
|
||||
import {
|
||||
Button,
|
||||
TextField,
|
||||
@@ -28,6 +29,15 @@ class SignUp extends React.Component {
|
||||
this.props.onSubmit();
|
||||
};
|
||||
|
||||
childFactory = el => {
|
||||
const key = el.key;
|
||||
const props = {
|
||||
indicateBlocker: () => this.props.indicateBlocker(key),
|
||||
indicateBlockerResolved: () => this.props.indicateBlockerResolved(key),
|
||||
};
|
||||
return React.cloneElement(el, props);
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
username,
|
||||
@@ -42,6 +52,7 @@ class SignUp extends React.Component {
|
||||
errorMessage,
|
||||
requireEmailConfirmation,
|
||||
success,
|
||||
blocked,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
@@ -103,6 +114,10 @@ class SignUp extends React.Component {
|
||||
onChange={this.handlePasswordRepeatChange}
|
||||
minLength="8"
|
||||
/>
|
||||
<Slot
|
||||
fill="talkPluginAuth.formField"
|
||||
childFactory={this.childFactory}
|
||||
/>
|
||||
<div className={styles.action}>
|
||||
<Button
|
||||
type="submit"
|
||||
@@ -110,6 +125,7 @@ class SignUp extends React.Component {
|
||||
id="coralSignUpButton"
|
||||
className={styles.button}
|
||||
full
|
||||
disabled={blocked}
|
||||
>
|
||||
{t('talk-plugin-auth.login.sign_up')}
|
||||
</Button>
|
||||
@@ -161,6 +177,9 @@ SignUp.propTypes = {
|
||||
errorMessage: PropTypes.string,
|
||||
requireEmailConfirmation: PropTypes.bool.isRequired,
|
||||
success: PropTypes.bool.isRequired,
|
||||
blocked: PropTypes.bool.isRequired,
|
||||
indicateBlocker: PropTypes.func.isRequired,
|
||||
indicateBlockerResolved: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default SignUp;
|
||||
|
||||
@@ -16,8 +16,19 @@ class SignUpContainer extends Component {
|
||||
emailError: null,
|
||||
passwordError: null,
|
||||
passwordRepeatError: null,
|
||||
blockers: [],
|
||||
};
|
||||
|
||||
indicateBlocker = key =>
|
||||
this.setState(state => ({
|
||||
blockers: state.blockers.concat(key),
|
||||
}));
|
||||
|
||||
indicateBlockerResolved = key =>
|
||||
this.setState(state => ({
|
||||
blockers: state.blockers.filter(i => i !== key),
|
||||
}));
|
||||
|
||||
validate = data => {
|
||||
let valid = true;
|
||||
const changes = {};
|
||||
@@ -48,7 +59,7 @@ class SignUpContainer extends Component {
|
||||
passwordRepeat: this.state.passwordRepeat,
|
||||
};
|
||||
|
||||
if (this.validate(data)) {
|
||||
if (this.validate(data) && !this.state.blockers.length) {
|
||||
this.props.signUp(data);
|
||||
}
|
||||
};
|
||||
@@ -76,6 +87,9 @@ class SignUpContainer extends Component {
|
||||
render() {
|
||||
return (
|
||||
<SignUp
|
||||
indicateBlocker={this.indicateBlocker}
|
||||
indicateBlockerResolved={this.indicateBlockerResolved}
|
||||
blocked={!!this.state.blockers.length}
|
||||
onSubmit={this.handleSubmit}
|
||||
onUsernameChange={this.setUsername}
|
||||
onEmailChange={this.props.setEmail}
|
||||
|
||||
@@ -14,10 +14,10 @@ import cn from 'classnames';
|
||||
|
||||
class Settings extends React.Component {
|
||||
childFactory = el => {
|
||||
const pluginName = el.type.talkPluginName;
|
||||
const key = el.key;
|
||||
const props = {
|
||||
indicateOn: () => this.props.indicateOn(pluginName),
|
||||
indicateOff: () => this.props.indicateOff(pluginName),
|
||||
indicateOn: () => this.props.indicateOn(key),
|
||||
indicateOff: () => this.props.indicateOff(key),
|
||||
};
|
||||
return React.cloneElement(el, props);
|
||||
};
|
||||
|
||||
@@ -20,14 +20,14 @@ class SettingsContainer extends React.Component {
|
||||
turnOffInput: {},
|
||||
};
|
||||
|
||||
indicateOn = plugin =>
|
||||
indicateOn = key =>
|
||||
this.setState(state => ({
|
||||
hasNotifications: state.hasNotifications.concat(plugin),
|
||||
hasNotifications: state.hasNotifications.concat(key),
|
||||
}));
|
||||
|
||||
indicateOff = plugin =>
|
||||
indicateOff = key =>
|
||||
this.setState(state => ({
|
||||
hasNotifications: state.hasNotifications.filter(i => i !== plugin),
|
||||
hasNotifications: state.hasNotifications.filter(i => i !== key),
|
||||
}));
|
||||
|
||||
setTurnOffInputFragment = fragment =>
|
||||
|
||||
Reference in New Issue
Block a user