mirror of
https://github.com/grafana/grafana.git
synced 2025-09-23 18:52:33 +08:00
Loki/Explore: Add query type selector (#28817)
* Create query type switcher * Add and update tests * Add handling in datasource * Refactor * Update tests, when checking higlighting, suppy logs * Remove both option as redundant * Add tooltip, remove old comments * Remove unused importts * Remove console.log, update width * Update public/app/plugins/datasource/loki/components/LokiExploreExtraField.tsx Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update tests * Prettier fixes * Fix test Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
This commit is contained in:
@ -20,6 +20,17 @@ export function LokiExploreQueryEditor(props: Props) {
|
||||
onChange(nextQuery);
|
||||
}
|
||||
|
||||
function onQueryTypeChange(value: string) {
|
||||
const { query, onChange } = props;
|
||||
let nextQuery;
|
||||
if (value === 'instant') {
|
||||
nextQuery = { ...query, instant: true, range: false };
|
||||
} else {
|
||||
nextQuery = { ...query, instant: false, range: true };
|
||||
}
|
||||
onChange(nextQuery);
|
||||
}
|
||||
|
||||
function preprocessMaxLines(value: string): number {
|
||||
if (value.length === 0) {
|
||||
// empty input - falls back to dataSource.maxLines limit
|
||||
@ -58,12 +69,11 @@ export function LokiExploreQueryEditor(props: Props) {
|
||||
range={range}
|
||||
ExtraFieldElement={
|
||||
<LokiExploreExtraField
|
||||
label={'Line limit'}
|
||||
onChangeFunc={onMaxLinesChange}
|
||||
queryType={query.instant ? 'instant' : 'range'}
|
||||
lineLimitValue={query?.maxLines?.toString() || ''}
|
||||
onQueryTypeChange={onQueryTypeChange}
|
||||
onLineLimitChange={onMaxLinesChange}
|
||||
onKeyDownFunc={onReturnKeyDown}
|
||||
value={query?.maxLines?.toString() || ''}
|
||||
type={'number'}
|
||||
min={0}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
|
Reference in New Issue
Block a user