mirror of
https://github.com/wassname/talk.git
synced 2026-08-14 12:50:17 +08:00
Give descriptive key for slot elements and use it instead of talkPluginName
This commit is contained in:
@@ -29,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,
|
||||
@@ -43,17 +52,9 @@ class SignUp extends React.Component {
|
||||
errorMessage,
|
||||
requireEmailConfirmation,
|
||||
success,
|
||||
indicateBlockerOn,
|
||||
indicateBlockerOff,
|
||||
hasBlockers,
|
||||
blocked,
|
||||
} = this.props;
|
||||
|
||||
const slotPassthrough = {
|
||||
indicateBlockerOn,
|
||||
indicateBlockerOff,
|
||||
hasBlockers,
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className={styles.header}>
|
||||
@@ -115,7 +116,7 @@ class SignUp extends React.Component {
|
||||
/>
|
||||
<Slot
|
||||
fill="talkPluginAuth-formField"
|
||||
passthrough={slotPassthrough}
|
||||
childFactory={this.childFactory}
|
||||
/>
|
||||
<div className={styles.action}>
|
||||
<Button
|
||||
@@ -124,7 +125,7 @@ class SignUp extends React.Component {
|
||||
id="coralSignUpButton"
|
||||
className={styles.button}
|
||||
full
|
||||
disabled={hasBlockers.length}
|
||||
disabled={blocked}
|
||||
>
|
||||
{t('talk-plugin-auth.login.sign_up')}
|
||||
</Button>
|
||||
@@ -176,9 +177,9 @@ SignUp.propTypes = {
|
||||
errorMessage: PropTypes.string,
|
||||
requireEmailConfirmation: PropTypes.bool.isRequired,
|
||||
success: PropTypes.bool.isRequired,
|
||||
hasBlockers: PropTypes.array.isRequired,
|
||||
indicateBlockerOn: PropTypes.func.isRequired,
|
||||
indicateBlockerOff: PropTypes.func.isRequired,
|
||||
blocked: PropTypes.bool.isRequired,
|
||||
indicateBlocker: PropTypes.func.isRequired,
|
||||
indicateBlockerResolved: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
export default SignUp;
|
||||
|
||||
@@ -16,17 +16,17 @@ class SignUpContainer extends Component {
|
||||
emailError: null,
|
||||
passwordError: null,
|
||||
passwordRepeatError: null,
|
||||
hasBlockers: [],
|
||||
blockers: [],
|
||||
};
|
||||
|
||||
indicateBlockerOn = plugin =>
|
||||
indicateBlocker = key =>
|
||||
this.setState(state => ({
|
||||
hasBlockers: state.hasBlockers.concat(plugin),
|
||||
blockers: state.blockers.concat(key),
|
||||
}));
|
||||
|
||||
indicateBlockerOff = plugin =>
|
||||
indicateBlockerResolved = key =>
|
||||
this.setState(state => ({
|
||||
hasBlockers: state.hasBlockers.filter(i => i !== plugin),
|
||||
blockers: state.blockers.filter(i => i !== key),
|
||||
}));
|
||||
|
||||
validate = data => {
|
||||
@@ -87,9 +87,9 @@ class SignUpContainer extends Component {
|
||||
render() {
|
||||
return (
|
||||
<SignUp
|
||||
indicateBlockerOn={this.indicateBlockerOn}
|
||||
indicateBlockerOff={this.indicateBlockerOff}
|
||||
hasBlockers={this.state.hasBlockers}
|
||||
indicateBlocker={this.indicateBlocker}
|
||||
indicateBlockerResolved={this.indicateBlockerResolved}
|
||||
blocked={!!this.state.blockers.length}
|
||||
onSubmit={this.handleSubmit}
|
||||
onUsernameChange={this.setUsername}
|
||||
onEmailChange={this.props.setEmail}
|
||||
|
||||
Reference in New Issue
Block a user