mirror of
https://github.com/getredash/redash.git
synced 2026-03-22 01:00:14 -04:00
38 lines
1.1 KiB
JavaScript
38 lines
1.1 KiB
JavaScript
import React, { useCallback } from "react";
|
|
import PropTypes from "prop-types";
|
|
import recordEvent from "@/services/recordEvent";
|
|
import Checkbox from "antd/lib/checkbox";
|
|
import Tooltip from "@/components/Tooltip";
|
|
|
|
export default function AutoLimitCheckbox({ available, checked, onChange }) {
|
|
const handleClick = useCallback(() => {
|
|
recordEvent("checkbox_auto_limit", "screen", "query_editor", { state: !checked });
|
|
onChange(!checked);
|
|
}, [checked, onChange]);
|
|
|
|
let tooltipMessage = null;
|
|
if (!available) {
|
|
tooltipMessage = "Auto limiting is not available for this Data Source type.";
|
|
} else {
|
|
tooltipMessage = "Auto limit results to first 1000 rows.";
|
|
}
|
|
|
|
return (
|
|
<Tooltip placement="top" title={tooltipMessage}>
|
|
<Checkbox
|
|
className="query-editor-controls-checkbox"
|
|
disabled={!available}
|
|
onClick={handleClick}
|
|
checked={available && checked}>
|
|
LIMIT 1000
|
|
</Checkbox>
|
|
</Tooltip>
|
|
);
|
|
}
|
|
|
|
AutoLimitCheckbox.propTypes = {
|
|
available: PropTypes.bool,
|
|
checked: PropTypes.bool.isRequired,
|
|
onChange: PropTypes.func.isRequired,
|
|
};
|