'use strict';
import React from 'react';
import { Link } from 'react-router';
import Moment from 'moment';
import Row from 'react-bootstrap/lib/Row';
import Col from 'react-bootstrap/lib/Col';
import Glyphicon from 'react-bootstrap/lib/Glyphicon';
import HistoryIterator from './history_iterator';
import MediaContainer from './media_container';
import CollapsibleParagraph from './../ascribe_collapsible/collapsible_paragraph';
import Form from './../ascribe_forms/form';
import Property from './../ascribe_forms/property';
import DetailProperty from './detail_property';
import LicenseDetail from './license_detail';
import FurtherDetails from './further_details';
import EditionActionPanel from './edition_action_panel';
import AclProxy from '../acl_proxy';
import Note from './note';
import ApiUrls from '../../constants/api_urls';
import AscribeSpinner from '../ascribe_spinner';
import { getLangText } from '../../utils/lang_utils';
/**
* This is the component that implements display-specific functionality
*/
let Edition = React.createClass({
propTypes: {
actionPanelButtonListType: React.PropTypes.func,
furtherDetailsType: React.PropTypes.func,
edition: React.PropTypes.object,
coaError: React.PropTypes.object,
currentUser: React.PropTypes.object,
loadEdition: React.PropTypes.func
},
getDefaultProps() {
return {
furtherDetailsType: FurtherDetails
};
},
render() {
let FurtherDetailsType = this.props.furtherDetailsType;
return (
{this.props.edition.title}
0}>
0}>
0}>
{return {'bitcoin_id': this.props.edition.bitcoin_id}; }}
label={getLangText('Personal note (private)')}
defaultValue={this.props.edition.private_note ? this.props.edition.private_note : null}
placeholder={getLangText('Enter your comments ...')}
editable={true}
successMessage={getLangText('Private note saved')}
url={ApiUrls.note_private_edition}
currentUser={this.props.currentUser}/>
{return {'bitcoin_id': this.props.edition.bitcoin_id}; }}
label={getLangText('Personal note (public)')}
defaultValue={this.props.edition.public_note ? this.props.edition.public_note : null}
placeholder={getLangText('Enter your comments ...')}
editable={!!this.props.edition.acl.acl_edit}
show={!!this.props.edition.public_note || !!this.props.edition.acl.acl_edit}
successMessage={getLangText('Public edition note saved')}
url={ApiUrls.note_public_edition}
currentUser={this.props.currentUser}/>
0
|| this.props.edition.other_data.length > 0}>
);
}
});
let EditionSummary = React.createClass({
propTypes: {
actionPanelButtonListType: React.PropTypes.func,
edition: React.PropTypes.object,
currentUser: React.PropTypes.object,
handleSuccess: React.PropTypes.func
},
handleSuccess() {
this.props.handleSuccess();
},
getStatus(){
let status = null;
if (this.props.edition.status.length > 0){
let statusStr = this.props.edition.status.join(', ').replace(/_/g, ' ');
status = ;
if (this.props.edition.pending_new_owner && this.props.edition.acl.acl_withdraw_transfer){
status = (
);
}
}
return status;
},
render() {
let { actionPanelButtonListType, edition, currentUser } = this.props;
return (
{this.getStatus()}
{/*
`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
`AclInformation` would show up
*/}
1}>
);
}
});
let CoaDetails = React.createClass({
propTypes: {
editionId: React.PropTypes.string,
coa: React.PropTypes.object,
coaError: React.PropTypes.object
},
contactOnIntercom() {
const { coaError, editionId } = this.props;
window.Intercom('showNewMessage', getLangText("Hi, I'm having problems generating a Certificate of Authenticity for Edition: %s", editionId));
console.logGlobal(new Error(`Coa couldn't be created for edition: ${editionId}`), coaError);
},
render() {
const { coa, coaError } = this.props;
let coaDetailElement;
if (coaError) {
coaDetailElement = [
{getLangText('There was an error generating your Certificate of Authenticity.')}
,
{getLangText('Try to refresh the page. If this happens repeatedly, please ')}
{getLangText('contact us')}.
];
} else if (coa && coa.url_safe) {
coaDetailElement = [
,
];
} else if (typeof coa === 'string') {
coaDetailElement = coa;
} else {
// TODO: Define Keys
coaDetailElement = [
,
{getLangText("Just a sec, we're generating your COA")}
,
{getLangText('(you may leave the page)')}
];
}
return (
{coaDetailElement}
{/* Hide the COA and just show that it's a seperate document when printing */}
{getLangText('The COA is available as a seperate document')}
);
}
});
let SpoolDetails = React.createClass({
propTypes: {
edition: React.PropTypes.object
},
render() {
const { edition: {
bitcoin_id: bitcoinId,
hash_as_address: hashAsAddress,
btc_owner_address_noprefix: bitcoinOwnerAddress
} } = this.props;
const bitcoinIdValue = (
{bitcoinId}
);
const hashOfArtwork = (
{hashAsAddress}
);
const ownerAddress = (
{bitcoinOwnerAddress}
);
return (
);
}
});
export default Edition;