grafana/public/app/plugins/datasource/grafana-azure-monitor-datasource/components/Field.tsx
Adam Simpson 5df694b924
AzureMonitor: changes to azureMonitorExperimentalUI after feedback (#50455)
* AzureMonitor: tweak experimental-ui after UX discussions.
- move metrics up to resource row
- allow resources field to take an inlineField prop and a labelWidth prop. Eventually once the feature toggle is removed
the inlineField prop will be the only code branch in Field.tsx.

* AzureMonitor: remove devmode req for azureMonitorExperimentalUI flag

* refactor: consolidate logic branch for inline Field
2022-06-09 18:24:48 +00:00

25 lines
785 B
TypeScript

import React from 'react';
import { EditorField } from '@grafana/experimental';
import { config } from '@grafana/runtime';
import { InlineField } from '@grafana/ui';
import { Props as InlineFieldProps } from '@grafana/ui/src/components/Forms/InlineField';
interface Props extends InlineFieldProps {
label: string;
inlineField?: boolean;
labelWidth?: number;
}
const DEFAULT_LABEL_WIDTH = 18;
export const Field = (props: Props) => {
const { labelWidth, inlineField, ...remainingProps } = props;
if (config.featureToggles.azureMonitorExperimentalUI && !inlineField) {
return <EditorField width={labelWidth || DEFAULT_LABEL_WIDTH} {...remainingProps} />;
} else {
return <InlineField labelWidth={labelWidth || DEFAULT_LABEL_WIDTH} {...remainingProps} />;
}
};