fix(sqllab): tab layout truncated (#32005)
This commit is contained in:
parent
1b375b715c
commit
aa74ba3da2
|
|
@ -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';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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 && (
|
||||||
|
|
|
||||||
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue