From e52d86e9bc56d6697cc221b7f044b3ef74433ba6 Mon Sep 17 00:00:00 2001 From: "grafana-delivery-bot[bot]" <132647405+grafana-delivery-bot[bot]@users.noreply.github.com> Date: Fri, 10 May 2024 17:09:02 +0300 Subject: [PATCH] [v11.0.x] Azure data sources: Set selected config type before save (#87632) Azure data sources: Set selected config type before save (#87481) * set selected config type before save * use effect once and move in mssql * add to prom * Update ConfigurationEditor.tsx * Update ConfigurationEditor.tsx * Delete public/app/plugins/datasource/mssql/configuration/ConfigurationEditor.tsx * omadsfdsa * remove unneeded assign (cherry picked from commit 5e19aa7bd1fe5c0f1b2818404ba8f5bd3d344037) Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com> --- .../components/ConfigEditor/MonitorConfig.tsx | 8 ++++++++ .../datasource/mssql/azureauth/AzureAuthSettings.tsx | 8 ++++++++ .../prometheus/configuration/AzureAuthSettings.tsx | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/public/app/plugins/datasource/azuremonitor/components/ConfigEditor/MonitorConfig.tsx b/public/app/plugins/datasource/azuremonitor/components/ConfigEditor/MonitorConfig.tsx index ff869479f9c..8a2dd691284 100644 --- a/public/app/plugins/datasource/azuremonitor/components/ConfigEditor/MonitorConfig.tsx +++ b/public/app/plugins/datasource/azuremonitor/components/ConfigEditor/MonitorConfig.tsx @@ -1,4 +1,5 @@ import React, { useMemo, useState } from 'react'; +import { useEffectOnce } from 'react-use'; import { SelectableValue } from '@grafana/data'; import { config } from '@grafana/runtime'; @@ -48,6 +49,13 @@ export const MonitorConfig = (props: Props) => { const onSubscriptionChange = (subscriptionId?: string) => updateOptions((options) => ({ ...options, jsonData: { ...options.jsonData, subscriptionId } })); + // The auth type needs to be set on the first load of the data source + useEffectOnce(() => { + if (!options.jsonData.authType) { + onCredentialsChange(credentials); + } + }); + return ( <> { onChange(updateCredentials(dsSettings, config, credentials)); }; + // The auth type needs to be set on the first load of the data source + useEffectOnce(() => { + if (!dsSettings.jsonData.authType) { + onCredentialsChange(credentials); + } + }); + return ( { const labelWidth = prometheusConfigOverhaulAuth ? 24 : 26; + // The auth type needs to be set on the first load of the data source + useEffectOnce(() => { + if (!dataSourceConfig.jsonData.authType) { + onCredentialsChange(credentials); + } + }); + return ( <>
Azure authentication