aboutsummaryrefslogtreecommitdiffstats
path: root/client/js/app/src/app/pages/querybuilder/query-response/query-response.jsx
blob: 3fc061805f17db0f6ec53936852ffcb5f7ad4a80 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
import React from 'react';
import {
  Badge,
  Button,
  Group,
  Stack,
  CopyButton,
  Textarea,
} from '@mantine/core';
import { DownloadJaeger } from 'app/pages/querybuilder/query-response/download-jaeger';
import { useQueryBuilderContext } from 'app/pages/querybuilder/context/query-builder-provider';
import { Icon } from 'app/components';

export function QueryResponse() {
  const response = useQueryBuilderContext((ctx) => ctx.http.response);

  return (
    <Stack>
      <Group position="apart">
        <Badge variant="filled">Response</Badge>
        <Group spacing="xs">
          <CopyButton value={response}>
            {({ copied, copy }) => (
              <Button
                leftIcon={<Icon name={copied ? 'check' : 'copy'} />}
                color={copied ? 'teal' : 'blue'}
                variant="outline"
                onClick={copy}
                size="xs"
                compact
              >
                Copy
              </Button>
            )}
          </CopyButton>
          <DownloadJaeger
            variant="outline"
            size="xs"
            compact
            response={response}
          />
        </Group>
      </Group>
      <Textarea
        styles={(theme) => ({
          input: {
            fontFamily: theme.fontFamilyMonospace,
            fontSize: theme.fontSizes.xs,
          },
        })}
        value={response ?? ''}
        variant="unstyled"
        minRows={21}
        autosize
      />
    </Stack>
  );
}