NodeGraphSettings.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { css } from '@emotion/css';
  2. import React from 'react';
  3. import {
  4. DataSourceJsonData,
  5. DataSourcePluginOptionsEditorProps,
  6. GrafanaTheme,
  7. updateDatasourcePluginJsonDataOption,
  8. } from '@grafana/data';
  9. import { InlineField, InlineFieldRow, InlineSwitch, useStyles } from '@grafana/ui';
  10. export interface NodeGraphOptions {
  11. enabled?: boolean;
  12. }
  13. export interface NodeGraphData extends DataSourceJsonData {
  14. nodeGraph?: NodeGraphOptions;
  15. }
  16. interface Props extends DataSourcePluginOptionsEditorProps<NodeGraphData> {}
  17. export function NodeGraphSettings({ options, onOptionsChange }: Props) {
  18. const styles = useStyles(getStyles);
  19. return (
  20. <div className={styles.container}>
  21. <h3 className="page-heading">Node Graph</h3>
  22. <InlineFieldRow className={styles.row}>
  23. <InlineField
  24. tooltip="Enables the Node Graph visualization in the trace viewer."
  25. label="Enable Node Graph"
  26. labelWidth={26}
  27. >
  28. <InlineSwitch
  29. id="enableNodeGraph"
  30. value={options.jsonData.nodeGraph?.enabled}
  31. onChange={(event: React.SyntheticEvent<HTMLInputElement>) =>
  32. updateDatasourcePluginJsonDataOption({ onOptionsChange, options }, 'nodeGraph', {
  33. ...options.jsonData.nodeGraph,
  34. enabled: event.currentTarget.checked,
  35. })
  36. }
  37. />
  38. </InlineField>
  39. </InlineFieldRow>
  40. </div>
  41. );
  42. }
  43. const getStyles = (theme: GrafanaTheme) => ({
  44. container: css`
  45. label: container;
  46. width: 100%;
  47. `,
  48. row: css`
  49. label: row;
  50. align-items: baseline;
  51. `,
  52. });