mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
Loki: Fix showing of default visual query only if no expression (#47764)
* AutoSizeInput: Fix updating of value * Update * Revert "Update" This reverts commita3b527e0c6
. * Revert "AutoSizeInput: Fix updating of value" This reverts commitd4b4ae0a10
. * Fix showing of default visual query only if no expression * Update public/app/plugins/datasource/loki/querybuilder/components/LokiQueryBuilderContainer.tsx * Update public/app/plugins/datasource/loki/querybuilder/components/LokiQueryBuilderContainer.tsx * Update * Update
This commit is contained in:
parent
4570615afc
commit
2aa6f4d17b
@ -26,11 +26,15 @@ export interface State {
|
||||
export function LokiQueryBuilderContainer(props: Props) {
|
||||
const { query, onChange, onRunQuery, datasource } = props;
|
||||
const [state, dispatch] = useReducer(stateSlice.reducer, {
|
||||
expr: '',
|
||||
visQuery: {
|
||||
expr: query.expr,
|
||||
// Use initial visual query only if query.expr is empty string
|
||||
visQuery:
|
||||
query.expr === ''
|
||||
? {
|
||||
labels: [],
|
||||
operations: [{ id: '__line_contains', params: [''] }],
|
||||
},
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
|
||||
// Only rebuild visual query if expr changes from outside
|
||||
@ -62,7 +66,7 @@ export function LokiQueryBuilderContainer(props: Props) {
|
||||
}
|
||||
|
||||
const stateSlice = createSlice({
|
||||
name: 'prom-builder-container',
|
||||
name: 'loki-builder-container',
|
||||
initialState: { expr: '' } as State,
|
||||
reducers: {
|
||||
visualQueryChange: (state, action: PayloadAction<{ visQuery: LokiVisualQuery; expr: string }>) => {
|
||||
|
Loading…
Reference in New Issue
Block a user