ServiceGraphSettings.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { css } from '@emotion/css';
  2. import React from 'react';
  3. import { DataSourcePluginOptionsEditorProps, GrafanaTheme, updateDatasourcePluginJsonDataOption } from '@grafana/data';
  4. import { DataSourcePicker } from '@grafana/runtime';
  5. import { Button, InlineField, InlineFieldRow, useStyles } from '@grafana/ui';
  6. import { TempoJsonData } from '../datasource';
  7. interface Props extends DataSourcePluginOptionsEditorProps<TempoJsonData> {}
  8. export function ServiceGraphSettings({ options, onOptionsChange }: Props) {
  9. const styles = useStyles(getStyles);
  10. return (
  11. <div className={css({ width: '100%' })}>
  12. <h3 className="page-heading">Service Graph</h3>
  13. <div className={styles.infoText}>
  14. To allow querying service graph data you have to select a Prometheus instance where the data is stored.
  15. </div>
  16. <InlineFieldRow className={styles.row}>
  17. <InlineField
  18. tooltip="The Prometheus data source with the service graph data"
  19. label="Data source"
  20. labelWidth={26}
  21. >
  22. <DataSourcePicker
  23. inputId="service-graph-data-source-picker"
  24. pluginId="prometheus"
  25. current={options.jsonData.serviceMap?.datasourceUid}
  26. noDefault={true}
  27. width={40}
  28. onChange={(ds) =>
  29. updateDatasourcePluginJsonDataOption({ onOptionsChange, options }, 'serviceMap', {
  30. datasourceUid: ds.uid,
  31. })
  32. }
  33. />
  34. </InlineField>
  35. {options.jsonData.serviceMap?.datasourceUid ? (
  36. <Button
  37. type={'button'}
  38. variant={'secondary'}
  39. size={'sm'}
  40. fill={'text'}
  41. onClick={() => {
  42. updateDatasourcePluginJsonDataOption({ onOptionsChange, options }, 'serviceMap', {
  43. datasourceUid: undefined,
  44. });
  45. }}
  46. >
  47. Clear
  48. </Button>
  49. ) : null}
  50. </InlineFieldRow>
  51. </div>
  52. );
  53. }
  54. const getStyles = (theme: GrafanaTheme) => ({
  55. infoText: css`
  56. label: infoText;
  57. padding-bottom: ${theme.spacing.md};
  58. color: ${theme.colors.textSemiWeak};
  59. `,
  60. row: css`
  61. label: row;
  62. align-items: baseline;
  63. `,
  64. });