(cherry picked from commit f8d5388758)
Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com>
This commit is contained in:
co-authored by
Hugo Häggmark
parent
d025e3b57e
commit
6bfe5ccf3e
@@ -4,20 +4,20 @@ import classNames from 'classnames';
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
// Utils & Services
|
// Utils & Services
|
||||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||||
import { AngularComponent, getAngularLoader } from '@grafana/runtime';
|
import { AngularComponent, getAngularLoader, getTemplateSrv } from '@grafana/runtime';
|
||||||
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
import { getTimeSrv } from 'app/features/dashboard/services/TimeSrv';
|
||||||
import { ErrorBoundaryAlert, HorizontalGroup, InfoBox } from '@grafana/ui';
|
import { ErrorBoundaryAlert, HorizontalGroup, InfoBox } from '@grafana/ui';
|
||||||
import {
|
import {
|
||||||
DataQuery,
|
DataQuery,
|
||||||
DataSourceApi,
|
DataSourceApi,
|
||||||
|
DataSourceInstanceSettings,
|
||||||
|
EventBusExtended,
|
||||||
|
EventBusSrv,
|
||||||
LoadingState,
|
LoadingState,
|
||||||
PanelData,
|
PanelData,
|
||||||
PanelEvents,
|
PanelEvents,
|
||||||
TimeRange,
|
TimeRange,
|
||||||
toLegacyResponseData,
|
toLegacyResponseData,
|
||||||
EventBusExtended,
|
|
||||||
DataSourceInstanceSettings,
|
|
||||||
EventBusSrv,
|
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { QueryEditorRowTitle } from './QueryEditorRowTitle';
|
import { QueryEditorRowTitle } from './QueryEditorRowTitle';
|
||||||
import {
|
import {
|
||||||
@@ -302,15 +302,16 @@ export class QueryEditorRow extends PureComponent<Props, State> {
|
|||||||
|
|
||||||
renderTitle = (props: QueryOperationRowRenderProps) => {
|
renderTitle = (props: QueryOperationRowRenderProps) => {
|
||||||
const { query, dsSettings, onChange, queries } = this.props;
|
const { query, dsSettings, onChange, queries } = this.props;
|
||||||
const { datasource } = this.state;
|
const dataSourceName = dsSettings.meta.mixed
|
||||||
|
? getTemplateSrv().replace(this.getQueryDataSourceIdentifier() ?? '')
|
||||||
|
: undefined;
|
||||||
const isDisabled = query.hide;
|
const isDisabled = query.hide;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<QueryEditorRowTitle
|
<QueryEditorRowTitle
|
||||||
query={query}
|
query={query}
|
||||||
queries={queries}
|
queries={queries}
|
||||||
inMixedMode={dsSettings.meta.mixed}
|
dataSourceName={dataSourceName}
|
||||||
dataSourceName={datasource!.name}
|
|
||||||
disabled={isDisabled}
|
disabled={isDisabled}
|
||||||
onClick={(e) => this.onToggleEditMode(e, props)}
|
onClick={(e) => this.onToggleEditMode(e, props)}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { fireEvent, render, screen } from '@testing-library/react';
|
import { fireEvent, render, screen } from '@testing-library/react';
|
||||||
import { QueryEditorRowTitle, Props } from './QueryEditorRowTitle';
|
import { Props, QueryEditorRowTitle } from './QueryEditorRowTitle';
|
||||||
|
|
||||||
function renderScenario(overrides: Partial<Props>) {
|
function renderScenario(overrides: Partial<Props>) {
|
||||||
const props: Props = {
|
const props: Props = {
|
||||||
@@ -16,7 +16,6 @@ function renderScenario(overrides: Partial<Props>) {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
dataSourceName: 'hello',
|
dataSourceName: 'hello',
|
||||||
inMixedMode: false,
|
|
||||||
disabled: false,
|
disabled: false,
|
||||||
onChange: jest.fn(),
|
onChange: jest.fn(),
|
||||||
onClick: jest.fn(),
|
onClick: jest.fn(),
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { css, cx } from 'emotion';
|
import { css, cx } from 'emotion';
|
||||||
import { DataQuery, GrafanaTheme } from '@grafana/data';
|
import { DataQuery, GrafanaTheme } from '@grafana/data';
|
||||||
import { Icon, Input, stylesFactory, useTheme, FieldValidationMessage } from '@grafana/ui';
|
import { FieldValidationMessage, Icon, Input, stylesFactory, useTheme } from '@grafana/ui';
|
||||||
import { selectors } from '@grafana/e2e-selectors';
|
import { selectors } from '@grafana/e2e-selectors';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
query: DataQuery;
|
query: DataQuery;
|
||||||
queries: DataQuery[];
|
queries: DataQuery[];
|
||||||
dataSourceName: string;
|
dataSourceName?: string;
|
||||||
inMixedMode?: boolean;
|
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
onChange: (query: DataQuery) => void;
|
onChange: (query: DataQuery) => void;
|
||||||
onClick: (e: React.MouseEvent) => void;
|
onClick: (e: React.MouseEvent) => void;
|
||||||
@@ -17,7 +16,6 @@ export interface Props {
|
|||||||
|
|
||||||
export const QueryEditorRowTitle: React.FC<Props> = ({
|
export const QueryEditorRowTitle: React.FC<Props> = ({
|
||||||
dataSourceName,
|
dataSourceName,
|
||||||
inMixedMode,
|
|
||||||
disabled,
|
disabled,
|
||||||
query,
|
query,
|
||||||
queries,
|
queries,
|
||||||
@@ -116,7 +114,7 @@ export const QueryEditorRowTitle: React.FC<Props> = ({
|
|||||||
{validationError && <FieldValidationMessage horizontal>{validationError}</FieldValidationMessage>}
|
{validationError && <FieldValidationMessage horizontal>{validationError}</FieldValidationMessage>}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{inMixedMode && <em className={styles.contextInfo}> ({dataSourceName})</em>}
|
{dataSourceName && <em className={styles.contextInfo}> ({dataSourceName})</em>}
|
||||||
{disabled && <em className={styles.contextInfo}> Disabled</em>}
|
{disabled && <em className={styles.contextInfo}> Disabled</em>}
|
||||||
|
|
||||||
{collapsedText && (
|
{collapsedText && (
|
||||||
|
|||||||
Reference in New Issue
Block a user