Skip to content
6 changes: 6 additions & 0 deletions .changeset/clever-bottles-cough.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@sap-ux-private/preview-middleware-client": patch
"@sap-ux/preview-middleware": patch
---

fix: Extension points under node 'element' not listed in Outline
11 changes: 8 additions & 3 deletions packages/preview-middleware-client/src/cpe/outline/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@ function getAdditionalData(id: string): AdditionalData {
* @returns An array of children nodes, or an empty array if none are found
*/
function getChildren(current: OutlineViewNode): OutlineViewNode[] {
return (current.elements ?? []).flatMap((element: OutlineViewNode) =>
element.type === 'aggregation' ? (element.elements ?? []) : []
);
return (current.elements ?? []).flatMap((element: OutlineViewNode) => {
if (element.type === 'aggregation') {
return element.elements ?? [];
} else if (element.type === 'extensionPoint') {
return [element];
}
return [];
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,5 +312,100 @@ describe('outline nodes', () => {
}
]);
});

test('element with extension point as direct child', async () => {
expect(
await transformNodes(
[
{
id: 'container-element',
technicalName: 'sap.m.VBox',
editable: false,
type: 'element',
visible: true,
elements: [
{
id: 'extension-point-1',
technicalName: 'sap.ui.extensionpoint',
name: 'CustomExtensionPoint',
editable: false,
type: 'extensionPoint',
visible: true,
extensionPointInfo: {
createdControls: ['control-1'],
defaultContent: []
}
}
]
}
],
'ADAPTATION_PROJECT'
)
).toStrictEqual([
{
controlId: 'container-element',
controlType: 'sap.m.VBox',
editable: false,
name: 'VBox',
visible: true,
children: [
{
controlId: 'extension-point-1--CustomExtensionPoint',
controlType: 'sap.ui.extensionpoint',
editable: false,
hasDefaultContent: false,
name: 'CustomExtensionPoint',
visible: true,
children: [
{
controlId: 'control-1',
controlType: 'some-name',
editable: false,
hasDefaultContent: false,
name: 'control-1',
visible: true,
children: []
}
]
}
]
}
]);
});

test('element with unprocessed child types', async () => {
expect(
await transformNodes(
[
{
id: 'parent-element',
technicalName: 'sap.m.Table',
editable: false,
type: 'element',
visible: true,
elements: [
{
id: 'template-1',
technicalName: 'aggregationBindingTemplate',
editable: false,
type: 'aggregationBindingTemplate' as any,
visible: true
}
]
}
],
'UI_ADAPTATION'
)
).toStrictEqual([
{
controlId: 'parent-element',
controlType: 'sap.m.Table',
editable: false,
name: 'Table',
visible: true,
children: []
}
]);
});
});
});
Loading