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, ThemeProvider,
CacheProvider as EmotionCacheProvider, CacheProvider as EmotionCacheProvider,
withTheme, withTheme,
type SerializedStyles,
} from '@emotion/react'; } from '@emotion/react';
export { default as createEmotionCache } from '@emotion/cache'; export { default as createEmotionCache } from '@emotion/cache';

View File

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

View File

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

View File

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