[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 5e19aa7bd1)
Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com>
This commit is contained in:
co-authored by
Andrew Hackmann
parent
587a1ef1de
commit
e52d86e9bc
@@ -1,4 +1,5 @@
|
|||||||
import React, { useMemo, useState } from 'react';
|
import React, { useMemo, useState } from 'react';
|
||||||
|
import { useEffectOnce } from 'react-use';
|
||||||
|
|
||||||
import { SelectableValue } from '@grafana/data';
|
import { SelectableValue } from '@grafana/data';
|
||||||
import { config } from '@grafana/runtime';
|
import { config } from '@grafana/runtime';
|
||||||
@@ -48,6 +49,13 @@ export const MonitorConfig = (props: Props) => {
|
|||||||
const onSubscriptionChange = (subscriptionId?: string) =>
|
const onSubscriptionChange = (subscriptionId?: string) =>
|
||||||
updateOptions((options) => ({ ...options, jsonData: { ...options.jsonData, subscriptionId } }));
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<AzureCredentialsForm
|
<AzureCredentialsForm
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
|
import { useEffectOnce } from 'react-use';
|
||||||
|
|
||||||
import { config } from '@grafana/runtime';
|
import { config } from '@grafana/runtime';
|
||||||
import { HttpSettingsBaseProps } from '@grafana/ui/src/components/DataSourceSettings/types';
|
import { HttpSettingsBaseProps } from '@grafana/ui/src/components/DataSourceSettings/types';
|
||||||
@@ -19,6 +20,13 @@ export const AzureAuthSettings = (props: HttpSettingsBaseProps) => {
|
|||||||
onChange(updateCredentials(dsSettings, config, credentials));
|
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 (
|
return (
|
||||||
<AzureCredentialsForm
|
<AzureCredentialsForm
|
||||||
managedIdentityEnabled={managedIdentityEnabled}
|
managedIdentityEnabled={managedIdentityEnabled}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { cx } from '@emotion/css';
|
import { cx } from '@emotion/css';
|
||||||
import React, { FormEvent, useMemo, useState } from 'react';
|
import React, { FormEvent, useMemo, useState } from 'react';
|
||||||
|
import { useEffectOnce } from 'react-use';
|
||||||
|
|
||||||
import { config } from '@grafana/runtime';
|
import { config } from '@grafana/runtime';
|
||||||
import { InlineField, InlineFieldRow, InlineSwitch, Input } from '@grafana/ui';
|
import { InlineField, InlineFieldRow, InlineSwitch, Input } from '@grafana/ui';
|
||||||
@@ -45,6 +46,13 @@ export const AzureAuthSettings = (props: HttpSettingsBaseProps) => {
|
|||||||
|
|
||||||
const labelWidth = prometheusConfigOverhaulAuth ? 24 : 26;
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<h6>Azure authentication</h6>
|
<h6>Azure authentication</h6>
|
||||||
|
|||||||
Reference in New Issue
Block a user