From 76e23a9fefb09d0c4e967cd0ac5800dff95b528d Mon Sep 17 00:00:00 2001 From: Andres Martinez Gotor Date: Tue, 20 Dec 2022 15:44:02 +0100 Subject: [PATCH] Azure Monitor: Fix config editor style (#60563) --- .../components/AzureCredentialsForm.test.tsx | 10 +- .../components/AzureCredentialsForm.tsx | 94 +++++++++---------- 2 files changed, 51 insertions(+), 53 deletions(-) diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.test.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.test.tsx index 5b4f4f0e061..b717cad9fef 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.test.tsx +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.test.tsx @@ -1,6 +1,8 @@ import { render, screen, waitFor } from '@testing-library/react'; import React from 'react'; +import { selectors } from '../e2e/selectors'; + import AzureCredentialsForm, { Props } from './AzureCredentialsForm'; const setup = (propsFunc?: (props: Props) => Props) => { @@ -64,7 +66,9 @@ describe('Render', () => { clientSecret: 'e7f3f661-a933-4b3f-8176-51c4f982ec48', }, })); - await waitFor(() => expect(screen.getByText('Load Subscriptions')).toBeInTheDocument()); + await waitFor(() => + expect(screen.getByTestId(selectors.components.configEditor.loadSubscriptions.button)).not.toBeDisabled() + ); }); describe('when disabled', () => { @@ -83,7 +87,9 @@ describe('Render', () => { ...props, disabled: true, })); - await waitFor(() => expect(screen.queryByText('Load Subscriptions')).not.toBeInTheDocument()); + await waitFor(() => + expect(screen.getByTestId(selectors.components.configEditor.loadSubscriptions.button)).toBeDisabled() + ); }); it('should render children components', () => { diff --git a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.tsx b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.tsx index 9bedcb7aa51..33eb02706ef 100644 --- a/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.tsx +++ b/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/AzureCredentialsForm.tsx @@ -1,7 +1,7 @@ import React, { ChangeEvent, FunctionComponent, useEffect, useReducer, useState } from 'react'; import { SelectableValue } from '@grafana/data'; -import { InlineFormLabel, LegacyForms, Button, Select, InlineField } from '@grafana/ui'; +import { LegacyForms, Button, Select, InlineField } from '@grafana/ui'; import { isCredentialsComplete } from '../credentials'; import { selectors } from '../e2e/selectors'; @@ -230,19 +230,19 @@ export const AzureCredentialsForm: FunctionComponent = (props: Props) => {!disabled && (typeof credentials.clientSecret === 'symbol' ? ( -
-
- Client Secret - -
-
-
- -
+ +
+ +
-
+ ) : ( = (props: Props) => placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" value={credentials.clientSecret || ''} onChange={onClientSecretChange} + id="client-secret" disabled={disabled} /> @@ -263,45 +264,36 @@ export const AzureCredentialsForm: FunctionComponent = (props: Props) => )} {getSubscriptions && ( - <> -
-
- Default Subscription -
- opt.value === credentials.defaultSubscriptionId) + : undefined + } + options={subscriptions} + onChange={onSubscriptionChange} + disabled={disabled} + /> +
- {!disabled && ( -
-
-
- -
-
-
- )} - + )} {props.children}