mirror of
https://github.com/grafana/grafana.git
synced 2025-09-21 21:15:29 +08:00

* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
27 lines
828 B
TypeScript
27 lines
828 B
TypeScript
import React, { useCallback } from 'react';
|
|
|
|
import { DataSourceInstanceSettings } from '@grafana/data';
|
|
import { DataSourcePicker } from '@grafana/runtime';
|
|
|
|
import { useRulesSourcesWithRuler } from '../../hooks/useRuleSourcesWithRuler';
|
|
|
|
interface Props {
|
|
onChange: (ds: DataSourceInstanceSettings) => void;
|
|
value: string | null;
|
|
onBlur?: () => void;
|
|
name?: string;
|
|
}
|
|
|
|
export function CloudRulesSourcePicker({ value, ...props }: Props): JSX.Element {
|
|
const rulesSourcesWithRuler = useRulesSourcesWithRuler();
|
|
|
|
const dataSourceFilter = useCallback(
|
|
(ds: DataSourceInstanceSettings): boolean => {
|
|
return !!rulesSourcesWithRuler.find(({ id }) => id === ds.id);
|
|
},
|
|
[rulesSourcesWithRuler]
|
|
);
|
|
|
|
return <DataSourcePicker noDefault alerting filter={dataSourceFilter} current={value} {...props} />;
|
|
}
|