mirror of
https://github.com/grafana/grafana.git
synced 2025-09-23 13:03:14 +08:00
Loki: Cleanup some code for default editorMode (#49431)
This commit is contained in:
@ -24,6 +24,8 @@ export const LokiQueryEditorSelector = React.memo<LokiQueryEditorProps>((props)
|
|||||||
const [dataIsStale, setDataIsStale] = useState(false);
|
const [dataIsStale, setDataIsStale] = useState(false);
|
||||||
|
|
||||||
const query = getQueryWithDefaults(props.query);
|
const query = getQueryWithDefaults(props.query);
|
||||||
|
// This should be filled in from the defaults by now.
|
||||||
|
const editorMode = query.editorMode!;
|
||||||
|
|
||||||
const onEditorModeChange = useCallback(
|
const onEditorModeChange = useCallback(
|
||||||
(newEditorMode: QueryEditorMode) => {
|
(newEditorMode: QueryEditorMode) => {
|
||||||
@ -54,8 +56,6 @@ export const LokiQueryEditorSelector = React.memo<LokiQueryEditorProps>((props)
|
|||||||
onChange({ ...query, rawQuery: isEnabled });
|
onChange({ ...query, rawQuery: isEnabled });
|
||||||
};
|
};
|
||||||
|
|
||||||
// If no expr (ie new query) then default to builder
|
|
||||||
const editorMode = query.editorMode ?? (query.expr ? QueryEditorMode.Code : QueryEditorMode.Builder);
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ConfirmModal
|
<ConfirmModal
|
||||||
|
@ -26,6 +26,7 @@ export const PromQueryEditorSelector = React.memo<PromQueryEditorProps>((props)
|
|||||||
const [dataIsStale, setDataIsStale] = useState(false);
|
const [dataIsStale, setDataIsStale] = useState(false);
|
||||||
|
|
||||||
const query = getQueryWithDefaults(props.query, app);
|
const query = getQueryWithDefaults(props.query, app);
|
||||||
|
// This should be filled in from the defaults by now.
|
||||||
const editorMode = query.editorMode!;
|
const editorMode = query.editorMode!;
|
||||||
|
|
||||||
const onEditorModeChange = useCallback(
|
const onEditorModeChange = useCallback(
|
||||||
|
Reference in New Issue
Block a user