ToolJet/frontend/src/_ui/JSONTreeViewer/JSONNodeValue.jsx
Arpit 7c7b011537
[inspector] followup to #2789 (#3027)
* followup to: 2789

* Revert "followup to: 2789"

This reverts commit 8a2b8b90a4.

* followup to: 2789
2022-05-11 15:01:12 +05:30

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;