ToolJet/frontend/src/_ui/JSONTreeViewer/JSONNodeValue.jsx

36 lines
945 B
React
Raw Normal View History

[Improvement/feature] Redesigned application inspector 🚀 (#2789) * JSON Tree Viewer component: init * JSON Node indicator * Node indicator and NodeString * function to get current node type and render component accordingly * Handles Object, Array, String type * Show/hide node identifier for only array and object with more than 0 items * adds option to render node icons * inspector json-tree: queries icons * inspector json-tree: component icons * fixes min/max width for the inspector popup card * renames node details: keys to entries * fixes getting the type of the currentNode * inspector styes and style fixes for string, bools and number * handles styles for undefined and null type * removes type label for null and undefined * fixes node margins * adds option to use indentation node block (css border for node groups) * improvement: update pinned icon as per pinned state * fixes expanding and flatenning the first element of a nested list * fixes length label displays false, should always be number. * handles function type * fixes margin for String nodes * inspector styles * updates hexacode for selected node bg * styles fixes * adds copy-to-clipboard for each nodes * show hide buttons for actions on mouse enter * adds: delete widget from inspector popup * adds: widget selector action * tooltip for showHide options action buttons * refactor * adds: runQuery action for queries * removes icons for root nodes for inspector * Toggle icon (NodeIndicator) should should be displayed for Object and array type (0 length) * hide node indicator for functions * removes hover for nodes * styles fixes * on hover icons are not visible for expanded items * style updates: selectable node * adds onSelect callback option on lables * adds: on expand with onclick lables props * fixes cursor styles on Mouse enter * fixes copy to clipboard action: from value to path * fixes currentPath * copy path to clipboard, return absolute path * fixes broken widget icons * selecting a widget in editor, selects the component/node in the tree * fixes app crash when adding runjs queries to the json-vieweer * fixes text-transformation to active nodes * fixes with selectedWidget in the editor, expandable node was alwasys the widget node * adds: dark theme * clean up * error boundary * fixes: current node and hovered node update callback on mouse enter * fixes options alignmeny * adds more actions menu option popover * refactored * fixes reverse selection fo widget and node * fixes radio button svg icon * fixes: two child nodes of different parent get the active class * fixes popover menu options * fixes selected node display:hidden * clean up * toggle icon should not expand if empty * adds tooltip for more actions * spliting into different files * minor improvements: toggling icon should select the label node, selected node if string should not updated to the last selected widget node * resolves lifecycle method changes * resolves changes * resolves changes * revert lock file changes * Revert "revert lock file changes" This reverts commit 10de6accf7026d48d5d13b5c94b2b91d91399e62. * fixes: app crash, undoing one widget from canvas * adds a comment for expand with labels * minor enhancement:onMouseEnter updates the current hovered node * minor enhancement: differentiate hovered node
2022-05-05 08:24:12 +00:00
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)} ... "`;
}
[Improvement/feature] Redesigned application inspector 🚀 (#2789) * JSON Tree Viewer component: init * JSON Node indicator * Node indicator and NodeString * function to get current node type and render component accordingly * Handles Object, Array, String type * Show/hide node identifier for only array and object with more than 0 items * adds option to render node icons * inspector json-tree: queries icons * inspector json-tree: component icons * fixes min/max width for the inspector popup card * renames node details: keys to entries * fixes getting the type of the currentNode * inspector styes and style fixes for string, bools and number * handles styles for undefined and null type * removes type label for null and undefined * fixes node margins * adds option to use indentation node block (css border for node groups) * improvement: update pinned icon as per pinned state * fixes expanding and flatenning the first element of a nested list * fixes length label displays false, should always be number. * handles function type * fixes margin for String nodes * inspector styles * updates hexacode for selected node bg * styles fixes * adds copy-to-clipboard for each nodes * show hide buttons for actions on mouse enter * adds: delete widget from inspector popup * adds: widget selector action * tooltip for showHide options action buttons * refactor * adds: runQuery action for queries * removes icons for root nodes for inspector * Toggle icon (NodeIndicator) should should be displayed for Object and array type (0 length) * hide node indicator for functions * removes hover for nodes * styles fixes * on hover icons are not visible for expanded items * style updates: selectable node * adds onSelect callback option on lables * adds: on expand with onclick lables props * fixes cursor styles on Mouse enter * fixes copy to clipboard action: from value to path * fixes currentPath * copy path to clipboard, return absolute path * fixes broken widget icons * selecting a widget in editor, selects the component/node in the tree * fixes app crash when adding runjs queries to the json-vieweer * fixes text-transformation to active nodes * fixes with selectedWidget in the editor, expandable node was alwasys the widget node * adds: dark theme * clean up * error boundary * fixes: current node and hovered node update callback on mouse enter * fixes options alignmeny * adds more actions menu option popover * refactored * fixes reverse selection fo widget and node * fixes radio button svg icon * fixes: two child nodes of different parent get the active class * fixes popover menu options * fixes selected node display:hidden * clean up * toggle icon should not expand if empty * adds tooltip for more actions * spliting into different files * minor improvements: toggling icon should select the label node, selected node if string should not updated to the last selected widget node * resolves lifecycle method changes * resolves changes * resolves changes * revert lock file changes * Revert "revert lock file changes" This reverts commit 10de6accf7026d48d5d13b5c94b2b91d91399e62. * fixes: app crash, undoing one widget from canvas * adds a comment for expand with labels * minor enhancement:onMouseEnter updates the current hovered node * minor enhancement: differentiate hovered node
2022-05-05 08:24:12 +00:00
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;