From e0b25e821c653dc3e25dbdce466f1cf95dbd2726 Mon Sep 17 00:00:00 2001
From: Alexa Vargas <239999+axelavargas@users.noreply.github.com>
Date: Thu, 2 Oct 2025 09:54:26 +0200
Subject: [PATCH] Saved Queries: Fix buttons should not be displayed in
Expressions query row (#111875)
---
.../query/components/QueryEditorRow.test.tsx | 24 +++++++++++++++++++
.../query/components/QueryEditorRow.tsx | 4 +++-
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/public/app/features/query/components/QueryEditorRow.test.tsx b/public/app/features/query/components/QueryEditorRow.test.tsx
index e87dd718b95..f839e570819 100644
--- a/public/app/features/query/components/QueryEditorRow.test.tsx
+++ b/public/app/features/query/components/QueryEditorRow.test.tsx
@@ -4,6 +4,7 @@ import { PropsWithChildren } from 'react';
import { CoreApp, DataQueryRequest, dateTime, LoadingState, PanelData, toDataFrame } from '@grafana/data';
import { DataQuery } from '@grafana/schema';
import { mockDataSource } from 'app/features/alerting/unified/mocks';
+import { ExpressionDatasourceUID } from 'app/features/expressions/types';
import { filterPanelDataToQuery, Props, QueryEditorRow } from './QueryEditorRow';
@@ -464,5 +465,28 @@ describe('QueryEditorRow', () => {
expect(screen.queryByText('Replace with saved query')).not.toBeInTheDocument();
});
});
+
+ it('should not render saved queries buttons when query is an expression query', async () => {
+ const expressionQuery = {
+ refId: 'B',
+ datasource: {
+ uid: ExpressionDatasourceUID,
+ type: '__expr__',
+ },
+ };
+
+ const expressionProps = {
+ ...props(testData),
+ query: expressionQuery,
+ queries: [expressionQuery],
+ };
+
+ render();
+
+ await waitFor(() => {
+ expect(screen.queryByText('Save query')).not.toBeInTheDocument();
+ expect(screen.queryByText('Replace with saved query')).not.toBeInTheDocument();
+ });
+ });
});
});
diff --git a/public/app/features/query/components/QueryEditorRow.tsx b/public/app/features/query/components/QueryEditorRow.tsx
index fb469d17aa7..fe8fa6c018e 100644
--- a/public/app/features/query/components/QueryEditorRow.tsx
+++ b/public/app/features/query/components/QueryEditorRow.tsx
@@ -34,6 +34,7 @@ import {
} from 'app/core/components/QueryOperationRow/QueryOperationRow';
import { useQueryLibraryContext } from '../../explore/QueryLibrary/QueryLibraryContext';
+import { ExpressionDatasourceUID } from '../../expressions/types';
import { QueryActionComponent, RowActionComponents } from './QueryActionComponent';
import { QueryEditorRowHeader } from './QueryEditorRowHeader';
@@ -386,10 +387,11 @@ export class QueryEditorRow extends PureComponent
- {!isEditingQueryLibrary && !isUnifiedAlerting && (
+ {!isEditingQueryLibrary && !isUnifiedAlerting && !isExpressionQuery && (