useAlertQueriesStatus.ts 421 B

12345678910111213
  1. import { useMemo } from 'react';
  2. import { getDataSourceSrv } from '@grafana/runtime';
  3. import { AlertQuery } from 'app/types/unified-alerting-dto';
  4. export function useAlertQueriesStatus(queries: AlertQuery[]) {
  5. const allDataSourcesAvailable = useMemo(
  6. () => queries.every((query) => Boolean(getDataSourceSrv().getInstanceSettings(query.datasourceUid))),
  7. [queries]
  8. );
  9. return { allDataSourcesAvailable };
  10. }