only show datasources that support alerting in query editor (#43776)

This commit is contained in:
Nathan Rodman
2022-01-07 09:27:20 -08:00
committed by GitHub
parent 8cf63a9d44
commit 0dd88d9480
3 changed files with 7 additions and 3 deletions

View File

@@ -51,6 +51,7 @@ interface Props<TQuery extends DataQuery> {
app?: CoreApp;
history?: Array<HistoryItem<TQuery>>;
eventBus?: EventBusExtended;
alerting?: boolean;
}
interface State<TQuery extends DataQuery> {
@@ -361,7 +362,7 @@ export class QueryEditorRow<TQuery extends DataQuery> extends PureComponent<Prop
};
renderHeader = (props: QueryOperationRowRenderProps) => {
const { query, dataSource, onChangeDataSource, onChange, queries, renderHeaderExtras } = this.props;
const { alerting, query, dataSource, onChangeDataSource, onChange, queries, renderHeaderExtras } = this.props;
return (
<QueryEditorRowHeader
@@ -374,6 +375,7 @@ export class QueryEditorRow<TQuery extends DataQuery> extends PureComponent<Prop
onChange={onChange}
collapsedText={!props.isOpen ? this.renderCollapsedText() : null}
renderExtras={renderHeaderExtras}
alerting={alerting}
/>
);
};

View File

@@ -15,6 +15,7 @@ export interface Props<TQuery extends DataQuery = DataQuery> {
onChange: (query: TQuery) => void;
onClick: (e: React.MouseEvent) => void;
collapsedText: string | null;
alerting?: boolean;
}
export const QueryEditorRowHeader = <TQuery extends DataQuery>(props: Props<TQuery>) => {
@@ -130,7 +131,7 @@ const renderDataSource = <TQuery extends DataQuery>(
props: Props<TQuery>,
styles: ReturnType<typeof getStyles>
): ReactNode => {
const { dataSource, onChangeDataSource } = props;
const { alerting, dataSource, onChangeDataSource } = props;
if (!onChangeDataSource) {
return <em className={styles.contextInfo}>({dataSource.name})</em>;
@@ -138,7 +139,7 @@ const renderDataSource = <TQuery extends DataQuery>(
return (
<div className={styles.itemWrapper}>
<DataSourcePicker current={dataSource.name} onChange={onChangeDataSource} />
<DataSourcePicker alerting={alerting} current={dataSource.name} onChange={onChangeDataSource} />
</div>
);
};