Skip to content

Commit

Permalink
[v10.3.x] Azure data sources: Set selected config type before save (#…
Browse files Browse the repository at this point in the history
…87584)

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 5e19aa7)

Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com>
  • Loading branch information
grafana-delivery-bot[bot] and bossinc committed May 10, 2024
1 parent 1679d8a commit d3ccac6
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -41,6 +42,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 (
<>
<AzureCredentialsForm
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useMemo } from 'react';
import { useEffectOnce } from 'react-use';

import { config } from '@grafana/runtime';
import { HttpSettingsBaseProps } from '@grafana/ui/src/components/DataSourceSettings/types';
Expand All @@ -19,6 +20,13 @@ export const AzureAuthSettings = (props: HttpSettingsBaseProps) => {
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 (
<AzureCredentialsForm
managedIdentityEnabled={managedIdentityEnabled}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { cx } from '@emotion/css';
import React, { FormEvent, useMemo, useState } from 'react';
import { useEffectOnce } from 'react-use';

import { config } from '@grafana/runtime';
import { InlineField, InlineFieldRow, InlineSwitch, Input } from '@grafana/ui';
Expand Down Expand Up @@ -45,6 +46,13 @@ export const AzureAuthSettings = (props: HttpSettingsBaseProps) => {

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 (
<>
<h6>Azure authentication</h6>
Expand Down

0 comments on commit d3ccac6

Please sign in to comment.