|
1 | | -import { useGuideContext, useStore } from "@knocklabs/react-core"; |
2 | | -import { Button } from "@telegraph/button"; |
3 | | -import { Icon } from "@telegraph/icon"; |
| 1 | +import { useGuideContext } from "@knocklabs/react-core"; |
4 | 2 | import { Box, Stack } from "@telegraph/layout"; |
5 | | -import { Tooltip } from "@telegraph/tooltip"; |
6 | 3 | import { Text } from "@telegraph/typography"; |
7 | | -import { ChevronDown, ChevronRight, Info } from "lucide-react"; |
8 | | -import * as React from "react"; |
9 | 4 |
|
10 | 5 | export const GuideContextDetails = () => { |
11 | 6 | const { client } = useGuideContext(); |
12 | | - const [isExpanded, setIsExpanded] = React.useState(false); |
13 | | - |
14 | | - const { defaultGroup, debugSettings } = useStore(client.store, (state) => { |
15 | | - return { |
16 | | - defaultGroup: state.guideGroups[0], |
17 | | - debugSettings: state.debug || {}, |
18 | | - }; |
19 | | - }); |
20 | | - const displayInterval = defaultGroup?.display_interval ?? null; |
21 | 7 |
|
22 | 8 | return ( |
23 | | - <Stack direction="column" borderTop="px"> |
24 | | - <Stack |
25 | | - h="5" |
26 | | - px="2" |
27 | | - bg="gray-3" |
28 | | - align="center" |
29 | | - gap="1" |
30 | | - style={{ cursor: "pointer" }} |
31 | | - onClick={() => setIsExpanded((prev) => !prev)} |
32 | | - > |
33 | | - <Text as="span" size="0" weight="medium"> |
34 | | - More |
35 | | - </Text> |
36 | | - {isExpanded ? <ChevronDown size={12} /> : <ChevronRight size={12} />} |
37 | | - </Stack> |
38 | | - |
39 | | - {isExpanded && ( |
40 | | - <Stack direction="column"> |
41 | | - <Stack |
42 | | - align="center" |
43 | | - justify="space-between" |
44 | | - py="1" |
45 | | - px="2" |
46 | | - borderTop="px" |
| 9 | + <Box py="3" px="3"> |
| 10 | + <Text as="span" size="1" weight="medium"> |
| 11 | + Target params |
| 12 | + </Text> |
| 13 | + <Stack direction="column" gap="2" mt="2"> |
| 14 | + <Stack direction="row" gap="2" align="center"> |
| 15 | + <Text |
| 16 | + as="span" |
| 17 | + size="1" |
| 18 | + weight="medium" |
| 19 | + color="gray" |
| 20 | + width="36" |
| 21 | + mt="1" |
47 | 22 | > |
48 | | - <Stack align="center" gap="1"> |
49 | | - <Text as="span" size="0" weight="medium"> |
50 | | - Client-only engagement |
51 | | - </Text> |
52 | | - <Tooltip label="Contain engagement actions to the client side only while in preview without sending engagement events to the API"> |
53 | | - <Icon icon={Info} size="0" color="gray" aria-hidden /> |
54 | | - </Tooltip> |
55 | | - </Stack> |
56 | | - <Button |
57 | | - size="0" |
58 | | - variant="soft" |
59 | | - color={debugSettings.skipEngagementTracking ? "green" : "gray"} |
60 | | - onClick={() => |
61 | | - client.setDebug({ |
62 | | - ...debugSettings, |
63 | | - skipEngagementTracking: !debugSettings.skipEngagementTracking, |
64 | | - }) |
65 | | - } |
66 | | - > |
67 | | - {debugSettings.skipEngagementTracking ? "On" : "Off"} |
68 | | - </Button> |
69 | | - </Stack> |
70 | | - |
71 | | - <Stack direction="column" py="1" px="2"> |
72 | | - <Stack align="center" justify="space-between"> |
73 | | - <Stack align="center" gap="1"> |
74 | | - <Text as="span" size="0" weight="medium"> |
75 | | - Suspend throttling |
76 | | - </Text> |
77 | | - <Tooltip label="Suspend throttling during preview, and show next guide immediately"> |
78 | | - <Icon icon={Info} size="0" color="gray" aria-hidden /> |
79 | | - </Tooltip> |
80 | | - </Stack> |
81 | | - <Button |
82 | | - size="0" |
83 | | - variant="soft" |
84 | | - color={debugSettings.ignoreDisplayInterval ? "green" : "gray"} |
85 | | - onClick={() => |
86 | | - client.setDebug({ |
87 | | - ...debugSettings, |
88 | | - ignoreDisplayInterval: !debugSettings.ignoreDisplayInterval, |
89 | | - }) |
90 | | - } |
91 | | - > |
92 | | - {debugSettings.ignoreDisplayInterval ? "On" : "Off"} |
93 | | - </Button> |
94 | | - </Stack> |
95 | | - <Stack direction="row" gap="0_5" py="1"> |
96 | | - <Text as="span" size="0" color="gray"> |
97 | | - Throttle:{" "} |
98 | | - {debugSettings.ignoreDisplayInterval |
99 | | - ? "(ignored)" |
100 | | - : displayInterval === null |
101 | | - ? "(none)" |
102 | | - : `Every ${displayInterval}s`} |
103 | | - </Text> |
104 | | - </Stack> |
105 | | - </Stack> |
106 | | - |
107 | | - <Stack direction="column" py="1" px="2" borderTop="px"> |
108 | | - <Text as="span" size="0" weight="medium"> |
109 | | - Target params |
110 | | - </Text> |
111 | | - <Stack direction="column" gap="0_5" mt="1"> |
112 | | - <Text as="span" size="0" color="gray"> |
113 | | - Tenant |
114 | | - </Text> |
115 | | - <Text as="code" size="0"> |
116 | | - {client.targetParams.tenant ? ( |
117 | | - <Box |
118 | | - rounded="2" |
119 | | - overflow="auto" |
120 | | - backgroundColor="gray-2" |
121 | | - border="px" |
122 | | - style={{ maxHeight: "200px" }} |
123 | | - > |
124 | | - <pre style={{ fontSize: "11px", margin: 0 }}> |
125 | | - <code>{client.targetParams.tenant}</code> |
126 | | - </pre> |
127 | | - </Box> |
128 | | - ) : ( |
129 | | - <Text as="code" size="0"> |
130 | | - - |
131 | | - </Text> |
132 | | - )} |
133 | | - </Text> |
134 | | - </Stack> |
135 | | - |
136 | | - <Stack direction="column" gap="0_5"> |
137 | | - <Text as="span" size="0" color="gray"> |
138 | | - Data |
139 | | - </Text> |
140 | | - {client.targetParams.data ? ( |
141 | | - <Box |
142 | | - rounded="2" |
143 | | - overflow="auto" |
144 | | - backgroundColor="gray-2" |
145 | | - border="px" |
146 | | - style={{ maxHeight: "200px" }} |
147 | | - > |
148 | | - <pre style={{ fontSize: "11px", margin: 0 }}> |
149 | | - <code> |
150 | | - {JSON.stringify(client.targetParams.data, null, 2)} |
151 | | - </code> |
152 | | - </pre> |
153 | | - </Box> |
154 | | - ) : ( |
155 | | - <Text as="code" size="0"> |
156 | | - - |
157 | | - </Text> |
158 | | - )} |
159 | | - </Stack> |
160 | | - </Stack> |
| 23 | + Tenant |
| 24 | + </Text> |
| 25 | + <Box |
| 26 | + rounded="2" |
| 27 | + overflow="auto" |
| 28 | + backgroundColor="surface-2" |
| 29 | + border="px" |
| 30 | + p="1" |
| 31 | + style={{ flex: 1, minWidth: 0 }} |
| 32 | + > |
| 33 | + <pre style={{ fontSize: "11px", margin: 0 }}> |
| 34 | + <code>{client.targetParams.tenant || "-"}</code> |
| 35 | + </pre> |
| 36 | + </Box> |
161 | 37 | </Stack> |
162 | | - )} |
163 | | - </Stack> |
| 38 | + <Stack direction="row" gap="2" align="flex-start"> |
| 39 | + <Text |
| 40 | + as="span" |
| 41 | + size="1" |
| 42 | + weight="medium" |
| 43 | + color="gray" |
| 44 | + width="36" |
| 45 | + mt="1" |
| 46 | + > |
| 47 | + Data |
| 48 | + </Text> |
| 49 | + <Box |
| 50 | + rounded="2" |
| 51 | + overflow="auto" |
| 52 | + backgroundColor="surface-2" |
| 53 | + border="px" |
| 54 | + p="1" |
| 55 | + style={{ |
| 56 | + flex: 1, |
| 57 | + minWidth: 0, |
| 58 | + minHeight: "50px", |
| 59 | + maxHeight: "200px", |
| 60 | + }} |
| 61 | + > |
| 62 | + <pre style={{ fontSize: "11px", margin: 0 }}> |
| 63 | + <code> |
| 64 | + {client.targetParams.data |
| 65 | + ? JSON.stringify(client.targetParams.data, null, 2) |
| 66 | + : "-"} |
| 67 | + </code> |
| 68 | + </pre> |
| 69 | + </Box> |
| 70 | + </Stack> |
| 71 | + </Stack> |
| 72 | + </Box> |
164 | 73 | ); |
165 | 74 | }; |
0 commit comments