|
1 |
| -import { Button, Space, Tooltip } from "@humansignal/ui"; |
2 | 1 | import { format } from "date-fns/esm";
|
| 2 | +import { Button, CodeBlock, IconFileCopy, Space, Tooltip } from "@humansignal/ui"; |
3 | 3 | import { DescriptionList } from "../../../components/DescriptionList/DescriptionList";
|
4 | 4 | import { modal } from "../../../components/Modal/Modal";
|
5 | 5 | import { Oneof } from "../../../components/Oneof/Oneof";
|
6 | 6 | import { getLastTraceback } from "../../../utils/helpers";
|
| 7 | +import { useCopyText } from "@humansignal/core/lib/hooks/useCopyText"; |
| 8 | + |
| 9 | +// Component to handle copy functionality within the modal |
| 10 | +const CopyButton = ({ msg }) => { |
| 11 | + const [copyText, copied] = useCopyText(msg); |
| 12 | + |
| 13 | + return ( |
| 14 | + <Button variant="neutral" icon={<IconFileCopy />} onClick={copyText} disabled={copied} className="w-[7rem]"> |
| 15 | + {copied ? "Copied!" : "Copy"} |
| 16 | + </Button> |
| 17 | + ); |
| 18 | +}; |
7 | 19 |
|
8 | 20 | export const StorageSummary = ({ target, storage, className, storageTypes = [] }) => {
|
9 | 21 | const storageStatus = storage.status.replace(/_/g, " ").replace(/(^\w)/, (match) => match.toUpperCase());
|
@@ -36,34 +48,34 @@ export const StorageSummary = ({ target, storage, className, storageTypes = [] }
|
36 | 48 | `storage ${storage.id} in project ${storage.project} and job ${storage.last_sync_job}:\n\n` +
|
37 | 49 | `${getLastTraceback(storage.traceback)}\n\n` +
|
38 | 50 | `meta = ${JSON.stringify(storage.meta)}\n`;
|
39 |
| - const targetType = target === "export" ? "Target" : "Source"; |
40 |
| - |
41 |
| - modal({ |
42 |
| - title: "Storage error logs", |
43 |
| - body: ( |
44 |
| - <> |
45 |
| - <pre className="bg-neutral-surface-inset text-neutral-content-subtler p-base mb-base rounded-md text-body-smaller overflow-scroll"> |
46 |
| - {msg} |
47 |
| - </pre> |
48 |
| - <Space spread> |
49 |
| - <Button |
50 |
| - size="small" |
51 |
| - look="outlined" |
52 |
| - onClick={() => { |
53 |
| - navigator.clipboard.writeText(msg); |
54 |
| - }} |
55 |
| - > |
56 |
| - Copy |
| 51 | + |
| 52 | + const currentModal = modal({ |
| 53 | + title: "Storage Sync Error Log", |
| 54 | + body: <CodeBlock code={msg} variant="negative" className="max-h-[50vh] overflow-y-auto" />, |
| 55 | + footer: ( |
| 56 | + <div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}> |
| 57 | + {!window.APP_SETTINGS?.whitelabel_is_active && ( |
| 58 | + <div> |
| 59 | + <> |
| 60 | + <a |
| 61 | + href="https://labelstud.io/guide/storage.html#Troubleshooting" |
| 62 | + target="_blank" |
| 63 | + rel="noreferrer noopener" |
| 64 | + aria-label="Learn more about cloud storage troubleshooting" |
| 65 | + > |
| 66 | + See docs |
| 67 | + </a>{" "} |
| 68 | + for troubleshooting tips on cloud storage connections. |
| 69 | + </> |
| 70 | + </div> |
| 71 | + )} |
| 72 | + <Space> |
| 73 | + <CopyButton msg={msg} /> |
| 74 | + <Button variant="primary" className="w-[7rem]" onClick={() => currentModal.close()}> |
| 75 | + Close |
57 | 76 | </Button>
|
58 |
| - <a |
59 |
| - target="_blank" |
60 |
| - rel="noreferrer" |
61 |
| - href={`https://labelstud.io/guide/storage.html#${targetType}-storage-permissions`} |
62 |
| - > |
63 |
| - Check {targetType} Storage documentation |
64 |
| - </a> |
65 | 77 | </Space>
|
66 |
| - </> |
| 78 | + </div> |
67 | 79 | ),
|
68 | 80 | style: { width: "700px" },
|
69 | 81 | optimize: false,
|
@@ -97,8 +109,11 @@ export const StorageSummary = ({ target, storage, className, storageTypes = [] }
|
97 | 109 | ].join("\n")}
|
98 | 110 | >
|
99 | 111 | {storageStatus === "Failed" ? (
|
100 |
| - <span style={{ cursor: "pointer", borderBottom: "1px dashed gray" }} onClick={handleButtonClick}> |
101 |
| - Failed |
| 112 | + <span |
| 113 | + className="cursor-pointer border-b border-dashed border-negative-border-subtle text-negative-content" |
| 114 | + onClick={handleButtonClick} |
| 115 | + > |
| 116 | + Failed (View Logs) |
102 | 117 | </span>
|
103 | 118 | ) : (
|
104 | 119 | storageStatus
|
|
0 commit comments