mirror of
https://github.com/ascribe/onion.git
synced 2024-11-14 09:05:08 +01:00
extend fileClassToUpload functionality and implement it in contract settings
This commit is contained in:
parent
d47ead1bff
commit
209d141939
@ -4,7 +4,6 @@ import React from 'react';
|
||||
|
||||
import Form from '../ascribe_forms/form';
|
||||
import Property from '../ascribe_forms/property';
|
||||
import InputCheckbox from '../ascribe_forms/input_checkbox';
|
||||
|
||||
import GlobalNotificationModel from '../../models/global_notification_model';
|
||||
import GlobalNotificationActions from '../../actions/global_notification_actions';
|
||||
@ -21,6 +20,16 @@ import { formSubmissionValidation } from '../ascribe_uploader/react_s3_fine_uplo
|
||||
|
||||
|
||||
let CreateContractForm = React.createClass({
|
||||
propTypes: {
|
||||
isPublic: React.PropTypes.bool,
|
||||
|
||||
// A class of a file the user has to upload
|
||||
// Needs to be defined both in singular as well as in plural
|
||||
fileClassToUpload: React.PropTypes.shape({
|
||||
singular: React.PropTypes.string,
|
||||
plural: React.PropTypes.string
|
||||
})
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
return {
|
||||
@ -58,7 +67,7 @@ let CreateContractForm = React.createClass({
|
||||
handleSuccess={this.handleCreateSuccess}>
|
||||
<Property
|
||||
name="blob"
|
||||
label="Contract file (*.pdf)">
|
||||
label="Contract file (*.pdf only)">
|
||||
<InputFineUploader
|
||||
submitFileName={this.submitFileName}
|
||||
keyRoutine={{
|
||||
@ -78,10 +87,7 @@ let CreateContractForm = React.createClass({
|
||||
submitFile={this.submitFile}
|
||||
setIsUploadReady={this.setIsUploadReady}
|
||||
isReadyForFormSubmission={formSubmissionValidation.atLeastOneUploadedFile}
|
||||
fileClassToUpload={{
|
||||
singular: 'contract',
|
||||
plural: 'contracts'
|
||||
}}/>
|
||||
fileClassToUpload={this.props.fileClassToUpload}/>
|
||||
</Property>
|
||||
<Property
|
||||
name='name'
|
||||
@ -91,6 +97,13 @@ let CreateContractForm = React.createClass({
|
||||
type="text"
|
||||
value={this.state.contractName}/>
|
||||
</Property>
|
||||
<Property
|
||||
name="is_public"
|
||||
hidden={true}>
|
||||
<input
|
||||
type="checkbox"
|
||||
value={this.props.isPublic} />
|
||||
</Property>
|
||||
</Form>
|
||||
);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ let InputFileUploader = React.createClass({
|
||||
}
|
||||
}}
|
||||
onInactive={this.props.onLoggedOut}
|
||||
enableLocalHashing={this.props.enableLocalHashing}
|
||||
enableLocalHashing={this.props.enableLocalHashing}
|
||||
fileClassToUpload={this.props.fileClassToUpload}/>
|
||||
);
|
||||
}
|
||||
|
@ -80,6 +80,18 @@ let ContractSettings = React.createClass({
|
||||
render() {
|
||||
let publicContracts = this.getPublicContracts();
|
||||
let privateContracts = this.getPrivateContracts();
|
||||
let createPublicContractForm = null;
|
||||
|
||||
if(publicContracts.length === 0) {
|
||||
createPublicContractForm = (
|
||||
<CreateContractForm
|
||||
isPublic={true}
|
||||
fileClassToUpload={{
|
||||
singular: 'new public contract',
|
||||
plural: 'new public contracts'
|
||||
}}/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<CollapsibleParagraph
|
||||
@ -94,6 +106,7 @@ let ContractSettings = React.createClass({
|
||||
title={getLangText('Public Contracts')}
|
||||
show={true}
|
||||
defaultExpanded={true}>
|
||||
{createPublicContractForm}
|
||||
{publicContracts.map((contract, i) => {
|
||||
return (
|
||||
<ActionPanel
|
||||
@ -109,7 +122,7 @@ let ContractSettings = React.createClass({
|
||||
className="btn btn-default btn-sm margin-left-2px"
|
||||
href={contract.blob.url_safe}
|
||||
target="_blank">
|
||||
DOWNLOAD
|
||||
PREVIEW
|
||||
</a>
|
||||
<button
|
||||
className="btn btn-default btn-sm margin-left-2px"
|
||||
@ -127,6 +140,12 @@ let ContractSettings = React.createClass({
|
||||
title={getLangText('Private Contracts')}
|
||||
show={true}
|
||||
defaultExpanded={true}>
|
||||
<CreateContractForm
|
||||
isPublic={false}
|
||||
fileClassToUpload={{
|
||||
singular: 'new private contract',
|
||||
plural: 'new private contracts'
|
||||
}}/>
|
||||
{privateContracts.map((contract, i) => {
|
||||
return (
|
||||
<ActionPanel
|
||||
@ -147,7 +166,7 @@ let ContractSettings = React.createClass({
|
||||
className="btn btn-default btn-sm margin-left-2px"
|
||||
href={contract.blob.url_safe}
|
||||
target="_blank">
|
||||
DOWNLOAD
|
||||
PREVIEW
|
||||
</a>
|
||||
<button
|
||||
className="btn btn-default btn-sm margin-left-2px"
|
||||
@ -162,12 +181,6 @@ let ContractSettings = React.createClass({
|
||||
})}
|
||||
</CollapsibleParagraph>
|
||||
</CollapsibleParagraph>
|
||||
<CollapsibleParagraph
|
||||
title={getLangText('Create Contract')}
|
||||
show={true}
|
||||
defaultExpanded={true}>
|
||||
<CreateContractForm />
|
||||
</CollapsibleParagraph>
|
||||
</CollapsibleParagraph>
|
||||
);
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ let FileDragAndDropDialog = React.createClass({
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
let dialog = queryParams.method === 'hash' ? getLangText('choose a %s to hash', this.props.fileClassToUpload.singular) : getLangText('choose a file to upload');
|
||||
let dialog = queryParams.method === 'hash' ? getLangText('choose a %s to hash', this.props.fileClassToUpload.singular) : getLangText('choose a %s to upload', this.props.fileClassToUpload.singular);
|
||||
|
||||
return (
|
||||
<span className="file-drag-and-drop-dialog">
|
||||
|
Loading…
Reference in New Issue
Block a user