Skip to content

Commit

Permalink
Fixed #1087 : Login dialog now is destroyed when it is closed (#1091) (
Browse files Browse the repository at this point in the history
…#1097)

* Fixed #1087 : Login dialog now is destroyed when it is closed

* changed all login tools to dialog
  • Loading branch information
MV88 authored and offtherailz committed Oct 7, 2016
1 parent 42ae8fb commit 77d5885
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 75 deletions.
7 changes: 0 additions & 7 deletions web/client/components/security/forms/LoginForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

const React = require('react');
const {Input, ButtonInput, Alert} = require('react-bootstrap');
Expand Down
9 changes: 1 addition & 8 deletions web/client/components/security/forms/PasswordReset.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

const React = require('react');
const {Input, Alert} = require('react-bootstrap');
Expand Down Expand Up @@ -68,7 +61,7 @@ const PasswordReset = React.createClass({
return null;
}
let pw = this.refs.password.getValue();
if (pw !== null && pw.length < this.props.minPasswordSize) {
if (pw !== null && pw.length < this.props.minPasswordSize && pw.length > 0) {
return <Alert bsStyle="danger"><Message msgId="user.passwordMinlenght" msgParams={{minSize: this.props.minPasswordSize}}/></Alert>;
} else if (pw !== null && pw !== this.refs.passwordcheck.getValue() ) {
return <Alert bsStyle="danger"><Message msgId="user.passwordCheckFail" /></Alert>;
Expand Down
45 changes: 23 additions & 22 deletions web/client/components/security/modals/LoginModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

const React = require('react');
const LoginForm = require('../forms/LoginForm');
Expand Down Expand Up @@ -61,8 +54,8 @@ const LoginModal = React.createClass({
includeCloseButton: true
};
},
render() {
const form = (<LoginForm
getForm() {
return (<LoginForm
role="body"
ref="loginForm"
showSubmitButton={false}
Expand All @@ -71,8 +64,10 @@ const LoginModal = React.createClass({
onLoginSuccess={this.props.onLoginSuccess}
onSubmit={this.props.onSubmit}
onError={this.props.onError}
/>);
const footer = (<span role="footer">
/>);
},
getFooter() {
return (<span role="footer">
<Button
ref="submit"
value={LocaleUtils.getMessageById(this.context.messages, "user.signIn")}
Expand All @@ -85,25 +80,31 @@ const LoginModal = React.createClass({
key="closeButton"
ref="closeButton"
bsSize={this.props.buttonSize}
onClick={this.props.onClose}>Close</Button> : <span/>}
onClick={this.props.onClose}><Message msgId="close"/></Button> : <span/>}
</span>);
return this.props.useModal ? (<Modal {...this.props.options} show={this.props.show} onHide={this.props.onClose}>
},
renderModal() {
return (<Modal {...this.props.options} show={this.props.show} onHide={this.props.onClose}>
<Modal.Header key="passwordChange" closeButton>
<Modal.Title><Message msgId="user.login"/></Modal.Title>
</Modal.Header>
<Modal.Body>
{form}
{this.getForm()}
</Modal.Body>
<Modal.Footer>
{footer}
{this.getFooter()}
</Modal.Footer>
</Modal>) : (
<Dialog modal id="mapstore-login-panel" style={assign({}, this.props.style, {display: this.props.show ? "block" : "none"})}>
<span role="header"><span className="login-panel-title"><Message msgId="user.login"/></span><button onClick={this.props.onClose} className="login-panel-close close">{this.props.closeGlyph ? <Glyphicon glyph={this.props.closeGlyph}/> : <span>×</span>}</button></span>
{form}
{footer}
</Dialog>
);
</Modal>);
},
renderDialog() {
return (this.props.show) ? (<Dialog modal id="mapstore-login-panel" style={assign({}, this.props.style, {display: "block" })}>
<span role="header"><span className="login-panel-title"><Message msgId="user.login"/></span><button onClick={this.props.onClose} className="login-panel-close close">{this.props.closeGlyph ? <Glyphicon glyph={this.props.closeGlyph}/> : <span>×</span>}</button></span>
{this.getForm()}
{this.getFooter()}
</Dialog>) : null;
},
render() {
return this.props.useModal ? this.renderModal() : this.renderDialog();
},
loginSubmit() {
this.refs.loginForm.submit();
Expand Down
36 changes: 23 additions & 13 deletions web/client/components/security/modals/PasswordResetModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const PasswordReset = require('../forms/PasswordReset');
const Message = require('../../../components/I18N/Message');
const {Modal, Button, Glyphicon} = require('react-bootstrap');

const Dialog = require('../../../components/misc/Dialog');
const Dialog = require('../../misc/Dialog');
const assign = require('object-assign');

const Spinner = require('react-spinkit');
Expand All @@ -26,6 +26,8 @@ const PasswordResetModal = React.createClass({
authHeader: React.PropTypes.string,
show: React.PropTypes.bool,
options: React.PropTypes.object,


onPasswordChange: React.PropTypes.func,
onPasswordChanged: React.PropTypes.func,
onClose: React.PropTypes.func,
Expand Down Expand Up @@ -75,8 +77,8 @@ const PasswordResetModal = React.createClass({
renderLoading() {
return this.state.loading ? <Spinner spinnerName="circle" key="loadingSpinner" noFadeIn/> : null;
},
render() {
const footer = (<span role="footer"><div style={{"float": "left"}}>{this.renderLoading()}</div>
getFooter() {
return (<span role="footer"><div style={{"float": "left"}}>{this.renderLoading()}</div>
<Button
ref="passwordChangeButton"
key="passwordChangeButton"
Expand All @@ -93,28 +95,36 @@ const PasswordResetModal = React.createClass({
bsSize={this.props.buttonSize}
onClick={this.props.onClose}><Message msgId="close"/></Button> : <span/>}
</span>);
const body = (<PasswordReset role="body" ref="passwordResetForm"
},
getBody() {
return (<PasswordReset role="body" ref="passwordResetForm"
onChange={() => {
this.setState({passwordValid: this.refs.passwordResetForm.isValid()});
}} />);
return this.props.useModal ? (
},
renderModal() {
return (
<Modal {...this.props.options} show={this.props.show} onHide={this.props.onClose}>
<Modal.Header key="passwordChange" closeButton>
<Modal.Title><Message msgId="user.changePwd"/></Modal.Title>
</Modal.Header>
<Modal.Body>
{body}
{this.getBody()}
</Modal.Body>
<Modal.Footer>
{footer}
{this.getFooter()}
</Modal.Footer>
</Modal>) : (
<Dialog id="mapstore-changepassword-panel" style={assign({}, this.props.style, {display: this.props.show ? "block" : "none"})}>
</Modal>);
},
renderDialog() {
return (this.props.show) ? (<Dialog modal id="mapstore-changepassword-panel" style={assign({}, this.props.style, {display: "block"})}>
<span role="header"><span className="changepassword-panel-title"><Message msgId="user.changePwd"/></span><button onClick={this.props.onClose} className="login-panel-close close">{this.props.closeGlyph ? <Glyphicon glyph={this.props.closeGlyph}/> : <span>×</span>}</button></span>
{body}
{footer}
</Dialog>
);
{this.getBody()}
{this.getFooter()}
</Dialog>) : null;
},
render() {
return this.props.useModal ? this.renderModal() : this.renderDialog();
}
});

Expand Down
39 changes: 18 additions & 21 deletions web/client/components/security/modals/UserDetailsModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Copyright 2016, GeoSolutions Sas.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/

const React = require('react');

const {Modal, Button, Table, Alert, Glyphicon} = require('react-bootstrap');
Expand Down Expand Up @@ -67,26 +59,31 @@ const UserDetails = React.createClass({
}
return <Alert type="info"><Message msgId="user.noAttributesMessage" /></Alert>;
},
render() {
const footer = this.props.includeCloseButton ? <Button bsSize={this.props.buttonSize} bsSize="small" onClick={this.props.onClose}><Message msgId="close"/></Button> : <span/>;
return this.props.useModal ? (
<Modal {...this.props.options} show={this.props.show} onHide={this.props.onClose}>
getFooter() {
return (this.props.includeCloseButton ? <Button bsSize={this.props.buttonSize} bsSize="small" onClick={this.props.onClose}><Message msgId="close"/></Button> : <span/>);
},
renderModal() {
return (<Modal {...this.props.options} show={this.props.show} onHide={this.props.onClose}>
<Modal.Header key="details" closeButton>
<Modal.Title>User Details</Modal.Title>
<Modal.Title><Message msgId="user.details" /></Modal.Title>
</Modal.Header>
<Modal.Body>
{this.renderAttributes()}
</Modal.Body>
<Modal.Footer>
{footer}
{this.getFooter()}
</Modal.Footer>
</Modal>) : (
<Dialog id="mapstore-user-panel" style={assign({}, this.props.style, {display: this.props.show ? "block" : "none"})}>
<span role="header"><span className="user-panel-title">Login</span><button onClick={this.props.onClose} className="login-panel-close close">{this.props.closeGlyph ? <Glyphicon glyph={this.props.closeGlyph}/> : <span>×</span>}</button></span>
{this.renderAttributes()}
{footer}
</Dialog>
);
</Modal>);
},
renderDialog() {
return (this.props.show) ? (<Dialog id="mapstore-user-panel" modal style={assign({}, this.props.style, {display: "block"})}>
<span role="header"><span className="user-panel-title"><Message msgId="user.details" /></span><button onClick={this.props.onClose} className="login-panel-close close">{this.props.closeGlyph ? <Glyphicon glyph={this.props.closeGlyph}/> : <span>×</span>}</button></span>
{this.renderAttributes()}
{this.getFooter()}
</Dialog>) : null;
},
render() {
return this.props.useModal ? this.renderModal() : this.renderDialog();
}

});
Expand Down
21 changes: 19 additions & 2 deletions web/client/localConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,25 @@
"nav": false,
"menuProps": {
"noCaret": true
}
}
},
"toolsCfg": [{
"buttonSize": "small",
"includeCloseButton": false,
"useModal": false,
"closeGlyph": "1-close"
}, {
"buttonSize": "small",
"includeCloseButton": false,
"useModal": false,
"closeGlyph": "1-close"
}, {
"buttonSize": "small",
"includeCloseButton": false,
"useModal": false,
"closeGlyph": "1-close"
}]

}
}, {"name": "Language"}, {
"name" : "Attribution",
"hide": true
Expand Down
2 changes: 1 addition & 1 deletion web/client/plugins/CreateNewMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const CreateNewMap = React.createClass({

render() {
const display = this.props.isLoggedIn ? null : "none";
return (<Grid fluid="true" style={{marginBottom: "30px", padding: 0, display}}>
return (<Grid fluid={true} style={{marginBottom: "30px", padding: 0, display}}>
<Col {...this.props.colProps} >
<Button bsStyle="primary" onClick={() => { this.context.router.push("/viewer/" + this.props.mapType + "/new"); }}>
<Message msgId="newMap" />
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.en-US
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@
"login": "Login",
"logout": "Logout",
"info": " Account Info",
"details": " User Details",
"noAttributesMessage": "There is no information related to your account",
"changePwd": "Change Password",
"newPwd": "New Password",
Expand Down
3 changes: 2 additions & 1 deletion web/client/translations/data.fr-FR
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@
"user":{
"login": "Login",
"logout": "Logout",
"info": " Informations du compte",
"info": "Informations du compte",
"details": "Détails de l'utilisateur",
"noAttributesMessage": "Il n'y a pas d'informations relatives à votre compte",
"changePwd": "Changer le mot de passe",
"newPwd": "Nouveau mot de passe",
Expand Down
1 change: 1 addition & 0 deletions web/client/translations/data.it-IT
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@
"login": "Login",
"logout": "Logout",
"info": " Informazioni Account",
"details": " Dettagli utente",
"noAttributesMessage": "Non ci sono informazioni sul tuo account",
"changePwd": "Cambia Password",
"newPwd": "Nuova Password",
Expand Down

0 comments on commit 77d5885

Please sign in to comment.