mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* First try * Update * app with drilldowns * Progres * Progress * update * Update * update * Update * Update * Progress * Update * Progress * Update * Progress * logs url sync * related metrics * Progress * progress * Progress * Update * Update * Update * Update * Update * fix * Update * update * Update * update * Update * Update * Update * Update * Update * Update * Update * Update * Update * Update * update * Update * Update * Settings * Update * Tweaks * update * Improve auto queries * Update * Update * Fixes * Update * Update * Update * fix * Update * Removing logs view, cleanup * Update * Update * disabled not implemented buttons * Update * Feature toggle on dashboard menu * remove unused prometheus change * removed bit * Fix failing test * chore: added `/public/app/features/trails/` to CODEOWNERS * go mod tidy * go mod tidy * fix: added missing arg * Moved panel action * Moved panel action --------- Co-authored-by: André Pereira <adrapereira@gmail.com> Co-authored-by: Darren Janeczek <darren.janeczek@grafana.com>
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import React from 'react';
|
|
|
|
import { SelectableValue } from '@grafana/data';
|
|
import { SceneComponentProps, SceneObject, SceneObjectBase, SceneObjectState } from '@grafana/scenes';
|
|
import { Field, RadioButtonGroup } from '@grafana/ui';
|
|
|
|
export interface LayoutSwitcherState extends SceneObjectState {
|
|
active: LayoutType;
|
|
layouts: SceneObject[];
|
|
options: Array<SelectableValue<LayoutType>>;
|
|
}
|
|
|
|
export type LayoutType = 'single' | 'grid' | 'rows';
|
|
|
|
export class LayoutSwitcher extends SceneObjectBase<LayoutSwitcherState> {
|
|
public Selector({ model }: { model: LayoutSwitcher }) {
|
|
const { active, options } = model.useState();
|
|
|
|
return (
|
|
<Field label="View">
|
|
<RadioButtonGroup options={options} value={active} onChange={model.onLayoutChange} />
|
|
</Field>
|
|
);
|
|
}
|
|
|
|
public onLayoutChange = (active: LayoutType) => {
|
|
this.setState({ active });
|
|
};
|
|
|
|
public static Component = ({ model }: SceneComponentProps<LayoutSwitcher>) => {
|
|
const { layouts, options, active } = model.useState();
|
|
|
|
const index = options.findIndex((o) => o.value === active);
|
|
if (index === -1) {
|
|
return null;
|
|
}
|
|
|
|
const layout = layouts[index];
|
|
|
|
return <layout.Component model={layout} />;
|
|
};
|
|
}
|