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
|
// 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,
Group,
Stack,
Button,
CopyButton,
Textarea,
} from '@mantine/core';
import {
ACTION,
dispatch,
useQueryBuilderContext,
} from 'app/pages/querybuilder/context/query-builder-provider';
import { Icon } from 'app/components';
export function QueryDerived() {
const { input, error } = useQueryBuilderContext('query');
return (
<Stack>
<Group position="apart">
<Badge variant="filled">Query</Badge>
<Group spacing="xs">
<CopyButton value={input}>
{({ copied, copy }) => (
<Button
leftIcon={<Icon name={copied ? 'check' : 'copy'} />}
color={copied ? 'teal' : 'blue'}
variant="outline"
onClick={copy}
size="xs"
compact
>
Copy
</Button>
)}
</CopyButton>
</Group>
</Group>
<Textarea
styles={(theme) => ({
input: {
fontFamily: theme.fontFamilyMonospace,
fontSize: theme.fontSizes.xs,
},
})}
value={input}
error={error}
onChange={({ target }) => dispatch(ACTION.SET_QUERY, target.value)}
variant="unstyled"
minRows={21}
autosize
/>
</Stack>
);
}
|