|
1 | 1 | import React, { useEffect, useState } from "react"; |
2 | | -import { Button, Flex, IconButton, Link, Text } from "@radix-ui/themes"; |
| 2 | +import { Button, Callout, Flex, IconButton, Link, Text } from "@radix-ui/themes"; |
3 | 3 | import ValueField from "@/app/components/ValueField"; |
4 | 4 | import { MW, NAV_H } from "@/app"; |
5 | 5 | import { |
6 | 6 | PiArrowsClockwise, |
7 | 7 | PiArrowSquareOut, |
8 | | - PiCaretRightFill, |
| 8 | + PiCaretRightFill, PiWarningFill, PiWarningOctagonFill, |
9 | 9 | PiXBold, |
10 | 10 | } from "react-icons/pi"; |
11 | 11 | import * as Accordion from "@radix-ui/react-accordion"; |
@@ -34,6 +34,7 @@ const panels: Record< |
34 | 34 | SDKHealthCheckResult & { |
35 | 35 | latestSdkVersion: string; |
36 | 36 | latestMinorSdkVersion: string; |
| 37 | + hasPayload: boolean; |
37 | 38 | } |
38 | 39 | > |
39 | 40 | > = { |
@@ -69,12 +70,14 @@ export default function SdkItemPanel({ |
69 | 70 | widthPercent, |
70 | 71 | latestSdkVersion, |
71 | 72 | latestMinorSdkVersion, |
| 73 | + hasPayload, |
72 | 74 | }: { |
73 | 75 | selectedItem: SdkItem; |
74 | 76 | unsetSelectedItem: () => void; |
75 | 77 | widthPercent: number; |
76 | 78 | latestSdkVersion: string; |
77 | 79 | latestMinorSdkVersion: string; |
| 80 | + hasPayload: boolean; |
78 | 81 | }) { |
79 | 82 | const { isResponsive } = useResponsiveContext(); |
80 | 83 |
|
@@ -216,11 +219,20 @@ function statusPanel({ |
216 | 219 | ) : null} |
217 | 220 |
|
218 | 221 | <div className="mb-4"> |
219 | | - {!activeTabId && !refreshing && ( |
220 | | - <div className="bg-red-100 border border-red-400 text-red-700 px-3 py-2 rounded text-sm mb-4"> |
221 | | - DevTools was unable to attach to the current window. |
222 | | - </div> |
223 | | - )} |
| 222 | + {!activeTabId && !refreshing ? ( |
| 223 | + <Callout.Root |
| 224 | + color="red" |
| 225 | + size="1" |
| 226 | + className="mb-4" |
| 227 | + > |
| 228 | + <Callout.Icon> |
| 229 | + <PiWarningOctagonFill /> |
| 230 | + </Callout.Icon> |
| 231 | + <Callout.Text> |
| 232 | + DevTools was unable to attach to the current window. |
| 233 | + </Callout.Text> |
| 234 | + </Callout.Root> |
| 235 | + ) : null} |
224 | 236 | <Button |
225 | 237 | variant="outline" |
226 | 238 | size="2" |
@@ -309,23 +321,51 @@ function versionPanel({ |
309 | 321 | return ( |
310 | 322 | <Text as="div" size="2" weight="regular"> |
311 | 323 | {!version ? ( |
312 | | - <Text> |
313 | | - Unable to find your SDK version. You might be using an old version of |
314 | | - the SDK. Consider updating to the latest version. |
315 | | - </Text> |
| 324 | + <> |
| 325 | + <Text> |
| 326 | + Unable to find your SDK version. This may indicate a version prior to 0.30.0. |
| 327 | + </Text> |
| 328 | + <div className="mt-4"> |
| 329 | + <Callout.Root |
| 330 | + color="red" |
| 331 | + size="1" |
| 332 | + className="mt-2 mb-4" |
| 333 | + > |
| 334 | + <Callout.Icon> |
| 335 | + <PiWarningOctagonFill /> |
| 336 | + </Callout.Icon> |
| 337 | + <Callout.Text> |
| 338 | + Possibly using an unsupported legacy version of the SDK (<0.30.0) |
| 339 | + </Callout.Text> |
| 340 | + </Callout.Root> |
| 341 | + <Text> |
| 342 | + Versions prior to 0.30.0 are unsupported in DevTools. Additionally, versions prior to |
| 343 | + 0.23.0 are considered unstable. Consider updating to the latest version. |
| 344 | + </Text> |
| 345 | + </div> |
| 346 | + </> |
316 | 347 | ) : ( |
317 | 348 | <> |
318 | 349 | <Text> |
319 | 350 | Detected version <strong>{version}</strong> of the JavaScript SDK. |
320 | 351 | {hasWindowConfig ? " Embedded via the HTML Script Tag." : null} |
321 | 352 | </Text> |
322 | | - {paddedVersionString(version) < paddedVersionString("0.23.0") ? ( |
| 353 | + {paddedVersionString(version) < paddedVersionString("0.30.0") ? ( |
323 | 354 | <div className="mt-4"> |
324 | | - <Text color="red"> |
325 | | - Using an unsupported legacy version of the SDK ({version}). |
326 | | - </Text>{" "} |
| 355 | + <Callout.Root |
| 356 | + color="red" |
| 357 | + size="1" |
| 358 | + className="mt-2 mb-4" |
| 359 | + > |
| 360 | + <Callout.Icon> |
| 361 | + <PiWarningOctagonFill /> |
| 362 | + </Callout.Icon> |
| 363 | + <Callout.Text> |
| 364 | + Using an unsupported legacy version of the SDK ({version}). |
| 365 | + </Callout.Text> |
| 366 | + </Callout.Root> |
327 | 367 | <Text> |
328 | | - Versions prior to 0.23.0 are considered unstable. Consider |
| 368 | + Versions prior to 0.30.0 are unsupported in DevTools. Consider |
329 | 369 | updating to the latest version. |
330 | 370 | </Text> |
331 | 371 | </div> |
@@ -465,13 +505,35 @@ function streamingPanel({ |
465 | 505 | ); |
466 | 506 | } |
467 | 507 |
|
468 | | -function payloadPanel({ payload }: SDKHealthCheckResult) { |
| 508 | +function payloadPanel({ hasPayload, payload }: SDKHealthCheckResult) { |
469 | 509 | return ( |
470 | | - <ValueField |
471 | | - value={payload} |
472 | | - valueType="json" |
473 | | - maxHeight={`calc(100vh - ${NAV_H}px - 150px)`} |
474 | | - /> |
| 510 | + <> |
| 511 | + {!hasPayload ? ( |
| 512 | + <> |
| 513 | + <Callout.Root |
| 514 | + color="amber" |
| 515 | + size="1" |
| 516 | + className="mb-4" |
| 517 | + > |
| 518 | + <Callout.Icon> |
| 519 | + <PiWarningFill /> |
| 520 | + </Callout.Icon> |
| 521 | + <Callout.Text> |
| 522 | + No payload present in your SDK |
| 523 | + </Callout.Text> |
| 524 | + </Callout.Root> |
| 525 | + <Text as="div" size="2" weight="regular"> |
| 526 | + Please check your implementation. |
| 527 | + </Text> |
| 528 | + </> |
| 529 | + ) : ( |
| 530 | + <ValueField |
| 531 | + value={payload} |
| 532 | + valueType="json" |
| 533 | + maxHeight={`calc(100vh - ${NAV_H}px - 150px)`} |
| 534 | + /> |
| 535 | + )} |
| 536 | + </> |
475 | 537 | ); |
476 | 538 | } |
477 | 539 |
|
|
0 commit comments