Skip to content

Commit

Permalink
preliminary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AAfghahi committed Feb 19, 2021
1 parent bb3413a commit ba40293
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 25 deletions.
29 changes: 26 additions & 3 deletions superset-frontend/src/SqlLab/components/ResultSet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { debounce } from 'lodash';
import ErrorMessageWithStackTrace from 'src/components/ErrorMessage/ErrorMessageWithStackTrace';
import { SaveDatasetModal } from 'src/SqlLab/components/SaveDatasetModal';
import { put as updateDatset } from 'src/api/dataset';
import Icon from 'src/components/Icon';
import Loading from '../../components/Loading';
import ExploreCtasResultsButton from './ExploreCtasResultsButton';
import ExploreResultsButton from './ExploreResultsButton';
Expand Down Expand Up @@ -482,11 +483,33 @@ export default class ResultSet extends React.PureComponent<
}

rowsReturned() {
const { query } = this.props;
let limitMessage;
const message = query.sql
.split(' ')
.filter((limit: string) => limit === 'LIMIT');
if (message.length > 0) {
limitMessage = t(
`The number of rows displayed is limited to %s by the query.`,
query.rows,
);
} else if (query.queryLimit === query.rows) {
limitMessage = t(
`The number of rows displayed is limited to %s by the limit dropdown.`,
query.queryLimit,
);
}

let limitWarning = null;
if (query.results?.displayLimitReached) {
limitWarning = <Icon className="ReturnedRowsImage" name="warning" />;
}
return (
<div className="ReturnedRows">
<span>
{t(`%s rows returned`, this.props.query.results.data.length)}
</span>
{console.log(query)}
{limitWarning}
<span>{t(`%s rows returned`, query.results.data.length)}</span>
<span className="LimitMessage">{limitMessage}</span>
</div>
);
}
Expand Down
22 changes: 0 additions & 22 deletions superset-frontend/src/SqlLab/components/SqlEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ import debounce from 'lodash/debounce';
import throttle from 'lodash/throttle';
import StyledModal from 'src/common/components/Modal';
import Mousetrap from 'mousetrap';

import { Tooltip } from 'src/common/components/Tooltip';
import Label from 'src/components/Label';
import Button from 'src/components/Button';
import Timer from 'src/components/Timer';
import {
Expand Down Expand Up @@ -560,23 +557,6 @@ class SqlEditor extends React.PureComponent {

renderEditorBottomBar() {
const { queryEditor: qe } = this.props;
let limitWarning = null;
if (this.props.latestQuery?.results?.displayLimitReached) {
limitWarning = (
<Tooltip
id="tooltip"
placement="left"
title={t(
`It appears that the number of rows in the query results displayed
was limited on the server side to
the %s limit.`,
this.props.latestQuery.rows,
)}
>
<Label type="warning">LIMIT</Label>
</Tooltip>
);
}

const { allow_ctas: allowCTAS, allow_cvas: allowCVAS } =
this.props.database || {};
Expand Down Expand Up @@ -647,7 +627,6 @@ class SqlEditor extends React.PureComponent {
/>
</span>
)}
{limitWarning}
<span>
<LimitSelectStyled>
<Dropdown overlay={this.renderQueryLimit()} trigger="click">
Expand Down Expand Up @@ -687,7 +666,6 @@ class SqlEditor extends React.PureComponent {
<span>
<ShareSqlLabQuery queryEditor={qe} />
</span>
{limitWarning}
<Dropdown overlay={this.renderDropdown()} trigger="click">
<Icon name="more-horiz" />
</Dropdown>
Expand Down
13 changes: 13 additions & 0 deletions superset-frontend/src/SqlLab/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,19 @@ div.tablePopover {
margin-bottom: -32px;
font-size: 13px;
line-height: 24px;

span {
margin-left: 8px;
}

.ReturnedRowsImage {
color: #FF7F43;
vertical-align: bottom;
}

.LimitMessage{
color: #8E94B0;
}
}

.result-set-error-message {
Expand Down
3 changes: 3 additions & 0 deletions superset-frontend/src/SqlLab/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type Query = {
link?: string;
progress: number;
results: {
displayLimitReached: boolean;
columns: Column[];
data: Record<string, unknown>[];
expanded_columns: Column[];
Expand All @@ -60,4 +61,6 @@ export type Query = {
tempTable: string;
trackingUrl: string | null;
templateParams: any;
rows: number;
queryLimit: number;
};

0 comments on commit ba40293

Please sign in to comment.