mirror of
https://github.com/getredash/redash.git
synced 2025-12-19 17:37:19 -05:00
* DynamicComponent for QuerySourceAlerts * General Settings updates * Dynamic Date[Range] updates * EmptyState updates * Query and SchemaBrowser updates * Adjust page headers and add disablePublish * Policy updates * Separate Home FavoritesList component * Update FormatQuery * Autolimit frontend fixes * Misc updates * Keep registering of QuerySourceDropdown * Undo changes in DynamicComponent * Change sql-formatter package.json syntax * Allow opening help trigger in new tab * Don't run npm commands as root in Dockerfile * Cypress: Remove extra execute query
25 lines
802 B
JavaScript
25 lines
802 B
JavaScript
import { useCallback, useState } from "react";
|
|
import localOptions from "@/lib/localOptions";
|
|
import { get, extend } from "lodash";
|
|
|
|
function isAutoLimitAvailable(dataSource) {
|
|
return get(dataSource, "supports_auto_limit", false);
|
|
}
|
|
|
|
export default function useAutoLimitFlags(dataSource, query, setQuery) {
|
|
const isAvailable = isAutoLimitAvailable(dataSource);
|
|
const [isChecked, setIsChecked] = useState(query.options.apply_auto_limit);
|
|
query.options.apply_auto_limit = isChecked;
|
|
|
|
const setAutoLimit = useCallback(
|
|
state => {
|
|
setIsChecked(state);
|
|
localOptions.set("applyAutoLimit", state);
|
|
setQuery(extend(query.clone(), { options: { ...query.options, apply_auto_limit: state } }));
|
|
},
|
|
[query, setQuery]
|
|
);
|
|
|
|
return [isAvailable, isChecked, setAutoLimit];
|
|
}
|