mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
output event messages during publishing flow
This commit is contained in:
parent
7b60127899
commit
1d1399248f
@ -154,7 +154,13 @@ export default class Step extends PureComponent<StepProps, {}> {
|
|||||||
{this.nextButton()}
|
{this.nextButton()}
|
||||||
|
|
||||||
{lastStep && (
|
{lastStep && (
|
||||||
<Button disabled={!this.context.isLogged} primary>
|
<Button
|
||||||
|
disabled={
|
||||||
|
!this.context.isLogged ||
|
||||||
|
this.props.state.isPublishing
|
||||||
|
}
|
||||||
|
primary
|
||||||
|
>
|
||||||
Register asset
|
Register asset
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
|
@ -4,6 +4,17 @@ import Spinner from '../../components/atoms/Spinner'
|
|||||||
import Button from '../../components/atoms/Button'
|
import Button from '../../components/atoms/Button'
|
||||||
import styles from './StepRegisterContent.module.scss'
|
import styles from './StepRegisterContent.module.scss'
|
||||||
|
|
||||||
|
export const messages: any = {
|
||||||
|
0: '1/4<br />Encrypting files...',
|
||||||
|
1: '1/4<br />Successfully encrypted files.',
|
||||||
|
2: '2/4<br />Generating proof...',
|
||||||
|
3: '2/4<br />Successfully generated proof.',
|
||||||
|
4: '3/4<br /> Registering DID...',
|
||||||
|
5: '3/4<br /> Successfully registered DID.',
|
||||||
|
6: '4/4<br /> Storing DDO...',
|
||||||
|
7: '4/4<br /> Successfully stored DDO.'
|
||||||
|
}
|
||||||
|
|
||||||
interface StepRegisterContentProps {
|
interface StepRegisterContentProps {
|
||||||
tryAgain(): void
|
tryAgain(): void
|
||||||
toStart(): void
|
toStart(): void
|
||||||
@ -12,6 +23,7 @@ interface StepRegisterContentProps {
|
|||||||
isPublishing: boolean
|
isPublishing: boolean
|
||||||
publishingError: string
|
publishingError: string
|
||||||
isPublished: boolean
|
isPublished: boolean
|
||||||
|
publishingStep: number
|
||||||
}
|
}
|
||||||
content?: string
|
content?: string
|
||||||
}
|
}
|
||||||
@ -20,9 +32,13 @@ export default class StepRegisterContent extends PureComponent<
|
|||||||
StepRegisterContentProps,
|
StepRegisterContentProps,
|
||||||
{}
|
{}
|
||||||
> {
|
> {
|
||||||
public publishingState = () => (
|
public publishingState = () => {
|
||||||
<Spinner message={'Please sign with your crypto wallet'} />
|
const { publishingStep } = this.props.state
|
||||||
)
|
|
||||||
|
const message = messages[publishingStep]
|
||||||
|
|
||||||
|
return <Spinner message={message} />
|
||||||
|
}
|
||||||
|
|
||||||
public errorState = () => (
|
public errorState = () => (
|
||||||
<div className={styles.message}>
|
<div className={styles.message}>
|
||||||
|
@ -30,11 +30,14 @@ interface PublishState {
|
|||||||
isPublished?: boolean
|
isPublished?: boolean
|
||||||
publishedDid?: string
|
publishedDid?: string
|
||||||
publishingError?: string
|
publishingError?: string
|
||||||
|
publishingStep?: number
|
||||||
currentStep?: number
|
currentStep?: number
|
||||||
validationStatus?: any
|
validationStatus?: any
|
||||||
}
|
}
|
||||||
|
|
||||||
class Publish extends Component<{}, PublishState> {
|
export default class Publish extends Component<{}, PublishState> {
|
||||||
|
public static contextType = User
|
||||||
|
|
||||||
public state = {
|
public state = {
|
||||||
currentStep: 1,
|
currentStep: 1,
|
||||||
name: '',
|
name: '',
|
||||||
@ -51,6 +54,7 @@ class Publish extends Component<{}, PublishState> {
|
|||||||
isPublished: false,
|
isPublished: false,
|
||||||
publishedDid: '',
|
publishedDid: '',
|
||||||
publishingError: '',
|
publishingError: '',
|
||||||
|
publishingStep: 0,
|
||||||
validationStatus: {
|
validationStatus: {
|
||||||
1: { name: false, files: false, allFieldsValid: false },
|
1: { name: false, files: false, allFieldsValid: false },
|
||||||
2: {
|
2: {
|
||||||
@ -126,6 +130,7 @@ class Publish extends Component<{}, PublishState> {
|
|||||||
categories: '',
|
categories: '',
|
||||||
isPublishing: false,
|
isPublishing: false,
|
||||||
isPublished: false,
|
isPublished: false,
|
||||||
|
publishingStep: 0,
|
||||||
currentStep: 1
|
currentStep: 1
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -251,14 +256,15 @@ class Publish extends Component<{}, PublishState> {
|
|||||||
|
|
||||||
private registerAsset = async (event: FormEvent<HTMLFormElement>) => {
|
private registerAsset = async (event: FormEvent<HTMLFormElement>) => {
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
ReactGA.event({
|
|
||||||
category: 'Publish',
|
ReactGA.event({ category: 'Publish', action: 'registerAsset-start' })
|
||||||
action: 'registerAsset-start'
|
|
||||||
})
|
|
||||||
this.setState({
|
this.setState({
|
||||||
publishingError: '',
|
publishingError: '',
|
||||||
isPublishing: true
|
isPublishing: true,
|
||||||
|
publishingStep: 0
|
||||||
})
|
})
|
||||||
|
|
||||||
const { ocean } = this.context
|
const { ocean } = this.context
|
||||||
const account = await ocean.accounts.list()
|
const account = await ocean.accounts.list()
|
||||||
const newAsset = {
|
const newAsset = {
|
||||||
@ -286,32 +292,33 @@ class Publish extends Component<{}, PublishState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const asset = await this.context.ocean.assets.create(
|
const asset = await this.context.ocean.assets
|
||||||
newAsset,
|
.create(newAsset, account[0])
|
||||||
account[0]
|
.next((publishingStep: number) =>
|
||||||
)
|
this.setState({ publishingStep })
|
||||||
|
)
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
publishedDid: asset.id,
|
publishedDid: asset.id,
|
||||||
isPublished: true
|
isPublished: true
|
||||||
})
|
})
|
||||||
|
|
||||||
ReactGA.event({
|
ReactGA.event({
|
||||||
category: 'Publish',
|
category: 'Publish',
|
||||||
action: 'registerAsset-end' + asset.id
|
action: `registerAsset-end ${asset.id}`
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (error) {
|
||||||
// make readable errors
|
// make readable errors
|
||||||
Logger.log('error:', e)
|
Logger.error('error:', error.message)
|
||||||
this.setState({
|
this.setState({ publishingError: error.message })
|
||||||
publishingError: e.message
|
|
||||||
})
|
|
||||||
ReactGA.event({
|
ReactGA.event({
|
||||||
category: 'Publish',
|
category: 'Publish',
|
||||||
action: 'registerAsset-error' + e.message
|
action: `registerAsset-error ${error.message}`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.setState({
|
|
||||||
isPublishing: false
|
this.setState({ isPublishing: false })
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
@ -355,6 +362,3 @@ class Publish extends Component<{}, PublishState> {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Publish.contextType = User
|
|
||||||
export default Publish
|
|
||||||
|
Loading…
Reference in New Issue
Block a user