Saved Queries: Fix buttons should not be displayed in Expressions query row (#111875)
This commit is contained in:
@@ -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(<QueryEditorRow {...expressionProps} />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByText('Save query')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Replace with saved query')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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<TQuery extends DataQuery> extends PureComponent<Prop
|
||||
const hasEditorHelp = datasource?.components?.QueryEditorHelp;
|
||||
const isEditingQueryLibrary = queryLibraryRef !== undefined;
|
||||
const isUnifiedAlerting = app === CoreApp.UnifiedAlerting;
|
||||
const isExpressionQuery = query.datasource?.uid === ExpressionDatasourceUID;
|
||||
|
||||
return (
|
||||
<>
|
||||
{!isEditingQueryLibrary && !isUnifiedAlerting && (
|
||||
{!isEditingQueryLibrary && !isUnifiedAlerting && !isExpressionQuery && (
|
||||
<SavedQueryButtons
|
||||
query={query}
|
||||
app={app}
|
||||
|
||||
Reference in New Issue
Block a user