1
0
Fork 0

chore(lab): Changes to handle multisets in core

This commit is contained in:
Joost De Cock 2022-09-17 10:30:21 +02:00
parent e163ed1782
commit f882a26408
18 changed files with 413 additions and 212 deletions

View file

@ -1,55 +1,67 @@
import React from 'react';
import React from 'react'
import ResetButtons from './reset-buttons'
import {EventGroup} from 'shared/components/workbench/events'
import DefaultErrorView from './view';
import { LogGroup } from 'shared/components/workbench/logs'
import DefaultErrorView from './view'
const ErrorView = (props) => {
if (props.children) return props.children
const inspectChildrenProps = {
type: 'error',
events: [props.error],
units: props.gist?.units
logs: [props.error],
units: props.gist?.units,
}
const inspectChildren = (<EventGroup {...inspectChildrenProps}></EventGroup>)
return (props.children || (<DefaultErrorView inspectChildren={inspectChildren}>
const inspectChildren = <LogGroup {...inspectChildrenProps}></LogGroup>
return (
props.children || (
<DefaultErrorView inspectChildren={inspectChildren}>
<h4>If you think your last action caused this error, you can: </h4>
<ResetButtons undoGist={props.undoGist} resetGist={props.resetGist} />
</DefaultErrorView>))
</DefaultErrorView>
)
)
}
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
super(props)
this.state = { hasError: false }
}
static getDerivedStateFromError(error) {
// Update state so the next render will show the fallback UI.
return { hasError: true, error };
return { hasError: true, error }
}
componentDidCatch(error, errorInfo) {
// You can also log the error to an error reporting service
console.log(error, errorInfo);
console.log(error, errorInfo)
}
componentDidUpdate(prevProps) {
if (this.props.gist !== prevProps.gist) {
this.setState({hasError: false})
this.setState({ hasError: false })
}
}
render() {
if (this.state.hasError) {
// You can render any custom fallback UI
return <ErrorView {...this.props} error={this.state.error}>{this.errorView}</ErrorView>
return (
<ErrorView {...this.props} error={this.state.error}>
{this.errorView}
</ErrorView>
)
}
try {
return this.props.children;
} catch(e) {
return <ErrorView {...this.props} error={e}>{this.errorView}</ErrorView>;
return this.props.children
} catch (e) {
return (
<ErrorView {...this.props} error={e}>
{this.errorView}
</ErrorView>
)
}
}
}