mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-06 06:48:21 +00:00
* followup to: 2789
* Revert "followup to: 2789"
This reverts commit 8a2b8b90a4.
* followup to: 2789
35 lines
945 B
JavaScript
35 lines
945 B
JavaScript
import React from 'react';
|
|
|
|
const JSONTreeValueNode = ({ data, type }) => {
|
|
if (type === 'Function') {
|
|
const functionString = `${data.toString().split('{')[0].trim()}{...}`;
|
|
return (
|
|
<React.Fragment>
|
|
<span
|
|
className={`text-secondary node-value-${type}`}
|
|
style={{ fontSize: '12px', fontFamily: 'monospace', textTransform: 'none' }}
|
|
>
|
|
{functionString}
|
|
</span>
|
|
</React.Fragment>
|
|
);
|
|
}
|
|
|
|
let value = type === 'String' ? `"${data}"` : String(data);
|
|
if (value.length > 65) {
|
|
value = `${value.substring(0, 65)} ... "`;
|
|
}
|
|
|
|
const clsForUndefinedOrNull = (type === 'Undefined' || type === 'Null') && 'badge badge-secondary';
|
|
return (
|
|
<span
|
|
className={`mx-2 json-tree-valuetype json-tree-node-${String(
|
|
type
|
|
).toLowerCase()} text-break ${clsForUndefinedOrNull}`}
|
|
>
|
|
{value}
|
|
</span>
|
|
);
|
|
};
|
|
|
|
export default JSONTreeValueNode;
|