feat(sqllab): primary/secondary action extensions (#36644)

This commit is contained in:
JUST.in DO IT
2026-01-12 12:06:15 -08:00
committed by GitHub
parent fa3d4a75ca
commit 7503ee4e09
32 changed files with 1840 additions and 388 deletions

View File

@@ -30,6 +30,7 @@ import { initialState, defaultQueryEditor } from 'src/SqlLab/fixtures';
import QueryLimitSelect, {
QueryLimitSelectProps,
convertToNumWithSpaces,
convertToShortNum,
} from 'src/SqlLab/components/QueryLimitSelect';
const middlewares = [thunk];
@@ -102,7 +103,7 @@ describe('QueryLimitSelect', () => {
},
}),
);
expect(getByText(convertToNumWithSpaces(queryLimit))).toBeInTheDocument();
expect(getByText(convertToShortNum(queryLimit))).toBeInTheDocument();
});
test('renders dropdown select', async () => {

View File

@@ -34,6 +34,19 @@ export function convertToNumWithSpaces(num: number) {
return num.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1 ');
}
export function convertToShortNum(num: number) {
if (num < 1000) {
return num;
}
if (num < 1_000_000) {
return `${num / 1000}K`;
}
if (num < 1_000_000_000) {
return `${num / 1000_000}M`;
}
return num;
}
function renderQueryLimit(
maxRow: number,
setQueryLimit: (limit: number) => void,
@@ -74,12 +87,15 @@ const QueryLimitSelect = ({
popupRender={() => renderQueryLimit(maxRow, setQueryLimit)}
trigger={['click']}
>
<Button size="small" showMarginRight={false} buttonStyle="link">
<span>{t('LIMIT')}:</span>
<span className="limitDropdown">
{convertToNumWithSpaces(queryLimit)}
</span>
<Icons.CaretDownOutlined iconSize="m" />
<Button
size="small"
color="primary"
variant="text"
showMarginRight={false}
>
<span>{t('Limit')}</span>
<span className="limitDropdown">{convertToShortNum(queryLimit)}</span>
<Icons.DownOutlined iconSize="m" />
</Button>
</Dropdown>
);