Skip to content

Commit 4933f81

Browse files
committed
feat(ui): Add interactive preserve-structure toggle to DataLogic editors
Wire up `onPreserveStructureChange` callback with local state so users can toggle the preserve-structure option in all detail views (DataLogic, Mapping, Task, ValidationRule). Bump package version to 2.0.16.
1 parent ad82d8b commit 4933f81

File tree

5 files changed

+21
-7
lines changed

5 files changed

+21
-7
lines changed

ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@goplasmatic/dataflow-ui",
3-
"version": "2.0.15",
3+
"version": "2.0.16",
44
"type": "module",
55
"description": "React visualization library for dataflow-rs workflow engine",
66
"author": "Plasmatic Engineering <shankar@goplasmatic.io>",

ui/src/components/workflow-visualizer/views/detail-views/DataLogicView.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useState } from 'react';
12
import { DataLogicEditor } from '@goplasmatic/datalogic-ui';
23
import type { JsonLogicValue } from '../../../../types';
34
import { useTheme } from '../../context';
@@ -9,14 +10,16 @@ interface DataLogicViewProps {
910

1011
export function DataLogicView({ value, data }: DataLogicViewProps) {
1112
const { resolvedTheme } = useTheme();
13+
const [preserveStructure, setPreserveStructure] = useState(true);
1214

1315
return (
1416
<div className="df-details-content">
1517
<div className="df-details-logic-editor" data-theme={resolvedTheme}>
1618
<DataLogicEditor
1719
value={value}
1820
theme={resolvedTheme}
19-
preserveStructure={true}
21+
preserveStructure={preserveStructure}
22+
onPreserveStructureChange={setPreserveStructure}
2023
className="df-datalogic-viewer"
2124
data={data}
2225
/>

ui/src/components/workflow-visualizer/views/detail-views/MappingContent.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useState } from 'react';
12
import { DataLogicEditor } from '@goplasmatic/datalogic-ui';
23
import type { JsonLogicValue } from '../../../../types';
34
import { getMappingContext } from '../../../../types';
@@ -12,6 +13,7 @@ export function MappingContent({ selection }: MappingContentProps) {
1213
const { mapping } = selection;
1314
const { resolvedTheme } = useTheme();
1415
const dbgContext = useDebuggerOptional();
16+
const [preserveStructure, setPreserveStructure] = useState(true);
1517

1618
// Show the mapping as { path: logic }
1719
const visualData: Record<string, JsonLogicValue> = {
@@ -37,7 +39,8 @@ export function MappingContent({ selection }: MappingContentProps) {
3739
<DataLogicEditor
3840
value={visualData}
3941
theme={resolvedTheme}
40-
preserveStructure={true}
42+
preserveStructure={preserveStructure}
43+
onPreserveStructureChange={setPreserveStructure}
4144
className="df-datalogic-viewer"
4245
data={debugData}
4346
/>

ui/src/components/workflow-visualizer/views/detail-views/TaskContent.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useState } from 'react';
12
import { DataLogicEditor } from '@goplasmatic/datalogic-ui';
23
import type { JsonLogicValue, MappingItem, ValidationRule } from '../../../../types';
34
import { getMappingContext } from '../../../../types';
@@ -13,6 +14,7 @@ export function TaskContent({ selection }: TaskContentProps) {
1314
const { task } = selection;
1415
const { resolvedTheme } = useTheme();
1516
const dbgContext = useDebuggerOptional();
17+
const [preserveStructure, setPreserveStructure] = useState(true);
1618
const functionName = task.function.name;
1719
const input = task.function.input as Record<string, unknown> | undefined;
1820

@@ -45,7 +47,8 @@ export function TaskContent({ selection }: TaskContentProps) {
4547
<DataLogicEditor
4648
value={visualData}
4749
theme={resolvedTheme}
48-
preserveStructure={true}
50+
preserveStructure={preserveStructure}
51+
onPreserveStructureChange={setPreserveStructure}
4952
className="df-datalogic-viewer"
5053
data={debugData}
5154
/>
@@ -66,7 +69,8 @@ export function TaskContent({ selection }: TaskContentProps) {
6669
<DataLogicEditor
6770
value={andExpression}
6871
theme={resolvedTheme}
69-
preserveStructure={true}
72+
preserveStructure={preserveStructure}
73+
onPreserveStructureChange={setPreserveStructure}
7074
className="df-datalogic-viewer"
7175
data={debugData}
7276
/>
@@ -82,7 +86,8 @@ export function TaskContent({ selection }: TaskContentProps) {
8286
<DataLogicEditor
8387
value={task.function.input as JsonLogicValue}
8488
theme={resolvedTheme}
85-
preserveStructure={true}
89+
preserveStructure={preserveStructure}
90+
onPreserveStructureChange={setPreserveStructure}
8691
className="df-datalogic-viewer"
8792
/>
8893
</div>

ui/src/components/workflow-visualizer/views/detail-views/ValidationRuleContent.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useState } from 'react';
12
import { DataLogicEditor } from '@goplasmatic/datalogic-ui';
23
import type { TreeSelectionType } from '../../WorkflowVisualizer';
34
import { useTheme, useDebuggerOptional } from '../../context';
@@ -10,6 +11,7 @@ export function ValidationRuleContent({ selection }: ValidationRuleContentProps)
1011
const { rule } = selection;
1112
const { resolvedTheme } = useTheme();
1213
const dbgContext = useDebuggerOptional();
14+
const [preserveStructure, setPreserveStructure] = useState(true);
1315

1416
// When debugger is active, pass the task-level message context (validation is read-only)
1517
let debugData: Record<string, unknown> | undefined;
@@ -31,7 +33,8 @@ export function ValidationRuleContent({ selection }: ValidationRuleContentProps)
3133
<DataLogicEditor
3234
value={rule.logic}
3335
theme={resolvedTheme}
34-
preserveStructure={true}
36+
preserveStructure={preserveStructure}
37+
onPreserveStructureChange={setPreserveStructure}
3538
className="df-datalogic-viewer"
3639
data={debugData}
3740
/>

0 commit comments

Comments
 (0)