mirror of
https://github.com/ascribe/onion.git
synced 2024-12-23 01:39:36 +01:00
Merge remote-tracking branch 'origin/master' into AD-727-missing-redirects-to-login-page
Conflicts: js/components/ascribe_detail/edition.js js/components/ascribe_forms/form_login.js js/components/ascribe_forms/form_signup.js
This commit is contained in:
commit
28dfcfa75a
@ -33,6 +33,10 @@ class EditionListActions {
|
|||||||
EditionListFetcher
|
EditionListFetcher
|
||||||
.fetch(pieceId, page, pageSize, orderBy, orderAsc, filterBy)
|
.fetch(pieceId, page, pageSize, orderBy, orderAsc, filterBy)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
if(res && !res.editions) {
|
||||||
|
throw new Error('Piece has no editions to fetch.');
|
||||||
|
}
|
||||||
|
|
||||||
this.actions.updateEditionList({
|
this.actions.updateEditionList({
|
||||||
pieceId,
|
pieceId,
|
||||||
page,
|
page,
|
||||||
@ -46,6 +50,7 @@ class EditionListActions {
|
|||||||
resolve(res);
|
resolve(res);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
console.logGlobal(err);
|
||||||
reject(err);
|
reject(err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -13,7 +13,7 @@ class UserActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fetchCurrentUser() {
|
fetchCurrentUser() {
|
||||||
return UserFetcher.fetchOne()
|
UserFetcher.fetchOne()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
this.actions.updateCurrentUser(res.users[0]);
|
this.actions.updateCurrentUser(res.users[0]);
|
||||||
})
|
})
|
||||||
@ -24,7 +24,7 @@ class UserActions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logoutCurrentUser() {
|
logoutCurrentUser() {
|
||||||
return UserFetcher.logout()
|
UserFetcher.logout()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.actions.deleteCurrentUser();
|
this.actions.deleteCurrentUser();
|
||||||
})
|
})
|
||||||
|
@ -6,15 +6,11 @@ import { Link, History } from 'react-router';
|
|||||||
import Row from 'react-bootstrap/lib/Row';
|
import Row from 'react-bootstrap/lib/Row';
|
||||||
import Col from 'react-bootstrap/lib/Col';
|
import Col from 'react-bootstrap/lib/Col';
|
||||||
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
|
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
|
||||||
import Button from 'react-bootstrap/lib/Button';
|
|
||||||
|
|
||||||
import UserActions from '../../actions/user_actions';
|
import UserActions from '../../actions/user_actions';
|
||||||
import UserStore from '../../stores/user_store';
|
import UserStore from '../../stores/user_store';
|
||||||
import CoaActions from '../../actions/coa_actions';
|
import CoaActions from '../../actions/coa_actions';
|
||||||
import CoaStore from '../../stores/coa_store';
|
import CoaStore from '../../stores/coa_store';
|
||||||
import PieceListActions from '../../actions/piece_list_actions';
|
|
||||||
import PieceListStore from '../../stores/piece_list_store';
|
|
||||||
import EditionListActions from '../../actions/edition_list_actions';
|
|
||||||
|
|
||||||
import HistoryIterator from './history_iterator';
|
import HistoryIterator from './history_iterator';
|
||||||
|
|
||||||
@ -28,13 +24,7 @@ import EditionDetailProperty from './detail_property';
|
|||||||
import LicenseDetail from './license_detail';
|
import LicenseDetail from './license_detail';
|
||||||
import FurtherDetails from './further_details';
|
import FurtherDetails from './further_details';
|
||||||
|
|
||||||
import ListRequestActions from './../ascribe_forms/list_form_request_actions';
|
import EditionActionPanel from './edition_action_panel';
|
||||||
import AclButtonList from './../ascribe_buttons/acl_button_list';
|
|
||||||
import UnConsignRequestButton from './../ascribe_buttons/unconsign_request_button';
|
|
||||||
import DeleteButton from '../ascribe_buttons/delete_button';
|
|
||||||
|
|
||||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
|
||||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
|
||||||
|
|
||||||
import Note from './note';
|
import Note from './note';
|
||||||
|
|
||||||
@ -42,7 +32,6 @@ import ApiUrls from '../../constants/api_urls';
|
|||||||
import AppConstants from '../../constants/application_constants';
|
import AppConstants from '../../constants/application_constants';
|
||||||
|
|
||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
import { mergeOptions } from '../../utils/general_utils';
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,15 +47,11 @@ let Edition = React.createClass({
|
|||||||
mixins: [History],
|
mixins: [History],
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return mergeOptions(
|
return UserStore.getState();
|
||||||
UserStore.getState(),
|
|
||||||
PieceListStore.getState()
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
UserStore.listen(this.onChange);
|
UserStore.listen(this.onChange);
|
||||||
PieceListStore.listen(this.onChange);
|
|
||||||
UserActions.fetchCurrentUser();
|
UserActions.fetchCurrentUser();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -81,31 +66,12 @@ let Edition = React.createClass({
|
|||||||
CoaActions.flushCoa();
|
CoaActions.flushCoa();
|
||||||
|
|
||||||
UserStore.unlisten(this.onChange);
|
UserStore.unlisten(this.onChange);
|
||||||
PieceListStore.unlisten(this.onChange);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
},
|
},
|
||||||
|
|
||||||
handleDeleteSuccess(response) {
|
|
||||||
this.refreshCollection();
|
|
||||||
|
|
||||||
EditionListActions.closeAllEditionLists();
|
|
||||||
EditionListActions.clearAllEditionSelections();
|
|
||||||
|
|
||||||
let notification = new GlobalNotificationModel(response.notification, 'success');
|
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
|
||||||
|
|
||||||
this.history.pushState(null, '/collection');
|
|
||||||
},
|
|
||||||
|
|
||||||
refreshCollection() {
|
|
||||||
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
|
||||||
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
|
||||||
EditionListActions.refreshEditionList({pieceId: this.props.edition.parent});
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Row>
|
<Row>
|
||||||
@ -122,12 +88,9 @@ let Edition = React.createClass({
|
|||||||
<hr/>
|
<hr/>
|
||||||
</div>
|
</div>
|
||||||
<EditionSummary
|
<EditionSummary
|
||||||
handleSuccess={this.props.loadEdition}
|
|
||||||
refreshCollection={this.refreshCollection}
|
|
||||||
currentUser={this.state.currentUser}
|
|
||||||
edition={this.props.edition}
|
edition={this.props.edition}
|
||||||
handleDeleteSuccess={this.handleDeleteSuccess}/>
|
currentUser={this.state.currentUser}
|
||||||
|
handleSuccess={this.props.loadEdition}/>
|
||||||
<CollapsibleParagraph
|
<CollapsibleParagraph
|
||||||
title={getLangText('Certificate of Authenticity')}
|
title={getLangText('Certificate of Authenticity')}
|
||||||
show={this.props.edition.acl.acl_coa === true}>
|
show={this.props.edition.acl.acl_coa === true}>
|
||||||
@ -211,29 +174,14 @@ let Edition = React.createClass({
|
|||||||
let EditionSummary = React.createClass({
|
let EditionSummary = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
edition: React.PropTypes.object,
|
edition: React.PropTypes.object,
|
||||||
handleSuccess: React.PropTypes.func,
|
|
||||||
currentUser: React.PropTypes.object,
|
currentUser: React.PropTypes.object,
|
||||||
handleDeleteSuccess: React.PropTypes.func,
|
handleSuccess: React.PropTypes.func
|
||||||
refreshCollection: React.PropTypes.func
|
|
||||||
},
|
|
||||||
|
|
||||||
getTransferWithdrawData(){
|
|
||||||
return {'bitcoin_id': this.props.edition.bitcoin_id};
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSuccess() {
|
handleSuccess() {
|
||||||
this.props.refreshCollection();
|
|
||||||
this.props.handleSuccess();
|
this.props.handleSuccess();
|
||||||
},
|
},
|
||||||
|
|
||||||
showNotification(response){
|
|
||||||
this.props.handleSuccess();
|
|
||||||
|
|
||||||
if (response){
|
|
||||||
let notification = new GlobalNotificationModel(response.notification, 'success');
|
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
getStatus(){
|
getStatus(){
|
||||||
let status = null;
|
let status = null;
|
||||||
if (this.props.edition.status.length > 0){
|
if (this.props.edition.status.length > 0){
|
||||||
@ -248,79 +196,26 @@ let EditionSummary = React.createClass({
|
|||||||
return status;
|
return status;
|
||||||
},
|
},
|
||||||
|
|
||||||
getActions(){
|
|
||||||
let actions = null;
|
|
||||||
if (this.props.edition &&
|
|
||||||
this.props.edition.notifications &&
|
|
||||||
this.props.edition.notifications.length > 0){
|
|
||||||
actions = (
|
|
||||||
<ListRequestActions
|
|
||||||
pieceOrEditions={[this.props.edition]}
|
|
||||||
currentUser={this.props.currentUser}
|
|
||||||
handleSuccess={this.showNotification}
|
|
||||||
notifications={this.props.edition.notifications}/>);
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
let withdrawButton = null;
|
|
||||||
if (this.props.edition.status.length > 0 && this.props.edition.pending_new_owner && this.props.edition.acl.acl_withdraw_transfer) {
|
|
||||||
withdrawButton = (
|
|
||||||
<Form
|
|
||||||
url={ApiUrls.ownership_transfers_withdraw}
|
|
||||||
getFormData={this.getTransferWithdrawData}
|
|
||||||
handleSuccess={this.showNotification}
|
|
||||||
className='inline'
|
|
||||||
isInline={true}>
|
|
||||||
<Button bsStyle="danger" className="btn-delete pull-center" bsSize="small" type="submit">
|
|
||||||
WITHDRAW TRANSFER
|
|
||||||
</Button>
|
|
||||||
</Form>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
let unconsignRequestButton = null;
|
|
||||||
if (this.props.edition.acl.acl_request_unconsign) {
|
|
||||||
unconsignRequestButton = (
|
|
||||||
<UnConsignRequestButton
|
|
||||||
currentUser={this.props.currentUser}
|
|
||||||
edition={this.props.edition}
|
|
||||||
handleSuccess={this.props.handleSuccess} />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
actions = (
|
|
||||||
<Row>
|
|
||||||
<Col md={12}>
|
|
||||||
<AclButtonList
|
|
||||||
className="text-center ascribe-button-list"
|
|
||||||
availableAcls={this.props.edition.acl}
|
|
||||||
editions={[this.props.edition]}
|
|
||||||
handleSuccess={this.handleSuccess}>
|
|
||||||
{withdrawButton}
|
|
||||||
<DeleteButton
|
|
||||||
handleSuccess={this.props.handleDeleteSuccess}
|
|
||||||
editions={[this.props.edition]}/>
|
|
||||||
{unconsignRequestButton}
|
|
||||||
</AclButtonList>
|
|
||||||
</Col>
|
|
||||||
</Row>);
|
|
||||||
}
|
|
||||||
return actions;
|
|
||||||
},
|
|
||||||
render() {
|
render() {
|
||||||
|
let { edition, currentUser } = this.props;
|
||||||
return (
|
return (
|
||||||
<div className="ascribe-detail-header">
|
<div className="ascribe-detail-header">
|
||||||
<EditionDetailProperty
|
<EditionDetailProperty
|
||||||
label={getLangText('EDITION')}
|
label={getLangText('EDITION')}
|
||||||
value={this.props.edition.edition_number + ' ' + getLangText('of') + ' ' + this.props.edition.num_editions} />
|
value={ edition.edition_number + ' ' + getLangText('of') + ' ' + edition.num_editions} />
|
||||||
<EditionDetailProperty
|
<EditionDetailProperty
|
||||||
label={getLangText('ID')}
|
label={getLangText('ID')}
|
||||||
value={ this.props.edition.bitcoin_id }
|
value={ edition.bitcoin_id }
|
||||||
ellipsis={true} />
|
ellipsis={true} />
|
||||||
<EditionDetailProperty
|
<EditionDetailProperty
|
||||||
label={getLangText('OWNER')}
|
label={getLangText('OWNER')}
|
||||||
value={ this.props.edition.owner } />
|
value={ edition.owner } />
|
||||||
<LicenseDetail license={this.props.edition.license_type}/>
|
<LicenseDetail license={edition.license_type}/>
|
||||||
{this.getStatus()}
|
{this.getStatus()}
|
||||||
{this.getActions()}
|
<EditionActionPanel
|
||||||
|
edition={edition}
|
||||||
|
currentUser={currentUser}
|
||||||
|
handleSuccess={this.handleSuccess} />
|
||||||
<hr/>
|
<hr/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
169
js/components/ascribe_detail/edition_action_panel.js
Normal file
169
js/components/ascribe_detail/edition_action_panel.js
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
import React from 'react';
|
||||||
|
import Router from 'react-router';
|
||||||
|
|
||||||
|
import Row from 'react-bootstrap/lib/Row';
|
||||||
|
import Col from 'react-bootstrap/lib/Col';
|
||||||
|
import Button from 'react-bootstrap/lib/Button';
|
||||||
|
|
||||||
|
import EditionListActions from '../../actions/edition_list_actions';
|
||||||
|
import PieceListActions from '../../actions/piece_list_actions';
|
||||||
|
import PieceListStore from '../../stores/piece_list_store';
|
||||||
|
|
||||||
|
import Form from './../ascribe_forms/form';
|
||||||
|
import Property from './../ascribe_forms/property';
|
||||||
|
|
||||||
|
import ListRequestActions from './../ascribe_forms/list_form_request_actions';
|
||||||
|
import AclButtonList from './../ascribe_buttons/acl_button_list';
|
||||||
|
import UnConsignRequestButton from './../ascribe_buttons/unconsign_request_button';
|
||||||
|
import DeleteButton from '../ascribe_buttons/delete_button';
|
||||||
|
|
||||||
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
|
|
||||||
|
import AclProxy from '../acl_proxy';
|
||||||
|
|
||||||
|
import ApiUrls from '../../constants/api_urls';
|
||||||
|
|
||||||
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
|
||||||
|
/*
|
||||||
|
A component that handles all the actions inside of the edition detail
|
||||||
|
handleSuccess requires a loadEdition action (could be refactored)
|
||||||
|
*/
|
||||||
|
let EditionActionPanel = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
edition: React.PropTypes.object,
|
||||||
|
currentUser: React.PropTypes.object,
|
||||||
|
handleSuccess: React.PropTypes.func
|
||||||
|
},
|
||||||
|
|
||||||
|
mixins: [Router.Navigation],
|
||||||
|
|
||||||
|
getInitialState() {
|
||||||
|
return PieceListStore.getState();
|
||||||
|
},
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
PieceListStore.listen(this.onChange);
|
||||||
|
},
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
PieceListStore.unlisten(this.onChange);
|
||||||
|
},
|
||||||
|
|
||||||
|
onChange(state) {
|
||||||
|
this.setState(state);
|
||||||
|
},
|
||||||
|
|
||||||
|
handleDeleteSuccess(response) {
|
||||||
|
this.refreshCollection();
|
||||||
|
|
||||||
|
EditionListActions.closeAllEditionLists();
|
||||||
|
EditionListActions.clearAllEditionSelections();
|
||||||
|
|
||||||
|
let notification = new GlobalNotificationModel(response.notification, 'success');
|
||||||
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
|
||||||
|
this.transitionTo('pieces');
|
||||||
|
},
|
||||||
|
|
||||||
|
refreshCollection() {
|
||||||
|
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||||
|
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||||
|
EditionListActions.refreshEditionList({pieceId: this.props.edition.parent});
|
||||||
|
},
|
||||||
|
|
||||||
|
handleSuccess(response){
|
||||||
|
this.refreshCollection();
|
||||||
|
this.props.handleSuccess();
|
||||||
|
if (response){
|
||||||
|
let notification = new GlobalNotificationModel(response.notification, 'success');
|
||||||
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
render(){
|
||||||
|
let {edition, currentUser} = this.props;
|
||||||
|
|
||||||
|
if (edition &&
|
||||||
|
edition.notifications &&
|
||||||
|
edition.notifications.length > 0){
|
||||||
|
return (
|
||||||
|
<ListRequestActions
|
||||||
|
pieceOrEditions={[edition]}
|
||||||
|
currentUser={currentUser}
|
||||||
|
handleSuccess={this.handleSuccess}
|
||||||
|
notifications={edition.notifications}/>);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
return (
|
||||||
|
<Row>
|
||||||
|
<Col md={12}>
|
||||||
|
<AclButtonList
|
||||||
|
className="text-center ascribe-button-list"
|
||||||
|
availableAcls={edition.acl}
|
||||||
|
editions={[edition]}
|
||||||
|
handleSuccess={this.handleSuccess}>
|
||||||
|
<AclProxy
|
||||||
|
aclObject={edition.acl}
|
||||||
|
aclName="acl_withdraw_transfer">
|
||||||
|
<Form
|
||||||
|
url={ApiUrls.ownership_transfers_withdraw}
|
||||||
|
handleSuccess={this.handleSuccess}
|
||||||
|
className='inline'
|
||||||
|
isInline={true}>
|
||||||
|
<Property
|
||||||
|
name="bitcoin_id"
|
||||||
|
hidden={true}>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={edition.bitcoin_id} />
|
||||||
|
</Property>
|
||||||
|
<Button bsStyle="danger" className="btn-delete pull-center" bsSize="small" type="submit">
|
||||||
|
{getLangText('WITHDRAW TRANSFER')}
|
||||||
|
</Button>
|
||||||
|
</Form>
|
||||||
|
</AclProxy>
|
||||||
|
<AclProxy
|
||||||
|
aclObject={edition.acl}
|
||||||
|
aclName="acl_withdraw_consign">
|
||||||
|
<Form
|
||||||
|
url={ApiUrls.ownership_consigns_withdraw}
|
||||||
|
handleSuccess={this.handleSuccess}
|
||||||
|
className='inline'
|
||||||
|
isInline={true}>
|
||||||
|
<Property
|
||||||
|
name="bitcoin_id"
|
||||||
|
hidden={true}>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
value={edition.bitcoin_id} />
|
||||||
|
</Property>
|
||||||
|
<Button bsStyle="danger" className="btn-delete pull-center" bsSize="small" type="submit">
|
||||||
|
{getLangText('WITHDRAW CONSIGN')}
|
||||||
|
</Button>
|
||||||
|
</Form>
|
||||||
|
</AclProxy>
|
||||||
|
<AclProxy
|
||||||
|
aclObject={edition.acl}
|
||||||
|
aclName="acl_request_unconsign">
|
||||||
|
<UnConsignRequestButton
|
||||||
|
currentUser={currentUser}
|
||||||
|
edition={edition}
|
||||||
|
handleSuccess={this.handleSuccess} />
|
||||||
|
</AclProxy>
|
||||||
|
<DeleteButton
|
||||||
|
handleSuccess={this.handleDeleteSuccess}
|
||||||
|
editions={[edition]}/>
|
||||||
|
</AclButtonList>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
export default EditionActionPanel;
|
@ -24,7 +24,6 @@ let LoginForm = React.createClass({
|
|||||||
submitMessage: React.PropTypes.string,
|
submitMessage: React.PropTypes.string,
|
||||||
redirectOnLoggedIn: React.PropTypes.bool,
|
redirectOnLoggedIn: React.PropTypes.bool,
|
||||||
redirectOnLoginSuccess: React.PropTypes.bool,
|
redirectOnLoginSuccess: React.PropTypes.bool,
|
||||||
onLogin: React.PropTypes.func,
|
|
||||||
location: React.PropTypes.object
|
location: React.PropTypes.object
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -45,6 +44,29 @@ let LoginForm = React.createClass({
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
UserStore.listen(this.onChange);
|
UserStore.listen(this.onChange);
|
||||||
|
let { redirect } = this.props.location.query;
|
||||||
|
if (redirect && redirect !== 'login'){
|
||||||
|
this.histoy.pushState(null, redirect, this.props.location.query);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
componentDidUpdate() {
|
||||||
|
// if user is already logged in, redirect him to piece list
|
||||||
|
if(this.state.currentUser && this.state.currentUser.email && this.props.redirectOnLoggedIn
|
||||||
|
&& this.props.redirectOnLoginSuccess) {
|
||||||
|
let { redirectAuthenticated } = this.props.location.query;
|
||||||
|
if(redirectAuthenticated) {
|
||||||
|
/*
|
||||||
|
* redirectAuthenticated contains an arbirary path
|
||||||
|
* eg pieces/<id>, editions/<bitcoin_id>, collection, settings, ...
|
||||||
|
* hence transitionTo cannot be used directly
|
||||||
|
*/
|
||||||
|
window.location = AppConstants.baseUrl + redirectAuthenticated;
|
||||||
|
} else {
|
||||||
|
this.history.pushState(null, 'collection');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
@ -53,12 +75,6 @@ let LoginForm = React.createClass({
|
|||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
|
|
||||||
// if user is already logged in, redirect him to piece list
|
|
||||||
if(this.state.currentUser && this.state.currentUser.email && this.props.redirectOnLoggedIn) {
|
|
||||||
// FIXME: hack to redirect out of the dispatch cycle
|
|
||||||
window.setTimeout(() => this.history.pushState(null, '/collection'), 0);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSuccess(){
|
handleSuccess(){
|
||||||
@ -70,28 +86,7 @@ let LoginForm = React.createClass({
|
|||||||
// The easiest way to check if the user was successfully logged in is to fetch the user
|
// The easiest way to check if the user was successfully logged in is to fetch the user
|
||||||
// in the user store (which is obviously only possible if the user is logged in), since
|
// in the user store (which is obviously only possible if the user is logged in), since
|
||||||
// register_piece is listening to the changes of the user_store.
|
// register_piece is listening to the changes of the user_store.
|
||||||
UserActions.fetchCurrentUser()
|
UserActions.fetchCurrentUser();
|
||||||
.then(() => {
|
|
||||||
if(this.props.redirectOnLoginSuccess) {
|
|
||||||
/* Taken from http://stackoverflow.com/a/14916411 */
|
|
||||||
/*
|
|
||||||
We actually have to trick the Browser into showing the "save password" dialog
|
|
||||||
as Chrome expects the login page to be reloaded after the login.
|
|
||||||
Users on Stack Overflow claim this is a bug in chrome and should be fixed in the future.
|
|
||||||
Until then, we redirect the HARD way, but reloading the whole page using window.location
|
|
||||||
*/
|
|
||||||
window.location = AppConstants.baseUrl + 'collection';
|
|
||||||
} else if(this.props.onLogin) {
|
|
||||||
// In some instances we want to give a callback to an outer container,
|
|
||||||
// to show that the one login action the user triggered actually went through.
|
|
||||||
// We can not do this by listening on a store's state as it wouldn't really tell us
|
|
||||||
// if the user did log in or was just fetching the user's data again
|
|
||||||
this.props.onLogin();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.logGlobal(err);
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import { History } from 'react-router';
|
|||||||
import { getLangText } from '../../utils/lang_utils';
|
import { getLangText } from '../../utils/lang_utils';
|
||||||
|
|
||||||
import UserStore from '../../stores/user_store';
|
import UserStore from '../../stores/user_store';
|
||||||
|
import UserActions from '../../actions/user_actions';
|
||||||
|
|
||||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||||
@ -14,6 +15,7 @@ import Form from './form';
|
|||||||
import Property from './property';
|
import Property from './property';
|
||||||
import InputCheckbox from './input_checkbox';
|
import InputCheckbox from './input_checkbox';
|
||||||
|
|
||||||
|
import AppConstants from '../../constants/application_constants';
|
||||||
import ApiUrls from '../../constants/api_urls';
|
import ApiUrls from '../../constants/api_urls';
|
||||||
|
|
||||||
|
|
||||||
@ -34,12 +36,35 @@ let SignupForm = React.createClass({
|
|||||||
submitMessage: getLangText('Sign up')
|
submitMessage: getLangText('Sign up')
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
return UserStore.getState();
|
return UserStore.getState();
|
||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
UserStore.listen(this.onChange);
|
UserStore.listen(this.onChange);
|
||||||
|
|
||||||
|
let { redirect } = this.props.location.query;
|
||||||
|
if (redirect && redirect !== 'signup'){
|
||||||
|
this.history.pushState(null, redirect, this.props.location.query);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
componentDidUpdate() {
|
||||||
|
// if user is already logged in, redirect him to piece list
|
||||||
|
if(this.state.currentUser && this.state.currentUser.email) {
|
||||||
|
//this.history.pushState(null, '/collection');
|
||||||
|
let { redirectAuthenticated } = this.props.location.query;
|
||||||
|
if(redirectAuthenticated) {
|
||||||
|
/*
|
||||||
|
* redirectAuthenticated contains an arbirary path
|
||||||
|
* eg pieces/<id>, editions/<bitcoin_id>, collection, settings, ...
|
||||||
|
* hence transitionTo cannot be used directly
|
||||||
|
*/
|
||||||
|
window.location = AppConstants.baseUrl + redirectAuthenticated;
|
||||||
|
}
|
||||||
|
this.history.pushState(null, '/collection');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
@ -48,21 +73,17 @@ let SignupForm = React.createClass({
|
|||||||
|
|
||||||
onChange(state) {
|
onChange(state) {
|
||||||
this.setState(state);
|
this.setState(state);
|
||||||
|
|
||||||
// if user is already logged in, redirect him to piece list
|
|
||||||
if(this.state.currentUser && this.state.currentUser.email) {
|
|
||||||
this.history.pushState(null, '/collection');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSuccess(response){
|
handleSuccess(response){
|
||||||
if (response.user) {
|
if (response.user) {
|
||||||
let notification = new GlobalNotificationModel(getLangText('Sign up successful'), 'success', 50000);
|
let notification = new GlobalNotificationModel(getLangText('Sign up successful'), 'success', 50000);
|
||||||
GlobalNotificationActions.appendGlobalNotification(notification);
|
GlobalNotificationActions.appendGlobalNotification(notification);
|
||||||
|
|
||||||
|
// Refactor this to its own component
|
||||||
this.props.handleSuccess(getLangText('We sent an email to your address') + ' ' + response.user.email + ', ' + getLangText('please confirm') + '.');
|
this.props.handleSuccess(getLangText('We sent an email to your address') + ' ' + response.user.email + ', ' + getLangText('please confirm') + '.');
|
||||||
}
|
} else {
|
||||||
else if (response.redirect) {
|
UserActions.fetchCurrentUser();
|
||||||
this.history.pushState(null, '/collection');
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -77,7 +98,9 @@ let SignupForm = React.createClass({
|
|||||||
let tooltipPassword = getLangText('Your password must be at least 10 characters') + '.\n ' +
|
let tooltipPassword = getLangText('Your password must be at least 10 characters') + '.\n ' +
|
||||||
getLangText('This password is securing your digital property like a bank account') + '.\n ' +
|
getLangText('This password is securing your digital property like a bank account') + '.\n ' +
|
||||||
getLangText('Store it in a safe place') + '!';
|
getLangText('Store it in a safe place') + '!';
|
||||||
|
|
||||||
let email = this.props.location.query.email || null;
|
let email = this.props.location.query.email || null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
className="ascribe-form-bordered"
|
className="ascribe-form-bordered"
|
||||||
|
@ -33,21 +33,28 @@ let PieceListBulkModal = React.createClass({
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
onChange(state) {
|
|
||||||
this.setState(state);
|
|
||||||
},
|
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
EditionListStore.listen(this.onChange);
|
EditionListStore.listen(this.onChange);
|
||||||
UserStore.listen(this.onChange);
|
UserStore.listen(this.onChange);
|
||||||
|
PieceListStore.listen(this.onChange);
|
||||||
|
|
||||||
UserActions.fetchCurrentUser();
|
UserActions.fetchCurrentUser();
|
||||||
|
PieceListActions.fetchPieceList(this.state.page, this.state.pageSize, this.state.search,
|
||||||
|
this.state.orderBy, this.state.orderAsc, this.state.filterBy);
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
EditionListStore.unlisten(this.onChange);
|
EditionListStore.unlisten(this.onChange);
|
||||||
|
PieceListStore.unlisten(this.onChange);
|
||||||
UserStore.unlisten(this.onChange);
|
UserStore.unlisten(this.onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onChange(state) {
|
||||||
|
this.setState(state);
|
||||||
|
},
|
||||||
|
|
||||||
fetchSelectedPieceEditionList() {
|
fetchSelectedPieceEditionList() {
|
||||||
let filteredPieceIdList = Object.keys(this.state.editionList)
|
let filteredPieceIdList = Object.keys(this.state.editionList)
|
||||||
.filter((pieceId) => {
|
.filter((pieceId) => {
|
||||||
|
@ -22,6 +22,7 @@ export function AuthComponent(Component) {
|
|||||||
|
|
||||||
componentDidUpdate() {
|
componentDidUpdate() {
|
||||||
if(this.state.currentUser && !this.state.currentUser.email) {
|
if(this.state.currentUser && !this.state.currentUser.email) {
|
||||||
|
console.log('redirect');
|
||||||
this.history.pushState(null, '/login');
|
this.history.pushState(null, '/login');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -61,10 +61,10 @@ let RegisterPiece = React.createClass( {
|
|||||||
},
|
},
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
WhitelabelActions.fetchWhitelabel();
|
|
||||||
PieceListStore.listen(this.onChange);
|
PieceListStore.listen(this.onChange);
|
||||||
UserStore.listen(this.onChange);
|
UserStore.listen(this.onChange);
|
||||||
WhitelabelStore.listen(this.onChange);
|
WhitelabelStore.listen(this.onChange);
|
||||||
|
WhitelabelActions.fetchWhitelabel();
|
||||||
},
|
},
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
@ -118,56 +118,16 @@ let RegisterPiece = React.createClass( {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// basically redirects to the second slide (index: 1), when the user is not logged in
|
|
||||||
onLoggedOut() {
|
|
||||||
// only transition to the login store, if user is not logged in
|
|
||||||
// ergo the currentUser object is not properly defined
|
|
||||||
if(this.state.currentUser && !this.state.currentUser.email) {
|
|
||||||
this.refs.slidesContainer.setSlideNum(1);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onLogin() {
|
|
||||||
// once the currentUser object from UserStore is defined (eventually the user was transitioned
|
|
||||||
// to the login form via the slider and successfully logged in), we can direct him back to the
|
|
||||||
// register_piece slide
|
|
||||||
if(this.state.currentUser && this.state.currentUser.email) {
|
|
||||||
window.history.back();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<SlidesContainer
|
|
||||||
ref="slidesContainer"
|
|
||||||
forwardProcess={false}
|
|
||||||
location={this.props.location}>
|
|
||||||
<div
|
|
||||||
onClick={this.onLoggedOut}
|
|
||||||
onFocus={this.onLoggedOut}>
|
|
||||||
<Row className="no-margin">
|
|
||||||
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
|
|
||||||
<RegisterPieceForm
|
<RegisterPieceForm
|
||||||
{...this.props}
|
{...this.props}
|
||||||
isFineUploaderActive={this.state.isFineUploaderActive}
|
isFineUploaderActive={this.state.isFineUploaderActive}
|
||||||
handleSuccess={this.handleSuccess}
|
handleSuccess={this.handleSuccess}
|
||||||
onLoggedOut={this.onLoggedOut}
|
|
||||||
location={this.props.location}>
|
location={this.props.location}>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
{this.getSpecifyEditions()}
|
{this.getSpecifyEditions()}
|
||||||
</RegisterPieceForm>
|
</RegisterPieceForm>
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<LoginContainer
|
|
||||||
message={getLangText('Please login before ascribing your work%s', '...')}
|
|
||||||
redirectOnLoggedIn={false}
|
|
||||||
redirectOnLoginSuccess={false}
|
|
||||||
onLogin={this.onLogin}
|
|
||||||
location={this.props.location}/>
|
|
||||||
</div>
|
|
||||||
</SlidesContainer>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -38,6 +38,7 @@ let ApiUrls = {
|
|||||||
'ownership_consigns': AppConstants.apiEndpoint + 'ownership/consigns/',
|
'ownership_consigns': AppConstants.apiEndpoint + 'ownership/consigns/',
|
||||||
'ownership_consigns_confirm': AppConstants.apiEndpoint + 'ownership/consigns/confirm/',
|
'ownership_consigns_confirm': AppConstants.apiEndpoint + 'ownership/consigns/confirm/',
|
||||||
'ownership_consigns_deny': AppConstants.apiEndpoint + 'ownership/consigns/deny/',
|
'ownership_consigns_deny': AppConstants.apiEndpoint + 'ownership/consigns/deny/',
|
||||||
|
'ownership_consigns_withdraw': AppConstants.apiEndpoint + 'ownership/consigns/withdraw/',
|
||||||
'ownership_loans_pieces': AppConstants.apiEndpoint + 'ownership/loans/pieces/',
|
'ownership_loans_pieces': AppConstants.apiEndpoint + 'ownership/loans/pieces/',
|
||||||
'ownership_loans_pieces_confirm': AppConstants.apiEndpoint + 'ownership/loans/pieces/confirm/',
|
'ownership_loans_pieces_confirm': AppConstants.apiEndpoint + 'ownership/loans/pieces/confirm/',
|
||||||
'ownership_loans_pieces_deny': AppConstants.apiEndpoint + 'ownership/loans/pieces/deny/',
|
'ownership_loans_pieces_deny': AppConstants.apiEndpoint + 'ownership/loans/pieces/deny/',
|
||||||
|
@ -13,7 +13,6 @@ class EditionListStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onUpdateEditionList({pieceId, editionListOfPiece, page, pageSize, orderBy, orderAsc, count, filterBy}) {
|
onUpdateEditionList({pieceId, editionListOfPiece, page, pageSize, orderBy, orderAsc, count, filterBy}) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Basically there are two modes an edition list can be updated.
|
Basically there are two modes an edition list can be updated.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user