mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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
This commit is contained in:
parent
7e2870b7bb
commit
5df694b924
@ -198,11 +198,10 @@ var (
|
|||||||
State: FeatureStateAlpha,
|
State: FeatureStateAlpha,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "azureMonitorExperimentalUI",
|
Name: "azureMonitorExperimentalUI",
|
||||||
Description: "Use grafana-experimental UI in Azure Monitor",
|
Description: "Use grafana-experimental UI in Azure Monitor",
|
||||||
State: FeatureStateAlpha,
|
State: FeatureStateAlpha,
|
||||||
RequiresDevMode: true,
|
FrontendOnly: true,
|
||||||
FrontendOnly: true,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "traceToMetrics",
|
Name: "traceToMetrics",
|
||||||
|
@ -7,13 +7,18 @@ import { Props as InlineFieldProps } from '@grafana/ui/src/components/Forms/Inli
|
|||||||
|
|
||||||
interface Props extends InlineFieldProps {
|
interface Props extends InlineFieldProps {
|
||||||
label: string;
|
label: string;
|
||||||
|
inlineField?: boolean;
|
||||||
|
labelWidth?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_LABEL_WIDTH = 18;
|
const DEFAULT_LABEL_WIDTH = 18;
|
||||||
|
|
||||||
export const Field = (props: Props) => {
|
export const Field = (props: Props) => {
|
||||||
if (config.featureToggles.azureMonitorExperimentalUI) {
|
const { labelWidth, inlineField, ...remainingProps } = props;
|
||||||
return <EditorField width={DEFAULT_LABEL_WIDTH} {...props} />;
|
|
||||||
|
if (config.featureToggles.azureMonitorExperimentalUI && !inlineField) {
|
||||||
|
return <EditorField width={labelWidth || DEFAULT_LABEL_WIDTH} {...remainingProps} />;
|
||||||
|
} else {
|
||||||
|
return <InlineField labelWidth={labelWidth || DEFAULT_LABEL_WIDTH} {...remainingProps} />;
|
||||||
}
|
}
|
||||||
return <InlineField labelWidth={DEFAULT_LABEL_WIDTH} {...props} />;
|
|
||||||
};
|
};
|
||||||
|
@ -44,6 +44,8 @@ const LogsQueryEditor: React.FC<LogsQueryEditorProps> = ({
|
|||||||
<ResourceField
|
<ResourceField
|
||||||
query={query}
|
query={query}
|
||||||
datasource={datasource}
|
datasource={datasource}
|
||||||
|
inlineField={true}
|
||||||
|
labelWidth={10}
|
||||||
subscriptionId={subscriptionId}
|
subscriptionId={subscriptionId}
|
||||||
variableOptionGroup={variableOptionGroup}
|
variableOptionGroup={variableOptionGroup}
|
||||||
onQueryChange={onChange}
|
onQueryChange={onChange}
|
||||||
|
@ -60,11 +60,6 @@ const MetricsQueryEditor: React.FC<MetricsQueryEditorProps> = ({
|
|||||||
setResource={setResource}
|
setResource={setResource}
|
||||||
resourceUri={query.azureMonitor?.resourceUri}
|
resourceUri={query.azureMonitor?.resourceUri}
|
||||||
/>
|
/>
|
||||||
</EditorFieldGroup>
|
|
||||||
</EditorRow>
|
|
||||||
|
|
||||||
<EditorRow>
|
|
||||||
<EditorFieldGroup>
|
|
||||||
<MetricNamespaceField
|
<MetricNamespaceField
|
||||||
metricNamespaces={metricNamespaces}
|
metricNamespaces={metricNamespaces}
|
||||||
query={query}
|
query={query}
|
||||||
|
@ -29,6 +29,8 @@ interface ResourceFieldProps extends AzureQueryEditorFieldProps {
|
|||||||
setResource: (query: AzureMonitorQuery, resourceURI?: string) => AzureMonitorQuery;
|
setResource: (query: AzureMonitorQuery, resourceURI?: string) => AzureMonitorQuery;
|
||||||
selectableEntryTypes: ResourceRowType[];
|
selectableEntryTypes: ResourceRowType[];
|
||||||
resourceUri?: string;
|
resourceUri?: string;
|
||||||
|
inlineField?: boolean;
|
||||||
|
labelWidth?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ResourceField: React.FC<ResourceFieldProps> = ({
|
const ResourceField: React.FC<ResourceFieldProps> = ({
|
||||||
@ -38,6 +40,8 @@ const ResourceField: React.FC<ResourceFieldProps> = ({
|
|||||||
setResource,
|
setResource,
|
||||||
selectableEntryTypes,
|
selectableEntryTypes,
|
||||||
resourceUri,
|
resourceUri,
|
||||||
|
inlineField,
|
||||||
|
labelWidth,
|
||||||
}) => {
|
}) => {
|
||||||
const styles = useStyles2(getStyles);
|
const styles = useStyles2(getStyles);
|
||||||
const [pickerIsOpen, setPickerIsOpen] = useState(false);
|
const [pickerIsOpen, setPickerIsOpen] = useState(false);
|
||||||
@ -77,8 +81,7 @@ const ResourceField: React.FC<ResourceFieldProps> = ({
|
|||||||
selectableEntryTypes={selectableEntryTypes}
|
selectableEntryTypes={selectableEntryTypes}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
<Field label="Resource" inlineField={inlineField} labelWidth={labelWidth}>
|
||||||
<Field label="Resource">
|
|
||||||
<Button className={styles.resourceFieldButton} variant="secondary" onClick={handleOpenPicker} type="button">
|
<Button className={styles.resourceFieldButton} variant="secondary" onClick={handleOpenPicker} type="button">
|
||||||
<ResourceLabel resource={resourceUri} datasource={datasource} />
|
<ResourceLabel resource={resourceUri} datasource={datasource} />
|
||||||
</Button>
|
</Button>
|
||||||
|
Loading…
Reference in New Issue
Block a user