grafana/public/app/plugins/panel/debug/StateView.tsx
Jack Westbrook 5815a37f47
Debug Panel: Introduce schema types (#62094)
* feat(debugpanel): schematizing debug panel plugin

* delete old types and update imports to new generated schema

* update to experimental

* derived counters, fix options key name

* num to int

* chore(debugpanel): update ts imports post type rename

* chore(kindsys): refresh report.json

* migrate UpdateCounters back to runtime

* merge with main

---------

Co-authored-by: Will Browne <will.browne@grafana.com>
Co-authored-by: sam boyer <sdboyer@grafana.com>
2023-02-03 11:57:04 +01:00

29 lines
806 B
TypeScript

import React, { FormEvent } from 'react';
import { PanelOptionsEditorProps, PanelProps } from '@grafana/data';
import { Field, Input, usePanelContext } from '@grafana/ui';
import { PanelOptions } from './panelcfg.gen';
export function StateView(props: PanelProps<PanelOptions>) {
const context = usePanelContext();
const onChangeName = (e: FormEvent<HTMLInputElement>) => {
context.onInstanceStateChange!({
name: e.currentTarget.value,
});
};
return (
<>
<Field label="State name">
<Input value={context.instanceState?.name ?? ''} onChange={onChangeName} />
</Field>
</>
);
}
export function StateViewEditor({ value, context, onChange, item }: PanelOptionsEditorProps<string>) {
return <div>Current value: {context.instanceState?.name} </div>;
}