1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

Small bug fixes for components affected by the UserStore and WhitelabelStore being passed down as a prop

This commit is contained in:
Brett Sun 2016-01-12 15:07:38 +01:00
parent 5b2178eb7e
commit b22ae7def1
7 changed files with 77 additions and 77 deletions

View File

@ -36,10 +36,12 @@ import { getLangText } from '../../utils/lang_utils';
*/ */
let Edition = React.createClass({ let Edition = React.createClass({
propTypes: { propTypes: {
currentUser: React.PropTypes.object.isRequired,
edition: React.PropTypes.object.isRequired,
whitelabel: React.PropTypes.object.isRequired,
actionPanelButtonListType: React.PropTypes.func, actionPanelButtonListType: React.PropTypes.func,
coaError: React.PropTypes.object, coaError: React.PropTypes.object,
currentUser: React.PropTypes.object,
edition: React.PropTypes.object,
furtherDetailsType: React.PropTypes.func, furtherDetailsType: React.PropTypes.func,
loadEdition: React.PropTypes.func loadEdition: React.PropTypes.func
}, },
@ -50,10 +52,6 @@ let Edition = React.createClass({
}; };
}, },
updateEdition() {
return EditionActions.fetchEdition(this.props.edition.bitcoin_id);
},
render() { render() {
const { const {
actionPanelButtonListType, actionPanelButtonListType,
@ -61,7 +59,8 @@ let Edition = React.createClass({
currentUser, currentUser,
edition, edition,
furtherDetailsType: FurtherDetailsType, furtherDetailsType: FurtherDetailsType,
loadEdition } = this.props; loadEdition,
whitelabel } = this.props;
return ( return (
<Row> <Row>
@ -69,49 +68,47 @@ let Edition = React.createClass({
<MediaContainer <MediaContainer
content={edition} content={edition}
currentUser={currentUser} currentUser={currentUser}
refreshObject={this.updateEdition} /> refreshObject={loadEdition} />
</Col> </Col>
<Col md={6} className="ascribe-edition-details ascribe-print-col-right"> <Col md={6} className="ascribe-edition-details ascribe-print-col-right">
<div className="ascribe-detail-header"> <div className="ascribe-detail-header">
<hr className="hidden-print" style={{marginTop: 0}}/> <hr className="hidden-print" style={{marginTop: 0}} />
<h1 className="ascribe-detail-title">{edition.title}</h1> <h1 className="ascribe-detail-title">{edition.title}</h1>
<DetailProperty label="BY" value={edition.artist_name} /> <DetailProperty label="BY" value={edition.artist_name} />
<DetailProperty label="DATE" value={Moment(edition.date_created, 'YYYY-MM-DD').year()} /> <DetailProperty label="DATE" value={Moment(edition.date_created, 'YYYY-MM-DD').year()} />
<hr/> <hr />
</div> </div>
<EditionSummary <EditionSummary
actionPanelButtonListType={actionPanelButtonListType} actionPanelButtonListType={actionPanelButtonListType}
edition={edition} edition={edition}
currentUser={currentUser} currentUser={currentUser}
handleSuccess={loadEdition}/> handleSuccess={loadEdition}
whitelabel={whitelabel} />
<CollapsibleParagraph <CollapsibleParagraph
title={getLangText('Certificate of Authenticity')} title={getLangText('Certificate of Authenticity')}
show={edition.acl.acl_coa === true}> show={edition.acl.acl_coa === true}>
<CoaDetails <CoaDetails
coa={edition.coa} coa={edition.coa}
coaError={coaError} coaError={coaError}
editionId={edition.bitcoin_id}/> editionId={edition.bitcoin_id} />
</CollapsibleParagraph> </CollapsibleParagraph>
<CollapsibleParagraph <CollapsibleParagraph
title={getLangText('Provenance/Ownership History')} title={getLangText('Provenance/Ownership History')}
show={edition.ownership_history && edition.ownership_history.length > 0}> show={edition.ownership_history && edition.ownership_history.length}>
<HistoryIterator <HistoryIterator history={edition.ownership_history} />
history={edition.ownership_history} />
</CollapsibleParagraph> </CollapsibleParagraph>
<CollapsibleParagraph <CollapsibleParagraph
title={getLangText('Consignment History')} title={getLangText('Consignment History')}
show={edition.consign_history && edition.consign_history.length > 0}> show={edition.consign_history && edition.consign_history.length > 0}>
<HistoryIterator <HistoryIterator history={edition.consign_history} />
history={edition.consign_history} />
</CollapsibleParagraph> </CollapsibleParagraph>
<CollapsibleParagraph <CollapsibleParagraph
title={getLangText('Loan History')} title={getLangText('Loan History')}
show={edition.loan_history && edition.loan_history.length > 0}> show={edition.loan_history && edition.loan_history.length > 0}>
<HistoryIterator <HistoryIterator history={edition.loan_history} />
history={edition.loan_history} />
</CollapsibleParagraph> </CollapsibleParagraph>
<CollapsibleParagraph <CollapsibleParagraph
@ -125,7 +122,7 @@ let Edition = React.createClass({
editable={true} editable={true}
successMessage={getLangText('Private note saved')} successMessage={getLangText('Private note saved')}
url={ApiUrls.note_private_edition} url={ApiUrls.note_private_edition}
currentUser={currentUser}/> currentUser={currentUser} />
<Note <Note
id={() => {return {'bitcoin_id': edition.bitcoin_id}; }} id={() => {return {'bitcoin_id': edition.bitcoin_id}; }}
label={getLangText('Personal note (public)')} label={getLangText('Personal note (public)')}
@ -135,13 +132,11 @@ let Edition = React.createClass({
show={!!edition.public_note || !!edition.acl.acl_edit} show={!!edition.public_note || !!edition.acl.acl_edit}
successMessage={getLangText('Public edition note saved')} successMessage={getLangText('Public edition note saved')}
url={ApiUrls.note_public_edition} url={ApiUrls.note_public_edition}
currentUser={currentUser}/> currentUser={currentUser} />
</CollapsibleParagraph> </CollapsibleParagraph>
<CollapsibleParagraph <CollapsibleParagraph
title={getLangText('Further Details')} title={getLangText('Further Details')}
show={edition.acl.acl_edit || show={edition.acl.acl_edit || Object.keys(edition.extra_data).length || edition.other_data.length}>
Object.keys(edition.extra_data).length > 0 ||
edition.other_data.length > 0}>
<FurtherDetailsType <FurtherDetailsType
editable={edition.acl.acl_edit} editable={edition.acl.acl_edit}
pieceId={edition.parent} pieceId={edition.parent}
@ -149,10 +144,8 @@ let Edition = React.createClass({
otherData={edition.other_data} otherData={edition.other_data}
handleSuccess={loadEdition} /> handleSuccess={loadEdition} />
</CollapsibleParagraph> </CollapsibleParagraph>
<CollapsibleParagraph <CollapsibleParagraph title={getLangText('SPOOL Details')}>
title={getLangText('SPOOL Details')}> <SpoolDetails edition={edition} />
<SpoolDetails
edition={edition} />
</CollapsibleParagraph> </CollapsibleParagraph>
</Col> </Col>
</Row> </Row>
@ -163,60 +156,56 @@ let Edition = React.createClass({
let EditionSummary = React.createClass({ let EditionSummary = React.createClass({
propTypes: { propTypes: {
currentUser: React.PropTypes.object.isRequired,
edition: React.PropTypes.object.isRequired,
whitelabel: React.PropTypes.object.isRequired,
actionPanelButtonListType: React.PropTypes.func, actionPanelButtonListType: React.PropTypes.func,
edition: React.PropTypes.object,
currentUser: React.PropTypes.object,
handleSuccess: React.PropTypes.func handleSuccess: React.PropTypes.func
}, },
handleSuccess() { getStatus() {
this.props.handleSuccess(); const { status } = this.props.edition;
},
getStatus(){ return status.length ? (
let status = null; <DetailProperty
if (this.props.edition.status.length > 0){ label="STATUS"
let statusStr = this.props.edition.status.join(', ').replace(/_/g, ' '); value={status.join(', ').replace(/_/g, ' ')} />
status = <DetailProperty label="STATUS" value={ statusStr }/>; ) : null;
if (this.props.edition.pending_new_owner && this.props.edition.acl.acl_withdraw_transfer){
status = (
<DetailProperty label="STATUS" value={ statusStr } />
);
}
}
return status;
}, },
render() { render() {
let { actionPanelButtonListType, edition, currentUser } = this.props; const { actionPanelButtonListType, currentUser, edition, handleSuccess, whitelabel } = this.props;
return ( return (
<div className="ascribe-detail-header"> <div className="ascribe-detail-header">
<DetailProperty <DetailProperty
label={getLangText('EDITION')} label={getLangText('EDITION')}
value={ edition.edition_number + ' ' + getLangText('of') + ' ' + edition.num_editions} /> value={edition.edition_number + ' ' + getLangText('of') + ' ' + edition.num_editions} />
<DetailProperty <DetailProperty
label={getLangText('ID')} label={getLangText('ID')}
value={ edition.bitcoin_id } value={edition.bitcoin_id}
ellipsis={true} /> ellipsis={true} />
<DetailProperty <DetailProperty
label={getLangText('OWNER')} label={getLangText('OWNER')}
value={ edition.owner } /> value={edition.owner} />
<LicenseDetail license={edition.license_type}/> <LicenseDetail license={edition.license_type} />
{this.getStatus()} {this.getStatus()}
{/* {/*
`acl_view` is always available in `edition.acl`, therefore if it has `acl_view` is always available in `edition.acl`, therefore if it has
no more than 1 key, we're hiding the `DetailProperty` actions as otherwise no more than 1 key, we're hiding the `DetailProperty` actions as otherwise
`AclInformation` would show up `AclInformation` would show up
*/} */}
<AclProxy show={currentUser && currentUser.email && Object.keys(edition.acl).length > 1}> <AclProxy show={currentUser.email && Object.keys(edition.acl).length > 1}>
<DetailProperty <DetailProperty
label={getLangText('ACTIONS')} label={getLangText('ACTIONS')}
className="hidden-print"> className="hidden-print">
<EditionActionPanel <EditionActionPanel
actionPanelButtonListType={actionPanelButtonListType} actionPanelButtonListType={actionPanelButtonListType}
edition={edition}
currentUser={currentUser} currentUser={currentUser}
handleSuccess={this.handleSuccess} /> edition={edition}
handleSuccess={handleSuccess}
whitelabel={whitelabel} />
</DetailProperty> </DetailProperty>
</AclProxy> </AclProxy>
<hr/> <hr/>
@ -365,4 +354,5 @@ let SpoolDetails = React.createClass({
} }
}); });
export default Edition; export default Edition;

View File

@ -36,8 +36,9 @@ import { getLangText } from '../../utils/lang_utils';
*/ */
let EditionActionPanel = React.createClass({ let EditionActionPanel = React.createClass({
propTypes: { propTypes: {
edition: React.PropTypes.object.isRequired,
currentUser: React.PropTypes.object.isRequired, currentUser: React.PropTypes.object.isRequired,
edition: React.PropTypes.object.isRequired,
whitelabel: React.PropTypes.object.isRequired,
actionPanelButtonListType: React.PropTypes.func, actionPanelButtonListType: React.PropTypes.func,
handleSuccess: React.PropTypes.func handleSuccess: React.PropTypes.func
@ -87,21 +88,25 @@ let EditionActionPanel = React.createClass({
handleSuccess(response) { handleSuccess(response) {
this.refreshCollection(); this.refreshCollection();
this.props.handleSuccess();
if (response){ if (response) {
let notification = new GlobalNotificationModel(response.notification, 'success'); const notification = new GlobalNotificationModel(response.notification, 'success');
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
} }
if (typeof this.props.handleSuccess === 'function') {
this.props.handleSuccess();
}
}, },
render() { render() {
const { const {
actionPanelButtonListType: ActionPanelButtonListType, actionPanelButtonListType: ActionPanelButtonListType,
currentUser,
edition, edition,
currentUser } = this.props; whitelabel } = this.props;
if (edition.notifications && if (edition.notifications && edition.notifications.length) {
edition.notifications.length > 0){
return ( return (
<ListRequestActions <ListRequestActions
currentUser={currentUser} currentUser={currentUser}
@ -116,8 +121,9 @@ let EditionActionPanel = React.createClass({
availableAcls={edition.acl} availableAcls={edition.acl}
className="ascribe-button-list" className="ascribe-button-list"
currentUser={currentUser} currentUser={currentUser}
handleSuccess={this.handleSuccess}
pieceOrEditions={[edition]} pieceOrEditions={[edition]}
handleSuccess={this.handleSuccess}> whitelabel={whitelabel}>
<AclProxy <AclProxy
aclObject={edition.acl} aclObject={edition.acl}
aclName="acl_withdraw_transfer"> aclName="acl_withdraw_transfer">

View File

@ -74,11 +74,11 @@ let EditionContainer = React.createClass({
onChange(state) { onChange(state) {
this.setState(state); this.setState(state);
if(state && state.edition && state.edition.digital_work) { if (state && state.edition && state.edition.digital_work) {
let isEncoding = state.edition.digital_work.isEncoding; const isEncoding = state.edition.digital_work.isEncoding;
if (state.edition.digital_work.mime === 'video' && typeof isEncoding === 'number' && isEncoding !== 100 && !this.state.timerId) { if (state.edition.digital_work.mime === 'video' && typeof isEncoding === 'number' && isEncoding !== 100 && !this.state.timerId) {
let timerId = window.setInterval(() => EditionActions.fetchOne(this.props.params.editionId), 10000); const timerId = window.setInterval(() => EditionActions.fetchOne(this.props.params.editionId), 10000);
this.setState({timerId: timerId}); this.setState({ timerId: timerId });
} }
} }
}, },

View File

@ -95,7 +95,7 @@ let SignupForm = React.createClass({
type="email" type="email"
placeholder={getLangText('(e.g. andy@warhol.co.uk)')} placeholder={getLangText('(e.g. andy@warhol.co.uk)')}
autoComplete="on" autoComplete="on"
defaultValue={email} defaultValue={emailQuery}
required/> required/>
</Property> </Property>
<Property <Property

View File

@ -32,7 +32,6 @@ import { getLangText } from '../../../../../utils/lang_utils';
let IkonotvRegisterPiece = React.createClass({ let IkonotvRegisterPiece = React.createClass({
propTypes: { propTypes: {
piece: React.PropTypes.object.isRequired,
handleSuccess: React.PropTypes.func, handleSuccess: React.PropTypes.func,
// Provided from PrizeApp // Provided from PrizeApp
@ -45,14 +44,15 @@ let IkonotvRegisterPiece = React.createClass({
mixins: [History], mixins: [History],
getInitialState(){ getInitialState() {
return mergeOptions( return mergeOptions(
PieceListStore.getState(), PieceListStore.getState(),
PieceStore.getState(), PieceStore.getState(),
{ {
step: 0, step: 0,
pageExitWarning: getLangText("If you leave this form now, your work will not be loaned to Ikono TV.") pageExitWarning: getLangText("If you leave this form now, your work will not be loaned to Ikono TV.")
}); }
);
}, },
componentDidMount() { componentDidMount() {
@ -90,13 +90,12 @@ let IkonotvRegisterPiece = React.createClass({
this.refreshPieceList(); this.refreshPieceList();
// also start loading the piece for the next step // also start loading the piece for the next step
if(response && response.piece) { if (response && response.piece) {
PieceActions.updatePiece(response.piece); PieceActions.updatePiece(response.piece);
} }
if (!this.canSubmit()) { if (!this.canSubmit()) {
this.history.push('/collection'); this.history.push('/collection');
} } else {
else {
this.incrementStep(); this.incrementStep();
this.refs.slidesContainer.nextSlide(); this.refs.slidesContainer.nextSlide();
} }
@ -119,7 +118,7 @@ let IkonotvRegisterPiece = React.createClass({
handleLoanSuccess(response) { handleLoanSuccess(response) {
this.setState({ pageExitWarning: null }); this.setState({ pageExitWarning: null });
let notification = new GlobalNotificationModel(response.notification, 'success', 10000); const notification = new GlobalNotificationModel(response.notification, 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
this.refreshPieceList(); this.refreshPieceList();
@ -189,7 +188,8 @@ let IkonotvRegisterPiece = React.createClass({
getSlideLoan() { getSlideLoan() {
if (this.canSubmit()) { if (this.canSubmit()) {
const { piece, whitelabel } = this.props; const { whitelabel } = this.props;
const { piece } = this.state;
const today = new Moment(); const today = new Moment();
const endDate = (new Moment()).add(2, 'years'); const endDate = (new Moment()).add(2, 'years');

View File

@ -46,7 +46,10 @@ let MarketAclButtonList = React.createClass({
return ( return (
<div className={className}> <div className={className}>
<MarketSubmitButton <MarketSubmitButton
{...buttonProps} availableAcls={availableAcls}
currentUser={currentUser}
editions={pieceOrEditions}
handleSuccess={handleSuccess}
whitelabel={whitelabel} /> whitelabel={whitelabel} />
<EmailButton {...buttonProps} /> <EmailButton {...buttonProps} />
<TransferButton {...buttonProps} /> <TransferButton {...buttonProps} />

View File

@ -115,7 +115,7 @@ let MarketAdditionalDataForm = React.createClass({
this.props.handleSuccess(); this.props.handleSuccess();
} }
let notification = new GlobalNotificationModel(getLangText('Further details successfully updated'), 'success', 10000); const notification = new GlobalNotificationModel(getLangText('Further details successfully updated'), 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
}, },
@ -128,7 +128,8 @@ let MarketAdditionalDataForm = React.createClass({
render() { render() {
const { editable, isInline, handleSuccess, showHeading, showNotification, submitLabel } = this.props; const { editable, isInline, handleSuccess, showHeading, showNotification, submitLabel } = this.props;
const { piece } = this.state; const { piece } = this.state;
let buttons, heading; let buttons;
let heading;
let spinner = <AscribeSpinner color='dark-blue' size='lg' />; let spinner = <AscribeSpinner color='dark-blue' size='lg' />;