fix(sqllab): tab layout truncated (#32005)

This commit is contained in:
JUST.in DO IT 2025-01-28 06:02:38 -08:00 committed by GitHub
parent 1b375b715c
commit aa74ba3da2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 23 additions and 9 deletions

View File

@ -27,6 +27,7 @@ export {
ThemeProvider,
CacheProvider as EmotionCacheProvider,
withTheme,
type SerializedStyles,
} from '@emotion/react';
export { default as createEmotionCache } from '@emotion/cache';

View File

@ -24,6 +24,7 @@ export interface ErrorBoundaryProps {
children: ReactNode;
onError?: (error: Error, info: ErrorInfo) => void;
showMessage?: boolean;
className?: string;
}
interface ErrorBoundaryState {
@ -51,14 +52,16 @@ export default class ErrorBoundary extends Component<
render() {
const { error, info } = this.state;
const { showMessage, className } = this.props;
if (error) {
const firstLine = error.toString().split('\n')[0];
if (this.props.showMessage) {
if (showMessage) {
return (
<ErrorAlert
errorType={t('Unexpected error')}
message={firstLine}
descriptionDetails={info?.componentStack}
className={className}
/>
);
}

View File

@ -35,6 +35,7 @@ export interface ErrorAlertProps {
children?: React.ReactNode; // Additional content to show in the modal
closable?: boolean; // Show close button, default true
showIcon?: boolean; // Show icon, default true
className?: string;
}
const ErrorAlert: React.FC<ErrorAlertProps> = ({
@ -49,6 +50,7 @@ const ErrorAlert: React.FC<ErrorAlertProps> = ({
children,
closable = true,
showIcon = true,
className,
}) => {
const [isDescriptionVisible, setIsDescriptionVisible] = useState(
!descriptionDetailsCollapsed,
@ -66,7 +68,7 @@ const ErrorAlert: React.FC<ErrorAlertProps> = ({
const color =
type === 'warning' ? theme.colors.warning.base : theme.colors.error.base;
return (
<div style={{ cursor: 'pointer' }}>
<div className={className} style={{ cursor: 'pointer' }}>
<span style={{ color }}>{icon} </span>
{errorType}
</div>
@ -100,13 +102,13 @@ const ErrorAlert: React.FC<ErrorAlertProps> = ({
)}
</div>
);
const renderAlert = (closable: boolean) => (
<Alert
description={renderDescription()}
type={type}
showIcon
closable={closable}
className={className}
>
<strong>{errorType}</strong>
{message && (

View File

@ -25,6 +25,7 @@ import {
useLocation,
} from 'react-router-dom';
import { bindActionCreators } from 'redux';
import { css } from '@superset-ui/core';
import { GlobalStyles } from 'src/GlobalStyles';
import ErrorBoundary from 'src/components/ErrorBoundary';
import Loading from 'src/components/Loading';
@ -83,12 +84,19 @@ const App = () => (
{routes.map(({ path, Component, props = {}, Fallback = Loading }) => (
<Route path={path} key={path}>
<Suspense fallback={<Fallback />}>
<Layout.Content>
<div style={{ padding: '16px' }}>
<ErrorBoundary>
<Layout.Content
css={css`
display: flex;
flex-direction: column;
`}
>
<ErrorBoundary
css={css`
margin: 16px;
`}
>
<Component user={bootstrapData.user} {...props} />
</ErrorBoundary>
</div>
</Layout.Content>
</Suspense>
</Route>