mirror of
https://github.com/opensupports/opensupports.git
synced 2025-07-31 01:35:15 +02:00
Merged master into add-name-to-signup
This commit is contained in:
commit
1b7b449ae6
@ -1,10 +1,12 @@
|
|||||||
const React = require('react');
|
const React = require('react');
|
||||||
|
const ReactDOM = require('react-dom');
|
||||||
const Reflux = require('reflux');
|
const Reflux = require('reflux');
|
||||||
const _ = require('lodash');
|
const _ = require('lodash');
|
||||||
const classNames = require('classnames');
|
const classNames = require('classnames');
|
||||||
|
|
||||||
const UserActions = require('actions/user-actions');
|
const UserActions = require('actions/user-actions');
|
||||||
const UserStore = require('stores/user-store');
|
const UserStore = require('stores/user-store');
|
||||||
|
const focus = require('lib-core/focus');
|
||||||
|
|
||||||
const Button = require('core-components/button');
|
const Button = require('core-components/button');
|
||||||
const Form = require('core-components/form');
|
const Form = require('core-components/form');
|
||||||
@ -35,7 +37,7 @@ let MainHomePageLoginWidget = React.createClass({
|
|||||||
|
|
||||||
renderLogin() {
|
renderLogin() {
|
||||||
return (
|
return (
|
||||||
<Widget className="main-home-page--widget" title="Login">
|
<Widget className="main-home-page--widget" title="Login" ref="loginWidget">
|
||||||
<Form className="login-widget--form" ref="loginForm" onSubmit={this.handleLoginFormSubmit} errors={this.state.loginFormErrors} onValidateErrors={this.handleLoginFormErrorsValidation}>
|
<Form className="login-widget--form" ref="loginForm" onSubmit={this.handleLoginFormSubmit} errors={this.state.loginFormErrors} onValidateErrors={this.handleLoginFormErrorsValidation}>
|
||||||
<div className="login-widget--inputs">
|
<div className="login-widget--inputs">
|
||||||
<Input placeholder="email" name="email" className="login-widget--input" validation="EMAIL" required/>
|
<Input placeholder="email" name="email" className="login-widget--input" validation="EMAIL" required/>
|
||||||
@ -46,7 +48,7 @@ let MainHomePageLoginWidget = React.createClass({
|
|||||||
<Button type="primary">LOG IN</Button>
|
<Button type="primary">LOG IN</Button>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
<Button className="login-widget--forgot-password" type="link" onClick={this.handleForgotPasswordClick}>
|
<Button className="login-widget--forgot-password" type="link" onClick={this.handleForgotPasswordClick} onMouseDown={(event) => {event.preventDefault()}}>
|
||||||
{'Forgot your password?'}
|
{'Forgot your password?'}
|
||||||
</Button>
|
</Button>
|
||||||
</Widget>
|
</Widget>
|
||||||
@ -55,7 +57,7 @@ let MainHomePageLoginWidget = React.createClass({
|
|||||||
|
|
||||||
renderPasswordRecovery() {
|
renderPasswordRecovery() {
|
||||||
return (
|
return (
|
||||||
<Widget className="main-home-page--widget main-home-page--password-widget" title="Password Recovery">
|
<Widget className="main-home-page--widget main-home-page--password-widget" title="Password Recovery" ref="recoverWidget">
|
||||||
<Form className="login-widget--form" onSubmit={this.handleForgotPasswordSubmit}>
|
<Form className="login-widget--form" onSubmit={this.handleForgotPasswordSubmit}>
|
||||||
<div className="login-widget--inputs">
|
<div className="login-widget--inputs">
|
||||||
<Input placeholder="email" name="email" className="login-widget--input" validation="EMAIL"/>
|
<Input placeholder="email" name="email" className="login-widget--input" validation="EMAIL"/>
|
||||||
@ -64,7 +66,7 @@ let MainHomePageLoginWidget = React.createClass({
|
|||||||
<Button type="primary">Recover my password</Button>
|
<Button type="primary">Recover my password</Button>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
<Button className="login-widget--forgot-password" type="link" onClick={this.handleBackToLoginClick}>
|
<Button className="login-widget--forgot-password" type="link" onClick={this.handleBackToLoginClick} onMouseDown={(event) => {event.preventDefault()}}>
|
||||||
{'Back to login form'}
|
{'Back to login form'}
|
||||||
</Button>
|
</Button>
|
||||||
</Widget>
|
</Widget>
|
||||||
@ -88,13 +90,13 @@ let MainHomePageLoginWidget = React.createClass({
|
|||||||
handleForgotPasswordClick() {
|
handleForgotPasswordClick() {
|
||||||
this.setState({
|
this.setState({
|
||||||
sideToShow: 'back'
|
sideToShow: 'back'
|
||||||
});
|
}, this.moveFocusToCurrentSide);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleBackToLoginClick() {
|
handleBackToLoginClick() {
|
||||||
this.setState({
|
this.setState({
|
||||||
sideToShow: 'front'
|
sideToShow: 'front'
|
||||||
});
|
}, this.moveFocusToCurrentSide);
|
||||||
},
|
},
|
||||||
|
|
||||||
onUserStoreChanged(event) {
|
onUserStoreChanged(event) {
|
||||||
@ -107,6 +109,23 @@ let MainHomePageLoginWidget = React.createClass({
|
|||||||
this.refs.loginForm.refs.password.focus()
|
this.refs.loginForm.refs.password.focus()
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
moveFocusToCurrentSide() {
|
||||||
|
let currentWidget;
|
||||||
|
let previousWidget;
|
||||||
|
|
||||||
|
if (this.state.sideToShow === 'front') {
|
||||||
|
currentWidget = ReactDOM.findDOMNode(this.refs.loginWidget);
|
||||||
|
previousWidget = ReactDOM.findDOMNode(this.refs.recoverWidget);
|
||||||
|
} else {
|
||||||
|
currentWidget = ReactDOM.findDOMNode(this.refs.recoverWidget);
|
||||||
|
previousWidget = ReactDOM.findDOMNode(this.refs.loginWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (focus.isActiveElementInsideDOMTree(previousWidget)) {
|
||||||
|
focus.focusFirstInput(currentWidget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
18
client/src/lib-core/focus.js
Normal file
18
client/src/lib-core/focus.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
const _ = require('lodash');
|
||||||
|
|
||||||
|
export default {
|
||||||
|
isActiveElementInsideDOMTree(domTree = document) {
|
||||||
|
let activeElement = document.activeElement;
|
||||||
|
let elements = domTree.querySelectorAll('*');
|
||||||
|
|
||||||
|
return (_.findIndex(elements, activeElement) !== -1);
|
||||||
|
},
|
||||||
|
|
||||||
|
focusFirstInput(domTree) {
|
||||||
|
let firstFocusableElement = domTree.querySelector('input');
|
||||||
|
|
||||||
|
if (firstFocusableElement) {
|
||||||
|
firstFocusableElement.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
@ -23,7 +23,12 @@ class InitSettingsController extends Controller {
|
|||||||
|
|
||||||
private function storeGlobalSettings() {
|
private function storeGlobalSettings() {
|
||||||
$this->storeSettings([
|
$this->storeSettings([
|
||||||
'language' => 'en'
|
'language' => 'en',
|
||||||
|
'no-reply-email' => 'noreply@opensupports.com',
|
||||||
|
'smtp-host' => 'localhost',
|
||||||
|
'smtp-port' => 7070,
|
||||||
|
'smtp-user' => '',
|
||||||
|
'smtp-pass' => '',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,15 +3,13 @@ class MailSender {
|
|||||||
|
|
||||||
private $mailOptions = [];
|
private $mailOptions = [];
|
||||||
|
|
||||||
//TODO: Add real initial options when Settings class is available
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->mailOptions['from'] = 'noreply@opensupports.com';
|
$this->mailOptions['from'] = Setting::getSetting('no-reply-email');
|
||||||
|
|
||||||
//SMTP Options
|
$this->mailOptions['smtp-host'] = Setting::getSetting('smtp-host');
|
||||||
$this->mailOptions['smtp_host'] = 'localhost';
|
$this->mailOptions['smtp-port'] = Setting::getSetting('smtp-host');
|
||||||
$this->mailOptions['smtp_port'] = 7070;
|
$this->mailOptions['smtp-user'] = Setting::getSetting('smtp-host');
|
||||||
$this->mailOptions['smtp_user'] = '';
|
$this->mailOptions['smtp-pass'] = Setting::getSetting('smtp-host');
|
||||||
$this->mailOptions['smtp_pass'] = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setTemplate($type, $config) {
|
public function setTemplate($type, $config) {
|
||||||
@ -29,14 +27,12 @@ class MailSender {
|
|||||||
$mailer->Subject = $this->mailOptions['subject'];
|
$mailer->Subject = $this->mailOptions['subject'];
|
||||||
$mailer->Body = $this->mailOptions['body'];
|
$mailer->Body = $this->mailOptions['body'];
|
||||||
|
|
||||||
//$mailer->SMTPDebug = 3;
|
|
||||||
$mailer->isSMTP();
|
$mailer->isSMTP();
|
||||||
$mailer->SMTPAuth = true;
|
$mailer->SMTPAuth = true;
|
||||||
$mailer->Host = $this->mailOptions['smtp_host'];
|
$mailer->Host = $this->mailOptions['smtp-host'];
|
||||||
$mailer->Port = $this->mailOptions['smtp_port'];
|
$mailer->Port = $this->mailOptions['smtp-port'];
|
||||||
$mailer->Username = $this->mailOptions['smtp_user'];
|
$mailer->Username = $this->mailOptions['smtp-user'];
|
||||||
$mailer->Password = $this->mailOptions['smtp_pass'];
|
$mailer->Password = $this->mailOptions['smtp-pass'];
|
||||||
//$mailer->SMTPSecure = "tls";
|
|
||||||
$mailer->Timeout = 1000;
|
$mailer->Timeout = 1000;
|
||||||
|
|
||||||
if ($mailer->smtpConnect()) {
|
if ($mailer->smtpConnect()) {
|
||||||
|
@ -12,7 +12,7 @@ class MailTemplate extends DataStore {
|
|||||||
|
|
||||||
$bean = RedBean::findOne(MailTemplate::TABLE, 'type = :type AND language = :language', array(
|
$bean = RedBean::findOne(MailTemplate::TABLE, 'type = :type AND language = :language', array(
|
||||||
':type' => $type,
|
':type' => $type,
|
||||||
':language' => $globalLanguage->value
|
':language' => $globalLanguage
|
||||||
));
|
));
|
||||||
|
|
||||||
return ($bean) ? new MailTemplate($bean) : null;
|
return ($bean) ? new MailTemplate($bean) : null;
|
||||||
|
@ -4,7 +4,9 @@ class Setting extends DataStore {
|
|||||||
const TABLE = 'setting';
|
const TABLE = 'setting';
|
||||||
|
|
||||||
public static function getSetting($name) {
|
public static function getSetting($name) {
|
||||||
return parent::getDataStore($name, 'name');
|
$dataStore = parent::getDataStore($name, 'name');
|
||||||
|
|
||||||
|
return ($dataStore !== null) ? $dataStore->value : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getProps() {
|
public static function getProps() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user