StateView.tsx 809 B

12345678910111213141516171819202122232425262728
  1. import React, { FormEvent } from 'react';
  2. import { PanelOptionsEditorProps, PanelProps } from '@grafana/data';
  3. import { Field, Input, usePanelContext } from '@grafana/ui';
  4. import { DebugPanelOptions } from './types';
  5. export function StateView(props: PanelProps<DebugPanelOptions>) {
  6. const context = usePanelContext();
  7. const onChangeName = (e: FormEvent<HTMLInputElement>) => {
  8. context.onInstanceStateChange!({
  9. name: e.currentTarget.value,
  10. });
  11. };
  12. return (
  13. <>
  14. <Field label="State name">
  15. <Input value={context.instanceState?.name ?? ''} onChange={onChangeName} />
  16. </Field>
  17. </>
  18. );
  19. }
  20. export function StateViewEditor({ value, context, onChange, item }: PanelOptionsEditorProps<string>) {
  21. return <div>Current value: {context.instanceState?.name} </div>;
  22. }