From cda81b6f5bd73abb9832fb7b31c91c7fe4534baf Mon Sep 17 00:00:00 2001 From: diminator Date: Tue, 29 Sep 2015 18:09:34 +0200 Subject: [PATCH 1/4] withdraw consign and acl buttonlist in detail refactor --- js/components/ascribe_detail/edition.js | 68 ++++++++++++++----------- js/constants/api_urls.js | 1 + 2 files changed, 39 insertions(+), 30 deletions(-) diff --git a/js/components/ascribe_detail/edition.js b/js/components/ascribe_detail/edition.js index 51884751..832ad386 100644 --- a/js/components/ascribe_detail/edition.js +++ b/js/components/ascribe_detail/edition.js @@ -38,6 +38,8 @@ import GlobalNotificationActions from '../../actions/global_notification_actions import Note from './note'; +import AclProxy from '../acl_proxy'; + import ApiUrls from '../../constants/api_urls'; import AppConstants from '../../constants/application_constants'; @@ -216,10 +218,6 @@ let EditionSummary = React.createClass({ refreshCollection: React.PropTypes.func }, - getTransferWithdrawData(){ - return {'bitcoin_id': this.props.edition.bitcoin_id}; - }, - handleSuccess() { this.props.refreshCollection(); this.props.handleSuccess(); @@ -261,30 +259,6 @@ let EditionSummary = React.createClass({ } 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 = ( -
- -
- ); - } - let unconsignRequestButton = null; - if (this.props.edition.acl.acl_request_unconsign) { - unconsignRequestButton = ( - - ); - } actions = ( @@ -293,11 +267,45 @@ let EditionSummary = React.createClass({ availableAcls={this.props.edition.acl} editions={[this.props.edition]} handleSuccess={this.handleSuccess}> - {withdrawButton} + +
{return {'bitcoin_id': this.props.edition.bitcoin_id}; }} + handleSuccess={this.showNotification} + className='inline' + isInline={true}> + +
+
+ +
{return {'bitcoin_id': this.props.edition.bitcoin_id}; }} + handleSuccess={this.showNotification} + className='inline' + isInline={true}> + +
+
+ + + - {unconsignRequestButton}
); diff --git a/js/constants/api_urls.js b/js/constants/api_urls.js index b8d6713d..2ff689fe 100644 --- a/js/constants/api_urls.js +++ b/js/constants/api_urls.js @@ -38,6 +38,7 @@ let ApiUrls = { 'ownership_consigns': AppConstants.apiEndpoint + 'ownership/consigns/', 'ownership_consigns_confirm': AppConstants.apiEndpoint + 'ownership/consigns/confirm/', '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_confirm': AppConstants.apiEndpoint + 'ownership/loans/pieces/confirm/', 'ownership_loans_pieces_deny': AppConstants.apiEndpoint + 'ownership/loans/pieces/deny/', From 4f6e39699f23fd05d51456f055b0ea6c07bd480e Mon Sep 17 00:00:00 2001 From: diminator Date: Wed, 30 Sep 2015 09:46:11 +0200 Subject: [PATCH 2/4] PR getlangtext --- js/components/ascribe_detail/edition.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/components/ascribe_detail/edition.js b/js/components/ascribe_detail/edition.js index 832ad386..e0ce16a5 100644 --- a/js/components/ascribe_detail/edition.js +++ b/js/components/ascribe_detail/edition.js @@ -277,7 +277,7 @@ let EditionSummary = React.createClass({ className='inline' isInline={true}> @@ -291,7 +291,7 @@ let EditionSummary = React.createClass({ className='inline' isInline={true}> From 44cf707e3472ea1305b08e6f7f3b86306ae9ebed Mon Sep 17 00:00:00 2001 From: diminator Date: Wed, 30 Sep 2015 12:12:14 +0200 Subject: [PATCH 3/4] refactoring out edition_actions --- js/components/ascribe_detail/edition.js | 141 ++------------- .../ascribe_detail/edition_actions.js | 170 ++++++++++++++++++ 2 files changed, 184 insertions(+), 127 deletions(-) create mode 100644 js/components/ascribe_detail/edition_actions.js diff --git a/js/components/ascribe_detail/edition.js b/js/components/ascribe_detail/edition.js index 8c718cc9..5a5df656 100644 --- a/js/components/ascribe_detail/edition.js +++ b/js/components/ascribe_detail/edition.js @@ -6,15 +6,11 @@ import Router from 'react-router'; import Row from 'react-bootstrap/lib/Row'; import Col from 'react-bootstrap/lib/Col'; import Glyphicon from 'react-bootstrap/lib/Glyphicon'; -import Button from 'react-bootstrap/lib/Button'; import UserActions from '../../actions/user_actions'; import UserStore from '../../stores/user_store'; import CoaActions from '../../actions/coa_actions'; 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'; @@ -28,23 +24,14 @@ import EditionDetailProperty from './detail_property'; import LicenseDetail from './license_detail'; import EditionFurtherDetails from './further_details'; -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 EditionActions from './edition_actions'; import Note from './note'; -import AclProxy from '../acl_proxy'; - import ApiUrls from '../../constants/api_urls'; import AppConstants from '../../constants/application_constants'; import { getLangText } from '../../utils/lang_utils'; -import { mergeOptions } from '../../utils/general_utils'; let Link = Router.Link; /** @@ -59,15 +46,11 @@ let Edition = React.createClass({ mixins: [Router.Navigation], getInitialState() { - return mergeOptions( - UserStore.getState(), - PieceListStore.getState() - ); + return UserStore.getState(); }, componentDidMount() { UserStore.listen(this.onChange); - PieceListStore.listen(this.onChange); UserActions.fetchCurrentUser(); }, @@ -82,31 +65,12 @@ let Edition = React.createClass({ CoaActions.flushCoa(); UserStore.unlisten(this.onChange); - 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}); - }, - render() { return ( @@ -123,12 +87,9 @@ let Edition = React.createClass({
- + currentUser={this.state.currentUser} + handleSuccess={this.props.loadEdition}/> @@ -211,25 +172,14 @@ let Edition = React.createClass({ let EditionSummary = React.createClass({ propTypes: { edition: React.PropTypes.object, - handleSuccess: React.PropTypes.func, currentUser: React.PropTypes.object, - handleDeleteSuccess: React.PropTypes.func, - refreshCollection: React.PropTypes.func + handleSuccess: React.PropTypes.func }, handleSuccess() { - this.props.refreshCollection(); this.props.handleSuccess(); }, - showNotification(response){ - this.props.handleSuccess(); - - if (response){ - let notification = new GlobalNotificationModel(response.notification, 'success'); - GlobalNotificationActions.appendGlobalNotification(notification); - } - }, getStatus(){ let status = null; if (this.props.edition.status.length > 0){ @@ -244,89 +194,26 @@ let EditionSummary = React.createClass({ return status; }, - getActions(){ - let actions = null; - if (this.props.edition && - this.props.edition.notifications && - this.props.edition.notifications.length > 0){ - actions = ( - ); - } - - else { - actions = ( - - - - -
{return {'bitcoin_id': this.props.edition.bitcoin_id}; }} - handleSuccess={this.showNotification} - className='inline' - isInline={true}> - -
-
- -
{return {'bitcoin_id': this.props.edition.bitcoin_id}; }} - handleSuccess={this.showNotification} - className='inline' - isInline={true}> - -
-
- - - - -
- -
); - } - return actions; - }, render() { + let { edition } = this.props; return (
+ value={ edition.edition_number + ' ' + getLangText('of') + ' ' + this.props.edition.num_editions} /> - + value={ edition.owner } /> + {this.getStatus()} - {this.getActions()} +
); diff --git a/js/components/ascribe_detail/edition_actions.js b/js/components/ascribe_detail/edition_actions.js new file mode 100644 index 00000000..c1d73dd2 --- /dev/null +++ b/js/components/ascribe_detail/edition_actions.js @@ -0,0 +1,170 @@ +'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 EditionActions = 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 ( + ); + } + + else { + return ( + + + + +
+ + +
+
+ +
+ + +
+
+ + + + +
+ +
+ ); + } + } +}); + +export default EditionActions; \ No newline at end of file From b233dbb937bae9845db0879b6826fe3ff19eee8f Mon Sep 17 00:00:00 2001 From: diminator Date: Thu, 1 Oct 2015 09:49:01 +0200 Subject: [PATCH 4/4] PR fixes --- js/components/ascribe_detail/edition.js | 10 +++++----- .../{edition_actions.js => edition_action_panel.js} | 5 ++--- 2 files changed, 7 insertions(+), 8 deletions(-) rename js/components/ascribe_detail/{edition_actions.js => edition_action_panel.js} (98%) diff --git a/js/components/ascribe_detail/edition.js b/js/components/ascribe_detail/edition.js index 5a5df656..62394631 100644 --- a/js/components/ascribe_detail/edition.js +++ b/js/components/ascribe_detail/edition.js @@ -24,7 +24,7 @@ import EditionDetailProperty from './detail_property'; import LicenseDetail from './license_detail'; import EditionFurtherDetails from './further_details'; -import EditionActions from './edition_actions'; +import EditionActionPanel from './edition_action_panel'; import Note from './note'; @@ -195,12 +195,12 @@ let EditionSummary = React.createClass({ }, render() { - let { edition } = this.props; + let { edition, currentUser } = this.props; return (
+ value={ edition.edition_number + ' ' + getLangText('of') + ' ' + edition.num_editions} /> {this.getStatus()} -
diff --git a/js/components/ascribe_detail/edition_actions.js b/js/components/ascribe_detail/edition_action_panel.js similarity index 98% rename from js/components/ascribe_detail/edition_actions.js rename to js/components/ascribe_detail/edition_action_panel.js index c1d73dd2..d82a6b8f 100644 --- a/js/components/ascribe_detail/edition_actions.js +++ b/js/components/ascribe_detail/edition_action_panel.js @@ -32,7 +32,7 @@ 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 EditionActions = React.createClass({ +let EditionActionPanel = React.createClass({ propTypes: { edition: React.PropTypes.object, currentUser: React.PropTypes.object, @@ -57,7 +57,6 @@ let EditionActions = React.createClass({ this.setState(state); }, - handleDeleteSuccess(response) { this.refreshCollection(); @@ -167,4 +166,4 @@ let EditionActions = React.createClass({ } }); -export default EditionActions; \ No newline at end of file +export default EditionActionPanel; \ No newline at end of file