Loki: Send current time range when fetching labels and values (#26622)

* Send current time range when fetching labels and values in Explore

* Pass range to Editors, in the same way as it was in Angular editors

* Remove unused imports

* Remove unused imports, props

* Update

* Update

* Update refresh condition

* Add comment
This commit is contained in:
Ivana Huckova
2020-07-30 18:04:20 +02:00
committed by GitHub
parent d88864f376
commit bf5d52c5c7
13 changed files with 63 additions and 110 deletions

View File

@ -5,14 +5,16 @@ import LokiLanguageProvider from '../language_provider';
type LokiQueryFieldProps = Omit<
LokiQueryFieldFormProps,
'syntax' | 'syntaxLoaded' | 'onLoadOptions' | 'onLabelsRefresh' | 'logLabelOptions'
'syntax' | 'syntaxLoaded' | 'onLoadOptions' | 'onLabelsRefresh' | 'logLabelOptions' | 'absoluteRange'
>;
export const LokiQueryField: FunctionComponent<LokiQueryFieldProps> = props => {
const { datasource, absoluteRange, ...otherProps } = props;
const { datasource, range, ...otherProps } = props;
const absoluteTimeRange = { from: range!.from!.valueOf(), to: range!.to!.valueOf() }; // Range here is never optional
const { isSyntaxReady, setActiveOption, refreshLabels, syntax, logLabelOptions } = useLokiSyntaxAndLabels(
datasource.languageProvider as LokiLanguageProvider,
absoluteRange
absoluteTimeRange
);
return (
@ -26,7 +28,7 @@ export const LokiQueryField: FunctionComponent<LokiQueryFieldProps> = props => {
*/
onLoadOptions={setActiveOption}
onLabelsRefresh={refreshLabels}
absoluteRange={absoluteRange}
absoluteRange={absoluteTimeRange}
syntax={syntax}
syntaxLoaded={isSyntaxReady}
logLabelOptions={logLabelOptions}