mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DSPicker: Use new DS picker everywhere in Grafana (#70609)
This commit is contained in:
@@ -792,9 +792,6 @@ exports[`better eslint`] = {
|
|||||||
"packages/grafana-runtime/src/analytics/types.ts:5381": [
|
"packages/grafana-runtime/src/analytics/types.ts:5381": [
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||||
],
|
],
|
||||||
"packages/grafana-runtime/src/components/DataSourcePicker.tsx:5381": [
|
|
||||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
|
|
||||||
],
|
|
||||||
"packages/grafana-runtime/src/components/PanelRenderer.tsx:5381": [
|
"packages/grafana-runtime/src/components/PanelRenderer.tsx:5381": [
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||||
|
|||||||
@@ -38,10 +38,9 @@ describe('Variables - Query - Add variable', () => {
|
|||||||
e2e().get('label').contains('Show on dashboard').should('be.visible');
|
e2e().get('label').contains('Show on dashboard').should('be.visible');
|
||||||
|
|
||||||
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsDataSourceSelect()
|
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsDataSourceSelect()
|
||||||
.should('be.visible')
|
.get('input[placeholder="gdev-testdata"]')
|
||||||
.within((select) => {
|
.scrollIntoView()
|
||||||
e2e.components.Select.singleValue().should('have.text', 'gdev-testdata');
|
.should('be.visible');
|
||||||
});
|
|
||||||
|
|
||||||
e2e().get('label').contains('Refresh').scrollIntoView().should('be.visible');
|
e2e().get('label').contains('Refresh').scrollIntoView().should('be.visible');
|
||||||
e2e().get('label').contains('On dashboard load').scrollIntoView().should('be.visible');
|
e2e().get('label').contains('On dashboard load').scrollIntoView().should('be.visible');
|
||||||
@@ -89,7 +88,7 @@ describe('Variables - Query - Add variable', () => {
|
|||||||
|
|
||||||
e2e().get('[placeholder="Descriptive text"]').should('be.visible').clear().type('a description');
|
e2e().get('[placeholder="Descriptive text"]').should('be.visible').clear().type('a description');
|
||||||
|
|
||||||
e2e.components.DataSourcePicker.inputV2().should('be.visible').type('gdev-testdata{enter}');
|
e2e.components.DataSourcePicker.container().should('be.visible').type('gdev-testdata{enter}');
|
||||||
|
|
||||||
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsQueryInput()
|
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsQueryInput()
|
||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
@@ -137,7 +136,7 @@ describe('Variables - Query - Add variable', () => {
|
|||||||
|
|
||||||
e2e().get('[placeholder="Descriptive text"]').should('be.visible').clear().type('a description');
|
e2e().get('[placeholder="Descriptive text"]').should('be.visible').clear().type('a description');
|
||||||
|
|
||||||
e2e.components.DataSourcePicker.inputV2().type('gdev-testdata{enter}');
|
e2e.components.DataSourcePicker.container().type('gdev-testdata{enter}');
|
||||||
|
|
||||||
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsQueryInput()
|
e2e.pages.Dashboard.Settings.Variables.Edit.QueryVariable.queryOptionsQueryInput()
|
||||||
.should('be.visible')
|
.should('be.visible')
|
||||||
|
|||||||
@@ -307,7 +307,7 @@ export const Components = {
|
|||||||
* @deprecated use inputV2 instead
|
* @deprecated use inputV2 instead
|
||||||
*/
|
*/
|
||||||
input: () => 'input[id="data-source-picker"]',
|
input: () => 'input[id="data-source-picker"]',
|
||||||
inputV2: 'Select a data source',
|
inputV2: 'data-testid Select a data source',
|
||||||
},
|
},
|
||||||
TimeZonePicker: {
|
TimeZonePicker: {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -188,7 +188,8 @@ export class DataSourcePicker extends PureComponent<DataSourcePickerProps, DataS
|
|||||||
<Select
|
<Select
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
aria-label={selectors.components.DataSourcePicker.inputV2}
|
aria-label={'Select a data source'}
|
||||||
|
data-testid={selectors.components.DataSourcePicker.inputV2}
|
||||||
inputId={inputId || 'data-source-picker'}
|
inputId={inputId || 'data-source-picker'}
|
||||||
className="ds-picker select-container"
|
className="ds-picker select-container"
|
||||||
isMulti={false}
|
isMulti={false}
|
||||||
|
|||||||
@@ -3,9 +3,9 @@ import React, { useCallback, useMemo } from 'react';
|
|||||||
|
|
||||||
import { DataSourceJsonData, DataSourceInstanceSettings, DataSourcePluginOptionsEditorProps } from '@grafana/data';
|
import { DataSourceJsonData, DataSourceInstanceSettings, DataSourcePluginOptionsEditorProps } from '@grafana/data';
|
||||||
import { ConfigSection } from '@grafana/experimental';
|
import { ConfigSection } from '@grafana/experimental';
|
||||||
import { DataSourcePicker } from '@grafana/runtime';
|
|
||||||
import { InlineField, InlineFieldRow, Input, InlineSwitch } from '@grafana/ui';
|
import { InlineField, InlineFieldRow, Input, InlineSwitch } from '@grafana/ui';
|
||||||
import { ConfigDescriptionLink } from 'app/core/components/ConfigDescriptionLink';
|
import { ConfigDescriptionLink } from 'app/core/components/ConfigDescriptionLink';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
|
|
||||||
import { IntervalInput } from '../IntervalInput/IntervalInput';
|
import { IntervalInput } from '../IntervalInput/IntervalInput';
|
||||||
|
|
||||||
|
|||||||
@@ -2,14 +2,15 @@ import { css } from '@emotion/css';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
DataSourceInstanceSettings,
|
||||||
DataSourceJsonData,
|
DataSourceJsonData,
|
||||||
DataSourcePluginOptionsEditorProps,
|
DataSourcePluginOptionsEditorProps,
|
||||||
GrafanaTheme2,
|
GrafanaTheme2,
|
||||||
updateDatasourcePluginJsonDataOption,
|
updateDatasourcePluginJsonDataOption,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { ConfigSection } from '@grafana/experimental';
|
import { ConfigSection } from '@grafana/experimental';
|
||||||
import { DataSourcePicker } from '@grafana/runtime';
|
|
||||||
import { Button, InlineField, InlineFieldRow, Input, useStyles2 } from '@grafana/ui';
|
import { Button, InlineField, InlineFieldRow, Input, useStyles2 } from '@grafana/ui';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
|
|
||||||
import { ConfigDescriptionLink } from '../ConfigDescriptionLink';
|
import { ConfigDescriptionLink } from '../ConfigDescriptionLink';
|
||||||
import { IntervalInput } from '../IntervalInput/IntervalInput';
|
import { IntervalInput } from '../IntervalInput/IntervalInput';
|
||||||
@@ -52,7 +53,7 @@ export function TraceToMetricsSettings({ options, onOptionsChange }: Props) {
|
|||||||
current={options.jsonData.tracesToMetrics?.datasourceUid}
|
current={options.jsonData.tracesToMetrics?.datasourceUid}
|
||||||
noDefault={true}
|
noDefault={true}
|
||||||
width={40}
|
width={40}
|
||||||
onChange={(ds) =>
|
onChange={(ds: DataSourceInstanceSettings) =>
|
||||||
updateDatasourcePluginJsonDataOption({ onOptionsChange, options }, 'tracesToMetrics', {
|
updateDatasourcePluginJsonDataOption({ onOptionsChange, options }, 'tracesToMetrics', {
|
||||||
...options.jsonData.tracesToMetrics,
|
...options.jsonData.tracesToMetrics,
|
||||||
datasourceUid: ds.uid,
|
datasourceUid: ds.uid,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React, { useCallback } from 'react';
|
|||||||
import { useAsync } from 'react-use';
|
import { useAsync } from 'react-use';
|
||||||
|
|
||||||
import { DataSourceInstanceSettings } from '@grafana/data';
|
import { DataSourceInstanceSettings } from '@grafana/data';
|
||||||
import { DataSourcePicker } from '@grafana/runtime';
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
import { dispatch } from 'app/store/store';
|
import { dispatch } from 'app/store/store';
|
||||||
|
|
||||||
import { useRulesSourcesWithRuler } from '../../hooks/useRuleSourcesWithRuler';
|
import { useRulesSourcesWithRuler } from '../../hooks/useRuleSourcesWithRuler';
|
||||||
@@ -28,14 +28,6 @@ export function CloudRulesSourcePicker({ value, ...props }: Props): JSX.Element
|
|||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DataSourcePicker
|
<DataSourcePicker disabled={loading} noDefault alerting filter={dataSourceFilter} current={value} {...props} />
|
||||||
disabled={loading}
|
|
||||||
isLoading={loading}
|
|
||||||
noDefault
|
|
||||||
alerting
|
|
||||||
filter={dataSourceFilter}
|
|
||||||
current={value}
|
|
||||||
{...props}
|
|
||||||
/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import React from 'react';
|
|||||||
import { Controller, useFormContext } from 'react-hook-form';
|
import { Controller, useFormContext } from 'react-hook-form';
|
||||||
|
|
||||||
import { DataSourceInstanceSettings, GrafanaTheme2 } from '@grafana/data';
|
import { DataSourceInstanceSettings, GrafanaTheme2 } from '@grafana/data';
|
||||||
import { DataSourcePicker } from '@grafana/runtime';
|
|
||||||
import { Card, Field, FieldSet, Input, useStyles2 } from '@grafana/ui';
|
import { Card, Field, FieldSet, Input, useStyles2 } from '@grafana/ui';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||||
|
|
||||||
import { getVariableUsageInfo } from '../../explore/utils/links';
|
import { getVariableUsageInfo } from '../../explore/utils/links';
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import React from 'react';
|
|||||||
import { Controller, useFormContext, useWatch } from 'react-hook-form';
|
import { Controller, useFormContext, useWatch } from 'react-hook-form';
|
||||||
|
|
||||||
import { DataSourceInstanceSettings } from '@grafana/data';
|
import { DataSourceInstanceSettings } from '@grafana/data';
|
||||||
import { DataSourcePicker } from '@grafana/runtime';
|
|
||||||
import { Field, FieldSet } from '@grafana/ui';
|
import { Field, FieldSet } from '@grafana/ui';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
|
|
||||||
import { QueryEditorField } from './QueryEditorField';
|
import { QueryEditorField } from './QueryEditorField';
|
||||||
import { useCorrelationsFormContext } from './correlationsFormContext';
|
import { useCorrelationsFormContext } from './correlationsFormContext';
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { Stack } from '@grafana/experimental';
|
import { Stack } from '@grafana/experimental';
|
||||||
import { DataSourcePicker, getDataSourceSrv, locationService } from '@grafana/runtime';
|
import { getDataSourceSrv, locationService } from '@grafana/runtime';
|
||||||
import { AnnotationPanelFilter } from '@grafana/schema/src/raw/dashboard/x/dashboard_types.gen';
|
import { AnnotationPanelFilter } from '@grafana/schema/src/raw/dashboard/x/dashboard_types.gen';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -27,6 +27,7 @@ import {
|
|||||||
import { ColorValueEditor } from 'app/core/components/OptionsUI/color';
|
import { ColorValueEditor } from 'app/core/components/OptionsUI/color';
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
import StandardAnnotationQueryEditor from 'app/features/annotations/components/StandardAnnotationQueryEditor';
|
import StandardAnnotationQueryEditor from 'app/features/annotations/components/StandardAnnotationQueryEditor';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
|
|
||||||
import { DashboardModel } from '../../state/DashboardModel';
|
import { DashboardModel } from '../../state/DashboardModel';
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { DataSourceInstanceSettings, DataSourcePluginMeta, PluginMetaInfo, PluginType } from '@grafana/data';
|
import { DataSourceInstanceSettings, DataSourcePluginMeta, PluginMetaInfo, PluginType } from '@grafana/data';
|
||||||
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { ModalRoot, ModalsProvider } from '@grafana/ui';
|
import { ModalRoot, ModalsProvider } from '@grafana/ui';
|
||||||
import config from 'app/core/config';
|
import config from 'app/core/config';
|
||||||
import { defaultFileUploadQuery } from 'app/plugins/datasource/grafana/types';
|
import { defaultFileUploadQuery } from 'app/plugins/datasource/grafana/types';
|
||||||
@@ -145,7 +146,10 @@ describe('DataSourceDropdown', () => {
|
|||||||
it('should display the current selected DS in the selector', async () => {
|
it('should display the current selected DS in the selector', async () => {
|
||||||
getInstanceSettingsMock.mockReturnValue(mockDS2);
|
getInstanceSettingsMock.mockReturnValue(mockDS2);
|
||||||
render(<DataSourceDropdown onChange={jest.fn()} current={mockDS2}></DataSourceDropdown>);
|
render(<DataSourceDropdown onChange={jest.fn()} current={mockDS2}></DataSourceDropdown>);
|
||||||
expect(screen.getByTestId('Select a data source')).toHaveAttribute('placeholder', mockDS2.name);
|
expect(screen.getByTestId(selectors.components.DataSourcePicker.inputV2)).toHaveAttribute(
|
||||||
|
'placeholder',
|
||||||
|
mockDS2.name
|
||||||
|
);
|
||||||
expect(screen.getByAltText(`${mockDS2.meta.name} logo`)).toBeVisible();
|
expect(screen.getByAltText(`${mockDS2.meta.name} logo`)).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -166,7 +170,10 @@ describe('DataSourceDropdown', () => {
|
|||||||
it('should display the default DS as selected when `current` is not set', async () => {
|
it('should display the default DS as selected when `current` is not set', async () => {
|
||||||
getInstanceSettingsMock.mockReturnValue(mockDS2);
|
getInstanceSettingsMock.mockReturnValue(mockDS2);
|
||||||
render(<DataSourceDropdown onChange={jest.fn()} current={undefined}></DataSourceDropdown>);
|
render(<DataSourceDropdown onChange={jest.fn()} current={undefined}></DataSourceDropdown>);
|
||||||
expect(screen.getByTestId('Select a data source')).toHaveAttribute('placeholder', mockDS2.name);
|
expect(screen.getByTestId(selectors.components.DataSourcePicker.inputV2)).toHaveAttribute(
|
||||||
|
'placeholder',
|
||||||
|
mockDS2.name
|
||||||
|
);
|
||||||
expect(screen.getByAltText(`${mockDS2.meta.name} logo`)).toBeVisible();
|
expect(screen.getByAltText(`${mockDS2.meta.name} logo`)).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -180,12 +187,15 @@ describe('DataSourceDropdown', () => {
|
|||||||
|
|
||||||
it('should disable the dropdown when `disabled` is true', () => {
|
it('should disable the dropdown when `disabled` is true', () => {
|
||||||
render(<DataSourceDropdown onChange={jest.fn()} disabled></DataSourceDropdown>);
|
render(<DataSourceDropdown onChange={jest.fn()} disabled></DataSourceDropdown>);
|
||||||
expect(screen.getByTestId('Select a data source')).toBeDisabled();
|
expect(screen.getByTestId(selectors.components.DataSourcePicker.inputV2)).toBeDisabled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should assign the correct `id` to the input element to pair it with a label', () => {
|
it('should assign the correct `id` to the input element to pair it with a label', () => {
|
||||||
render(<DataSourceDropdown onChange={jest.fn()} inputId={'custom.input.id'}></DataSourceDropdown>);
|
render(<DataSourceDropdown onChange={jest.fn()} inputId={'custom.input.id'}></DataSourceDropdown>);
|
||||||
expect(screen.getByTestId('Select a data source')).toHaveAttribute('id', 'custom.input.id');
|
expect(screen.getByTestId(selectors.components.DataSourcePicker.inputV2)).toHaveAttribute(
|
||||||
|
'id',
|
||||||
|
'custom.input.id'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not set the default DS when setting `noDefault` to true and `current` is not provided', () => {
|
it('should not set the default DS when setting `noDefault` to true and `current` is not provided', () => {
|
||||||
@@ -195,7 +205,10 @@ describe('DataSourceDropdown', () => {
|
|||||||
// Doesn't try to get the default DS
|
// Doesn't try to get the default DS
|
||||||
expect(getListMock).not.toBeCalled();
|
expect(getListMock).not.toBeCalled();
|
||||||
expect(getInstanceSettingsMock).not.toBeCalled();
|
expect(getInstanceSettingsMock).not.toBeCalled();
|
||||||
expect(screen.getByTestId('Select a data source')).toHaveAttribute('placeholder', 'Select data source');
|
expect(screen.getByTestId(selectors.components.DataSourcePicker.inputV2)).toHaveAttribute(
|
||||||
|
'placeholder',
|
||||||
|
'Select data source'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -197,6 +197,7 @@ export function DataSourceDropdown(props: DataSourceDropdownProps) {
|
|||||||
id={inputId || 'data-source-picker'}
|
id={inputId || 'data-source-picker'}
|
||||||
className={inputHasFocus ? undefined : styles.input}
|
className={inputHasFocus ? undefined : styles.input}
|
||||||
data-testid={selectors.components.DataSourcePicker.inputV2}
|
data-testid={selectors.components.DataSourcePicker.inputV2}
|
||||||
|
aria-label="Select a data source"
|
||||||
prefix={currentValue ? prefixIcon : undefined}
|
prefix={currentValue ? prefixIcon : undefined}
|
||||||
suffix={<Icon name={isOpen ? 'search' : 'angle-down'} />}
|
suffix={<Icon name={isOpen ? 'search' : 'angle-down'} />}
|
||||||
placeholder={hideTextValue ? '' : dataSourceLabel(currentValue) || placeholder}
|
placeholder={hideTextValue ? '' : dataSourceLabel(currentValue) || placeholder}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { DataSourcePicker } from '@grafana/runtime';
|
|
||||||
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
|
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
@@ -15,6 +14,7 @@ import {
|
|||||||
Legend,
|
Legend,
|
||||||
} from '@grafana/ui';
|
} from '@grafana/ui';
|
||||||
import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker';
|
import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
DashboardInput,
|
DashboardInput,
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ describe('QueryEditorRowHeader', () => {
|
|||||||
it('should render variables in the data source picker', async () => {
|
it('should render variables in the data source picker', async () => {
|
||||||
renderScenario({ onChangeDataSource: () => {} });
|
renderScenario({ onChangeDataSource: () => {} });
|
||||||
|
|
||||||
const dsSelect = screen.getByLabelText(selectors.components.DataSourcePicker.inputV2);
|
const dsSelect = screen.getByTestId(selectors.components.DataSourcePicker.container).querySelector('input')!;
|
||||||
openMenu(dsSelect);
|
openMenu(dsSelect);
|
||||||
expect(await screen.findByText('${dsVariable}')).toBeInTheDocument();
|
expect(await screen.findByText('${dsVariable}')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -60,12 +60,14 @@ describe('AdHocVariableEditor', () => {
|
|||||||
it('has a datasource select menu', async () => {
|
it('has a datasource select menu', async () => {
|
||||||
render(<AdHocVariableEditor {...props} />);
|
render(<AdHocVariableEditor {...props} />);
|
||||||
|
|
||||||
expect(await screen.findByLabelText(selectors.components.DataSourcePicker.inputV2)).toBeInTheDocument();
|
expect(await screen.getByTestId(selectors.components.DataSourcePicker.container)).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls the callback when changing the datasource', async () => {
|
it('calls the callback when changing the datasource', async () => {
|
||||||
render(<AdHocVariableEditor {...props} />);
|
render(<AdHocVariableEditor {...props} />);
|
||||||
const selectEl = screen.getByLabelText(selectors.components.DataSourcePicker.inputV2);
|
const selectEl = screen
|
||||||
|
.getByTestId(selectors.components.DataSourcePicker.container)
|
||||||
|
.getElementsByTagName('input')[0];
|
||||||
await selectOptionInTest(selectEl, 'Loki');
|
await selectOptionInTest(selectEl, 'Loki');
|
||||||
|
|
||||||
expect(props.changeVariableDatasource).toBeCalledWith(
|
expect(props.changeVariableDatasource).toBeCalledWith(
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import React, { PureComponent } from 'react';
|
|||||||
import { connect, ConnectedProps } from 'react-redux';
|
import { connect, ConnectedProps } from 'react-redux';
|
||||||
|
|
||||||
import { DataSourceInstanceSettings, getDataSourceRef } from '@grafana/data';
|
import { DataSourceInstanceSettings, getDataSourceRef } from '@grafana/data';
|
||||||
import { DataSourcePicker } from '@grafana/runtime';
|
|
||||||
import { Alert, Field } from '@grafana/ui';
|
import { Alert, Field } from '@grafana/ui';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
import { StoreState } from 'app/types';
|
import { StoreState } from 'app/types';
|
||||||
|
|
||||||
import { VariableLegend } from '../editor/VariableLegend';
|
import { VariableLegend } from '../editor/VariableLegend';
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ import { connect, ConnectedProps } from 'react-redux';
|
|||||||
|
|
||||||
import { DataSourceInstanceSettings, getDataSourceRef, LoadingState, SelectableValue } from '@grafana/data';
|
import { DataSourceInstanceSettings, getDataSourceRef, LoadingState, SelectableValue } from '@grafana/data';
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { DataSourcePicker, getTemplateSrv } from '@grafana/runtime';
|
import { getTemplateSrv } from '@grafana/runtime';
|
||||||
import { Field } from '@grafana/ui';
|
import { Field } from '@grafana/ui';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
|
|
||||||
import { StoreState } from '../../../types';
|
import { StoreState } from '../../../types';
|
||||||
import { getTimeSrv } from '../../dashboard/services/TimeSrv';
|
import { getTimeSrv } from '../../dashboard/services/TimeSrv';
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { GrafanaTheme2 } from '@grafana/data';
|
import { GrafanaTheme2, DataSourceInstanceSettings } from '@grafana/data';
|
||||||
import { DataSourcePicker } from '@grafana/runtime';
|
|
||||||
import { Alert, InlineField, useStyles2 } from '@grafana/ui';
|
import { Alert, InlineField, useStyles2 } from '@grafana/ui';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||||
|
|
||||||
const getStyles = (theme: GrafanaTheme2) => ({
|
const getStyles = (theme: GrafanaTheme2) => ({
|
||||||
@@ -51,7 +51,7 @@ export function XrayLinkConfig({ datasourceUid, onChange }: Props) {
|
|||||||
>
|
>
|
||||||
<DataSourcePicker
|
<DataSourcePicker
|
||||||
pluginId={xRayDsId}
|
pluginId={xRayDsId}
|
||||||
onChange={(ds) => onChange(ds.uid)}
|
onChange={(ds: DataSourceInstanceSettings) => onChange(ds.uid)}
|
||||||
current={datasourceUid}
|
current={datasourceUid}
|
||||||
noDefault={true}
|
noDefault={true}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import { css } from '@emotion/css';
|
|||||||
import React, { Dispatch, SetStateAction, useEffect, useState } from 'react';
|
import React, { Dispatch, SetStateAction, useEffect, useState } from 'react';
|
||||||
import { usePrevious } from 'react-use';
|
import { usePrevious } from 'react-use';
|
||||||
|
|
||||||
import { VariableSuggestion } from '@grafana/data';
|
import { DataSourceInstanceSettings, VariableSuggestion } from '@grafana/data';
|
||||||
import { DataSourcePicker } from '@grafana/runtime';
|
|
||||||
import { Button, LegacyForms, DataLinkInput, stylesFactory } from '@grafana/ui';
|
import { Button, LegacyForms, DataLinkInput, stylesFactory } from '@grafana/ui';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
|
|
||||||
import { DataLinkConfig } from '../types';
|
import { DataLinkConfig } from '../types';
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ export const DataLink = (props: Props) => {
|
|||||||
<DataSourcePicker
|
<DataSourcePicker
|
||||||
tracing={true}
|
tracing={true}
|
||||||
// Uid and value should be always set in the db and so in the items.
|
// Uid and value should be always set in the db and so in the items.
|
||||||
onChange={(ds) => {
|
onChange={(ds: DataSourceInstanceSettings) => {
|
||||||
onChange({
|
onChange({
|
||||||
...value,
|
...value,
|
||||||
datasourceUid: ds.uid,
|
datasourceUid: ds.uid,
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ describe('DerivedField', () => {
|
|||||||
);
|
);
|
||||||
expect(await screen.findByText('Name')).toBeInTheDocument();
|
expect(await screen.findByText('Name')).toBeInTheDocument();
|
||||||
|
|
||||||
expect(screen.getByLabelText(selectors.components.DataSourcePicker.inputV2)).toBeInTheDocument();
|
expect(screen.getByTestId(selectors.components.DataSourcePicker.container)).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows url link if uid is not set', async () => {
|
it('shows url link if uid is not set', async () => {
|
||||||
@@ -89,7 +89,7 @@ describe('DerivedField', () => {
|
|||||||
);
|
);
|
||||||
expect(await screen.findByText('Name')).toBeInTheDocument();
|
expect(await screen.findByText('Name')).toBeInTheDocument();
|
||||||
|
|
||||||
expect(screen.queryByLabelText(selectors.components.DataSourcePicker.inputV2)).not.toBeInTheDocument();
|
expect(await screen.queryByTestId(selectors.components.DataSourcePicker.container)).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('shows only tracing datasources for internal link', async () => {
|
it('shows only tracing datasources for internal link', async () => {
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ import { css } from '@emotion/css';
|
|||||||
import React, { ChangeEvent, useEffect, useState } from 'react';
|
import React, { ChangeEvent, useEffect, useState } from 'react';
|
||||||
import { usePrevious } from 'react-use';
|
import { usePrevious } from 'react-use';
|
||||||
|
|
||||||
import { GrafanaTheme2, VariableSuggestion } from '@grafana/data';
|
import { GrafanaTheme2, DataSourceInstanceSettings, VariableSuggestion } from '@grafana/data';
|
||||||
import { DataSourcePicker } from '@grafana/runtime';
|
|
||||||
import { Button, DataLinkInput, Field, Icon, Input, Label, Tooltip, useStyles2, Switch } from '@grafana/ui';
|
import { Button, DataLinkInput, Field, Icon, Input, Label, Tooltip, useStyles2, Switch } from '@grafana/ui';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
|
|
||||||
import { DerivedFieldConfig } from '../types';
|
import { DerivedFieldConfig } from '../types';
|
||||||
|
|
||||||
@@ -145,7 +145,7 @@ export const DerivedField = (props: Props) => {
|
|||||||
<Field label="" className={styles.dataSource}>
|
<Field label="" className={styles.dataSource}>
|
||||||
<DataSourcePicker
|
<DataSourcePicker
|
||||||
tracing={true}
|
tracing={true}
|
||||||
onChange={(ds) =>
|
onChange={(ds: DataSourceInstanceSettings) =>
|
||||||
onChange({
|
onChange({
|
||||||
...value,
|
...value,
|
||||||
datasourceUid: ds.uid,
|
datasourceUid: ds.uid,
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
|
import { DataSourceInstanceSettings } from '@grafana/data';
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
import { DataSourcePicker } from '@grafana/runtime';
|
|
||||||
import { Button, InlineField, Input, Switch, useTheme2 } from '@grafana/ui';
|
import { Button, InlineField, Input, Switch, useTheme2 } from '@grafana/ui';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
|
|
||||||
import { ExemplarTraceIdDestination } from '../types';
|
import { ExemplarTraceIdDestination } from '../types';
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ export default function ExemplarSetting({ value, onChange, onDelete, disabled }:
|
|||||||
current={value.datasourceUid}
|
current={value.datasourceUid}
|
||||||
noDefault={true}
|
noDefault={true}
|
||||||
width={40}
|
width={40}
|
||||||
onChange={(ds) =>
|
onChange={(ds: DataSourceInstanceSettings) =>
|
||||||
onChange({
|
onChange({
|
||||||
...value,
|
...value,
|
||||||
datasourceUid: ds.uid,
|
datasourceUid: ds.uid,
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { DataSourcePluginOptionsEditorProps, updateDatasourcePluginJsonDataOption } from '@grafana/data';
|
import {
|
||||||
import { DataSourcePicker } from '@grafana/runtime';
|
DataSourceInstanceSettings,
|
||||||
|
DataSourcePluginOptionsEditorProps,
|
||||||
|
updateDatasourcePluginJsonDataOption,
|
||||||
|
} from '@grafana/data';
|
||||||
import { Button, InlineField, InlineFieldRow, useStyles2 } from '@grafana/ui';
|
import { Button, InlineField, InlineFieldRow, useStyles2 } from '@grafana/ui';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
|
|
||||||
import { TempoJsonData } from '../types';
|
import { TempoJsonData } from '../types';
|
||||||
|
|
||||||
@@ -33,7 +37,7 @@ export function LokiSearchSettings({ options, onOptionsChange }: Props) {
|
|||||||
current={options.jsonData.lokiSearch?.datasourceUid}
|
current={options.jsonData.lokiSearch?.datasourceUid}
|
||||||
noDefault={true}
|
noDefault={true}
|
||||||
width={40}
|
width={40}
|
||||||
onChange={(ds) =>
|
onChange={(ds: DataSourceInstanceSettings) =>
|
||||||
updateDatasourcePluginJsonDataOption({ onOptionsChange, options }, 'lokiSearch', {
|
updateDatasourcePluginJsonDataOption({ onOptionsChange, options }, 'lokiSearch', {
|
||||||
datasourceUid: ds.uid,
|
datasourceUid: ds.uid,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { DataSourcePluginOptionsEditorProps, updateDatasourcePluginJsonDataOption } from '@grafana/data';
|
import {
|
||||||
import { DataSourcePicker } from '@grafana/runtime';
|
DataSourceInstanceSettings,
|
||||||
|
DataSourcePluginOptionsEditorProps,
|
||||||
|
updateDatasourcePluginJsonDataOption,
|
||||||
|
} from '@grafana/data';
|
||||||
import { Button, InlineField, InlineFieldRow, useStyles2 } from '@grafana/ui';
|
import { Button, InlineField, InlineFieldRow, useStyles2 } from '@grafana/ui';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
|
|
||||||
import { TempoJsonData } from '../types';
|
import { TempoJsonData } from '../types';
|
||||||
|
|
||||||
@@ -27,7 +31,7 @@ export function ServiceGraphSettings({ options, onOptionsChange }: Props) {
|
|||||||
current={options.jsonData.serviceMap?.datasourceUid}
|
current={options.jsonData.serviceMap?.datasourceUid}
|
||||||
noDefault={true}
|
noDefault={true}
|
||||||
width={40}
|
width={40}
|
||||||
onChange={(ds) =>
|
onChange={(ds: DataSourceInstanceSettings) =>
|
||||||
updateDatasourcePluginJsonDataOption({ onOptionsChange, options }, 'serviceMap', {
|
updateDatasourcePluginJsonDataOption({ onOptionsChange, options }, 'serviceMap', {
|
||||||
datasourceUid: ds.uid,
|
datasourceUid: ds.uid,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { PanelPlugin } from '@grafana/data';
|
import { DataSourceInstanceSettings, PanelPlugin } from '@grafana/data';
|
||||||
import { config, DataSourcePicker } from '@grafana/runtime';
|
import { config } from '@grafana/runtime';
|
||||||
import { TagsInput } from '@grafana/ui';
|
import { TagsInput } from '@grafana/ui';
|
||||||
import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker';
|
import { OldFolderPicker } from 'app/core/components/Select/OldFolderPicker';
|
||||||
import {
|
import {
|
||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
GENERAL_FOLDER,
|
GENERAL_FOLDER,
|
||||||
ReadonlyFolderPicker,
|
ReadonlyFolderPicker,
|
||||||
} from 'app/core/components/Select/ReadonlyFolderPicker/ReadonlyFolderPicker';
|
} from 'app/core/components/Select/ReadonlyFolderPicker/ReadonlyFolderPicker';
|
||||||
|
import { DataSourcePicker } from 'app/features/datasources/components/picker/DataSourcePicker';
|
||||||
import { PermissionLevelString } from 'app/types';
|
import { PermissionLevelString } from 'app/types';
|
||||||
|
|
||||||
import { GRAFANA_DATASOURCE_NAME } from '../../../features/alerting/unified/utils/datasource';
|
import { GRAFANA_DATASOURCE_NAME } from '../../../features/alerting/unified/utils/datasource';
|
||||||
@@ -259,7 +260,7 @@ const unifiedAlertList = new PanelPlugin<UnifiedAlertListOptions>(UnifiedAlertLi
|
|||||||
type={['prometheus', 'loki', 'grafana']}
|
type={['prometheus', 'loki', 'grafana']}
|
||||||
noDefault
|
noDefault
|
||||||
current={props.value}
|
current={props.value}
|
||||||
onChange={(ds) => props.onChange(ds.name)}
|
onChange={(ds: DataSourceInstanceSettings) => props.onChange(ds.name)}
|
||||||
onClear={() => props.onChange(null)}
|
onClear={() => props.onChange(null)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user