AnnotationsQueryEditor.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Libraries
  2. import React, { memo } from 'react';
  3. // Types
  4. import { LokiDatasource } from '../datasource';
  5. import { LokiQuery } from '../types';
  6. import { LokiOptionFields } from './LokiOptionFields';
  7. import { LokiQueryField } from './LokiQueryField';
  8. interface Props {
  9. expr: string;
  10. maxLines?: number;
  11. instant?: boolean;
  12. datasource: LokiDatasource;
  13. onChange: (query: LokiQuery) => void;
  14. }
  15. export const LokiAnnotationsQueryEditor = memo(function LokiAnnotationQueryEditor(props: Props) {
  16. const { expr, maxLines, instant, datasource, onChange } = props;
  17. const queryWithRefId: LokiQuery = {
  18. refId: '',
  19. expr,
  20. maxLines,
  21. instant,
  22. };
  23. return (
  24. <div className="gf-form-group">
  25. <LokiQueryField
  26. datasource={datasource}
  27. query={queryWithRefId}
  28. onChange={onChange}
  29. onRunQuery={() => {}}
  30. onBlur={() => {}}
  31. history={[]}
  32. ExtraFieldElement={
  33. <LokiOptionFields
  34. lineLimitValue={queryWithRefId?.maxLines?.toString() || ''}
  35. resolution={queryWithRefId.resolution || 1}
  36. query={queryWithRefId}
  37. onRunQuery={() => {}}
  38. onChange={onChange}
  39. />
  40. }
  41. />
  42. </div>
  43. );
  44. });