Dashboard Scene: Add Missing Overrides Tab to Panel Edit (#95276)

Add overrides tab
This commit is contained in:
Haris Rozajac 2024-10-31 07:58:53 -06:00 committed by GitHub
parent 8f2893edd3
commit 6c45f7f556
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -9,6 +9,7 @@ import {
PanelPluginMeta, PanelPluginMeta,
restoreCustomOverrideRules, restoreCustomOverrideRules,
PluginType, PluginType,
SelectableValue,
} from '@grafana/data'; } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors'; import { selectors } from '@grafana/e2e-selectors';
import { config, locationService, reportInteraction } from '@grafana/runtime'; import { config, locationService, reportInteraction } from '@grafana/runtime';
@ -21,7 +22,7 @@ import {
VizPanel, VizPanel,
sceneGraph, sceneGraph,
} from '@grafana/scenes'; } from '@grafana/scenes';
import { Button, Card, FilterInput, Stack, ToolbarButton, useStyles2 } from '@grafana/ui'; import { Button, Card, FilterInput, RadioButtonGroup, Stack, ToolbarButton, useStyles2 } from '@grafana/ui';
import { Trans } from 'app/core/internationalization'; import { Trans } from 'app/core/internationalization';
import { OptionFilter } from 'app/features/dashboard/components/PanelEditor/OptionsPaneOptions'; import { OptionFilter } from 'app/features/dashboard/components/PanelEditor/OptionsPaneOptions';
import { getPanelPluginNotFound } from 'app/features/panel/components/PanelPluginError'; import { getPanelPluginNotFound } from 'app/features/panel/components/PanelPluginError';
@ -104,6 +105,13 @@ export class PanelOptionsPane extends SceneObjectBase<PanelOptionsPaneState> {
}); });
}; };
getOptionRadioFilters(): Array<SelectableValue<OptionFilter>> {
return [
{ label: OptionFilter.All, value: OptionFilter.All },
{ label: OptionFilter.Overrides, value: OptionFilter.Overrides },
];
}
static Component = ({ model }: SceneComponentProps<PanelOptionsPane>) => { static Component = ({ model }: SceneComponentProps<PanelOptionsPane>) => {
const { isVizPickerOpen, searchQuery, listMode, panelRef } = model.useState(); const { isVizPickerOpen, searchQuery, listMode, panelRef } = model.useState();
const panel = panelRef.resolve(); const panel = panelRef.resolve();
@ -111,6 +119,8 @@ export class PanelOptionsPane extends SceneObjectBase<PanelOptionsPaneState> {
const { data } = sceneGraph.getData(panel).useState(); const { data } = sceneGraph.getData(panel).useState();
const styles = useStyles2(getStyles); const styles = useStyles2(getStyles);
const isAngularPanel = isUsingAngularPanelPlugin(panel); const isAngularPanel = isUsingAngularPanelPlugin(panel);
const isSearching = searchQuery.length > 0;
const showSearchRadioButtons = !isSearching && !panel.getPlugin()?.fieldConfigRegistry.isEmpty();
return ( return (
<> <>
{!isVizPickerOpen && ( {!isVizPickerOpen && (
@ -123,6 +133,14 @@ export class PanelOptionsPane extends SceneObjectBase<PanelOptionsPaneState> {
placeholder="Search options" placeholder="Search options"
onChange={model.onSetSearchQuery} onChange={model.onSetSearchQuery}
/> />
{showSearchRadioButtons && (
<RadioButtonGroup
options={model.getOptionRadioFilters()}
value={listMode}
fullWidth
onChange={model.onSetListMode}
/>
)}
</div> </div>
{isAngularPanel && ( {isAngularPanel && (
<div className={styles.angularDeprecationContainer}> <div className={styles.angularDeprecationContainer}>