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 && (