grafana/public/app/features/scenes/apps/SceneRadioToggle.tsx
Torkel Ödegaard 5c9898a860
Scenes: SceneApp example in core (#64686)
* Scenes: Progress on demo app

* Argh

* Fixing breadcrumbs

* Added spacer

* Conditional scene objects

* Quick and dirty test for drilldown link via panel title

* Changed the toggle

* Add url state syncing for most links

* Add url state syncing for most links

* Fix instance in url params

* Quick and dirty tabs on the handler page

* fixing breadcrumbs

* Hide footer

* Updates

* new table styles

* Update table cell link styles

* Added search box

* Scene app demo: dynamic data link (#60398)

* Dynamically build data links

* Add field override tests

* Updates

* Updated

* Updates

* before nesting routing

* Something is working

* Caching and nested routes working

* Simplify model

* Use app components from grafana/scenes

* Make the monitoring app work with section nav

* Fixing

* Update scenes

* Remove unused route

* Updates

* remove file

* Update scenes version and use new features

* Remove semicolon

* removed unused thing

* Add refresh pickers

---------

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
2023-03-20 11:15:42 +01:00

25 lines
812 B
TypeScript

import React from 'react';
import { SelectableValue } from '@grafana/data';
import { SceneComponentProps, SceneObjectBase, SceneObjectStatePlain } from '@grafana/scenes';
import { RadioButtonGroup } from '@grafana/ui';
export interface SceneRadioToggleState extends SceneObjectStatePlain {
options: Array<SelectableValue<string>>;
value: string;
onChange: (value: string) => void;
}
export class SceneRadioToggle extends SceneObjectBase<SceneRadioToggleState> {
public onChange = (value: string) => {
this.setState({ value });
this.state.onChange(value);
};
public static Component = ({ model }: SceneComponentProps<SceneRadioToggle>) => {
const { options, value } = model.useState();
return <RadioButtonGroup options={options} value={value} onChange={model.onChange} />;
};
}