mirror of
https://github.com/grafana/grafana.git
synced 2026-08-08 20:28:14 -05:00
Cloudwatch: remove direct import on getDatasourceSrv (#80660)
Cloudwatch: remove direct import on getDatasourceSrv
This commit is contained in:
+3
-5
@@ -15,11 +15,6 @@ import { ConfigEditor, Props } from './ConfigEditor';
|
||||
|
||||
const datasource = new CloudWatchDatasource(CloudWatchSettings);
|
||||
const loadDataSourceMock = jest.fn();
|
||||
jest.mock('app/features/plugins/datasource_srv', () => ({
|
||||
getDatasourceSrv: () => ({
|
||||
loadDatasource: loadDataSourceMock,
|
||||
}),
|
||||
}));
|
||||
|
||||
jest.mock('./XrayLinkConfig', () => ({
|
||||
XrayLinkConfig: () => <></>,
|
||||
@@ -36,6 +31,9 @@ jest.mock('@grafana/runtime', () => ({
|
||||
put: putMock,
|
||||
get: getMock,
|
||||
}),
|
||||
getDataSourceSrv: () => ({
|
||||
get: loadDataSourceMock,
|
||||
}),
|
||||
getAppEvents: () => mockAppEvents,
|
||||
config: {
|
||||
...jest.requireActual('@grafana/runtime').config,
|
||||
|
||||
@@ -11,11 +11,10 @@ import {
|
||||
DataSourceTestFailed,
|
||||
} from '@grafana/data';
|
||||
import { ConfigSection } from '@grafana/experimental';
|
||||
import { getAppEvents, usePluginInteractionReporter, config } from '@grafana/runtime';
|
||||
import { getAppEvents, usePluginInteractionReporter, getDataSourceSrv, config } from '@grafana/runtime';
|
||||
import { Input, InlineField, FieldProps, SecureSocksProxySettings, Field, Divider } from '@grafana/ui';
|
||||
import { notifyApp } from 'app/core/actions';
|
||||
import { createWarningNotification } from 'app/core/copy/appNotification';
|
||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||
import { store } from 'app/store/store';
|
||||
|
||||
import { CloudWatchDatasource } from '../../datasource';
|
||||
@@ -296,8 +295,8 @@ function useDatasource(props: Props) {
|
||||
|
||||
useEffect(() => {
|
||||
if (props.options.version) {
|
||||
getDatasourceSrv()
|
||||
.loadDatasource(props.options.name)
|
||||
getDataSourceSrv()
|
||||
.get(props.options.name)
|
||||
.then((datasource) => {
|
||||
if (datasource instanceof CloudWatchDatasource) {
|
||||
setDatasource(datasource);
|
||||
|
||||
@@ -3,9 +3,8 @@ import React from 'react';
|
||||
|
||||
import { GrafanaTheme2, DataSourceInstanceSettings } from '@grafana/data';
|
||||
import { ConfigSection } from '@grafana/experimental';
|
||||
import { DataSourcePicker } from '@grafana/runtime';
|
||||
import { DataSourcePicker, getDataSourceSrv } from '@grafana/runtime';
|
||||
import { Alert, Field, InlineField, useStyles2 } from '@grafana/ui';
|
||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||
|
||||
const getStyles = (theme: GrafanaTheme2) => ({
|
||||
infoText: css`
|
||||
@@ -23,7 +22,7 @@ interface Props {
|
||||
const xRayDsId = 'grafana-x-ray-datasource';
|
||||
|
||||
export function XrayLinkConfig({ newFormStyling, datasourceUid, onChange }: Props) {
|
||||
const hasXrayDatasource = Boolean(getDatasourceSrv().getList({ pluginId: xRayDsId }).length);
|
||||
const hasXrayDatasource = Boolean(getDataSourceSrv().getList({ pluginId: xRayDsId }).length);
|
||||
|
||||
const styles = useStyles2(getStyles);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user