mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
fix: remount block with error
This commit is contained in:
@@ -47,7 +47,7 @@ export const Main: React.FC = function Main() {
|
||||
<space as="main">
|
||||
<Split sticky={30}>
|
||||
<Pane main>
|
||||
<ErrorBoundary>
|
||||
<ErrorBoundary remount>
|
||||
<NavigationTree />
|
||||
</ErrorBoundary>
|
||||
</Pane>
|
||||
|
||||
@@ -61,18 +61,18 @@ export const RightArea = observer(function RightArea() {
|
||||
return styled(useStyles(styles, splitStyles, splitHorizontalStyles, slideBoxStyles))(
|
||||
<SlideBox open={optionsPanelService.active}>
|
||||
<SlideElement>
|
||||
<ErrorBoundary><OptionsPanel /></ErrorBoundary>
|
||||
<ErrorBoundary remount><OptionsPanel /></ErrorBoundary>
|
||||
</SlideElement>
|
||||
<SlideElement>
|
||||
<Split sticky={30} split="horizontal" mode={logViewerService.isActive ? undefined : 'minimize'} keepRatio>
|
||||
<Pane>
|
||||
<ErrorBoundary>
|
||||
<ErrorBoundary remount>
|
||||
<NavigationTabsBar />
|
||||
</ErrorBoundary>
|
||||
</Pane>
|
||||
{logViewerService.isActive && <ResizerControls />}
|
||||
<Pane main>
|
||||
<ErrorBoundary>
|
||||
<ErrorBoundary remount>
|
||||
<LogViewer />
|
||||
</ErrorBoundary>
|
||||
</Pane>
|
||||
|
||||
@@ -22,6 +22,7 @@ const style = css`
|
||||
interface IProps {
|
||||
onRefresh?: () => any;
|
||||
root?: boolean;
|
||||
remount?: boolean;
|
||||
}
|
||||
|
||||
interface IState {
|
||||
@@ -36,6 +37,9 @@ export class ErrorBoundary extends React.Component<IProps, IState> {
|
||||
error: null,
|
||||
errorInfo: null,
|
||||
};
|
||||
|
||||
this.remount = this.remount.bind(this);
|
||||
this.refresh = this.refresh.bind(this);
|
||||
}
|
||||
|
||||
componentDidCatch(error: Error, errorInfo: ErrorInfo): void {
|
||||
@@ -47,13 +51,14 @@ export class ErrorBoundary extends React.Component<IProps, IState> {
|
||||
|
||||
render(): React.ReactNode {
|
||||
const { errorInfo, error } = this.state;
|
||||
const { root, onRefresh } = this.props;
|
||||
const { remount, root, onRefresh } = this.props;
|
||||
|
||||
if (errorInfo) {
|
||||
return styled(style)(
|
||||
<DisplayError root={root}>
|
||||
{root && <action><AppRefreshButton /></action>}
|
||||
{onRefresh && <action><Button onClick={onRefresh}>Refresh</Button></action>}
|
||||
{onRefresh && <action><Button onClick={this.refresh}>Refresh</Button></action>}
|
||||
{remount && <action><Button onClick={this.remount}>Refresh</Button></action>}
|
||||
<details style={{ whiteSpace: 'pre-wrap' }}>
|
||||
{error?.toString() ?? ''}
|
||||
<br />
|
||||
@@ -65,4 +70,16 @@ export class ErrorBoundary extends React.Component<IProps, IState> {
|
||||
|
||||
return this.props.children;
|
||||
}
|
||||
|
||||
private remount() {
|
||||
this.setState({
|
||||
error: null,
|
||||
errorInfo: null,
|
||||
});
|
||||
}
|
||||
|
||||
private refresh() {
|
||||
this.props.onRefresh?.();
|
||||
this.remount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export const TabPanel: React.FC<TabPanelProps> = function TabPanel({
|
||||
|
||||
if (typeof children === 'function') {
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
<ErrorBoundary remount>
|
||||
<TabContext.Provider value={tabContext}>
|
||||
<BaseTabPanel {...state.state} tabId={tabId} className={className}>
|
||||
{(children as (state: TabStateReturn) => React.ReactNode)(state.state)}
|
||||
@@ -45,7 +45,7 @@ export const TabPanel: React.FC<TabPanelProps> = function TabPanel({
|
||||
}
|
||||
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
<ErrorBoundary remount>
|
||||
<TabContext.Provider value={tabContext}>
|
||||
<BaseTabPanel {...state.state} tabId={tabId} className={className}>
|
||||
{children}
|
||||
|
||||
Reference in New Issue
Block a user