From 5e19aa7bd1fe5c0f1b2818404ba8f5bd3d344037 Mon Sep 17 00:00:00 2001 From: Andrew Hackmann <5140848+bossinc@users.noreply.github.com> Date: Thu, 9 May 2024 19:54:24 -0500 Subject: [PATCH] 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 --- .../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