From 343108924c8ed415f56d3d94edd0da144231ec0b Mon Sep 17 00:00:00 2001 From: Miguel Palau Zarza Date: Thu, 12 Dec 2024 14:30:02 -0600 Subject: [PATCH] make use of a Field label --- .../Auth/auth-method/AuthMethodSettings.tsx | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/ConfigEditor/Auth/auth-method/AuthMethodSettings.tsx b/src/ConfigEditor/Auth/auth-method/AuthMethodSettings.tsx index 29d1893..edb1af0 100644 --- a/src/ConfigEditor/Auth/auth-method/AuthMethodSettings.tsx +++ b/src/ConfigEditor/Auth/auth-method/AuthMethodSettings.tsx @@ -1,10 +1,10 @@ import React, { ReactElement, useMemo, useState } from 'react'; import { css } from '@emotion/css'; -import { useTheme2, Select } from '@grafana/ui'; +import { useTheme2, Select, Field } from '@grafana/ui'; import { SelectableValue } from '@grafana/data'; import { BasicAuth, Props as BasicAuthProps } from './BasicAuth'; import { ConfigSubSection } from '../../ConfigSection'; -import { AuthMethod, CustomMethod, CustomMethodId , AuthMethodSelectOption } from '../types'; +import { AuthMethod, CustomMethod, CustomMethodId, AuthMethodSelectOption } from '../types'; const defaultOptions: Record> = { [AuthMethod.BasicAuth]: { @@ -83,7 +83,7 @@ export const AuthMethodSettings = ({ preparedDefaultOptions[k] = { ...defaultOptions[k], ...defaultOptionsOverrides?.[k], - } + }; } const allOptions: Record> = { @@ -119,11 +119,11 @@ export const AuthMethodSettings = ({ AuthFieldsComponent = customMethods?.find((m) => m.id === selected)?.component ?? null; } - const title = hasSelect ? 'Authentication methods' : preparedOptions[0].label ?? ''; + const title = hasSelect ? 'Authentication methods' : (preparedOptions[0].label ?? ''); const description = hasSelect ? 'Choose an authentication method to access the data source' - : preparedOptions[0].description ?? ''; + : (preparedOptions[0].description ?? ''); const styles = { authMethods: css({ @@ -142,15 +142,18 @@ export const AuthMethodSettings = ({
{hasSelect && ( - { + setAuthMethodChanged(true); + onAuthMethodSelect(option.value!); + }} + disabled={readOnly} + /> + )} {AuthFieldsComponent &&
{AuthFieldsComponent}
}