mirror of
https://github.com/grafana/grafana.git
synced 2025-01-24 23:37:01 -06:00
Add a button to clear Azure Monitor Logs credentials (#36256)
This commit is contained in:
parent
1ab452e88a
commit
759f9c44cb
@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { render, screen } from '@testing-library/react';
|
import { render, screen } from '@testing-library/react';
|
||||||
import AnalyticsConfig, { Props } from './AnalyticsConfig';
|
import AnalyticsConfig, { Props } from './AnalyticsConfig';
|
||||||
|
import userEvent from '@testing-library/user-event';
|
||||||
|
|
||||||
const setup = (propsFunc?: (props: Props) => Props) => {
|
const setup = (propsFunc?: (props: Props) => Props) => {
|
||||||
let props: Props = {
|
let props: Props = {
|
||||||
@ -103,6 +104,26 @@ describe('Render', () => {
|
|||||||
expect(screen.queryByText('is no longer supported', { exact: false })).toBeInTheDocument();
|
expect(screen.queryByText('is no longer supported', { exact: false })).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should clean up the error when reseting the credentials', async () => {
|
||||||
|
const onUpdate = jest.fn();
|
||||||
|
setup((props) => ({
|
||||||
|
...props,
|
||||||
|
options: {
|
||||||
|
...props.options,
|
||||||
|
jsonData: {
|
||||||
|
...props.options.jsonData,
|
||||||
|
azureLogAnalyticsSameAs: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
updateOptions: onUpdate,
|
||||||
|
}));
|
||||||
|
expect(screen.queryByText('is no longer supported', { exact: false })).toBeInTheDocument();
|
||||||
|
userEvent.click(screen.getByText('Clear Azure Monitor Logs Credentials'));
|
||||||
|
expect(onUpdate).toHaveBeenCalled();
|
||||||
|
const newOpts = onUpdate.mock.calls[0][0]({});
|
||||||
|
expect(newOpts).toEqual({ jsonData: { azureLogAnalyticsSameAs: true } });
|
||||||
|
});
|
||||||
|
|
||||||
it('should disable inputs', () => {
|
it('should disable inputs', () => {
|
||||||
setup((props) => ({
|
setup((props) => ({
|
||||||
...props,
|
...props,
|
||||||
|
@ -91,6 +91,18 @@ export const AnalyticsConfig: FunctionComponent<Props> = (props: Props) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onClearAzLogsCreds = () => {
|
||||||
|
updateOptions((options) => {
|
||||||
|
return {
|
||||||
|
...options,
|
||||||
|
jsonData: {
|
||||||
|
...options.jsonData,
|
||||||
|
azureLogAnalyticsSameAs: true,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h3 className="page-heading">Azure Monitor Logs</h3>
|
<h3 className="page-heading">Azure Monitor Logs</h3>
|
||||||
@ -113,7 +125,9 @@ export const AnalyticsConfig: FunctionComponent<Props> = (props: Props) => {
|
|||||||
}}
|
}}
|
||||||
getSubscriptions={getSubscriptions}
|
getSubscriptions={getSubscriptions}
|
||||||
disabled={true}
|
disabled={true}
|
||||||
/>
|
>
|
||||||
|
<Button onClick={onClearAzLogsCreds}>Clear Azure Monitor Logs Credentials</Button>
|
||||||
|
</AzureCredentialsForm>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<div className="gf-form-group">
|
<div className="gf-form-group">
|
||||||
|
@ -95,5 +95,14 @@ describe('Render', () => {
|
|||||||
const selects = wrapper.find(Select);
|
const selects = wrapper.find(Select);
|
||||||
selects.forEach((s) => expect(s.prop('isDisabled')).toBe(true));
|
selects.forEach((s) => expect(s.prop('isDisabled')).toBe(true));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should render a children component', () => {
|
||||||
|
const wrapper = setup((props) => ({
|
||||||
|
...props,
|
||||||
|
children: <button>click me</button>,
|
||||||
|
}));
|
||||||
|
const button = wrapper.find('button');
|
||||||
|
expect(button.text()).toBe('click me');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -12,6 +12,7 @@ export interface Props {
|
|||||||
onCredentialsChange?: (updatedCredentials: AzureCredentials) => void;
|
onCredentialsChange?: (updatedCredentials: AzureCredentials) => void;
|
||||||
getSubscriptions?: () => Promise<SelectableValue[]>;
|
getSubscriptions?: () => Promise<SelectableValue[]>;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
children?: JSX.Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
const authTypeOptions: Array<SelectableValue<AzureAuthType>> = [
|
const authTypeOptions: Array<SelectableValue<AzureAuthType>> = [
|
||||||
@ -282,6 +283,7 @@ export const AzureCredentialsForm: FunctionComponent<Props> = (props: Props) =>
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{props.children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -284,6 +284,15 @@ exports[`Render should enable azure log analytics load workspaces button 1`] = `
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<button
|
||||||
|
class="css-5tn967-button"
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
class="css-1mhnkuh"
|
||||||
|
>
|
||||||
|
Clear Azure Monitor Logs Credentials
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="gf-form-group"
|
class="gf-form-group"
|
||||||
|
Loading…
Reference in New Issue
Block a user