mirror of
https://github.com/grafana/grafana.git
synced 2025-07-31 21:42:38 +08:00

* feat(grafana-ui): introduce development exports to prevent importing from grafana/ui/src * refactor(theme-generation): move theme templates into scripts so themes continue to build * refactor(frontend): replace grafana/ui paths that use nested src with /internal or /unstable * chore(betterer): update better results file * feat(grafana-ui): support enterprise, remove Text component from internal * docs(packages): update readme with exporting code conventions
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import { useMemo } from 'react';
|
|
import { useEffectOnce } from 'react-use';
|
|
|
|
import { AzureCredentials, AzureCloud, updateDatasourceCredentials } from '@grafana/azure-sdk';
|
|
import { SelectableValue } from '@grafana/data';
|
|
import { config } from '@grafana/runtime';
|
|
import { HttpSettingsBaseProps } from '@grafana/ui/internal';
|
|
|
|
import { getCredentials } from './AzureCredentialsConfig';
|
|
import { AzureCredentialsForm } from './AzureCredentialsForm';
|
|
|
|
export const KnownAzureClouds: Array<SelectableValue<AzureCloud>> = [{ value: AzureCloud.Public, label: 'Azure' }];
|
|
|
|
export const AzureAuthSettings = (props: HttpSettingsBaseProps) => {
|
|
const { dataSourceConfig: dsSettings, onChange } = props;
|
|
const managedIdentityEnabled = config.azure.managedIdentityEnabled;
|
|
const azureEntraPasswordCredentialsEnabled = config.azure.azureEntraPasswordCredentialsEnabled;
|
|
|
|
const credentials = useMemo(() => getCredentials(dsSettings), [dsSettings]);
|
|
|
|
const onCredentialsChange = (credentials: AzureCredentials): void => {
|
|
onChange(updateDatasourceCredentials(dsSettings, 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}
|
|
azureEntraPasswordCredentialsEnabled={azureEntraPasswordCredentialsEnabled}
|
|
credentials={credentials}
|
|
azureCloudOptions={KnownAzureClouds}
|
|
onCredentialsChange={onCredentialsChange}
|
|
disabled={dsSettings.readOnly}
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default AzureAuthSettings;
|