[FIX] Show registration form when add server by a invite link (#2187)

Co-authored-by: Diego Mello <diegolmello@gmail.com>
This commit is contained in:
Djorkaeff Alexandre 2020-06-12 16:12:08 -03:00 committed by GitHub
parent 48be6764f4
commit 88f69717ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 10 deletions

View File

@ -73,7 +73,8 @@ class LoginView extends React.Component {
error: PropTypes.object, error: PropTypes.object,
failure: PropTypes.bool, failure: PropTypes.bool,
theme: PropTypes.string, theme: PropTypes.string,
loginRequest: PropTypes.func loginRequest: PropTypes.func,
inviteLinkToken: PropTypes.string
} }
constructor(props) { constructor(props) {
@ -91,6 +92,11 @@ class LoginView extends React.Component {
} }
} }
get showRegistrationButton() {
const { Accounts_RegistrationForm, inviteLinkToken } = this.props;
return Accounts_RegistrationForm === 'Public' || (Accounts_RegistrationForm === 'Secret URL' && inviteLinkToken?.length);
}
login = () => { login = () => {
const { navigation, Site_Name } = this.props; const { navigation, Site_Name } = this.props;
navigation.navigate('LoginView', { title: Site_Name }); navigation.navigate('LoginView', { title: Site_Name });
@ -125,7 +131,7 @@ class LoginView extends React.Component {
renderUserForm = () => { renderUserForm = () => {
const { const {
Accounts_EmailOrUsernamePlaceholder, Accounts_PasswordPlaceholder, Accounts_PasswordReset, Accounts_RegistrationForm, Accounts_RegistrationForm_LinkReplacementText, isFetching, theme, Accounts_ShowFormLogin Accounts_EmailOrUsernamePlaceholder, Accounts_PasswordPlaceholder, Accounts_PasswordReset, Accounts_RegistrationForm_LinkReplacementText, isFetching, theme, Accounts_ShowFormLogin
} = this.props; } = this.props;
if (!Accounts_ShowFormLogin) { if (!Accounts_ShowFormLogin) {
@ -183,7 +189,7 @@ class LoginView extends React.Component {
fontSize={14} fontSize={14}
/> />
)} )}
{Accounts_RegistrationForm === 'Public' ? ( {this.showRegistrationButton ? (
<View style={styles.bottomContainer}> <View style={styles.bottomContainer}>
<Text style={[styles.bottomContainerText, { color: themes[theme].auxiliaryText }]}>{I18n.t('Dont_Have_An_Account')}</Text> <Text style={[styles.bottomContainerText, { color: themes[theme].auxiliaryText }]}>{I18n.t('Dont_Have_An_Account')}</Text>
<Text <Text
@ -222,7 +228,8 @@ const mapStateToProps = state => ({
error: state.login.error && state.login.error.data, error: state.login.error && state.login.error.data,
Accounts_EmailOrUsernamePlaceholder: state.settings.Accounts_EmailOrUsernamePlaceholder, Accounts_EmailOrUsernamePlaceholder: state.settings.Accounts_EmailOrUsernamePlaceholder,
Accounts_PasswordPlaceholder: state.settings.Accounts_PasswordPlaceholder, Accounts_PasswordPlaceholder: state.settings.Accounts_PasswordPlaceholder,
Accounts_PasswordReset: state.settings.Accounts_PasswordReset Accounts_PasswordReset: state.settings.Accounts_PasswordReset,
inviteLinkToken: state.inviteLinks.token
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({

View File

@ -26,9 +26,15 @@ class WorkspaceView extends React.Component {
Site_Url: PropTypes.string, Site_Url: PropTypes.string,
server: PropTypes.string, server: PropTypes.string,
Assets_favicon_512: PropTypes.object, Assets_favicon_512: PropTypes.object,
registrationEnabled: PropTypes.bool, registrationForm: PropTypes.string,
registrationText: PropTypes.string, registrationText: PropTypes.string,
showLoginButton: PropTypes.bool showLoginButton: PropTypes.bool,
inviteLinkToken: PropTypes.string
}
get showRegistrationButton() {
const { registrationForm, inviteLinkToken } = this.props;
return registrationForm === 'Public' || (registrationForm === 'Secret URL' && inviteLinkToken?.length);
} }
login = () => { login = () => {
@ -43,7 +49,7 @@ class WorkspaceView extends React.Component {
render() { render() {
const { const {
theme, Site_Name, Site_Url, Assets_favicon_512, server, registrationEnabled, registrationText, showLoginButton theme, Site_Name, Site_Url, Assets_favicon_512, server, registrationText, showLoginButton
} = this.props; } = this.props;
return ( return (
<FormContainer theme={theme} testID='workspace-view'> <FormContainer theme={theme} testID='workspace-view'>
@ -64,7 +70,7 @@ class WorkspaceView extends React.Component {
/> />
) : null} ) : null}
{ {
registrationEnabled ? ( this.showRegistrationButton ? (
<Button <Button
title={I18n.t('Create_account')} title={I18n.t('Create_account')}
type='secondary' type='secondary'
@ -89,9 +95,10 @@ const mapStateToProps = state => ({
Site_Name: state.settings.Site_Name, Site_Name: state.settings.Site_Name,
Site_Url: state.settings.Site_Url, Site_Url: state.settings.Site_Url,
Assets_favicon_512: state.settings.Assets_favicon_512, Assets_favicon_512: state.settings.Assets_favicon_512,
registrationEnabled: state.settings.Accounts_RegistrationForm === 'Public', registrationForm: state.settings.Accounts_RegistrationForm,
registrationText: state.settings.Accounts_RegistrationForm_LinkReplacementText, registrationText: state.settings.Accounts_RegistrationForm_LinkReplacementText,
showLoginButton: getShowLoginButton(state) showLoginButton: getShowLoginButton(state),
inviteLinkToken: state.inviteLinks.token
}); });
export default connect(mapStateToProps)(withTheme(WorkspaceView)); export default connect(mapStateToProps)(withTheme(WorkspaceView));