Skip to content

Commit 214e8c2

Browse files
fix: FIT-159: Storage error logs modal not optimized for dark mode (#7867)
Co-authored-by: ricardoantoniocm <[email protected]>
1 parent aa23c80 commit 214e8c2

File tree

5 files changed

+67
-36
lines changed

5 files changed

+67
-36
lines changed

web/apps/labelstudio/src/components/Card/Card.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
font-size: 16px;
1313
line-height: 18px;
1414
justify-content: space-between;
15-
box-shadow: 0 1px 0 0 rgb(0 0 0 / 10%);
15+
border-bottom: 1px solid var(--color-neutral-border);
1616

1717
&-content {
1818
display: flex;

web/apps/labelstudio/src/pages/Settings/StorageSettings/StorageCard.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ export const StorageCard = ({ rootClass, target, storage, onEditStorage, onDelet
6363
storageTypes={storageTypes}
6464
/>
6565
<div className={rootClass.elem("sync")}>
66-
<div>
66+
<div className="mt-base">
6767
<Button
6868
look="outlined"
6969
waiting={syncing}
7070
onClick={startSync}
7171
disabled={notSyncedYet}
72-
aria-label="Sync storage"
72+
aria-label="Sync Storage"
7373
>
7474
Sync Storage
7575
</Button>

web/apps/labelstudio/src/pages/Settings/StorageSettings/StorageSummary.jsx

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,21 @@
1-
import { Button, Space, Tooltip } from "@humansignal/ui";
21
import { format } from "date-fns/esm";
2+
import { Button, CodeBlock, IconFileCopy, Space, Tooltip } from "@humansignal/ui";
33
import { DescriptionList } from "../../../components/DescriptionList/DescriptionList";
44
import { modal } from "../../../components/Modal/Modal";
55
import { Oneof } from "../../../components/Oneof/Oneof";
66
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+
};
719

820
export const StorageSummary = ({ target, storage, className, storageTypes = [] }) => {
921
const storageStatus = storage.status.replace(/_/g, " ").replace(/(^\w)/, (match) => match.toUpperCase());
@@ -36,34 +48,34 @@ export const StorageSummary = ({ target, storage, className, storageTypes = [] }
3648
`storage ${storage.id} in project ${storage.project} and job ${storage.last_sync_job}:\n\n` +
3749
`${getLastTraceback(storage.traceback)}\n\n` +
3850
`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
5776
</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>
6577
</Space>
66-
</>
78+
</div>
6779
),
6880
style: { width: "700px" },
6981
optimize: false,
@@ -97,8 +109,11 @@ export const StorageSummary = ({ target, storage, className, storageTypes = [] }
97109
].join("\n")}
98110
>
99111
{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)
102117
</span>
103118
) : (
104119
storageStatus

web/libs/ui/src/lib/Card/Card.module.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.card {
22
border-radius: 5px;
33
background-color: var(--color-neutral-background);
4-
border: 1px solid var(--sand_300);
4+
border: 1px solid var(--color-neutral-border);
55

66

77
&:not(:first-child) {
@@ -24,7 +24,7 @@
2424
line-height: 18px;
2525
align-items: center;
2626
justify-content: space-between;
27-
box-shadow: 0 1px 0 0 rgb(0 0 0 / 10%);
27+
border-bottom: 1px solid var(--color-neutral-border);
2828
}
2929

3030
.header.headerNoUnderline {
Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1+
import { cnm } from "@humansignal/ui";
2+
13
export function CodeBlock({
24
code,
35
className,
6+
variant = "default",
47
}: {
58
title?: string;
69
description?: string;
710
code: string;
811
className?: string;
12+
variant?: "default" | "warning" | "negative";
913
}) {
14+
const variantStyles = {
15+
default: "bg-neutral-surface border-neutral-border",
16+
warning: "bg-warning-background border-warning-border-subtle",
17+
negative: "bg-negative-background border-negative-border-subtle",
18+
};
19+
1020
return (
11-
<div className={`whitespace-pre-wrap font-mono mt-2 p-3 bg-neutral-surface rounded-md ${className || ""}`}>
12-
{code.trim()}
21+
<div
22+
className={cnm(
23+
"p-3 rounded-small border scrollbar-thin scrollbar-thumb-neutral-border-bold scrollbar-track-transparent",
24+
variantStyles[variant],
25+
className,
26+
)}
27+
>
28+
<pre className="whitespace-pre-wrap">{code.trim()}</pre>
1329
</div>
1430
);
1531
}

0 commit comments

Comments
 (0)