Skip to content

Commit f9e94fd

Browse files
niklubnik
andauthoredJun 11, 2025
fix: BROS-99: Task source JSON payload overflows the modal (#7739)
Co-authored-by: nik <nik@heartex.net>
1 parent 96a0eda commit f9e94fd

File tree

1 file changed

+42
-7
lines changed
  • web/libs/datamanager/src/components/Common/Table

1 file changed

+42
-7
lines changed
 

‎web/libs/datamanager/src/components/Common/Table/Table.jsx

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import { observer } from "mobx-react";
22
import { createContext, forwardRef, useCallback, useEffect, useMemo, useRef, useState } from "react";
33
import { useSDK } from "../../../providers/SDKProvider";
44
import { isDefined } from "../../../utils/utils";
5-
import { Button } from "../Button/Button";
65
import { Icon } from "../Icon/Icon";
76
import { modal } from "../Modal/Modal";
8-
import { IconCode, IconGear, IconGearNewUI } from "@humansignal/icons";
9-
import { AutoSizerTable, Tooltip } from "@humansignal/ui";
7+
import { IconCode, IconGear, IconGearNewUI, IconCopyOutline } from "@humansignal/icons";
8+
import { AutoSizerTable, Tooltip, Button } from "@humansignal/ui";
9+
import { useCopyText } from "@humansignal/core/lib/hooks/useCopyText";
1010
import "./Table.scss";
1111
import { TableCheckboxCell } from "./TableCheckbox";
1212
import { tableCN, TableContext } from "./TableContext";
@@ -132,16 +132,16 @@ export const Table = observer(
132132
return (
133133
<Tooltip title="Show task source">
134134
<Button
135-
type="link"
136-
style={{ width: 32, height: 32, padding: 0 }}
135+
look="string"
136+
className="w-6 h-6 p-0 text-primary-content hover:text-primary-content-hover"
137137
onClick={() => {
138138
modal({
139139
title: `Source for task ${out?.id}`,
140140
style: { width: 800 },
141141
body: <TaskSourceView content={out} onTaskLoad={onTaskLoad} sdkType={type} />,
142142
});
143143
}}
144-
icon={<Icon icon={IconCode} />}
144+
leading={<Icon icon={IconCode} />}
145145
/>
146146
</Tooltip>
147147
);
@@ -445,5 +445,40 @@ const TaskSourceView = ({ content, onTaskLoad, sdkType }) => {
445445
});
446446
}, []);
447447

448-
return <pre>{source ? JSON.stringify(source, null, " ") : null}</pre>;
448+
const jsonString = useMemo(() => {
449+
return source ? JSON.stringify(source, null, 2) : "";
450+
}, [source]);
451+
452+
const [handleCopy, copied] = useCopyText(jsonString);
453+
454+
return (
455+
<div
456+
className="bg-neutral-surface rounded-small font-mono text-body-small leading-body-small overflow-auto max-h-[500px]"
457+
style={{ position: "relative" }}
458+
>
459+
<div style={{ padding: "16px", paddingTop: "16px" }}>
460+
<Tooltip title={copied ? "Copied!" : "Copy JSON"}>
461+
<Button
462+
look="string"
463+
variant="neutral"
464+
style={{
465+
position: "absolute",
466+
top: "8px",
467+
right: "8px",
468+
width: 32,
469+
height: 32,
470+
padding: 0,
471+
zIndex: 10,
472+
color: "var(--color-neutral-content-subtle)",
473+
}}
474+
onClick={handleCopy}
475+
leading={<Icon icon={IconCopyOutline} style={{ color: "var(--color-neutral-content-subtle)" }} />}
476+
/>
477+
</Tooltip>
478+
<pre className="m-0 whitespace-pre-wrap break-words max-w-full" style={{ marginRight: "40px" }}>
479+
{jsonString}
480+
</pre>
481+
</div>
482+
</div>
483+
);
449484
};

0 commit comments

Comments
 (0)