Skip to content

Commit e5f2631

Browse files
authored
Fixes issue where results panel height was incorrect [sc-49045] (apache#20204)
This commit fixes a dynamic height assignment issue where the SQL Editor results panel would be clipped offscreen and user could not see bottom of results, the height got assigned to zero after toggling online, then offline, and height would be calculated wrong if the result set rows returned message above the results table was long enough for a line wrap.
1 parent 8638f59 commit e5f2631

File tree

2 files changed

+52
-33
lines changed

2 files changed

+52
-33
lines changed

superset-frontend/src/SqlLab/components/ResultSet/index.tsx

Lines changed: 45 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,8 @@ const MonospaceDiv = styled.div`
127127
const ReturnedRows = styled.div`
128128
font-size: 13px;
129129
line-height: 24px;
130-
.limitMessage {
131-
color: ${({ theme }) => theme.colors.secondary.light1};
132-
margin-left: ${({ theme }) => theme.gridUnit * 2}px;
133-
}
134130
`;
131+
135132
const ResultSetControls = styled.div`
136133
display: flex;
137134
justify-content: space-between;
@@ -148,6 +145,19 @@ const ResultSetErrorMessage = styled.div`
148145
padding-top: ${({ theme }) => 4 * theme.gridUnit}px;
149146
`;
150147

148+
const ResultSetRowsReturned = styled.span`
149+
white-space: nowrap;
150+
text-overflow: ellipsis;
151+
width: 100%;
152+
overflow: hidden;
153+
display: inline-block;
154+
`;
155+
156+
const LimitMessage = styled.span`
157+
color: ${({ theme }) => theme.colors.secondary.light1};
158+
margin-left: ${({ theme }) => theme.gridUnit * 2}px;
159+
`;
160+
151161
const updateDataset = async (
152162
dbId: number,
153163
datasetId: number,
@@ -608,42 +618,38 @@ export default class ResultSet extends React.PureComponent<
608618
limitingFactor === LIMITING_FACTOR.DROPDOWN;
609619

610620
if (limitingFactor === LIMITING_FACTOR.QUERY && this.props.csv) {
611-
limitMessage = (
612-
<span className="limitMessage">
613-
{t(
614-
'The number of rows displayed is limited to %(rows)d by the query',
615-
{ rows },
616-
)}
617-
</span>
621+
limitMessage = t(
622+
'The number of rows displayed is limited to %(rows)d by the query',
623+
{ rows },
618624
);
619625
} else if (
620626
limitingFactor === LIMITING_FACTOR.DROPDOWN &&
621627
!shouldUseDefaultDropdownAlert
622628
) {
623-
limitMessage = (
624-
<span className="limitMessage">
625-
{t(
626-
'The number of rows displayed is limited to %(rows)d by the limit dropdown.',
627-
{ rows },
628-
)}
629-
</span>
629+
limitMessage = t(
630+
'The number of rows displayed is limited to %(rows)d by the limit dropdown.',
631+
{ rows },
630632
);
631633
} else if (limitingFactor === LIMITING_FACTOR.QUERY_AND_DROPDOWN) {
632-
limitMessage = (
633-
<span className="limitMessage">
634-
{t(
635-
'The number of rows displayed is limited to %(rows)d by the query and limit dropdown.',
636-
{ rows },
637-
)}
638-
</span>
634+
limitMessage = t(
635+
'The number of rows displayed is limited to %(rows)d by the query and limit dropdown.',
636+
{ rows },
639637
);
640638
}
639+
640+
const rowsReturnedMessage = t('%(rows)d rows returned', {
641+
rows,
642+
});
643+
644+
const tooltipText = `${rowsReturnedMessage}. ${limitMessage}`;
645+
641646
return (
642647
<ReturnedRows>
643648
{!limitReached && !shouldUseDefaultDropdownAlert && (
644-
<span>
645-
{t('%(rows)d rows returned', { rows })} {limitMessage}
646-
</span>
649+
<ResultSetRowsReturned title={tooltipText}>
650+
{rowsReturnedMessage}
651+
<LimitMessage>{limitMessage}</LimitMessage>
652+
</ResultSetRowsReturned>
647653
)}
648654
{!limitReached && shouldUseDefaultDropdownAlert && (
649655
<div ref={this.calculateAlertRefHeight}>
@@ -678,6 +684,7 @@ export default class ResultSet extends React.PureComponent<
678684

679685
render() {
680686
const { query } = this.props;
687+
const limitReached = query?.results?.displayLimitReached;
681688
let sql;
682689
let exploreDBId = query.dbId;
683690
if (this.props.database && this.props.database.explore_database_id) {
@@ -747,9 +754,17 @@ export default class ResultSet extends React.PureComponent<
747754
}
748755
if (query.state === 'success' && query.results) {
749756
const { results } = query;
757+
// Accounts for offset needed for height of ResultSetRowsReturned component if !limitReached
758+
const rowMessageHeight = !limitReached ? 32 : 0;
759+
// Accounts for offset needed for height of Alert if this.state.alertIsOpen
760+
const alertContainerHeight = 70;
761+
// We need to calculate the height of this.renderRowsReturned()
762+
// if we want results panel to be propper height because the
763+
// FilterTable component nedds an explcit height to render
764+
// react-virtualized Table component
750765
const height = this.state.alertIsOpen
751-
? this.props.height - 70
752-
: this.props.height;
766+
? this.props.height - alertContainerHeight
767+
: this.props.height - rowMessageHeight;
753768
let data;
754769
if (this.props.cache && query.cached) {
755770
({ data } = this.state);

superset-frontend/src/SqlLab/components/SouthPane/index.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,13 @@ interface SouthPanePropTypes {
6262
defaultQueryLimit: number;
6363
}
6464

65-
const StyledPane = styled.div`
66-
width: 100%;
65+
type StyledPaneProps = {
66+
height: number;
67+
};
6768

69+
const StyledPane = styled.div<StyledPaneProps>`
70+
width: 100%;
71+
height: ${props => props.height}px;
6872
.ant-tabs .ant-tabs-content-holder {
6973
overflow: visible;
7074
}
@@ -207,7 +211,7 @@ export default function SouthPane({
207211
return offline ? (
208212
renderOfflineStatus()
209213
) : (
210-
<StyledPane className="SouthPane" ref={southPaneRef}>
214+
<StyledPane className="SouthPane" height={height} ref={southPaneRef}>
211215
<Tabs
212216
activeKey={activeSouthPaneTab}
213217
className="SouthPaneTabs"

0 commit comments

Comments
 (0)