From c3a8590fe5f5cad71b3e68bea55ccdd834840931 Mon Sep 17 00:00:00 2001 From: Gilles De Mey Date: Thu, 1 Dec 2022 17:05:28 +0100 Subject: [PATCH] Alerting: Reduce number of buildinfo calls (#59319) --- .../src/components/DataSourcePicker.test.tsx | 9 ++++++++- .../src/components/DataSourcePicker.tsx | 16 +++++++++++++++- .../features/alerting/unified/RuleEditor.tsx | 12 +++++++----- .../rule-editor/CloudRulesSourcePicker.tsx | 17 ++++++++++++++++- .../rule-editor/rule-types/RuleTypePicker.tsx | 8 +++++++- .../features/alerting/unified/state/actions.ts | 1 + 6 files changed, 54 insertions(+), 9 deletions(-) diff --git a/packages/grafana-runtime/src/components/DataSourcePicker.test.tsx b/packages/grafana-runtime/src/components/DataSourcePicker.test.tsx index e41eaeaa4f0..bdd44487e7b 100644 --- a/packages/grafana-runtime/src/components/DataSourcePicker.test.tsx +++ b/packages/grafana-runtime/src/components/DataSourcePicker.test.tsx @@ -1,4 +1,4 @@ -import { render } from '@testing-library/react'; +import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import React from 'react'; @@ -24,5 +24,12 @@ describe('DataSourcePicker', () => { select.getByLabelText('select-clear-value'); }).toThrowError(); }); + + it('should pass disabled prop', async () => { + render(); + + const input = screen.getByLabelText('Select a data source'); + expect(input).toHaveProperty('disabled', true); + }); }); }); diff --git a/packages/grafana-runtime/src/components/DataSourcePicker.tsx b/packages/grafana-runtime/src/components/DataSourcePicker.tsx index 0ceba9231be..b9ad9c2b761 100644 --- a/packages/grafana-runtime/src/components/DataSourcePicker.tsx +++ b/packages/grafana-runtime/src/components/DataSourcePicker.tsx @@ -47,6 +47,8 @@ export interface DataSourcePickerProps { filter?: (dataSource: DataSourceInstanceSettings) => boolean; onClear?: () => void; invalid?: boolean; + disabled?: boolean; + isLoading?: boolean; } /** @@ -162,7 +164,17 @@ export class DataSourcePicker extends PureComponent