import React, { FC } from 'react'; import { DataFrame, DataTransformerID, getFrameDisplayName, SelectableValue } from '@grafana/data'; import { Field, HorizontalGroup, Select, Switch, VerticalGroup } from '@grafana/ui'; import { QueryOperationRow } from 'app/core/components/QueryOperationRow/QueryOperationRow'; import { PanelModel } from 'app/features/dashboard/state'; import { DetailText } from 'app/features/inspector/DetailText'; import { GetDataOptions } from 'app/features/query/state/PanelQueryRunner'; import { getPanelInspectorStyles } from './styles'; interface Props { options: GetDataOptions; dataFrames: DataFrame[]; transformId: DataTransformerID; transformationOptions: Array>; selectedDataFrame: number | DataTransformerID; downloadForExcel: boolean; onDataFrameChange: (item: SelectableValue) => void; toggleDownloadForExcel: () => void; data?: DataFrame[]; panel?: PanelModel; onOptionsChange?: (options: GetDataOptions) => void; } export const InspectDataOptions: FC = ({ options, onOptionsChange, panel, data, dataFrames, transformId, transformationOptions, selectedDataFrame, onDataFrameChange, downloadForExcel, toggleDownloadForExcel, }) => { const styles = getPanelInspectorStyles(); const panelTransformations = panel?.getTransformations(); const showPanelTransformationsOption = Boolean(panelTransformations?.length) && (transformId as any) !== 'join by time'; const showFieldConfigsOption = panel && !panel.plugin?.fieldConfigRegistry.isEmpty(); let dataSelect = dataFrames; if (selectedDataFrame === DataTransformerID.seriesToColumns) { dataSelect = data!; } const choices = dataSelect.map((frame, index) => { return { value: index, label: `${getFrameDisplayName(frame)} (${index})`, } as SelectableValue; }); const selectableOptions = [...transformationOptions, ...choices]; function getActiveString() { let activeString = ''; if (!data) { return activeString; } const parts: string[] = []; if (selectedDataFrame === DataTransformerID.seriesToColumns) { parts.push('Series joined by time'); } else if (data.length > 1) { parts.push(getFrameDisplayName(data[selectedDataFrame as number])); } if (options.withTransforms || options.withFieldConfig) { if (options.withTransforms) { parts.push('Panel transforms'); } if (options.withTransforms && options.withFieldConfig) { } if (options.withFieldConfig) { parts.push('Formatted data'); } } if (downloadForExcel) { parts.push('Excel header'); } return parts.join(', '); } return (
{getActiveString()}} isOpen={false} >
{data!.length > 1 && (