@tduniec/plugin-template-designer 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +2 -2
- package/dist/alpha.esm.js +2 -2
- package/dist/alpha.esm.js.map +1 -1
- package/dist/components/DesignerFlow/DesignerFlow.esm.js +97 -54
- package/dist/components/DesignerFlow/DesignerFlow.esm.js.map +1 -1
- package/dist/components/DesignerFlow/handlers.esm.js +14 -3
- package/dist/components/DesignerFlow/handlers.esm.js.map +1 -1
- package/dist/components/Nodes/ActionNode.esm.js +6 -4
- package/dist/components/Nodes/ActionNode.esm.js.map +1 -1
- package/dist/components/Nodes/OutputNode.esm.js +3 -1
- package/dist/components/Nodes/OutputNode.esm.js.map +1 -1
- package/dist/components/Nodes/ParametersNode.esm.js +3 -1
- package/dist/components/Nodes/ParametersNode.esm.js.map +1 -1
- package/dist/components/Nodes/action/schema.esm.js +36 -9
- package/dist/components/Nodes/action/schema.esm.js.map +1 -1
- package/dist/components/TemplateDesigner/TemplateDesigner.esm.js +70 -46
- package/dist/components/TemplateDesigner/TemplateDesigner.esm.js.map +1 -1
- package/dist/components/TemplateDesigner/components/FieldEditorDialog.esm.js +42 -19
- package/dist/components/TemplateDesigner/components/FieldEditorDialog.esm.js.map +1 -1
- package/dist/components/TemplateDesigner/components/TemplateLanding.esm.js +1 -0
- package/dist/components/TemplateDesigner/components/TemplateLanding.esm.js.map +1 -1
- package/dist/components/TemplateDesigner/components/TemplateWorkspace.esm.js +224 -174
- package/dist/components/TemplateDesigner/components/TemplateWorkspace.esm.js.map +1 -1
- package/dist/components/TemplateDesigner/components/codemirrorTheme.esm.js +30 -0
- package/dist/components/TemplateDesigner/components/codemirrorTheme.esm.js.map +1 -0
- package/dist/components/TemplateDesigner/useFieldEditor.esm.js +31 -32
- package/dist/components/TemplateDesigner/useFieldEditor.esm.js.map +1 -1
- package/dist/components/TemplateDesigner/useTemplateState.esm.js +253 -53
- package/dist/components/TemplateDesigner/useTemplateState.esm.js.map +1 -1
- package/dist/components/TemplateDesignerIcon.esm.js +33 -0
- package/dist/components/TemplateDesignerIcon.esm.js.map +1 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.esm.js +1 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/package.json.esm.js +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -58,11 +58,11 @@ const routes = (
|
|
|
58
58
|
In `packages/app/src/components/Root/Root.tsx`:
|
|
59
59
|
|
|
60
60
|
```tsx
|
|
61
|
-
import DesignServicesIcon from "@mui/icons-material/DesignServices";
|
|
62
61
|
import { SidebarItem } from "@backstage/core-components";
|
|
62
|
+
import { TemplateDesignerIcon } from "@tduniec/plugin-template-designer";
|
|
63
63
|
|
|
64
64
|
<SidebarItem
|
|
65
|
-
icon={
|
|
65
|
+
icon={TemplateDesignerIcon}
|
|
66
66
|
to="template-designer"
|
|
67
67
|
text="Template Designer"
|
|
68
68
|
/>;
|
package/dist/alpha.esm.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { NavItemBlueprint, PageBlueprint, createFrontendPlugin } from '@backstage/frontend-plugin-api';
|
|
3
3
|
import { rootRouteRef } from './routes.esm.js';
|
|
4
|
-
import
|
|
4
|
+
import { TemplateDesignerIcon } from './components/TemplateDesignerIcon.esm.js';
|
|
5
5
|
|
|
6
6
|
const templateDesignerNavItem = NavItemBlueprint.make({
|
|
7
7
|
params: {
|
|
8
8
|
title: "Template designer",
|
|
9
9
|
routeRef: rootRouteRef,
|
|
10
|
-
icon:
|
|
10
|
+
icon: TemplateDesignerIcon
|
|
11
11
|
}
|
|
12
12
|
});
|
|
13
13
|
const templateDesignerPage = PageBlueprint.make({
|
package/dist/alpha.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["import {\n createFrontendPlugin,\n NavItemBlueprint,\n PageBlueprint,\n} from \"@backstage/frontend-plugin-api\";\nimport { rootRouteRef } from \"./routes\";\nimport
|
|
1
|
+
{"version":3,"file":"alpha.esm.js","sources":["../src/alpha.tsx"],"sourcesContent":["import {\n createFrontendPlugin,\n NavItemBlueprint,\n PageBlueprint,\n} from \"@backstage/frontend-plugin-api\";\nimport { rootRouteRef } from \"./routes\";\nimport { TemplateDesignerIcon } from \"./components/TemplateDesignerIcon\";\n\nconst templateDesignerNavItem = NavItemBlueprint.make({\n params: {\n title: \"Template designer\",\n routeRef: rootRouteRef,\n icon: TemplateDesignerIcon,\n },\n});\n\nconst templateDesignerPage = PageBlueprint.make({\n params: {\n path: \"/template-designer\",\n routeRef: rootRouteRef,\n loader: () =>\n import(\"./components/TemplateDesigner\").then((m) => (\n <m.TemplateDesigner />\n )),\n },\n});\n\n/**\n * Backstage frontend plugin.\n *\n * @alpha\n */\nexport default createFrontendPlugin({\n pluginId: \"template-designer\",\n info: { packageJson: () => import(\"../package.json\") },\n routes: {\n root: rootRouteRef,\n },\n extensions: [templateDesignerPage, templateDesignerNavItem],\n});\n"],"names":[],"mappings":";;;;;AAQA,MAAM,uBAAA,GAA0B,iBAAiB,IAAA,CAAK;AAAA,EACpD,MAAA,EAAQ;AAAA,IACN,KAAA,EAAO,mBAAA;AAAA,IACP,QAAA,EAAU,YAAA;AAAA,IACV,IAAA,EAAM;AAAA;AAEV,CAAC,CAAA;AAED,MAAM,oBAAA,GAAuB,cAAc,IAAA,CAAK;AAAA,EAC9C,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM,oBAAA;AAAA,IACN,QAAA,EAAU,YAAA;AAAA,IACV,MAAA,EAAQ,MACN,OAAO,4CAA+B,CAAA,CAAE,IAAA,CAAK,CAAC,CAAA,qBAC5C,GAAA,CAAC,CAAA,CAAE,gBAAA,EAAF,EAAmB,CACrB;AAAA;AAEP,CAAC,CAAA;AAOD,YAAe,oBAAA,CAAqB;AAAA,EAClC,QAAA,EAAU,mBAAA;AAAA,EACV,MAAM,EAAE,WAAA,EAAa,MAAM,OAAO,uBAAiB,CAAA,EAAE;AAAA,EACrD,MAAA,EAAQ;AAAA,IACN,IAAA,EAAM;AAAA,GACR;AAAA,EACA,UAAA,EAAY,CAAC,oBAAA,EAAsB,uBAAuB;AAC5D,CAAC,CAAA;;;;"}
|
|
@@ -82,6 +82,10 @@ function App({
|
|
|
82
82
|
const lastCacheFingerprintRef = useRef(null);
|
|
83
83
|
const nodeHeightsRef = useRef({});
|
|
84
84
|
const shouldAutoFitViewRef = useRef(true);
|
|
85
|
+
const emitDebounceRef = useRef(null);
|
|
86
|
+
const isDraggingRef = useRef(false);
|
|
87
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
88
|
+
const emitAfterDragRef = useRef(false);
|
|
85
89
|
useEffect(() => {
|
|
86
90
|
const isCacheChanged = cacheFingerprint !== lastCacheFingerprintRef.current;
|
|
87
91
|
const shouldSkip = modelHash === skipNextModelHashRef.current && !isCacheChanged;
|
|
@@ -178,7 +182,21 @@ function App({
|
|
|
178
182
|
[nodes, parameterReferences]
|
|
179
183
|
);
|
|
180
184
|
const onNodesChange = useCallback(
|
|
181
|
-
(changes) => setNodes((ns) =>
|
|
185
|
+
(changes) => setNodes((ns) => {
|
|
186
|
+
if (changes.some(
|
|
187
|
+
(change) => change.type === "position" && change.dragging
|
|
188
|
+
)) {
|
|
189
|
+
isDraggingRef.current = true;
|
|
190
|
+
setIsDragging(true);
|
|
191
|
+
} else if (changes.some(
|
|
192
|
+
(change) => change.type === "position" && change.dragging === false
|
|
193
|
+
)) {
|
|
194
|
+
const stillDragging = ns.some((node) => node.dragging);
|
|
195
|
+
isDraggingRef.current = stillDragging;
|
|
196
|
+
setIsDragging(stillDragging);
|
|
197
|
+
}
|
|
198
|
+
return applyNodeChanges(changes, ns);
|
|
199
|
+
}),
|
|
182
200
|
[setNodes]
|
|
183
201
|
);
|
|
184
202
|
const onEdgesChange = useCallback(
|
|
@@ -198,6 +216,8 @@ function App({
|
|
|
198
216
|
);
|
|
199
217
|
const onNodeDragStop = useCallback(
|
|
200
218
|
(_, node) => {
|
|
219
|
+
isDraggingRef.current = false;
|
|
220
|
+
setIsDragging(false);
|
|
201
221
|
reorderAndAlignNodes(node);
|
|
202
222
|
},
|
|
203
223
|
[reorderAndAlignNodes]
|
|
@@ -248,59 +268,55 @@ function App({
|
|
|
248
268
|
}),
|
|
249
269
|
[setNodes, setEdges]
|
|
250
270
|
);
|
|
251
|
-
const nodesWithHandlers = useMemo(
|
|
252
|
-
(
|
|
271
|
+
const nodesWithHandlers = useMemo(() => {
|
|
272
|
+
if (!nodes.length) {
|
|
273
|
+
return nodes;
|
|
274
|
+
}
|
|
275
|
+
return nodes.map((node) => {
|
|
253
276
|
const stepOutputReferences = stepOutputReferencesByNode[node.id] ?? [];
|
|
254
277
|
if (node.type === "parametersNode") {
|
|
255
278
|
const data2 = node.data;
|
|
256
|
-
|
|
257
|
-
...
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
onUpdateSections,
|
|
262
|
-
stepOutputReferences
|
|
263
|
-
}
|
|
279
|
+
const nextData2 = data2.onAddNode === handleAddNode && data2.onUpdateSections === onUpdateSections && data2.stepOutputReferences === stepOutputReferences ? data2 : {
|
|
280
|
+
...data2,
|
|
281
|
+
onAddNode: handleAddNode,
|
|
282
|
+
onUpdateSections,
|
|
283
|
+
stepOutputReferences
|
|
264
284
|
};
|
|
285
|
+
return data2 === nextData2 ? node : { ...node, data: nextData2 };
|
|
265
286
|
}
|
|
266
287
|
if (node.type === "outputNode") {
|
|
267
288
|
const data2 = node.data;
|
|
268
|
-
|
|
269
|
-
...
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
onUpdateOutput,
|
|
274
|
-
stepOutputReferences
|
|
275
|
-
}
|
|
289
|
+
const nextData2 = data2.onAddNode === handleAddNode && data2.onUpdateOutput === onUpdateOutput && data2.stepOutputReferences === stepOutputReferences ? data2 : {
|
|
290
|
+
...data2,
|
|
291
|
+
onAddNode: handleAddNode,
|
|
292
|
+
onUpdateOutput,
|
|
293
|
+
stepOutputReferences
|
|
276
294
|
};
|
|
295
|
+
return data2 === nextData2 ? node : { ...node, data: nextData2 };
|
|
277
296
|
}
|
|
278
297
|
const data = node.data;
|
|
279
|
-
|
|
280
|
-
...
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
onRemoveInputKey,
|
|
288
|
-
stepOutputReferences
|
|
289
|
-
}
|
|
298
|
+
const nextData = data.onAddNode === handleAddNode && data.onRemoveNode === handleRemoveNode && data.onUpdateField === onUpdateField && data.onUpdateInput === onUpdateInput && data.onRemoveInputKey === onRemoveInputKey && data.stepOutputReferences === stepOutputReferences ? data : {
|
|
299
|
+
...data,
|
|
300
|
+
onAddNode: handleAddNode,
|
|
301
|
+
onRemoveNode: handleRemoveNode,
|
|
302
|
+
onUpdateField,
|
|
303
|
+
onUpdateInput,
|
|
304
|
+
onRemoveInputKey,
|
|
305
|
+
stepOutputReferences
|
|
290
306
|
};
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
);
|
|
307
|
+
return data === nextData ? node : { ...node, data: nextData };
|
|
308
|
+
});
|
|
309
|
+
}, [
|
|
310
|
+
nodes,
|
|
311
|
+
handleAddNode,
|
|
312
|
+
handleRemoveNode,
|
|
313
|
+
onUpdateField,
|
|
314
|
+
onUpdateInput,
|
|
315
|
+
onRemoveInputKey,
|
|
316
|
+
onUpdateOutput,
|
|
317
|
+
onUpdateSections,
|
|
318
|
+
stepOutputReferencesByNode
|
|
319
|
+
]);
|
|
304
320
|
const stepsFromNodes = useMemo(() => extractStepsFromNodes(nodes), [nodes]);
|
|
305
321
|
const parametersFromNodes = useMemo(
|
|
306
322
|
() => extractParametersFromNodes(nodes),
|
|
@@ -312,6 +328,10 @@ function App({
|
|
|
312
328
|
if (!onStepsChange && !onParametersChange && !onOutputChange) {
|
|
313
329
|
return;
|
|
314
330
|
}
|
|
331
|
+
if (isDragging) {
|
|
332
|
+
emitAfterDragRef.current = true;
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
315
335
|
const serialized = stableStringify({
|
|
316
336
|
steps: stepsFromNodes,
|
|
317
337
|
parameters: parametersFromNodes ?? null,
|
|
@@ -320,17 +340,22 @@ function App({
|
|
|
320
340
|
if (serialized === lastEmittedModelHashRef.current) {
|
|
321
341
|
return;
|
|
322
342
|
}
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
if (onStepsChange) {
|
|
326
|
-
onStepsChange(stepsFromNodes);
|
|
327
|
-
}
|
|
328
|
-
if (onParametersChange) {
|
|
329
|
-
onParametersChange(parametersFromNodes ?? void 0);
|
|
330
|
-
}
|
|
331
|
-
if (onOutputChange) {
|
|
332
|
-
onOutputChange(outputFromNodes);
|
|
343
|
+
if (emitDebounceRef.current) {
|
|
344
|
+
clearTimeout(emitDebounceRef.current);
|
|
333
345
|
}
|
|
346
|
+
emitDebounceRef.current = setTimeout(() => {
|
|
347
|
+
lastEmittedModelHashRef.current = serialized;
|
|
348
|
+
skipNextModelHashRef.current = serialized;
|
|
349
|
+
if (onStepsChange) {
|
|
350
|
+
onStepsChange(stepsFromNodes);
|
|
351
|
+
}
|
|
352
|
+
if (onParametersChange) {
|
|
353
|
+
onParametersChange(parametersFromNodes ?? void 0);
|
|
354
|
+
}
|
|
355
|
+
if (onOutputChange) {
|
|
356
|
+
onOutputChange(outputFromNodes);
|
|
357
|
+
}
|
|
358
|
+
}, 120);
|
|
334
359
|
}, [
|
|
335
360
|
stepsFromNodes,
|
|
336
361
|
parametersFromNodes,
|
|
@@ -338,8 +363,17 @@ function App({
|
|
|
338
363
|
outputFromNodes,
|
|
339
364
|
onStepsChange,
|
|
340
365
|
onParametersChange,
|
|
341
|
-
onOutputChange
|
|
366
|
+
onOutputChange,
|
|
367
|
+
isDragging
|
|
342
368
|
]);
|
|
369
|
+
useEffect(
|
|
370
|
+
() => () => {
|
|
371
|
+
if (emitDebounceRef.current) {
|
|
372
|
+
clearTimeout(emitDebounceRef.current);
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
[]
|
|
376
|
+
);
|
|
343
377
|
const fitViewOptions = useMemo(() => ({ padding: 0.2, duration: 300 }), []);
|
|
344
378
|
const [reactFlowInstance, setReactFlowInstance] = useState(null);
|
|
345
379
|
const fitFlowToView = useCallback(() => {
|
|
@@ -367,6 +401,15 @@ function App({
|
|
|
367
401
|
window.removeEventListener("resize", fitFlowToView);
|
|
368
402
|
};
|
|
369
403
|
}, [fitFlowToView, reactFlowInstance]);
|
|
404
|
+
useEffect(() => {
|
|
405
|
+
if (!isDragging) {
|
|
406
|
+
if (emitAfterDragRef.current) {
|
|
407
|
+
emitAfterDragRef.current = false;
|
|
408
|
+
lastEmittedModelHashRef.current = null;
|
|
409
|
+
}
|
|
410
|
+
lastEmittedModelHashRef.current = null;
|
|
411
|
+
}
|
|
412
|
+
}, [isDragging]);
|
|
370
413
|
return /* @__PURE__ */ jsx("div", { style: { width: "100%", height: "100%", minHeight: "70vh" }, children: /* @__PURE__ */ jsx(
|
|
371
414
|
ReactFlow,
|
|
372
415
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DesignerFlow.esm.js","sources":["../../../src/components/DesignerFlow/DesignerFlow.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { MouseEvent as ReactMouseEvent } from \"react\";\nimport {\n ReactFlow,\n applyNodeChanges,\n applyEdgeChanges,\n addEdge,\n Node,\n Edge,\n NodeChange,\n EdgeChange,\n useNodesState,\n ReactFlowInstance,\n} from \"@xyflow/react\";\nimport \"@xyflow/react/dist/style.css\";\nimport type {\n ScaffolderTaskOutput,\n TaskStep,\n} from \"@backstage/plugin-scaffolder-common\";\nimport type {\n ActionNodeData,\n OutputNodeData,\n ParametersNodeData,\n TemplateParametersValue,\n} from \"../Nodes/types\";\nimport { createSequentialEdges } from \"../../utils/createSequentialEdges\";\nimport {\n collectStepOutputReferences,\n createHandleAddNode,\n createHandleRemoveNode,\n createHandleRemoveInputKey,\n createHandleReorderAndAlignNodes,\n createHandleUpdateField,\n createHandleUpdateInput,\n createHandleUpdateOutput,\n createHandleUpdateSections,\n} from \"./handlers\";\nimport {\n buildNodesFromModel,\n collectParameterReferences,\n stableStringify,\n resolveNodeHeightForTracking,\n extractStepsFromNodes,\n extractParametersFromNodes,\n extractOutputFromNodes,\n} from \"./model\";\nimport { alignNodes } from \"./nodeLayout\";\nimport { FLOW_LAYOUT, nodeDefaults, nodeTypes } from \"./flowConfig\";\nimport { useScaffolderActions } from \"../../api/scaffolderActions\";\n\n// Main orchestration component that renders and synchronizes the Designer flow.\n\nconst FIXED_X_POSITION = FLOW_LAYOUT.fixedXPosition;\nconst VERTICAL_SPACING = FLOW_LAYOUT.verticalSpacing;\n\ntype DesignerFlowProps = {\n steps?: TaskStep[];\n parameters?: TemplateParametersValue;\n output?: ScaffolderTaskOutput | null;\n onStepsChange?: (steps: TaskStep[]) => void;\n onParametersChange?: (parameters: TemplateParametersValue) => void;\n onOutputChange?: (output: ScaffolderTaskOutput | undefined) => void;\n};\n\nexport default function App({\n steps = [],\n parameters,\n output,\n onStepsChange,\n onParametersChange,\n onOutputChange,\n}: DesignerFlowProps) {\n const scaffolderActionsCache = useScaffolderActions();\n\n const {\n ids: scaffolderActionIds,\n inputsById: scaffolderActionInputsById,\n outputsById: scaffolderActionOutputsById,\n inputRequiredById: scaffolderActionInputRequiredById,\n } = scaffolderActionsCache;\n\n const normalizedParametersProp = parameters ?? undefined;\n const normalizedOutputProp = output ?? null;\n\n const initialNodes = useMemo(\n () =>\n buildNodesFromModel(\n steps,\n normalizedParametersProp,\n normalizedOutputProp,\n {\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionOutputsById,\n scaffolderActionInputRequiredById,\n }\n ),\n [\n steps,\n normalizedParametersProp,\n normalizedOutputProp,\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionOutputsById,\n scaffolderActionInputRequiredById,\n ]\n );\n\n const [nodes, setNodes] = useNodesState(initialNodes);\n const [edges, setEdges] = useState<Edge[]>(() =>\n createSequentialEdges(initialNodes)\n );\n\n const modelHash = useMemo(\n () =>\n stableStringify({\n steps,\n parameters: normalizedParametersProp,\n output: normalizedOutputProp,\n }),\n [steps, normalizedParametersProp, normalizedOutputProp]\n );\n\n const cacheFingerprint = useMemo(\n () =>\n stableStringify({\n ids: scaffolderActionIds,\n inputs: scaffolderActionInputsById,\n outputs: scaffolderActionOutputsById,\n inputRequired: scaffolderActionInputRequiredById,\n }),\n [\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionOutputsById,\n scaffolderActionInputRequiredById,\n ]\n );\n\n const lastAppliedModelHashRef = useRef<string | null>(null);\n const lastEmittedModelHashRef = useRef<string | null>(null);\n const skipNextModelHashRef = useRef<string | null>(null);\n const lastCacheFingerprintRef = useRef<string | null>(null);\n const nodeHeightsRef = useRef<Record<string, number>>({});\n const shouldAutoFitViewRef = useRef(true);\n\n useEffect(() => {\n const isCacheChanged = cacheFingerprint !== lastCacheFingerprintRef.current;\n const shouldSkip =\n modelHash === skipNextModelHashRef.current && !isCacheChanged;\n\n if (shouldSkip) {\n skipNextModelHashRef.current = null;\n lastAppliedModelHashRef.current = modelHash;\n lastCacheFingerprintRef.current = cacheFingerprint;\n return;\n }\n\n if (modelHash === lastAppliedModelHashRef.current && !isCacheChanged) {\n return;\n }\n\n const nextNodes = buildNodesFromModel(\n steps,\n normalizedParametersProp,\n normalizedOutputProp,\n {\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionOutputsById,\n scaffolderActionInputRequiredById,\n }\n );\n\n lastAppliedModelHashRef.current = modelHash;\n lastCacheFingerprintRef.current = cacheFingerprint;\n lastEmittedModelHashRef.current = modelHash;\n\n setNodes(nextNodes);\n setEdges(createSequentialEdges(nextNodes));\n shouldAutoFitViewRef.current = true;\n }, [\n steps,\n normalizedParametersProp,\n normalizedOutputProp,\n modelHash,\n cacheFingerprint,\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionOutputsById,\n scaffolderActionInputRequiredById,\n setNodes,\n setEdges,\n ]);\n\n useEffect(() => {\n if (!nodes.length) {\n return;\n }\n\n if (nodes.some((node) => node.dragging)) {\n return;\n }\n\n const activeNodeIds = new Set<string>();\n let hasMeasuredChange = false;\n\n nodes.forEach((node) => {\n activeNodeIds.add(node.id);\n const measuredHeight = resolveNodeHeightForTracking(node);\n if (typeof measuredHeight !== \"number\") {\n return;\n }\n const previousHeight = nodeHeightsRef.current[node.id];\n if (previousHeight !== measuredHeight) {\n nodeHeightsRef.current[node.id] = measuredHeight;\n hasMeasuredChange = true;\n }\n });\n\n Object.keys(nodeHeightsRef.current).forEach((id) => {\n if (!activeNodeIds.has(id)) {\n delete nodeHeightsRef.current[id];\n }\n });\n\n if (!hasMeasuredChange) {\n return;\n }\n\n setNodes((currentNodes) => {\n const alignedNodes = alignNodes(\n currentNodes,\n FIXED_X_POSITION,\n VERTICAL_SPACING\n );\n const positionsChanged = alignedNodes.some((node, index) => {\n const previousNode = currentNodes[index];\n if (!previousNode) {\n return true;\n }\n return (\n node.position.x !== previousNode.position.x ||\n node.position.y !== previousNode.position.y\n );\n });\n\n return positionsChanged ? alignedNodes : currentNodes;\n });\n }, [nodes, setNodes]);\n\n const parameterReferences = useMemo(\n () => collectParameterReferences(normalizedParametersProp),\n [normalizedParametersProp]\n );\n\n const stepOutputReferencesByNode = useMemo(\n () => collectStepOutputReferences(nodes, parameterReferences),\n [nodes, parameterReferences]\n );\n\n const onNodesChange = useCallback(\n (changes: NodeChange<Node>[]) =>\n setNodes((ns) => applyNodeChanges(changes, ns)),\n [setNodes]\n );\n\n const onEdgesChange = useCallback(\n (changes: EdgeChange<Edge>[]) =>\n setEdges((es) => applyEdgeChanges(changes, es)),\n [setEdges]\n );\n\n const onConnect = useCallback(\n (params: any) => setEdges((es) => addEdge(params, es)),\n [setEdges]\n );\n\n const reorderAndAlignNodes = useMemo(\n () =>\n createHandleReorderAndAlignNodes(setNodes, setEdges, {\n fixedXPosition: FIXED_X_POSITION,\n verticalSpacing: VERTICAL_SPACING,\n }),\n [setNodes, setEdges]\n );\n\n const onNodeDragStop = useCallback(\n (_: ReactMouseEvent, node: Node) => {\n reorderAndAlignNodes(node);\n },\n [reorderAndAlignNodes]\n );\n\n const onUpdateField = useMemo(\n () => createHandleUpdateField(setNodes),\n [setNodes]\n );\n\n const onUpdateInput = useMemo(\n () => createHandleUpdateInput(setNodes),\n [setNodes]\n );\n\n const onRemoveInputKey = useMemo(\n () => createHandleRemoveInputKey(setNodes),\n [setNodes]\n );\n\n const onUpdateOutput = useMemo(\n () => createHandleUpdateOutput(setNodes),\n [setNodes]\n );\n\n const onUpdateSections = useMemo(\n () => createHandleUpdateSections(setNodes),\n [setNodes]\n );\n\n const handleAddNode = useMemo(\n () =>\n createHandleAddNode(setNodes, setEdges, {\n fixedXPosition: FIXED_X_POSITION,\n verticalSpacing: VERTICAL_SPACING,\n nodeDefaults,\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionInputRequiredById,\n scaffolderActionOutputsById,\n }),\n [\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionOutputsById,\n scaffolderActionInputRequiredById,\n setNodes,\n setEdges,\n ]\n );\n\n const handleRemoveNode = useMemo(\n () =>\n createHandleRemoveNode(setNodes, setEdges, {\n fixedXPosition: FIXED_X_POSITION,\n verticalSpacing: VERTICAL_SPACING,\n }),\n [setNodes, setEdges]\n );\n\n const nodesWithHandlers = useMemo(\n () =>\n nodes.map((node) => {\n const stepOutputReferences = stepOutputReferencesByNode[node.id] ?? [];\n if (node.type === \"parametersNode\") {\n const data = node.data as ParametersNodeData;\n return {\n ...node,\n data: {\n ...data,\n onAddNode: handleAddNode,\n onUpdateSections,\n stepOutputReferences,\n },\n };\n }\n if (node.type === \"outputNode\") {\n const data = node.data as OutputNodeData;\n return {\n ...node,\n data: {\n ...data,\n onAddNode: handleAddNode,\n onUpdateOutput,\n stepOutputReferences,\n },\n };\n }\n\n const data = node.data as ActionNodeData;\n return {\n ...node,\n data: {\n ...data,\n onAddNode: handleAddNode,\n onRemoveNode: handleRemoveNode,\n onUpdateField,\n onUpdateInput,\n onRemoveInputKey,\n stepOutputReferences,\n },\n };\n }),\n [\n nodes,\n handleAddNode,\n handleRemoveNode,\n onUpdateField,\n onUpdateInput,\n onRemoveInputKey,\n onUpdateOutput,\n onUpdateSections,\n stepOutputReferencesByNode,\n ]\n );\n\n const stepsFromNodes = useMemo(() => extractStepsFromNodes(nodes), [nodes]);\n\n const parametersFromNodes = useMemo(\n () => extractParametersFromNodes(nodes),\n [nodes]\n );\n\n const outputFromNodes = useMemo(() => extractOutputFromNodes(nodes), [nodes]);\n\n const normalizedOutputFromNodes = outputFromNodes ?? null;\n\n useEffect(() => {\n if (!onStepsChange && !onParametersChange && !onOutputChange) {\n return;\n }\n const serialized = stableStringify({\n steps: stepsFromNodes,\n parameters: parametersFromNodes ?? null,\n output: normalizedOutputFromNodes,\n });\n if (serialized === lastEmittedModelHashRef.current) {\n return;\n }\n lastEmittedModelHashRef.current = serialized;\n skipNextModelHashRef.current = serialized;\n if (onStepsChange) {\n onStepsChange(stepsFromNodes);\n }\n if (onParametersChange) {\n onParametersChange(parametersFromNodes ?? undefined);\n }\n if (onOutputChange) {\n onOutputChange(outputFromNodes);\n }\n }, [\n stepsFromNodes,\n parametersFromNodes,\n normalizedOutputFromNodes,\n outputFromNodes,\n onStepsChange,\n onParametersChange,\n onOutputChange,\n ]);\n\n const fitViewOptions = useMemo(() => ({ padding: 0.2, duration: 300 }), []);\n const [reactFlowInstance, setReactFlowInstance] =\n useState<ReactFlowInstance | null>(null);\n\n const fitFlowToView = useCallback(() => {\n if (!reactFlowInstance) {\n return;\n }\n reactFlowInstance.fitView(fitViewOptions);\n }, [fitViewOptions, reactFlowInstance]);\n\n useEffect(() => {\n if (!reactFlowInstance) {\n return;\n }\n if (!shouldAutoFitViewRef.current) {\n return;\n }\n shouldAutoFitViewRef.current = false;\n fitFlowToView();\n }, [fitFlowToView, nodes, edges, reactFlowInstance]);\n\n useEffect(() => {\n if (!reactFlowInstance) {\n return undefined;\n }\n window.addEventListener(\"resize\", fitFlowToView);\n return () => {\n window.removeEventListener(\"resize\", fitFlowToView);\n };\n }, [fitFlowToView, reactFlowInstance]);\n\n return (\n <div style={{ width: \"100%\", height: \"100%\", minHeight: \"70vh\" }}>\n <ReactFlow\n nodes={nodesWithHandlers}\n edges={edges}\n nodeTypes={nodeTypes}\n onNodesChange={onNodesChange}\n onEdgesChange={onEdgesChange}\n onNodeDragStop={onNodeDragStop}\n onConnect={onConnect}\n fitView\n onInit={setReactFlowInstance}\n fitViewOptions={fitViewOptions}\n />\n </div>\n );\n}\n"],"names":["data"],"mappings":";;;;;;;;;;;AAoDA,MAAM,mBAAmB,WAAA,CAAY,cAAA;AACrC,MAAM,mBAAmB,WAAA,CAAY,eAAA;AAWrC,SAAwB,GAAA,CAAI;AAAA,EAC1B,QAAQ,EAAC;AAAA,EACT,UAAA;AAAA,EACA,MAAA;AAAA,EACA,aAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAA,EAAsB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,CAAC,aAAA,EAAe,KAAA,EAAO,KAAA,EAAO,iBAAiB,CAAC,CAAA;AAEnD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,iBAAA,EAAmB;AACtB,MAAA,OAAO,MAAA;AAAA,IACT;AACA,IAAA,MAAA,CAAO,gBAAA,CAAiB,UAAU,aAAa,CAAA;AAC/C,IAAA,OAAO,MAAM;AACX,MAAA,MAAA,CAAO,mBAAA,CAAoB,UAAU,aAAa,CAAA;AAAA,IACpD,CAAA;AAAA,EACF,CAAA,EAAG,CAAC,aAAA,EAAe,iBAAiB,CAAC,CAAA;AAErC,EAAA,uBACE,GAAA,CAAC,KAAA,EAAA,EAAI,KAAA,EAAO,EAAE,KAAA,EAAO,QAAQ,MAAA,EAAQ,MAAA,EAAQ,SAAA,EAAW,MAAA,EAAO,EAC7D,QAAA,kBAAA,GAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,KAAA,EAAO,iBAAA;AAAA,MACP,KAAA;AAAA,MACA,SAAA;AAAA,MACA,aAAA;AAAA,MACA,aAAA;AAAA,MACA,cAAA;AAAA,MACA,SAAA;AAAA,MACA,OAAA,EAAO,IAAA;AAAA,MACP,MAAA,EAAQ,oBAAA;AAAA,MACR;AAAA;AAAA,GACF,EACF,CAAA;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"DesignerFlow.esm.js","sources":["../../../src/components/DesignerFlow/DesignerFlow.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport type { MouseEvent as ReactMouseEvent } from \"react\";\nimport {\n ReactFlow,\n applyNodeChanges,\n applyEdgeChanges,\n addEdge,\n Node,\n Edge,\n NodeChange,\n EdgeChange,\n useNodesState,\n ReactFlowInstance,\n} from \"@xyflow/react\";\nimport \"@xyflow/react/dist/style.css\";\nimport type {\n ScaffolderTaskOutput,\n TaskStep,\n} from \"@backstage/plugin-scaffolder-common\";\nimport type {\n ActionNodeData,\n OutputNodeData,\n ParametersNodeData,\n TemplateParametersValue,\n} from \"../Nodes/types\";\nimport { createSequentialEdges } from \"../../utils/createSequentialEdges\";\nimport {\n collectStepOutputReferences,\n createHandleAddNode,\n createHandleRemoveNode,\n createHandleRemoveInputKey,\n createHandleReorderAndAlignNodes,\n createHandleUpdateField,\n createHandleUpdateInput,\n createHandleUpdateOutput,\n createHandleUpdateSections,\n} from \"./handlers\";\nimport {\n buildNodesFromModel,\n collectParameterReferences,\n stableStringify,\n resolveNodeHeightForTracking,\n extractStepsFromNodes,\n extractParametersFromNodes,\n extractOutputFromNodes,\n} from \"./model\";\nimport { alignNodes } from \"./nodeLayout\";\nimport { FLOW_LAYOUT, nodeDefaults, nodeTypes } from \"./flowConfig\";\nimport { useScaffolderActions } from \"../../api/scaffolderActions\";\n\n// Main orchestration component that renders and synchronizes the Designer flow.\n\nconst FIXED_X_POSITION = FLOW_LAYOUT.fixedXPosition;\nconst VERTICAL_SPACING = FLOW_LAYOUT.verticalSpacing;\n\ntype DesignerFlowProps = {\n steps?: TaskStep[];\n parameters?: TemplateParametersValue;\n output?: ScaffolderTaskOutput | null;\n onStepsChange?: (steps: TaskStep[]) => void;\n onParametersChange?: (parameters: TemplateParametersValue) => void;\n onOutputChange?: (output: ScaffolderTaskOutput | undefined) => void;\n};\n\nexport default function App({\n steps = [],\n parameters,\n output,\n onStepsChange,\n onParametersChange,\n onOutputChange,\n}: DesignerFlowProps) {\n const scaffolderActionsCache = useScaffolderActions();\n\n const {\n ids: scaffolderActionIds,\n inputsById: scaffolderActionInputsById,\n outputsById: scaffolderActionOutputsById,\n inputRequiredById: scaffolderActionInputRequiredById,\n } = scaffolderActionsCache;\n\n const normalizedParametersProp = parameters ?? undefined;\n const normalizedOutputProp = output ?? null;\n\n const initialNodes = useMemo(\n () =>\n buildNodesFromModel(\n steps,\n normalizedParametersProp,\n normalizedOutputProp,\n {\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionOutputsById,\n scaffolderActionInputRequiredById,\n }\n ),\n [\n steps,\n normalizedParametersProp,\n normalizedOutputProp,\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionOutputsById,\n scaffolderActionInputRequiredById,\n ]\n );\n\n const [nodes, setNodes] = useNodesState(initialNodes);\n const [edges, setEdges] = useState<Edge[]>(() =>\n createSequentialEdges(initialNodes)\n );\n\n const modelHash = useMemo(\n () =>\n stableStringify({\n steps,\n parameters: normalizedParametersProp,\n output: normalizedOutputProp,\n }),\n [steps, normalizedParametersProp, normalizedOutputProp]\n );\n\n const cacheFingerprint = useMemo(\n () =>\n stableStringify({\n ids: scaffolderActionIds,\n inputs: scaffolderActionInputsById,\n outputs: scaffolderActionOutputsById,\n inputRequired: scaffolderActionInputRequiredById,\n }),\n [\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionOutputsById,\n scaffolderActionInputRequiredById,\n ]\n );\n\n const lastAppliedModelHashRef = useRef<string | null>(null);\n const lastEmittedModelHashRef = useRef<string | null>(null);\n const skipNextModelHashRef = useRef<string | null>(null);\n const lastCacheFingerprintRef = useRef<string | null>(null);\n const nodeHeightsRef = useRef<Record<string, number>>({});\n const shouldAutoFitViewRef = useRef(true);\n const emitDebounceRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isDraggingRef = useRef(false);\n const [isDragging, setIsDragging] = useState(false);\n const emitAfterDragRef = useRef(false);\n\n useEffect(() => {\n const isCacheChanged = cacheFingerprint !== lastCacheFingerprintRef.current;\n const shouldSkip =\n modelHash === skipNextModelHashRef.current && !isCacheChanged;\n\n if (shouldSkip) {\n skipNextModelHashRef.current = null;\n lastAppliedModelHashRef.current = modelHash;\n lastCacheFingerprintRef.current = cacheFingerprint;\n return;\n }\n\n if (modelHash === lastAppliedModelHashRef.current && !isCacheChanged) {\n return;\n }\n\n const nextNodes = buildNodesFromModel(\n steps,\n normalizedParametersProp,\n normalizedOutputProp,\n {\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionOutputsById,\n scaffolderActionInputRequiredById,\n }\n );\n\n lastAppliedModelHashRef.current = modelHash;\n lastCacheFingerprintRef.current = cacheFingerprint;\n lastEmittedModelHashRef.current = modelHash;\n\n setNodes(nextNodes);\n setEdges(createSequentialEdges(nextNodes));\n shouldAutoFitViewRef.current = true;\n }, [\n steps,\n normalizedParametersProp,\n normalizedOutputProp,\n modelHash,\n cacheFingerprint,\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionOutputsById,\n scaffolderActionInputRequiredById,\n setNodes,\n setEdges,\n ]);\n\n useEffect(() => {\n if (!nodes.length) {\n return;\n }\n\n if (nodes.some((node) => node.dragging)) {\n return;\n }\n\n const activeNodeIds = new Set<string>();\n let hasMeasuredChange = false;\n\n nodes.forEach((node) => {\n activeNodeIds.add(node.id);\n const measuredHeight = resolveNodeHeightForTracking(node);\n if (typeof measuredHeight !== \"number\") {\n return;\n }\n const previousHeight = nodeHeightsRef.current[node.id];\n if (previousHeight !== measuredHeight) {\n nodeHeightsRef.current[node.id] = measuredHeight;\n hasMeasuredChange = true;\n }\n });\n\n Object.keys(nodeHeightsRef.current).forEach((id) => {\n if (!activeNodeIds.has(id)) {\n delete nodeHeightsRef.current[id];\n }\n });\n\n if (!hasMeasuredChange) {\n return;\n }\n\n setNodes((currentNodes) => {\n const alignedNodes = alignNodes(\n currentNodes,\n FIXED_X_POSITION,\n VERTICAL_SPACING\n );\n const positionsChanged = alignedNodes.some((node, index) => {\n const previousNode = currentNodes[index];\n if (!previousNode) {\n return true;\n }\n return (\n node.position.x !== previousNode.position.x ||\n node.position.y !== previousNode.position.y\n );\n });\n\n return positionsChanged ? alignedNodes : currentNodes;\n });\n }, [nodes, setNodes]);\n\n const parameterReferences = useMemo(\n () => collectParameterReferences(normalizedParametersProp),\n [normalizedParametersProp]\n );\n\n const stepOutputReferencesByNode = useMemo(\n () => collectStepOutputReferences(nodes, parameterReferences),\n [nodes, parameterReferences]\n );\n\n const onNodesChange = useCallback(\n (changes: NodeChange<Node>[]) =>\n setNodes((ns) => {\n if (\n changes.some(\n (change) => change.type === \"position\" && change.dragging\n )\n ) {\n isDraggingRef.current = true;\n setIsDragging(true);\n } else if (\n changes.some(\n (change) => change.type === \"position\" && change.dragging === false\n )\n ) {\n const stillDragging = ns.some((node) => node.dragging);\n isDraggingRef.current = stillDragging;\n setIsDragging(stillDragging);\n }\n return applyNodeChanges(changes, ns);\n }),\n [setNodes]\n );\n\n const onEdgesChange = useCallback(\n (changes: EdgeChange<Edge>[]) =>\n setEdges((es) => applyEdgeChanges(changes, es)),\n [setEdges]\n );\n\n const onConnect = useCallback(\n (params: any) => setEdges((es) => addEdge(params, es)),\n [setEdges]\n );\n\n const reorderAndAlignNodes = useMemo(\n () =>\n createHandleReorderAndAlignNodes(setNodes, setEdges, {\n fixedXPosition: FIXED_X_POSITION,\n verticalSpacing: VERTICAL_SPACING,\n }),\n [setNodes, setEdges]\n );\n\n const onNodeDragStop = useCallback(\n (_: ReactMouseEvent, node: Node) => {\n isDraggingRef.current = false;\n setIsDragging(false);\n reorderAndAlignNodes(node);\n },\n [reorderAndAlignNodes]\n );\n\n const onUpdateField = useMemo(\n () => createHandleUpdateField(setNodes),\n [setNodes]\n );\n\n const onUpdateInput = useMemo(\n () => createHandleUpdateInput(setNodes),\n [setNodes]\n );\n\n const onRemoveInputKey = useMemo(\n () => createHandleRemoveInputKey(setNodes),\n [setNodes]\n );\n\n const onUpdateOutput = useMemo(\n () => createHandleUpdateOutput(setNodes),\n [setNodes]\n );\n\n const onUpdateSections = useMemo(\n () => createHandleUpdateSections(setNodes),\n [setNodes]\n );\n\n const handleAddNode = useMemo(\n () =>\n createHandleAddNode(setNodes, setEdges, {\n fixedXPosition: FIXED_X_POSITION,\n verticalSpacing: VERTICAL_SPACING,\n nodeDefaults,\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionInputRequiredById,\n scaffolderActionOutputsById,\n }),\n [\n scaffolderActionIds,\n scaffolderActionInputsById,\n scaffolderActionOutputsById,\n scaffolderActionInputRequiredById,\n setNodes,\n setEdges,\n ]\n );\n\n const handleRemoveNode = useMemo(\n () =>\n createHandleRemoveNode(setNodes, setEdges, {\n fixedXPosition: FIXED_X_POSITION,\n verticalSpacing: VERTICAL_SPACING,\n }),\n [setNodes, setEdges]\n );\n\n const nodesWithHandlers = useMemo(() => {\n if (!nodes.length) {\n return nodes;\n }\n return nodes.map((node) => {\n const stepOutputReferences = stepOutputReferencesByNode[node.id] ?? [];\n if (node.type === \"parametersNode\") {\n const data = node.data as ParametersNodeData;\n const nextData =\n data.onAddNode === handleAddNode &&\n data.onUpdateSections === onUpdateSections &&\n data.stepOutputReferences === stepOutputReferences\n ? data\n : {\n ...data,\n onAddNode: handleAddNode,\n onUpdateSections,\n stepOutputReferences,\n };\n return data === nextData ? node : { ...node, data: nextData };\n }\n if (node.type === \"outputNode\") {\n const data = node.data as OutputNodeData;\n const nextData =\n data.onAddNode === handleAddNode &&\n data.onUpdateOutput === onUpdateOutput &&\n data.stepOutputReferences === stepOutputReferences\n ? data\n : {\n ...data,\n onAddNode: handleAddNode,\n onUpdateOutput,\n stepOutputReferences,\n };\n return data === nextData ? node : { ...node, data: nextData };\n }\n\n const data = node.data as ActionNodeData;\n const nextData =\n data.onAddNode === handleAddNode &&\n data.onRemoveNode === handleRemoveNode &&\n data.onUpdateField === onUpdateField &&\n data.onUpdateInput === onUpdateInput &&\n data.onRemoveInputKey === onRemoveInputKey &&\n data.stepOutputReferences === stepOutputReferences\n ? data\n : {\n ...data,\n onAddNode: handleAddNode,\n onRemoveNode: handleRemoveNode,\n onUpdateField,\n onUpdateInput,\n onRemoveInputKey,\n stepOutputReferences,\n };\n return data === nextData ? node : { ...node, data: nextData };\n });\n }, [\n nodes,\n handleAddNode,\n handleRemoveNode,\n onUpdateField,\n onUpdateInput,\n onRemoveInputKey,\n onUpdateOutput,\n onUpdateSections,\n stepOutputReferencesByNode,\n ]);\n\n const stepsFromNodes = useMemo(() => extractStepsFromNodes(nodes), [nodes]);\n\n const parametersFromNodes = useMemo(\n () => extractParametersFromNodes(nodes),\n [nodes]\n );\n\n const outputFromNodes = useMemo(() => extractOutputFromNodes(nodes), [nodes]);\n\n const normalizedOutputFromNodes = outputFromNodes ?? null;\n\n useEffect(() => {\n if (!onStepsChange && !onParametersChange && !onOutputChange) {\n return;\n }\n if (isDragging) {\n emitAfterDragRef.current = true;\n return;\n }\n const serialized = stableStringify({\n steps: stepsFromNodes,\n parameters: parametersFromNodes ?? null,\n output: normalizedOutputFromNodes,\n });\n if (serialized === lastEmittedModelHashRef.current) {\n return;\n }\n if (emitDebounceRef.current) {\n clearTimeout(emitDebounceRef.current);\n }\n emitDebounceRef.current = setTimeout(() => {\n lastEmittedModelHashRef.current = serialized;\n skipNextModelHashRef.current = serialized;\n if (onStepsChange) {\n onStepsChange(stepsFromNodes);\n }\n if (onParametersChange) {\n onParametersChange(parametersFromNodes ?? undefined);\n }\n if (onOutputChange) {\n onOutputChange(outputFromNodes);\n }\n }, 120);\n }, [\n stepsFromNodes,\n parametersFromNodes,\n normalizedOutputFromNodes,\n outputFromNodes,\n onStepsChange,\n onParametersChange,\n onOutputChange,\n isDragging,\n ]);\n\n useEffect(\n () => () => {\n if (emitDebounceRef.current) {\n clearTimeout(emitDebounceRef.current);\n }\n },\n []\n );\n\n const fitViewOptions = useMemo(() => ({ padding: 0.2, duration: 300 }), []);\n const [reactFlowInstance, setReactFlowInstance] =\n useState<ReactFlowInstance | null>(null);\n\n const fitFlowToView = useCallback(() => {\n if (!reactFlowInstance) {\n return;\n }\n reactFlowInstance.fitView(fitViewOptions);\n }, [fitViewOptions, reactFlowInstance]);\n\n useEffect(() => {\n if (!reactFlowInstance) {\n return;\n }\n if (!shouldAutoFitViewRef.current) {\n return;\n }\n shouldAutoFitViewRef.current = false;\n fitFlowToView();\n }, [fitFlowToView, nodes, edges, reactFlowInstance]);\n\n useEffect(() => {\n if (!reactFlowInstance) {\n return undefined;\n }\n window.addEventListener(\"resize\", fitFlowToView);\n return () => {\n window.removeEventListener(\"resize\", fitFlowToView);\n };\n }, [fitFlowToView, reactFlowInstance]);\n\n useEffect(() => {\n if (!isDragging) {\n if (emitAfterDragRef.current) {\n emitAfterDragRef.current = false;\n lastEmittedModelHashRef.current = null;\n }\n // Trigger emit cycle after drag ends so external state is up to date.\n lastEmittedModelHashRef.current = null;\n }\n }, [isDragging]);\n\n return (\n <div style={{ width: \"100%\", height: \"100%\", minHeight: \"70vh\" }}>\n <ReactFlow\n nodes={nodesWithHandlers}\n edges={edges}\n nodeTypes={nodeTypes}\n onNodesChange={onNodesChange}\n onEdgesChange={onEdgesChange}\n onNodeDragStop={onNodeDragStop}\n onConnect={onConnect}\n fitView\n onInit={setReactFlowInstance}\n fitViewOptions={fitViewOptions}\n />\n </div>\n );\n}\n"],"names":["data","nextData"],"mappings":";;;;;;;;;;;AAoDA,MAAM,mBAAmB,WAAA,CAAY,cAAA;AACrC,MAAM,mBAAmB,WAAA,CAAY,eAAA;AAWrC,SAAwB,GAAA,CAAI;AAAA,EAC1B,QAAQ,EAAC;AAAA,EACT,UAAA;AAAA,EACA,MAAA;AAAA,EACA,aAAA;AAAA,EACA,kBAAA;AAAA,EACA;AACF,CAAA,EAAsB;AACpB,EAAA,MAAM,yBAAyB,oBAAA,EAAqB;AAEpD,EAAA,MAAM;AAAA,IACJ,GAAA,EAAK,mBAAA;AAAA,IACL,UAAA,EAAY,0BAAA;AAAA,IACZ,WAAA,EAAa,2BAAA;AAAA,IACb,iBAAA,EAAmB;AAAA,GACrB,GAAI,sBAAA;AAEJ,EAAA,MAAM,2BAA2B,UAAA,IAAc,MAAA;AAC/C,EAAA,MAAM,uBAAuB,MAAA,IAAU,IAAA;AAEvC,EAAA,MAAM,YAAA,GAAe,OAAA;AAAA,IACnB,MACE,mBAAA;AAAA,MACE,KAAA;AAAA,MACA,wBAAA;AAAA,MACA,oBAAA;AAAA,MACA;AAAA,QACE,mBAAA;AAAA,QACA,0BAAA;AAAA,QACA,2BAAA;AAAA,QACA;AAAA;AACF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AAAA,MACP,KAAA;AAAA,MACA,SAAA;AAAA,MACA,aAAA;AAAA,MACA,aAAA;AAAA,MACA,cAAA;AAAA,MACA,SAAA;AAAA,MACA,OAAA,EAAO,IAAA;AAAA,MACP,MAAA,EAAQ,oBAAA;AAAA,MACR;AAAA;AAAA,GACF,EACF,CAAA;AAEJ;;;;"}
|
|
@@ -3,6 +3,17 @@ import { normalizeParametersToSections, sanitizeSections, sectionsToParametersVa
|
|
|
3
3
|
import { alignNodes } from './nodeLayout.esm.js';
|
|
4
4
|
|
|
5
5
|
const orderNodes = (parameterNodes, actionNodes, outputNodes) => [...parameterNodes, ...actionNodes, ...outputNodes];
|
|
6
|
+
const setSequentialEdgesIfChanged = (setEdges, alignedNodes) => {
|
|
7
|
+
setEdges((prevEdges) => {
|
|
8
|
+
const nextEdges = createSequentialEdges(alignedNodes);
|
|
9
|
+
if (prevEdges.length === nextEdges.length && prevEdges.every(
|
|
10
|
+
(edge, index) => edge.source === nextEdges[index]?.source && edge.target === nextEdges[index]?.target
|
|
11
|
+
)) {
|
|
12
|
+
return prevEdges;
|
|
13
|
+
}
|
|
14
|
+
return nextEdges;
|
|
15
|
+
});
|
|
16
|
+
};
|
|
6
17
|
const createHandleAddNode = (setNodes, setEdges, options) => {
|
|
7
18
|
const {
|
|
8
19
|
fixedXPosition,
|
|
@@ -29,7 +40,7 @@ const createHandleAddNode = (setNodes, setEdges, options) => {
|
|
|
29
40
|
const composeAndAlign = (nextParameters, nextActions, nextOutputs) => {
|
|
30
41
|
const ordered = orderNodes(nextParameters, nextActions, nextOutputs);
|
|
31
42
|
const aligned = alignNodes(ordered, fixedXPosition, verticalSpacing);
|
|
32
|
-
setEdges
|
|
43
|
+
setSequentialEdgesIfChanged(setEdges, aligned);
|
|
33
44
|
return aligned;
|
|
34
45
|
};
|
|
35
46
|
if (nodeType === "parametersNode") {
|
|
@@ -143,7 +154,7 @@ const createHandleRemoveNode = (setNodes, setEdges, options) => {
|
|
|
143
154
|
fixedXPosition,
|
|
144
155
|
verticalSpacing
|
|
145
156
|
);
|
|
146
|
-
setEdges
|
|
157
|
+
setSequentialEdgesIfChanged(setEdges, alignedNodes);
|
|
147
158
|
return alignedNodes;
|
|
148
159
|
});
|
|
149
160
|
};
|
|
@@ -179,7 +190,7 @@ const createHandleReorderAndAlignNodes = (setNodes, setEdges, options) => {
|
|
|
179
190
|
const outputNodes = updatedNodes.filter((node) => node.type === "outputNode").sort((a, b) => a.position.y - b.position.y);
|
|
180
191
|
const ordered = orderNodes(parameterNodes, actionNodes, outputNodes);
|
|
181
192
|
const aligned = alignNodes(ordered, fixedXPosition, verticalSpacing);
|
|
182
|
-
setEdges
|
|
193
|
+
setSequentialEdgesIfChanged(setEdges, aligned);
|
|
183
194
|
return aligned;
|
|
184
195
|
});
|
|
185
196
|
};
|