Commit 2098b9eb by Shavonn Brown Committed by GitHub

Azure Monitor: Standardize Config Editor Implementation (#20455)

* initial changes - removal from state, remove anon functions, reset secrets empty

* post testing cleanup

* init promise cancellation, other cleanup

* workspaces response parser, remove version incrementing

* update datasource funcs - DRYer

* remove prop mutation

* func to modify root config opt

* fix version issue

* update snapshot
parent 5f72bfe6
......@@ -272,6 +272,64 @@ export abstract class DataSourceApi<
interpolateVariablesInQueries?(queries: TQuery[]): TQuery[];
}
export function updateDatasourcePluginOption(props: DataSourcePluginOptionsEditorProps, key: string, val: any) {
let config = props.options;
config = {
...config,
[key]: val,
};
props.onOptionsChange(config);
}
export function updateDatasourcePluginJsonDataOption(
props: DataSourcePluginOptionsEditorProps,
key: string,
val: any,
secure: boolean
) {
let config = props.options;
if (secure) {
config = {
...config,
secureJsonData: {
...config.secureJsonData,
[key]: val,
},
};
} else {
config = {
...config,
jsonData: {
...config.jsonData,
[key]: val,
},
};
}
props.onOptionsChange(config);
}
export function updateDatasourcePluginResetKeyOption(props: DataSourcePluginOptionsEditorProps, key: string) {
let config = props.options;
config = {
...config,
secureJsonData: {
...config.secureJsonData,
[key]: '',
},
secureJsonFields: {
...config.secureJsonFields,
[key]: false,
},
};
props.onOptionsChange(config);
}
export interface QueryEditorProps<
DSType extends DataSourceApi<TQuery, TOptions>,
TQuery extends DataQuery = DataQuery,
......
......@@ -149,4 +149,25 @@ export default class ResponseParser {
return list;
}
static parseWorkspacesForSelect(result: any): Array<{ label: string; value: string }> {
const list: Array<{ label: string; value: string }> = [];
if (!result) {
return list;
}
const valueFieldName = 'customerId';
const textFieldName = 'name';
for (let i = 0; i < result.data.value.length; i++) {
if (!_.find(list, ['value', _.get(result.data.value[i].properties, valueFieldName)])) {
list.push({
label: _.get(result.data.value[i], textFieldName),
value: _.get(result.data.value[i].properties, valueFieldName),
});
}
}
return list;
}
}
......@@ -4,7 +4,7 @@ import AnalyticsConfig, { Props } from './AnalyticsConfig';
const setup = (propOverrides?: object) => {
const props: Props = {
datasourceConfig: {
options: {
id: 21,
orgId: 1,
name: 'Azure Monitor-10-10',
......@@ -24,9 +24,10 @@ const setup = (propOverrides?: object) => {
logAnalyticsClientSecret: false,
},
jsonData: {
cloudName: '',
subscriptionId: '',
azureLogAnalyticsSameAs: false,
logAnalyticsDefaultWorkspace: '',
logAnalyticsClientSecret: '',
logAnalyticsTenantId: '',
},
secureJsonData: {
......@@ -35,9 +36,10 @@ const setup = (propOverrides?: object) => {
version: 1,
readOnly: false,
},
logAnalyticsSubscriptions: [],
logAnalyticsWorkspaces: [],
onDatasourceUpdate: jest.fn(),
subscriptions: [],
workspaces: [],
onUpdateOption: jest.fn(),
onResetOptionKey: jest.fn(),
onLoadSubscriptions: jest.fn(),
onLoadWorkspaces: jest.fn(),
};
......
import React, { PureComponent } from 'react';
import React, { PureComponent, ChangeEvent } from 'react';
import { SelectableValue } from '@grafana/data';
import { AzureCredentialsForm } from './AzureCredentialsForm';
import { Switch, FormLabel, Select, Button } from '@grafana/ui';
import { AzureDataSourceSettings } from '../types';
export interface Props {
datasourceConfig: any;
logAnalyticsSubscriptions: SelectableValue[];
logAnalyticsWorkspaces: SelectableValue[];
onDatasourceUpdate: (config: any) => void;
options: AzureDataSourceSettings;
subscriptions: SelectableValue[];
workspaces: SelectableValue[];
onUpdateOption: (key: string, val: any, secure: boolean) => void;
onResetOptionKey: (key: string) => void;
onLoadSubscriptions: (type?: string) => void;
onLoadWorkspaces: (type?: string) => void;
}
export interface State {
config: any;
logAnalyticsSubscriptions: SelectableValue[];
logAnalyticsWorkspaces: SelectableValue[];
}
export class AnalyticsConfig extends PureComponent<Props, State> {
constructor(props: Props) {
super(props);
const { datasourceConfig } = this.props;
this.state = {
config: datasourceConfig,
logAnalyticsSubscriptions: [],
logAnalyticsWorkspaces: [],
};
}
static getDerivedStateFromProps(props: Props, state: State) {
return {
...state,
config: props.datasourceConfig,
logAnalyticsSubscriptions: props.logAnalyticsSubscriptions,
logAnalyticsWorkspaces: props.logAnalyticsWorkspaces,
};
}
onLogAnalyticsTenantIdChange = (logAnalyticsTenantId: string) => {
this.props.onDatasourceUpdate({
...this.state.config,
jsonData: {
...this.state.config.jsonData,
logAnalyticsTenantId,
},
});
export class AnalyticsConfig extends PureComponent<Props> {
onLogAnalyticsTenantIdChange = (event: ChangeEvent<HTMLInputElement>) => {
this.props.onUpdateOption('logAnalyticsTenantId', event.target.value, false);
};
onLogAnalyticsClientIdChange = (logAnalyticsClientId: string) => {
this.props.onDatasourceUpdate({
...this.state.config,
jsonData: {
...this.state.config.jsonData,
logAnalyticsClientId,
},
});
onLogAnalyticsClientIdChange = (event: ChangeEvent<HTMLInputElement>) => {
this.props.onUpdateOption('logAnalyticsClientId', event.target.value, false);
};
onLogAnalyticsClientSecretChange = (logAnalyticsClientSecret: string) => {
this.props.onDatasourceUpdate({
...this.state.config,
secureJsonData: {
...this.state.config.secureJsonData,
logAnalyticsClientSecret,
},
});
};
onLogAnalyticsResetClientSecret = () => {
this.props.onDatasourceUpdate({
...this.state.config,
version: this.state.config.version + 1,
secureJsonFields: { ...this.state.config.secureJsonFields, logAnalyticsClientSecret: false },
});
onLogAnalyticsClientSecretChange = (event: ChangeEvent<HTMLInputElement>) => {
this.props.onUpdateOption('logAnalyticsClientSecret', event.target.value, true);
};
onLogAnalyticsSubscriptionSelect = (logAnalyticsSubscription: SelectableValue<string>) => {
this.props.onDatasourceUpdate({
...this.state.config,
jsonData: {
...this.state.config.jsonData,
logAnalyticsSubscriptionId: logAnalyticsSubscription.value,
},
});
this.props.onUpdateOption('logAnalyticsSubscriptionId', logAnalyticsSubscription.value, false);
};
onWorkspaceSelectChange = (logAnalyticsDefaultWorkspace: SelectableValue<string>) => {
this.props.onDatasourceUpdate({
...this.state.config,
jsonData: {
...this.state.config.jsonData,
logAnalyticsDefaultWorkspace: logAnalyticsDefaultWorkspace.value,
},
});
this.props.onUpdateOption('logAnalyticsDefaultWorkspace', logAnalyticsDefaultWorkspace.value, false);
};
onAzureLogAnalyticsSameAsChange = (azureLogAnalyticsSameAs: boolean) => {
this.props.onDatasourceUpdate({
...this.state.config,
jsonData: {
...this.state.config.jsonData,
azureLogAnalyticsSameAs,
},
});
onAzureLogAnalyticsSameAsChange = () => {
const { options } = this.props;
this.props.onUpdateOption('azureLogAnalyticsSameAs', !options.jsonData.azureLogAnalyticsSameAs, false);
};
onLogAnalyticsResetClientSecret = () => {
this.props.onResetOptionKey('logAnalyticsClientSecret');
};
hasWorkspaceRequiredFields = () => {
const {
config: { jsonData, secureJsonData, secureJsonFields },
} = this.state;
options: { jsonData, secureJsonData, secureJsonFields },
} = this.props;
if (jsonData.azureLogAnalyticsSameAs) {
return (
......@@ -134,10 +69,14 @@ export class AnalyticsConfig extends PureComponent<Props, State> {
render() {
const {
config: { jsonData, secureJsonData, secureJsonFields },
logAnalyticsSubscriptions,
logAnalyticsWorkspaces,
} = this.state;
options: { jsonData, secureJsonData, secureJsonFields },
subscriptions,
workspaces,
} = this.props;
if (!jsonData.hasOwnProperty('azureLogAnalyticsSameAs')) {
jsonData.azureLogAnalyticsSameAs = true;
}
const addtlAttrs = {
...(jsonData.azureLogAnalyticsSameAs && {
......@@ -150,12 +89,12 @@ export class AnalyticsConfig extends PureComponent<Props, State> {
<Switch
label="Same details as Azure Monitor API"
checked={jsonData.azureLogAnalyticsSameAs}
onChange={event => this.onAzureLogAnalyticsSameAsChange(!jsonData.azureLogAnalyticsSameAs)}
onChange={this.onAzureLogAnalyticsSameAsChange}
{...addtlAttrs}
/>
{!jsonData.azureLogAnalyticsSameAs && (
<AzureCredentialsForm
subscriptionOptions={logAnalyticsSubscriptions}
subscriptionOptions={subscriptions}
selectedSubscription={jsonData.logAnalyticsSubscriptionId}
tenantId={jsonData.logAnalyticsTenantId}
clientId={jsonData.logAnalyticsClientId}
......@@ -180,10 +119,8 @@ export class AnalyticsConfig extends PureComponent<Props, State> {
</FormLabel>
<div className="width-25">
<Select
value={logAnalyticsWorkspaces.find(
workspace => workspace.value === jsonData.logAnalyticsDefaultWorkspace
)}
options={logAnalyticsWorkspaces}
value={workspaces.find(workspace => workspace.value === jsonData.logAnalyticsDefaultWorkspace)}
options={workspaces}
defaultValue={jsonData.logAnalyticsDefaultWorkspace}
onChange={this.onWorkspaceSelectChange}
/>
......
......@@ -5,15 +5,15 @@ import AzureCredentialsForm, { Props } from './AzureCredentialsForm';
const setup = (propOverrides?: object) => {
const props: Props = {
selectedAzureCloud: 'azuremonitor',
selectedSubscription: '44693801-6ee6-49de-9b2d-9106972f9572',
selectedSubscription: '44987801-6nn6-49he-9b2d-9106972f9789',
azureCloudOptions: [
{ value: 'azuremonitor', label: 'Azure' },
{ value: 'govazuremonitor', label: 'Azure US Government' },
{ value: 'germanyazuremonitor', label: 'Azure Germany' },
{ value: 'chinaazuremonitor', label: 'Azure China' },
],
tenantId: 'e7f3f661-a933-4b3f-8176-51c4f982ec48',
clientId: '77409fad-c0a9-45df-9e25-f1ff95af6554',
tenantId: 'e7f3f661-a933-3h3f-0294-31c4f962ec48',
clientId: '34509fad-c0r9-45df-9e25-f1ee34af6900',
clientSecret: '',
clientSecretConfigured: false,
subscriptionOptions: [],
......
......@@ -13,26 +13,15 @@ export interface Props {
subscriptionOptions?: SelectableValue[];
onAzureCloudChange?: (value: SelectableValue<string>) => void;
onSubscriptionSelectChange?: (value: SelectableValue<string>) => void;
onTenantIdChange: (tenantId: string) => void;
onClientIdChange: (clientId: string) => void;
onClientSecretChange: (clientSecret: string) => void;
onTenantIdChange: (event: ChangeEvent<HTMLInputElement>) => void;
onClientIdChange: (event: ChangeEvent<HTMLInputElement>) => void;
onClientSecretChange: (event: ChangeEvent<HTMLInputElement>) => void;
onResetClientSecret: () => void;
onLoadSubscriptions?: () => void;
}
export interface State {
selectedAzureCloud?: string;
selectedSubscription: string;
tenantId: string;
clientId: string;
clientSecret: string;
clientSecretConfigured: boolean;
}
export class AzureCredentialsForm extends PureComponent<Props, State> {
constructor(props: Props) {
super(props);
export class AzureCredentialsForm extends PureComponent<Props> {
render() {
const {
selectedAzureCloud,
selectedSubscription,
......@@ -40,31 +29,6 @@ export class AzureCredentialsForm extends PureComponent<Props, State> {
clientId,
clientSecret,
clientSecretConfigured,
} = this.props;
this.state = {
selectedAzureCloud,
selectedSubscription,
tenantId,
clientId,
clientSecret,
clientSecretConfigured,
};
}
static getDerivedStateFromProps(nextProps: Props, prevState: Props) {
const { selectedAzureCloud, tenantId, clientId, clientSecret, clientSecretConfigured } = nextProps;
return {
selectedAzureCloud,
tenantId,
clientId,
clientSecret,
clientSecretConfigured,
};
}
render() {
const {
azureCloudOptions,
subscriptionOptions,
onAzureCloudChange,
......@@ -75,16 +39,9 @@ export class AzureCredentialsForm extends PureComponent<Props, State> {
onResetClientSecret,
onLoadSubscriptions,
} = this.props;
const {
selectedAzureCloud,
selectedSubscription,
tenantId,
clientId,
clientSecret,
clientSecretConfigured,
} = this.state;
const hasRequiredFields = tenantId && clientId && (clientSecret || clientSecretConfigured);
const hasSubscriptions = onLoadSubscriptions && subscriptionOptions;
return (
<>
<div className="gf-form-group">
......@@ -112,7 +69,7 @@ export class AzureCredentialsForm extends PureComponent<Props, State> {
className="width-30"
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value={tenantId || ''}
onChange={(event: ChangeEvent<HTMLInputElement>) => onTenantIdChange(event.target.value)}
onChange={onTenantIdChange}
/>
</div>
</div>
......@@ -125,7 +82,7 @@ export class AzureCredentialsForm extends PureComponent<Props, State> {
className="width-30"
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value={clientId || ''}
onChange={(event: ChangeEvent<HTMLInputElement>) => onClientIdChange(event.target.value)}
onChange={onClientIdChange}
/>
</div>
</div>
......@@ -153,7 +110,7 @@ export class AzureCredentialsForm extends PureComponent<Props, State> {
className="width-30"
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value={clientSecret || ''}
onChange={(event: ChangeEvent<HTMLInputElement>) => onClientSecretChange(event.target.value)}
onChange={onClientSecretChange}
/>
</div>
</div>
......
......@@ -21,7 +21,7 @@ const setup = () => {
withCredentials: false,
isDefault: false,
jsonData: {
subscriptionId: '',
subscriptionId: '44987801-6nn6-49he-9b2d-9106972f9789',
azureLogAnalyticsSameAs: true,
cloudName: 'azuremonitor',
},
......
......@@ -4,7 +4,7 @@ import InsightsConfig, { Props } from './InsightsConfig';
const setup = (propOverrides?: object) => {
const props: Props = {
datasourceConfig: {
options: {
id: 21,
orgId: 1,
name: 'Azure Monitor-10-10',
......@@ -24,15 +24,18 @@ const setup = (propOverrides?: object) => {
appInsightsApiKey: false,
},
jsonData: {
appInsightsAppId: 'cddcc020-2c94-460a-a3d0-df3147ffa792',
cloudName: '',
subscriptionId: '',
appInsightsAppId: 'cvvcc020-2cpo-123a-a3d0-df6547fki792',
},
secureJsonData: {
appInsightsApiKey: 'e7f3f661-a933-4b3f-8176-51c4f982ec48',
appInsightsApiKey: 'e7f3f775-a987-4b3f-3835-51c4f982kl48',
},
version: 1,
readOnly: false,
},
onDatasourceUpdate: jest.fn(),
onUpdateOption: jest.fn(),
onResetOptionKey: jest.fn(),
};
Object.assign(props, propOverrides);
......
import React, { PureComponent } from 'react';
import React, { PureComponent, ChangeEvent } from 'react';
import { FormLabel, Button, Input } from '@grafana/ui';
import { AzureDataSourceSettings } from '../types';
export interface Props {
datasourceConfig: any;
onDatasourceUpdate: (config: any) => void;
options: AzureDataSourceSettings;
onUpdateOption: (key: string, val: any, secure: boolean) => void;
onResetOptionKey: (key: string) => void;
}
export interface State {
config: any;
}
export class InsightsConfig extends PureComponent<Props, State> {
constructor(props: Props) {
super(props);
const { datasourceConfig } = this.props;
this.state = {
config: datasourceConfig,
};
}
static getDerivedStateFromProps(props: Props, state: State) {
return {
...state,
config: props.datasourceConfig,
};
}
onAppInsightsAppIdChange = (appInsightsAppId: string) => {
this.props.onDatasourceUpdate({
...this.state.config,
jsonData: {
...this.state.config.jsonData,
appInsightsAppId,
},
});
export class InsightsConfig extends PureComponent<Props> {
onAppInsightsAppIdChange = (event: ChangeEvent<HTMLInputElement>) => {
this.props.onUpdateOption('appInsightsAppId', event.target.value, false);
};
onAppInsightsApiKeyChange = (appInsightsApiKey: string) => {
this.props.onDatasourceUpdate({
...this.state.config,
secureJsonData: {
...this.state.config.secureJsonData,
appInsightsApiKey,
},
});
onAppInsightsApiKeyChange = (event: ChangeEvent<HTMLInputElement>) => {
this.props.onUpdateOption('appInsightsApiKey', event.target.value, true);
};
onAppInsightsResetApiKey = () => {
this.props.onDatasourceUpdate({
...this.state.config,
version: this.state.config.version + 1,
secureJsonFields: {
...this.state.config.secureJsonFields,
appInsightsApiKey: false,
},
});
this.props.onResetOptionKey('appInsightsApiKey');
};
render() {
const { config } = this.state;
const { options } = this.props;
return (
<>
<h3 className="page-heading">Application Insights Details</h3>
<div className="gf-form-group">
{config.secureJsonFields.appInsightsApiKey ? (
{options.secureJsonFields.appInsightsApiKey ? (
<div className="gf-form-inline">
<div className="gf-form">
<FormLabel className="width-12">API Key</FormLabel>
......@@ -87,8 +48,8 @@ export class InsightsConfig extends PureComponent<Props, State> {
<Input
className="width-30"
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value={config.secureJsonData.appInsightsApiKey || ''}
onChange={event => this.onAppInsightsApiKeyChange(event.target.value)}
value={options.secureJsonData.appInsightsApiKey || ''}
onChange={this.onAppInsightsApiKeyChange}
/>
</div>
</div>
......@@ -100,8 +61,8 @@ export class InsightsConfig extends PureComponent<Props, State> {
<div className="width-15">
<Input
className="width-30"
value={config.jsonData.appInsightsAppId || ''}
onChange={event => this.onAppInsightsAppIdChange(event.target.value)}
value={options.jsonData.appInsightsAppId || ''}
onChange={this.onAppInsightsAppIdChange}
/>
</div>
</div>
......
import React, { PureComponent } from 'react';
import React, { PureComponent, ChangeEvent } from 'react';
import { SelectableValue } from '@grafana/data';
import { AzureCredentialsForm } from './AzureCredentialsForm';
import { AzureDataSourceSettings } from '../types';
const azureClouds = [
{ value: 'azuremonitor', label: 'Azure' },
{ value: 'govazuremonitor', label: 'Azure US Government' },
{ value: 'germanyazuremonitor', label: 'Azure Germany' },
{ value: 'chinaazuremonitor', label: 'Azure China' },
] as SelectableValue[];
export interface Props {
datasourceConfig: any;
options: AzureDataSourceSettings;
subscriptions: SelectableValue[];
onDatasourceUpdate: (config: any) => void;
onUpdateOption: (key: string, val: any, secure: boolean) => void;
onResetOptionKey: (key: string) => void;
onLoadSubscriptions: () => void;
}
export interface State {
config: any;
azureClouds: SelectableValue[];
subscriptions: SelectableValue[];
}
export class MonitorConfig extends PureComponent<Props, State> {
constructor(props: Props) {
super(props);
const { datasourceConfig } = this.props;
this.state = {
config: datasourceConfig,
azureClouds: [
{ value: 'azuremonitor', label: 'Azure' },
{ value: 'govazuremonitor', label: 'Azure US Government' },
{ value: 'germanyazuremonitor', label: 'Azure Germany' },
{ value: 'chinaazuremonitor', label: 'Azure China' },
],
subscriptions: [],
};
}
static getDerivedStateFromProps(props: Props, state: State) {
return {
...state,
config: props.datasourceConfig,
subscriptions: props.subscriptions,
};
}
export class MonitorConfig extends PureComponent<Props> {
onAzureCloudSelect = (cloudName: SelectableValue<string>) => {
this.props.onDatasourceUpdate({
...this.state.config,
jsonData: {
...this.state.config.jsonData,
cloudName: cloudName.value,
},
});
this.props.onUpdateOption('cloudName', cloudName.value, false);
};
onTenantIdChange = (tenantId: string) => {
this.props.onDatasourceUpdate({
...this.state.config,
jsonData: {
...this.state.config.jsonData,
tenantId,
},
});
onTenantIdChange = (event: ChangeEvent<HTMLInputElement>) => {
this.props.onUpdateOption('tenantId', event.target.value, false);
};
onClientIdChange = (clientId: string) => {
this.props.onDatasourceUpdate({
...this.state.config,
jsonData: {
...this.state.config.jsonData,
clientId,
},
});
onClientIdChange = (event: ChangeEvent<HTMLInputElement>) => {
this.props.onUpdateOption('clientId', event.target.value, false);
};
onClientSecretChange = (clientSecret: string) => {
this.props.onDatasourceUpdate({
...this.state.config,
secureJsonData: {
...this.state.config.secureJsonData,
clientSecret,
},
});
onClientSecretChange = (event: ChangeEvent<HTMLInputElement>) => {
this.props.onUpdateOption('clientSecret', event.target.value, true);
};
onResetClientSecret = () => {
this.props.onDatasourceUpdate({
...this.state.config,
version: this.state.config.version + 1,
secureJsonFields: {
...this.state.config.secureJsonFields,
clientSecret: false,
},
});
this.props.onResetOptionKey('clientSecret');
};
onSubscriptionSelect = (subscription: SelectableValue<string>) => {
this.props.onDatasourceUpdate({
...this.state.config,
jsonData: {
...this.state.config.jsonData,
subscriptionId: subscription.value,
},
});
this.props.onUpdateOption('subscriptionId', subscription.value, false);
};
render() {
const { azureClouds, config, subscriptions } = this.state;
const { options, subscriptions } = this.props;
return (
<>
<h3 className="page-heading">Azure Monitor Details</h3>
<AzureCredentialsForm
selectedAzureCloud={config.jsonData.cloudName}
selectedAzureCloud={options.jsonData.cloudName || 'azuremonitor'}
azureCloudOptions={azureClouds}
subscriptionOptions={subscriptions}
selectedSubscription={config.jsonData.subscriptionId}
tenantId={config.jsonData.tenantId}
clientId={config.jsonData.clientId}
clientSecret={config.secureJsonData.clientSecret}
clientSecretConfigured={config.secureJsonFields.clientSecret}
selectedSubscription={options.jsonData.subscriptionId}
tenantId={options.jsonData.tenantId}
clientId={options.jsonData.clientId}
clientSecret={options.secureJsonData.clientSecret}
clientSecretConfigured={options.secureJsonFields.clientSecret}
onAzureCloudChange={this.onAzureCloudSelect}
onSubscriptionSelectChange={this.onSubscriptionSelect}
onTenantIdChange={this.onTenantIdChange}
......
......@@ -86,9 +86,9 @@ exports[`Render should disable azure monitor secret input 1`] = `
>
<Input
className="width-30"
onChange={[Function]}
onChange={[MockFunction]}
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value="e7f3f661-a933-4b3f-8176-51c4f982ec48"
value="e7f3f661-a933-3h3f-0294-31c4f962ec48"
/>
</div>
</div>
......@@ -109,9 +109,9 @@ exports[`Render should disable azure monitor secret input 1`] = `
>
<Input
className="width-30"
onChange={[Function]}
onChange={[MockFunction]}
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value="77409fad-c0a9-45df-9e25-f1ff95af6554"
value="34509fad-c0r9-45df-9e25-f1ee34af6900"
/>
</div>
</div>
......@@ -177,7 +177,7 @@ exports[`Render should disable azure monitor secret input 1`] = `
"SingleValue": [Function],
}
}
defaultValue="44693801-6ee6-49de-9b2d-9106972f9572"
defaultValue="44987801-6nn6-49he-9b2d-9106972f9789"
isClearable={false}
isDisabled={false}
isLoading={false}
......@@ -303,9 +303,9 @@ exports[`Render should enable azure monitor load subscriptions button 1`] = `
>
<Input
className="width-30"
onChange={[Function]}
onChange={[MockFunction]}
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value="e7f3f661-a933-4b3f-8176-51c4f982ec48"
value="e7f3f661-a933-3h3f-0294-31c4f962ec48"
/>
</div>
</div>
......@@ -326,9 +326,9 @@ exports[`Render should enable azure monitor load subscriptions button 1`] = `
>
<Input
className="width-30"
onChange={[Function]}
onChange={[MockFunction]}
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value="77409fad-c0a9-45df-9e25-f1ff95af6554"
value="34509fad-c0r9-45df-9e25-f1ee34af6900"
/>
</div>
</div>
......@@ -349,7 +349,7 @@ exports[`Render should enable azure monitor load subscriptions button 1`] = `
>
<Input
className="width-30"
onChange={[Function]}
onChange={[MockFunction]}
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value="e7f3f661-a933-4b3f-8176-51c4f982ec48"
/>
......@@ -384,7 +384,7 @@ exports[`Render should enable azure monitor load subscriptions button 1`] = `
"SingleValue": [Function],
}
}
defaultValue="44693801-6ee6-49de-9b2d-9106972f9572"
defaultValue="44987801-6nn6-49he-9b2d-9106972f9789"
isClearable={false}
isDisabled={false}
isLoading={false}
......@@ -510,9 +510,9 @@ exports[`Render should render component 1`] = `
>
<Input
className="width-30"
onChange={[Function]}
onChange={[MockFunction]}
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value="e7f3f661-a933-4b3f-8176-51c4f982ec48"
value="e7f3f661-a933-3h3f-0294-31c4f962ec48"
/>
</div>
</div>
......@@ -533,9 +533,9 @@ exports[`Render should render component 1`] = `
>
<Input
className="width-30"
onChange={[Function]}
onChange={[MockFunction]}
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value="77409fad-c0a9-45df-9e25-f1ff95af6554"
value="34509fad-c0r9-45df-9e25-f1ee34af6900"
/>
</div>
</div>
......@@ -556,7 +556,7 @@ exports[`Render should render component 1`] = `
>
<Input
className="width-30"
onChange={[Function]}
onChange={[MockFunction]}
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value=""
/>
......@@ -591,7 +591,7 @@ exports[`Render should render component 1`] = `
"SingleValue": [Function],
}
}
defaultValue="44693801-6ee6-49de-9b2d-9106972f9572"
defaultValue="44987801-6nn6-49he-9b2d-9106972f9789"
isClearable={false}
isDisabled={false}
isLoading={false}
......
......@@ -3,7 +3,10 @@
exports[`Render should render component 1`] = `
<Fragment>
<MonitorConfig
datasourceConfig={
onLoadSubscriptions={[Function]}
onResetOptionKey={[Function]}
onUpdateOption={[Function]}
options={
Object {
"access": "proxy",
"basicAuth": false,
......@@ -15,6 +18,7 @@ exports[`Render should render component 1`] = `
"jsonData": Object {
"azureLogAnalyticsSameAs": true,
"cloudName": "azuremonitor",
"subscriptionId": "44987801-6nn6-49he-9b2d-9106972f9789",
},
"name": "Azure Monitor-10-10",
"orgId": 1,
......@@ -24,18 +28,20 @@ exports[`Render should render component 1`] = `
"secureJsonFields": Object {},
"type": "grafana-azure-monitor-datasource",
"typeLogoUrl": "",
"url": "/api/datasources/proxy/21",
"url": "",
"user": "",
"version": 1,
"withCredentials": false,
}
}
onDatasourceUpdate={[Function]}
onLoadSubscriptions={[Function]}
subscriptions={Array []}
/>
<AnalyticsConfig
datasourceConfig={
onLoadSubscriptions={[Function]}
onLoadWorkspaces={[Function]}
onResetOptionKey={[Function]}
onUpdateOption={[Function]}
options={
Object {
"access": "proxy",
"basicAuth": false,
......@@ -47,6 +53,7 @@ exports[`Render should render component 1`] = `
"jsonData": Object {
"azureLogAnalyticsSameAs": true,
"cloudName": "azuremonitor",
"subscriptionId": "44987801-6nn6-49he-9b2d-9106972f9789",
},
"name": "Azure Monitor-10-10",
"orgId": 1,
......@@ -56,20 +63,19 @@ exports[`Render should render component 1`] = `
"secureJsonFields": Object {},
"type": "grafana-azure-monitor-datasource",
"typeLogoUrl": "",
"url": "/api/datasources/proxy/21",
"url": "",
"user": "",
"version": 1,
"withCredentials": false,
}
}
logAnalyticsSubscriptions={Array []}
logAnalyticsWorkspaces={Array []}
onDatasourceUpdate={[Function]}
onLoadSubscriptions={[Function]}
onLoadWorkspaces={[Function]}
subscriptions={Array []}
workspaces={Array []}
/>
<InsightsConfig
datasourceConfig={
onResetOptionKey={[Function]}
onUpdateOption={[Function]}
options={
Object {
"access": "proxy",
"basicAuth": false,
......@@ -81,6 +87,7 @@ exports[`Render should render component 1`] = `
"jsonData": Object {
"azureLogAnalyticsSameAs": true,
"cloudName": "azuremonitor",
"subscriptionId": "44987801-6nn6-49he-9b2d-9106972f9789",
},
"name": "Azure Monitor-10-10",
"orgId": 1,
......@@ -90,13 +97,12 @@ exports[`Render should render component 1`] = `
"secureJsonFields": Object {},
"type": "grafana-azure-monitor-datasource",
"typeLogoUrl": "",
"url": "/api/datasources/proxy/21",
"url": "",
"user": "",
"version": 1,
"withCredentials": false,
}
}
onDatasourceUpdate={[Function]}
/>
</Fragment>
`;
......@@ -21,25 +21,15 @@ exports[`Render should disable insights api key input 1`] = `
>
API Key
</Component>
<Input
className="width-25"
disabled={true}
placeholder="configured"
/>
</div>
<div
className="gf-form"
>
<div
className="max-width-30 gf-form-inline"
className="width-15"
>
<Button
onClick={[Function]}
type="button"
variant="secondary"
>
reset
</Button>
<Input
className="width-30"
onChange={[Function]}
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value="e7f3f775-a987-4b3f-3835-51c4f982kl48"
/>
</div>
</div>
</div>
......@@ -60,7 +50,7 @@ exports[`Render should disable insights api key input 1`] = `
<Input
className="width-30"
onChange={[Function]}
value="cddcc020-2c94-460a-a3d0-df3147ffa792"
value="cvvcc020-2cpo-123a-a3d0-df6547fki792"
/>
</div>
</div>
......@@ -97,7 +87,7 @@ exports[`Render should enable insights api key input 1`] = `
className="width-30"
onChange={[Function]}
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value="e7f3f661-a933-4b3f-8176-51c4f982ec48"
value="e7f3f775-a987-4b3f-3835-51c4f982kl48"
/>
</div>
</div>
......@@ -119,7 +109,7 @@ exports[`Render should enable insights api key input 1`] = `
<Input
className="width-30"
onChange={[Function]}
value="cddcc020-2c94-460a-a3d0-df3147ffa792"
value="cvvcc020-2cpo-123a-a3d0-df6547fki792"
/>
</div>
</div>
......@@ -156,7 +146,7 @@ exports[`Render should render component 1`] = `
className="width-30"
onChange={[Function]}
placeholder="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
value="e7f3f661-a933-4b3f-8176-51c4f982ec48"
value="e7f3f775-a987-4b3f-3835-51c4f982kl48"
/>
</div>
</div>
......@@ -178,7 +168,7 @@ exports[`Render should render component 1`] = `
<Input
className="width-30"
onChange={[Function]}
value="cddcc020-2c94-460a-a3d0-df3147ffa792"
value="cvvcc020-2cpo-123a-a3d0-df6547fki792"
/>
</div>
</div>
......
import { DataQuery, DataSourceJsonData } from '@grafana/data';
import { DataQuery, DataSourceJsonData, DataSourceSettings } from '@grafana/data';
export type AzureDataSourceSettings = DataSourceSettings<AzureDataSourceJsonData, AzureDataSourceSecureJsonData>;
export interface AzureMonitorQuery extends DataQuery {
refId: string;
......@@ -29,8 +31,9 @@ export interface AzureDataSourceJsonData extends DataSourceJsonData {
}
export interface AzureDataSourceSecureJsonData {
clientSecret: string;
logAnalyticsClientSecret: string;
clientSecret?: string;
logAnalyticsClientSecret?: string;
appInsightsApiKey?: string;
}
export interface AzureMetricQuery {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment