1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

fix tests, lints

This commit is contained in:
Jernej Pregelj 2019-04-29 10:39:41 +02:00
parent 8bff58f19d
commit 07acf042e5
3 changed files with 48 additions and 33 deletions

View File

@ -16,8 +16,8 @@ describe('CategoryImage', () => {
}) })
it('renders all the category images', () => { it('renders all the category images', () => {
const { options } = formPublish.steps[1].fields const { options } = formPublish.dataset.steps[1].fields
? formPublish.steps[1].fields.categories ? formPublish.dataset.steps[1].fields.categories
: [] : []
options.map((category: string) => { options.map((category: string) => {

View File

@ -11,23 +11,23 @@ class Publish extends Component<{}, PublishState> {
public state = { public state = {
type: 'start' type: 'start'
} }
publishDataset = () => { public publishDataset = () => {
this.setState({ type: 'dataset' }) this.setState({ type: 'dataset' })
} }
publishContainer = () => { public publishContainer = () => {
this.setState({ type: 'container' }) this.setState({ type: 'container' })
} }
publishAlgorithm = () => { public publishAlgorithm = () => {
this.setState({ type: 'algorithm' }) this.setState({ type: 'algorithm' })
} }
publishWorkflow = () => { public publishWorkflow = () => {
this.setState({ type: 'workflow' }) this.setState({ type: 'workflow' })
} }
public render() { public render() {
return ( return (
<div> <div>
{this.state.type !== 'start' && ( {this.state.type !== 'start' && (
<Loader loadType={this.state.type}/> <Loader loadType={this.state.type} />
)} )}
{this.state.type === 'start' && ( {this.state.type === 'start' && (
<Route <Route
@ -35,9 +35,13 @@ class Publish extends Component<{}, PublishState> {
description="What do you want to publish?" description="What do you want to publish?"
> >
<button onClick={this.publishDataset}>Dataset</button> <button onClick={this.publishDataset}>Dataset</button>
<button onClick={this.publishContainer}>Container</button> <button onClick={this.publishContainer}>
Container
</button>
<button onClick={this.publishWorkflow}>Workflow</button> <button onClick={this.publishWorkflow}>Workflow</button>
<button onClick={this.publishAlgorithm}>Algorithm</button> <button onClick={this.publishAlgorithm}>
Algorithm
</button>
</Route> </Route>
)} )}
</div> </div>

View File

@ -31,8 +31,9 @@ class Loader extends Component<LoaderProps, LoaderState> {
isPublished: false, isPublished: false,
publishedDid: '', publishedDid: '',
publishingError: '', publishingError: '',
validationStatus: ((dataPublishForm as any)[this.props.loadType]).validation, validationStatus: (dataPublishForm as any)[this.props.loadType]
...((dataPublishForm as any)[this.props.loadType]).defaults .validation,
...(dataPublishForm as any)[this.props.loadType].defaults
} }
private inputChange = ( private inputChange = (
@ -57,7 +58,8 @@ class Loader extends Component<LoaderProps, LoaderState> {
private next = () => { private next = () => {
let { currentStep } = this.state let { currentStep } = this.state
const totalSteps = ((dataPublishForm as any)[this.props.loadType]).steps.length const totalSteps = (dataPublishForm as any)[this.props.loadType].steps
.length
currentStep = currentStep =
currentStep >= totalSteps - 1 ? totalSteps : currentStep + 1 currentStep >= totalSteps - 1 ? totalSteps : currentStep + 1
@ -85,7 +87,7 @@ class Loader extends Component<LoaderProps, LoaderState> {
isPublishing: false, isPublishing: false,
isPublished: false, isPublished: false,
currentStep: 1, currentStep: 1,
...((dataPublishForm as any)[this.props.loadType]).defaults ...(dataPublishForm as any)[this.props.loadType].defaults
}) })
} }
@ -229,28 +231,37 @@ class Loader extends Component<LoaderProps, LoaderState> {
<Web3message /> <Web3message />
)} )}
<Progress steps={((dataPublishForm as any)[this.props.loadType]).steps} currentStep={this.state.currentStep} /> <Progress
steps={(dataPublishForm as any)[this.props.loadType].steps}
currentStep={this.state.currentStep}
/>
<Form onSubmit={this.submitAction}> <Form onSubmit={this.submitAction}>
{((dataPublishForm as any)[this.props.loadType]).steps.map((step: any, index: number) => ( {(dataPublishForm as any)[this.props.loadType].steps.map(
<Step (step: any, index: number) => (
key={index} <Step
index={index} key={index}
title={step.title} index={index}
description={step.description} title={step.title}
currentStep={this.state.currentStep} description={step.description}
fields={step.fields} currentStep={this.state.currentStep}
inputChange={this.inputChange} fields={step.fields}
inputToArrayChange={this.inputToArrayChange} inputChange={this.inputChange}
state={this.state} inputToArrayChange={this.inputToArrayChange}
next={this.next} state={this.state}
prev={this.prev} next={this.next}
totalSteps={((dataPublishForm as any)[this.props.loadType]).steps.length} prev={this.prev}
tryAgain={this.tryAgain} totalSteps={
toStart={this.toStart} (dataPublishForm as any)[
content={step.content} this.props.loadType
/> ].steps.length
))} }
tryAgain={this.tryAgain}
toStart={this.toStart}
content={step.content}
/>
)
)}
</Form> </Form>
</Route> </Route>
) )