Skip to content

Commit aa06224

Browse files
committed
feat(ui): deprecate 'web-services' and 'xml' eip namespaces
1 parent bd02542 commit aa06224

File tree

11 files changed

+304
-71
lines changed

11 files changed

+304
-71
lines changed

ui/src/components/palette/EipComponentPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { EipId } from "../../api/generated/eipFlow"
1212
import { EIP_SCHEMA } from "../../singletons/eipDefinitions"
1313
import getIconUrl from "../../singletons/eipIconCatalog"
1414
import { useNodeCount } from "../../singletons/store/getterHooks"
15-
import { toTitleCase } from "../../utils/titleTransform"
15+
import { getNamespaceAlias, toTitleCase } from "../../utils/titleTransform"
1616
import { DragTypes } from "./dragTypes"
1717

1818
interface Namespace {
@@ -67,7 +67,7 @@ const EipNamespaceCollection = ({
6767

6868
return (
6969
<AccordionItem
70-
title={toTitleCase(namespace.name)}
70+
title={toTitleCase(getNamespaceAlias(namespace.name))}
7171
open={allExpanded || expandedNamespace === namespace.name}
7272
onHeadingClick={({ isOpen }) => handleExpand(isOpen)}
7373
>

ui/src/json/springIntegrationEipComponents.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

ui/src/singletons/eipDefinitions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ const contentBasedRouterTargets: ReadonlyMap<string, RouterTarget> = new Map([
6060
{ name: "header-name", type: "attribute" },
6161
],
6262
["integration.router", { name: "expression", type: "attribute" }],
63-
["xml.xpath-router", { name: "xpath-expression", type: "child" }],
63+
["int-xml.xpath-router", { name: "xpath-expression", type: "child" }],
6464
])
6565

6666
export const lookupContentBasedRouterKeys = (

ui/src/singletons/store/__snapshots__/appActions.test.ts.snap

Lines changed: 142 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ exports[`import flow from an exported JSON file > 'import a deprecated flow part
3232
"eipIds": [
3333
{
3434
"name": "inbound-gateway",
35-
"namespace": "web-services",
35+
"namespace": "ws",
3636
},
3737
{
3838
"name": "transformer",
@@ -99,48 +99,46 @@ exports[`import flow from an exported JSON file > 'import a deprecated flow part
9999
}
100100
`;
101101

102-
exports[`import flow from an exported JSON file > 'import a valid flow success' 1`] = `
102+
exports[`import flow from an exported JSON file > 'import a flow with deprecated namespa…' 1`] = `
103103
{
104104
"children": [
105105
{
106-
"81HAL73ElW": [],
106+
"EhSdB7aSPh": [],
107107
},
108108
{
109-
"Hz22QyhCpj": [],
109+
"e5ZObyhckj": [],
110110
},
111111
{
112-
"THgI9WvsJh": [
113-
"mbL_mB1wGOY",
114-
],
112+
"PFC0tD2Jjq": [],
115113
},
116114
],
117115
"edges": [
118116
{
119-
"id": "reactflow__edge-81HAL73ElWoutput-Hz22QyhCpjinput",
120-
"source": "81HAL73ElW",
117+
"id": "xy-edge__EhSdB7aSPhoutput-e5ZObyhckjinput",
118+
"source": "EhSdB7aSPh",
121119
"sourceHandle": "output",
122-
"target": "Hz22QyhCpj",
120+
"target": "e5ZObyhckj",
123121
"targetHandle": "input",
124122
},
125123
{
126-
"id": "reactflow__edge-Hz22QyhCpjoutput-THgI9WvsJhinput",
127-
"source": "Hz22QyhCpj",
124+
"id": "xy-edge__PFC0tD2Jjqoutput-EhSdB7aSPhinput",
125+
"source": "PFC0tD2Jjq",
128126
"sourceHandle": "output",
129-
"target": "THgI9WvsJh",
127+
"target": "EhSdB7aSPh",
130128
"targetHandle": "input",
131129
},
132130
],
133131
"eipIds": [
134132
{
135-
"name": "inbound-gateway",
136-
"namespace": "web-services",
133+
"name": "xpath-transformer",
134+
"namespace": "int-xml",
137135
},
138136
{
139-
"name": "transformer",
140-
"namespace": "integration",
137+
"name": "outbound-gateway",
138+
"namespace": "ws",
141139
},
142140
{
143-
"name": "outbound-gateway",
141+
"name": "inbound-channel-adapter",
144142
"namespace": "http",
145143
},
146144
],
@@ -151,11 +149,51 @@ exports[`import flow from an exported JSON file > 'import a valid flow success'
151149
"nodes": [
152150
{
153151
"data": {
154-
"label": "ws-in",
152+
"label": "transform",
155153
},
156154
"dragging": false,
157-
"height": 124,
158-
"id": "81HAL73ElW",
155+
"id": "EhSdB7aSPh",
156+
"measured": {
157+
"height": 90,
158+
"width": 104,
159+
},
160+
"position": {
161+
"x": 203,
162+
"y": 22.5,
163+
},
164+
"selected": false,
165+
"sourcePosition": "right",
166+
"targetPosition": "left",
167+
"type": "eipNode",
168+
},
169+
{
170+
"data": {
171+
"label": "out1",
172+
},
173+
"dragging": false,
174+
"id": "e5ZObyhckj",
175+
"measured": {
176+
"height": 127,
177+
"width": 128,
178+
},
179+
"position": {
180+
"x": 382,
181+
"y": 4,
182+
},
183+
"selected": false,
184+
"sourcePosition": "right",
185+
"targetPosition": "left",
186+
"type": "eipNode",
187+
},
188+
{
189+
"data": {
190+
"label": "in1",
191+
},
192+
"id": "PFC0tD2Jjq",
193+
"measured": {
194+
"height": 135,
195+
"width": 128,
196+
},
159197
"position": {
160198
"x": 0,
161199
"y": 0,
@@ -164,16 +202,73 @@ exports[`import flow from an exported JSON file > 'import a valid flow success'
164202
"sourcePosition": "right",
165203
"targetPosition": "left",
166204
"type": "eipNode",
167-
"width": 128,
205+
},
206+
],
207+
}
208+
`;
209+
210+
exports[`import flow from an exported JSON file > 'import a valid flow success' 1`] = `
211+
{
212+
"children": [
213+
{
214+
"Hz22QyhCpj": [],
168215
},
216+
{
217+
"THgI9WvsJh": [
218+
"mbL_mB1wGOY",
219+
],
220+
},
221+
{
222+
"OuC9d1xC5e": [],
223+
},
224+
],
225+
"edges": [
226+
{
227+
"id": "reactflow__edge-Hz22QyhCpjoutput-THgI9WvsJhinput",
228+
"source": "Hz22QyhCpj",
229+
"sourceHandle": "output",
230+
"target": "THgI9WvsJh",
231+
"targetHandle": "input",
232+
},
233+
{
234+
"id": "xy-edge__OuC9d1xC5eoutput-Hz22QyhCpjinput",
235+
"source": "OuC9d1xC5e",
236+
"sourceHandle": "output",
237+
"target": "Hz22QyhCpj",
238+
"targetHandle": "input",
239+
},
240+
],
241+
"eipIds": [
242+
{
243+
"name": "transformer",
244+
"namespace": "integration",
245+
},
246+
{
247+
"name": "outbound-gateway",
248+
"namespace": "http",
249+
},
250+
{
251+
"name": "message-driven-channel-adapter",
252+
"namespace": "jms",
253+
},
254+
],
255+
"layout": {
256+
"density": "comfortable",
257+
"orientation": "horizontal",
258+
},
259+
"nodes": [
169260
{
170261
"data": {},
171262
"dragging": false,
172263
"height": 87,
173264
"id": "Hz22QyhCpj",
265+
"measured": {
266+
"height": 87,
267+
"width": 99,
268+
},
174269
"position": {
175270
"x": 203,
176-
"y": 18.5,
271+
"y": 24,
177272
},
178273
"selected": false,
179274
"sourcePosition": "right",
@@ -186,16 +281,39 @@ exports[`import flow from an exported JSON file > 'import a valid flow success'
186281
"dragging": false,
187282
"height": 121,
188283
"id": "THgI9WvsJh",
284+
"measured": {
285+
"height": 121,
286+
"width": 109,
287+
},
189288
"position": {
190289
"x": 377,
191-
"y": 5.5,
290+
"y": 7,
192291
},
193292
"selected": false,
194293
"sourcePosition": "right",
195294
"targetPosition": "left",
196295
"type": "eipNode",
197296
"width": 109,
198297
},
298+
{
299+
"data": {
300+
"label": "jms-in",
301+
},
302+
"dragging": false,
303+
"id": "OuC9d1xC5e",
304+
"measured": {
305+
"height": 135,
306+
"width": 128,
307+
},
308+
"position": {
309+
"x": 0,
310+
"y": 0,
311+
},
312+
"selected": false,
313+
"sourcePosition": "right",
314+
"targetPosition": "left",
315+
"type": "eipNode",
316+
},
199317
],
200318
}
201319
`;

ui/src/singletons/store/appActions.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import {
5858
getNodesView,
5959
} from "./storeViews"
6060
import deprecatedExportedFlow from "./testdata/exported-diagrams/deprecatedFlow.json?raw"
61+
import deprecatedNamespacesFlow from "./testdata/exported-diagrams/deprecatedNamespaces.json?raw"
6162
import validExportedFlow from "./testdata/exported-diagrams/validFlow.json?raw"
6263

6364
vi.mock("zustand")
@@ -594,6 +595,10 @@ describe("import flow from an exported JSON file", () => {
594595
msg: "import a deprecated flow partial success",
595596
flow: deprecatedExportedFlow,
596597
},
598+
{
599+
msg: "import a flow with deprecated namespaces success",
600+
flow: deprecatedNamespacesFlow,
601+
},
597602
])("$msg", ({ flow }) => {
598603
const initNodes = getNodesView()
599604

ui/src/singletons/store/appActions.ts

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,16 @@ export const importFlowFromObject = (flow: SerializedFlow) => {
231231
throw new Error("Failed to import an EIP flow JSON. Malformed input")
232232
}
233233

234-
// Maintain backwards compatibility with older exported formats
235234
if (!flow.eipConfigs && !flow.version) {
236235
return importDeprecatedFlow(flow)
237236
}
238237

238+
const eipConfigs = convertDeprecatedNamespaces(flow.eipConfigs)
239+
239240
return {
240241
nodes: flow.nodes,
241242
edges: flow.edges,
242-
eipConfigs: flow.eipConfigs,
243+
eipConfigs,
243244
customEntities: flow.customEntities ?? {},
244245
}
245246
})
@@ -418,15 +419,15 @@ const isStoreType = (state: unknown): state is AppStore => {
418419
)
419420
}
420421

421-
// Maintains compatibility with older exported formats
422+
// Maintain backwards compatibility with older exported formats
422423
const importDeprecatedFlow = (flow: SerializedFlow): Partial<AppStore> => {
423424
const eipConfigs = {} as AppStore["eipConfigs"]
424425
const nodes = flow.nodes.map((node) => {
425426
const { eipId: oldEipId, ...rest } = node.data as { eipId: EipId }
426427
eipConfigs[node.id] = {
427428
attributes: {},
428429
children: [],
429-
eipId: oldEipId,
430+
eipId: fixDeprecatedEipId(oldEipId),
430431
}
431432
return {
432433
...node,
@@ -441,6 +442,42 @@ const importDeprecatedFlow = (flow: SerializedFlow): Partial<AppStore> => {
441442
}
442443
}
443444

445+
const DEPRECATED_EIP_NAMESPACES: Record<string, string> = {
446+
xml: "int-xml",
447+
"web-services": "ws",
448+
}
449+
450+
// Maintain backwards compatibility with older exported namespaces
451+
const convertDeprecatedNamespaces = (
452+
eipConfigs: SerializedFlow["eipConfigs"]
453+
) =>
454+
Object.fromEntries(
455+
Object.entries(eipConfigs).map(([id, config]) => {
456+
const eipId = config.eipId
457+
if (eipId.namespace in DEPRECATED_EIP_NAMESPACES) {
458+
const convertedEipId = fixDeprecatedEipId(eipId)
459+
460+
console.warn(
461+
`Imported flow has a deprecated namespace '${eipId.namespace}'. Converting the namespace to '${convertedEipId.namespace}'.`
462+
)
463+
464+
return [
465+
id,
466+
{
467+
...config,
468+
eipId: convertedEipId,
469+
},
470+
]
471+
}
472+
return [id, config]
473+
})
474+
)
475+
476+
const fixDeprecatedEipId = (eipId: EipId): EipId => ({
477+
...eipId,
478+
namespace: DEPRECATED_EIP_NAMESPACES[eipId.namespace] ?? eipId.namespace,
479+
})
480+
444481
const isWellFormedXML = (content: string) => {
445482
if (!content) {
446483
return false

0 commit comments

Comments
 (0)