|
1 | | -import { useContext } from "react"; |
2 | | -import { Button, Tooltip, HStack, useToast } from "@chakra-ui/react"; |
3 | | -import copy from 'copy-to-clipboard'; |
4 | | -import Context from './context'; |
5 | | -import ControlConfigImport from './ControlConfigImport'; |
| 1 | +import { useState, useContext } from "react"; |
| 2 | +import { Tooltip, HStack, FormControl, FormLabel } from "@chakra-ui/react"; |
| 3 | +import { Switch } from "@chakra-ui/react"; |
| 4 | +import ControlConfigImport from "./ControlConfigImportExport"; |
| 5 | +import Context from "./context"; |
| 6 | + |
| 7 | +const TOGGLEMOREID = "toggle-more-info"; |
6 | 8 |
|
7 | 9 | const ControlConfig = () => { |
8 | 10 | const ctx = useContext(Context); |
9 | | - const toast = useToast(); |
10 | | - const onExport = () => { |
11 | | - const stateStr = ctx.export(); |
12 | | - copy(stateStr); |
13 | | - toast({ |
14 | | - title: "Copied to clipboard.", |
15 | | - status: "success", |
16 | | - duration: 2000, |
17 | | - isClosable: true, |
18 | | - }); |
| 11 | + const [moreInfoEnabled, setMoreInfoEnabled] = useState( |
| 12 | + ctx.options().enableMoreInfo |
| 13 | + ); |
| 14 | + const onToggleMoreInfo = () => { |
| 15 | + const enableMoreInfo = !ctx.options().enableMoreInfo; |
| 16 | + ctx.options({ enableMoreInfo }); |
| 17 | + setMoreInfoEnabled(enableMoreInfo); |
19 | 18 | }; |
20 | 19 | return ( |
21 | | - <HStack> |
22 | | - <ControlConfigImport /> |
23 | | - <Tooltip label="Export will copy a state string to your clipboard. Save this somewhere on your computer. You can load it by clicking import and pasting the string."> |
24 | | - <Button size="md" onClick={onExport} colorScheme="teal"> |
25 | | - Export |
26 | | - </Button> |
27 | | - </Tooltip> |
| 20 | + <HStack justifyContent="space-between"> |
| 21 | + <FormControl display="flex" alignItems="center"> |
| 22 | + <Tooltip label="Include response examples in the specification. This could include private information. Your choice will persist across sessions."> |
| 23 | + <FormLabel htmlFor={TOGGLEMOREID} mb="0"> |
| 24 | + More info |
| 25 | + </FormLabel> |
| 26 | + </Tooltip> |
| 27 | + <Switch |
| 28 | + id={TOGGLEMOREID} |
| 29 | + onChange={onToggleMoreInfo} |
| 30 | + isChecked={moreInfoEnabled} |
| 31 | + /> |
| 32 | + </FormControl> |
| 33 | + <HStack> |
| 34 | + <ControlConfigImport /> |
| 35 | + </HStack> |
28 | 36 | </HStack> |
29 | 37 | ); |
30 | 38 | }; |
|
0 commit comments