Saved Queries: Entry point removal in Alerting (#110189)
* Saved queries: Remove query editor row buttons in Alerts * Naming tweaks in test file
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { render, screen, waitFor } from '@testing-library/react';
|
||||
import { PropsWithChildren } from 'react';
|
||||
|
||||
import { DataQueryRequest, dateTime, LoadingState, PanelData, toDataFrame } from '@grafana/data';
|
||||
import { CoreApp, DataQueryRequest, dateTime, LoadingState, PanelData, toDataFrame } from '@grafana/data';
|
||||
import { DataQuery } from '@grafana/schema';
|
||||
import { mockDataSource } from 'app/features/alerting/unified/mocks';
|
||||
|
||||
@@ -455,5 +455,14 @@ describe('QueryEditorRow', () => {
|
||||
|
||||
expect(mockQueryLibraryContext.renderQueryLibraryEditingHeader).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should not render saved queries buttons when app is unified alerting', async () => {
|
||||
render(<QueryEditorRow {...props(testData)} app={CoreApp.UnifiedAlerting} />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.queryByText('Save query')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('Replace with saved query')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -379,29 +379,30 @@ export class QueryEditorRow<TQuery extends DataQuery> extends PureComponent<Prop
|
||||
};
|
||||
|
||||
renderActions = (props: QueryOperationRowRenderProps) => {
|
||||
const { query, hideHideQueryButton: hideHideQueryButton = false, queryLibraryRef } = this.props;
|
||||
const { query, hideHideQueryButton: hideHideQueryButton = false, queryLibraryRef, app } = this.props;
|
||||
const { datasource, showingHelp } = this.state;
|
||||
const isHidden = !!query.hide;
|
||||
|
||||
const hasEditorHelp = datasource?.components?.QueryEditorHelp;
|
||||
const isEditingQueryLibrary = queryLibraryRef !== undefined;
|
||||
const isUnifiedAlerting = app === CoreApp.UnifiedAlerting;
|
||||
|
||||
return (
|
||||
<>
|
||||
{!isEditingQueryLibrary && (
|
||||
{!isEditingQueryLibrary && !isUnifiedAlerting && (
|
||||
<MaybeQueryLibrarySaveButton
|
||||
query={query}
|
||||
app={this.props.app}
|
||||
app={app}
|
||||
onSelectQuery={this.onSelectQueryFromLibrary}
|
||||
onUpdateSuccess={this.onExitQueryLibraryEditingMode}
|
||||
/>
|
||||
)}
|
||||
|
||||
{!isEditingQueryLibrary && (
|
||||
{!isEditingQueryLibrary && !isUnifiedAlerting && (
|
||||
<ReplaceQueryFromLibrary
|
||||
datasourceFilters={datasource?.name ? [datasource.name] : []}
|
||||
onSelectQuery={this.onSelectQueryFromLibrary}
|
||||
app={this.props.app}
|
||||
app={app}
|
||||
/>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user