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', () => {
const { options } = formPublish.steps[1].fields
? formPublish.steps[1].fields.categories
const { options } = formPublish.dataset.steps[1].fields
? formPublish.dataset.steps[1].fields.categories
: []
options.map((category: string) => {

View File

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

View File

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