Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace custom HTML with a JSON view #187

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 4 additions & 25 deletions frontend/src/components/nodes/NodeOutputDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import SyntaxHighlighter from 'react-syntax-highlighter/dist/cjs/prism'
import { oneDark } from 'react-syntax-highlighter/dist/cjs/styles/prism'
import { Icon } from '@iconify/react'

import JsonView from 'react18-json-view'
import 'react18-json-view/src/style.css'

interface NodeOutputDisplayProps {
output: Record<string, any>
}
Expand Down Expand Up @@ -143,31 +146,7 @@ const NodeOutputDisplay: React.FC<NodeOutputDisplayProps> = ({ output }) => {
const renderJsonObject = (obj: Record<string, any>) => {
return (
<div style={{ width: '100%' }}>
{Object.entries(obj).map(([key, val]) => (
<div
key={key}
className="group mb-2 ml-2 border-l-2 border-gray-200 dark:border-gray-700/50 pl-2"
>
<div className="text-lg font-semibold mb-1">{key}:</div>
<div className="ml-2">{renderValue(val)}</div>
<div className="flex justify-end mt-3">
<button
onClick={(e) => {
e.stopPropagation();
copyToClipboard(val, key);
}}
className="px-3 py-1.5 rounded-md bg-white/10 dark:bg-gray-800/50 hover:bg-gray-100 dark:hover:bg-gray-700/50 transition-all flex items-center gap-2 border border-gray-200 dark:border-gray-700/50 text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200"
title="Copy to clipboard"
>
<Icon
icon={copiedKey === key ? 'solar:check-circle-bold' : 'solar:copy-linear'}
className={copiedKey === key ? 'text-green-500 dark:text-green-400' : 'text-gray-500 dark:text-gray-400'}
width={16}
/>
</button>
</div>
</div>
))}
<JsonView src={obj} />
</div>
)
}
Expand Down