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

Merge pull request #43 from ascribe/AD-1149-fix-comments-in-pr

Ad 1149 fix comments in pr
This commit is contained in:
Brett Sun 2015-12-02 14:22:25 +01:00
commit 8f14b27eac
15 changed files with 56 additions and 143 deletions

View File

@ -10,6 +10,8 @@ import ApiUrls from '../../constants/api_urls';
import AppConstants from '../../constants/application_constants';
import { getCookie } from '../../utils/fetch_api_utils';
import { getLangText } from '../../utils/lang_utils';
let FurtherDetailsFileuploader = React.createClass({
propTypes: {
@ -26,7 +28,7 @@ let FurtherDetailsFileuploader = React.createClass({
getDefaultProps() {
return {
label: 'Additional files',
label: getLangText('Additional files'),
multiple: false
};
},

View File

@ -26,7 +26,6 @@ let RegisterPieceForm = React.createClass({
isFineUploaderActive: React.PropTypes.bool,
isFineUploaderEditable: React.PropTypes.bool,
enableLocalHashing: React.PropTypes.bool,
onLoggedOut: React.PropTypes.func,
// For this form to work with SlideContainer, we sometimes have to disable it
disabled: React.PropTypes.bool,
@ -116,7 +115,6 @@ let RegisterPieceForm = React.createClass({
setIsUploadReady={this.setIsUploadReady}
isReadyForFormSubmission={formSubmissionValidation.atLeastOneUploadedFile}
isFineUploaderActive={this.props.isFineUploaderActive}
onLoggedOut={this.props.onLoggedOut}
disabled={!this.props.isFineUploaderEditable}
enableLocalHashing={enableLocalHashing}
uploadMethod={this.props.location.query.method} />

View File

@ -38,7 +38,6 @@ const InputFineUploader = React.createClass({
// a user is actually not logged in already to prevent him from droping files
// before login in
isFineUploaderActive: bool,
onLoggedOut: func,
enableLocalHashing: bool,
uploadMethod: string,
@ -51,7 +50,10 @@ const InputFineUploader = React.createClass({
fileClassToUpload: shape({
singular: string,
plural: string
})
}),
// Provided by `Property`
onChange: React.PropTypes.func
},
getDefaultProps() {
@ -101,16 +103,16 @@ const InputFineUploader = React.createClass({
setIsUploadReady,
isReadyForFormSubmission,
areAssetsDownloadable,
onLoggedOut,
enableLocalHashing,
uploadMethod,
fileClassToUpload,
location } = this.props;
disabled } = this.props;
let editable = this.props.isFineUploaderActive;
// if disabled is actually set by property, we want to override
// isFineUploaderActive
if(typeof this.props.disabled !== 'undefined') {
editable = !this.props.disabled;
if(typeof disabled !== 'undefined') {
editable = !disabled;
}
return (
@ -139,10 +141,9 @@ const InputFineUploader = React.createClass({
'X-CSRFToken': getCookie(AppConstants.csrftoken)
}
}}
onInactive={this.props.onLoggedOut}
enableLocalHashing={this.props.enableLocalHashing}
uploadMethod={this.props.uploadMethod}
fileClassToUpload={this.props.fileClassToUpload} />
enableLocalHashing={enableLocalHashing}
uploadMethod={uploadMethod}
fileClassToUpload={fileClassToUpload} />
);
}
});

View File

@ -15,7 +15,6 @@ let FileDragAndDrop = React.createClass({
className: React.PropTypes.string,
onDrop: React.PropTypes.func.isRequired,
onDragOver: React.PropTypes.func,
onInactive: React.PropTypes.func,
filesToUpload: React.PropTypes.array,
handleDeleteFile: React.PropTypes.func,
handleCancelFile: React.PropTypes.func,
@ -60,28 +59,21 @@ let FileDragAndDrop = React.createClass({
handleDrop(event) {
event.preventDefault();
event.stopPropagation();
let files;
if(this.props.dropzoneInactive) {
// if there is a handle function for doing stuff
// when the dropzone is inactive, then call it
if(this.props.onInactive) {
this.props.onInactive();
if (!this.props.dropzoneInactive) {
let files;
// handle Drag and Drop
if(event.dataTransfer && event.dataTransfer.files.length > 0) {
files = event.dataTransfer.files;
} else if(event.target.files) { // handle input type file
files = event.target.files;
}
return;
}
// handle Drag and Drop
if(event.dataTransfer && event.dataTransfer.files.length > 0) {
files = event.dataTransfer.files;
} else if(event.target.files) { // handle input type file
files = event.target.files;
if(typeof this.props.onDrop === 'function' && files) {
this.props.onDrop(files);
}
}
if(typeof this.props.onDrop === 'function' && files) {
this.props.onDrop(files);
}
},
handleDeleteFile(fileId) {
@ -113,31 +105,25 @@ let FileDragAndDrop = React.createClass({
},
handleOnClick() {
let evt;
// when multiple is set to false and the user already uploaded a piece,
// do not propagate event
if(this.props.dropzoneInactive) {
// if there is a handle function for doing stuff
// when the dropzone is inactive, then call it
if(this.props.onInactive) {
this.props.onInactive();
// do not propagate event if the drop zone's inactive,
// for example when multiple is set to false and the user already uploaded a piece
if (!this.props.dropzoneInactive) {
let evt;
try {
evt = new MouseEvent('click', {
view: window,
bubbles: true,
cancelable: true
});
} catch(e) {
// For browsers that do not support the new MouseEvent syntax
evt = document.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
}
return;
}
try {
evt = new MouseEvent('click', {
view: window,
bubbles: true,
cancelable: true
});
} catch(e) {
// For browsers that do not support the new MouseEvent syntax
evt = document.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
this.refs.fileSelector.getDOMNode().dispatchEvent(evt);
}
this.refs.fileSelector.getDOMNode().dispatchEvent(evt);
},
render: function () {

View File

@ -99,7 +99,6 @@ let ReactS3FineUploader = React.createClass({
areAssetsDownloadable: React.PropTypes.bool,
areAssetsEditable: React.PropTypes.bool,
defaultErrorMessage: React.PropTypes.string,
onInactive: React.PropTypes.func,
// We encountered some cases where people had difficulties to upload their
// works to ascribe due to a slow internet connection.
@ -891,7 +890,6 @@ let ReactS3FineUploader = React.createClass({
multiple,
areAssetsDownloadable,
areAssetsEditable,
onInactive,
enableLocalHashing,
fileClassToUpload,
fileInputElement: FileInputElement,
@ -901,7 +899,6 @@ let ReactS3FineUploader = React.createClass({
multiple,
areAssetsDownloadable,
areAssetsEditable,
onInactive,
enableLocalHashing,
uploadMethod,
fileClassToUpload,

View File

@ -133,7 +133,7 @@ let PieceList = React.createClass({
const defaultFilterBy = {};
if (filterParams && typeof filterParams.forEach === 'function') {
filterParams.forEach(({ label, items }) => {
filterParams.forEach(({ items }) => {
items.forEach((item) => {
if (typeof item === 'object' && item.defaultValue) {
defaultFilterBy[item.key] = true;
@ -211,7 +211,7 @@ let PieceList = React.createClass({
},
loadPieceList({ page, filterBy = this.state.filterBy, search = this.state.search }) {
let orderBy = this.state.orderBy ? this.state.orderBy : this.props.orderBy;
const orderBy = this.state.orderBy || this.props.orderBy;
return PieceListActions.fetchPieceList(page, this.state.pageSize, search,
orderBy, this.state.orderAsc, filterBy);
@ -259,7 +259,6 @@ let PieceList = React.createClass({
const availableAcls = getAvailableAcls(selectedEditions, (aclName) => aclName !== 'acl_view');
setDocumentTitle(getLangText('Collection'));
return (
<div>
<PieceListToolbar

View File

@ -97,12 +97,12 @@ let PieceListFilterDisplay = React.createClass({
render() {
let { filterBy } = this.props;
let filtersWithLabel = this.transformFilterParamsItemsToBools();
// do not show the FilterDisplay if there are no filters applied
if(filterBy && Object.keys(filterBy).length === 0) {
return null;
} else {
const filtersWithLabel = this.transformFilterParamsItemsToBools();
return (
<div className="row">
<div className="ascribe-piece-list-filter-display col-xs-12 col-sm-10 col-md-8 col-lg-8 col-sm-offset-1 col-md-offset-2 col-lg-offset-2">

View File

@ -45,10 +45,7 @@ let RegisterPiece = React.createClass( {
UserStore.getState(),
WhitelabelStore.getState(),
PieceListStore.getState(),
{
selectedLicense: 0,
isFineUploaderActive: false
});
);
},
componentDidMount() {
@ -66,13 +63,6 @@ let RegisterPiece = React.createClass( {
onChange(state) {
this.setState(state);
if(this.state.currentUser && this.state.currentUser.email) {
// we should also make the fineuploader component editable again
this.setState({
isFineUploaderActive: true
});
}
},
handleSuccess(response){
@ -117,7 +107,7 @@ let RegisterPiece = React.createClass( {
<Col xs={12} sm={10} md={8} smOffset={1} mdOffset={2}>
<RegisterPieceForm
{...this.props}
isFineUploaderActive={this.state.isFineUploaderActive}
isFineUploaderActive={true}
handleSuccess={this.handleSuccess}
location={this.props.location}>
{this.props.children}

View File

@ -53,8 +53,6 @@ let CylandRegisterPiece = React.createClass({
PieceStore.getState(),
WhitelabelStore.getState(),
{
selectedLicense: 0,
isFineUploaderActive: false,
step: 0
});
},
@ -90,13 +88,6 @@ let CylandRegisterPiece = React.createClass({
onChange(state) {
this.setState(state);
if(this.state.currentUser && this.state.currentUser.email) {
// we should also make the fineuploader component editable again
this.setState({
isFineUploaderActive: true
});
}
},
handleRegisterSuccess(response){
@ -167,11 +158,6 @@ let CylandRegisterPiece = React.createClass({
}
},
// basically redirects to the second slide (index: 1), when the user is not logged in
onLoggedOut() {
this.history.pushState(null, '/login');
},
render() {
let today = new Moment();
@ -197,9 +183,8 @@ let CylandRegisterPiece = React.createClass({
enableLocalHashing={false}
headerMessage={getLangText('Submit to Cyland Archive')}
submitMessage={getLangText('Submit')}
isFineUploaderActive={this.state.isFineUploaderActive}
isFineUploaderActive={true}
handleSuccess={this.handleRegisterSuccess}
onLoggedOut={this.onLoggedOut}
location={this.props.location}/>
</Col>
</Row>

View File

@ -85,13 +85,6 @@ let IkonotvRegisterPiece = React.createClass({
onChange(state) {
this.setState(state);
if(this.state.currentUser && this.state.currentUser.email) {
// we should also make the fineuploader component editable again
this.setState({
isFineUploaderActive: true
});
}
},
@ -157,19 +150,6 @@ let IkonotvRegisterPiece = React.createClass({
);
},
changeSlide() {
// 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.onLoggedOut();
}
},
// basically redirects to the second slide (index: 1), when the user is not logged in
onLoggedOut() {
this.history.pushState(null, '/login');
},
canSubmit() {
let currentUser = this.state.currentUser;
return currentUser && currentUser.acl && currentUser.acl.acl_wallet_submit;
@ -260,9 +240,8 @@ let IkonotvRegisterPiece = React.createClass({
enableLocalHashing={false}
headerMessage={getLangText('Register work')}
submitMessage={getLangText('Register')}
isFineUploaderActive={this.state.isFineUploaderActive}
isFineUploaderActive={true}
handleSuccess={this.handleRegisterSuccess}
onLoggedOut={this.onLoggedOut}
location={this.props.location}/>
</Col>
</Row>

View File

@ -53,8 +53,8 @@ let MarketSubmitButton = React.createClass({
const { extra_data, other_data } = edition;
if (extra_data.artist_bio && extra_data.work_description &&
extra_data.technology_details && extra_data.display_instructions &&
other_data.length > 0) {
extra_data.technology_details && extra_data.display_instructions &&
other_data.length > 0) {
return true;
}
}

View File

@ -8,6 +8,7 @@ import Property from '../../../../../ascribe_forms/property';
import InputTextAreaToggable from '../../../../../ascribe_forms/input_textarea_toggable';
import FurtherDetailsFileuploader from '../../../../../ascribe_detail/further_details_fileuploader';
import AscribeSpinner from '../../../../../ascribe_spinner';
import GlobalNotificationModel from '../../../../../../models/global_notification_model';
import GlobalNotificationActions from '../../../../../../actions/global_notification_actions';
@ -24,6 +25,7 @@ import requests from '../../../../../../utils/requests';
import { mergeOptions } from '../../../../../../utils/general_utils';
import { getLangText } from '../../../../../../utils/lang_utils';
let MarketAdditionalDataForm = React.createClass({
propTypes: {
pieceId: React.PropTypes.oneOfType([
@ -96,7 +98,7 @@ let MarketAdditionalDataForm = React.createClass({
},
isUploadReadyOnChange(piece) {
return piece && piece.other_data && piece.other_data.length > 0 ? true : false;
return piece && piece.other_data && piece.other_data.length > 0;
},
handleSuccessWithNotification() {
@ -211,7 +213,7 @@ let MarketAdditionalDataForm = React.createClass({
} else {
return (
<div className="ascribe-loading-position">
<img src={AppConstants.baseUrl + 'static/img/ascribe_animated_medium.gif'} />
<AscribeSpinner color='dark-blue' size='lg' />
</div>
);
}

View File

@ -50,7 +50,7 @@ let MarketPieceList = React.createClass({
render() {
const { currentUser, whitelabel } = this.state;
let filterParams = undefined;
let filterParams = null;
let canLoadPieceList = false;
if (currentUser.email && whitelabel.user) {

View File

@ -35,8 +35,6 @@ let MarketRegisterPiece = React.createClass({
UserStore.getState(),
PieceListStore.getState(),
{
selectedLicense: 0,
isFineUploaderActive: false,
step: 0
});
},
@ -58,13 +56,6 @@ let MarketRegisterPiece = React.createClass({
onChange(state) {
this.setState(state);
if (this.state.currentUser && this.state.currentUser.email) {
// we should also make the fineuploader component editable again
this.setState({
isFineUploaderActive: true
});
}
},
handleRegisterSuccess(response) {
@ -115,11 +106,6 @@ let MarketRegisterPiece = React.createClass({
);
},
// basically redirects to the second slide (index: 1), when the user is not logged in
onLoggedOut() {
this.history.pushState(null, '/login');
},
render() {
setDocumentTitle(getLangText('Register a new piece'));
@ -140,9 +126,8 @@ let MarketRegisterPiece = React.createClass({
enableLocalHashing={false}
headerMessage={getLangText('Consign to Market')}
submitMessage={getLangText('Proceed to additional details')}
isFineUploaderActive={this.state.isFineUploaderActive}
isFineUploaderActive={true}
handleSuccess={this.handleRegisterSuccess}
onLoggedOut={this.onLoggedOut}
location={this.props.location}>
<Property
name="num_editions"

View File

@ -228,16 +228,6 @@ let ROUTES = {
)
};
function getRoutes(commonRoutes, subdomain) {
if(subdomain in ROUTES) {
return ROUTES[subdomain];
} else {
throw new Error('Subdomain wasn\'t specified in the wallet app.');
}
};
function getRoutes(commonRoutes, subdomain) {
if(subdomain in ROUTES) {
return ROUTES[subdomain];
@ -246,5 +236,4 @@ function getRoutes(commonRoutes, subdomain) {
}
}
export default getRoutes;