Prometheus: fix auth component select for sigv4 option (#73647)

* fix sigV4 selected auth option bug

* use precommit hooks
This commit is contained in:
Brendan O'Handley
2023-08-28 11:47:44 -04:00
committed by GitHub
parent 8dbd70b91b
commit 4e2710670e
@@ -1,4 +1,4 @@
import React, { useCallback, useState } from 'react';
import React, { useState } from 'react';
import { DataSourceSettings } from '@grafana/data';
import { Auth, ConnectionSettings, convertLegacyAuthProps } from '@grafana/experimental';
@@ -55,16 +55,6 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
customMethods.push(sigV4Option);
}
const onSettingsChange = useCallback(
(change: Partial<DataSourceSettings<PromOptions, {}>>) => {
onOptionsChange({
...options,
...change,
});
},
[options, onOptionsChange]
);
const azureAuthEnabled: boolean =
(azureAuthSettings?.azureAuthSupported && azureAuthSettings.getAzureAuthEnabled(options)) || false;
@@ -150,9 +140,8 @@ export const DataSourcehttpSettingsOverhaul = (props: Props) => {
// sigV4Id
if (sigV4AuthToggleEnabled) {
setSigV4Selected(method === sigV4Id);
onSettingsChange({
jsonData: { ...options.jsonData, sigV4Auth: method === sigV4Id },
});
// mutate jsonData here to store the selected option because of auth component issue with onOptionsChange being overridden
options.jsonData.sigV4Auth = method === sigV4Id;
}
// Azure