mirror of
https://github.com/mickael-kerjean/filestash.git
synced 2024-04-21 12:32:08 +00:00
fix (login): gracefull handling of connection page error when the config is invalid
This commit is contained in:
@@ -18,9 +18,9 @@ export const FormObjToJSON = function(o, fn){
|
||||
|
||||
export function createFormBackend(backend_available, backend_data){
|
||||
if(!backend_available) return {};
|
||||
else if(!backend_available[backend_data.type]) return {};
|
||||
|
||||
let template = JSON.parse(JSON.stringify(backend_available[backend_data.type]));
|
||||
|
||||
for(let key in backend_data){
|
||||
if(key in template){
|
||||
template[key].value = backend_data[key];
|
||||
|
||||
@@ -3,12 +3,13 @@ import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
|
||||
|
||||
import './connectpage.scss';
|
||||
import { Session } from '../model/';
|
||||
import { Container, NgIf, NgShow, Loader, Notification } from '../components/';
|
||||
import { Container, NgIf, NgShow, Loader, Notification, ErrorPage } from '../components/';
|
||||
import { ForkMe, RememberMe, Credentials, Form } from './connectpage/';
|
||||
import { cache, notify, urlParams } from '../helpers/';
|
||||
|
||||
import { Alert } from '../components/';
|
||||
|
||||
@ErrorPage
|
||||
export class ConnectPage extends React.Component {
|
||||
constructor(props){
|
||||
super(props);
|
||||
@@ -84,6 +85,10 @@ export class ConnectPage extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
onError(err){
|
||||
this.props.error(err);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className="component_page_connect">
|
||||
@@ -98,6 +103,7 @@ export class ConnectPage extends React.Component {
|
||||
<ReactCSSTransitionGroup transitionName="form" transitionLeave={false} transitionEnter={false} transitionAppear={true} transitionAppearTimeout={500}>
|
||||
<Form credentials={this.state.credentials}
|
||||
onLoadingChange={this.setLoading.bind(this)}
|
||||
onError={this.onError.bind(this)}
|
||||
onSubmit={this.onFormSubmit.bind(this)} />
|
||||
</ReactCSSTransitionGroup>
|
||||
<ReactCSSTransitionGroup transitionName="remember" transitionLeave={false} transitionEnter={false} transitionAppear={true} transitionAppearTimeout={5000}>
|
||||
|
||||
@@ -33,12 +33,8 @@ export class Form extends React.Component {
|
||||
backends_enabled: window.CONFIG["connections"].map((conn) => {
|
||||
return createFormBackend(backend, conn);
|
||||
})
|
||||
}, () => {
|
||||
return this.publishState(this.props);
|
||||
});
|
||||
}).catch((err) => {
|
||||
this.props.error(err);
|
||||
});
|
||||
}, () => this.publishState(this.props));
|
||||
}).catch((err) => this.props.onError(err));
|
||||
}
|
||||
|
||||
componentWillUnmount(){
|
||||
@@ -107,9 +103,10 @@ export class Form extends React.Component {
|
||||
{
|
||||
this.state.backends_enabled.map((backend, i) => {
|
||||
const key = Object.keys(backend)[0];
|
||||
if(!backend[key]) return null;
|
||||
return (
|
||||
<Button key={"menu-"+i} className={i === this.state.select ? "active primary" : ""} onClick={this.onTypeChange.bind(this, i)}>
|
||||
{ backend[key].label.value }
|
||||
{ backend[key].label.value }
|
||||
</Button>
|
||||
);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user