Skip to content

Commit

Permalink
Merge branch 'main' into 2128/confirm-validator-not-invoked
Browse files Browse the repository at this point in the history
  • Loading branch information
longieirl authored Oct 7, 2024
2 parents 7a4b6a9 + 3bf3f79 commit df87e09
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 110 deletions.
7 changes: 6 additions & 1 deletion nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
"targetDefaults": {
"build": {
"dependsOn": ["^build"],
"outputs": ["{projectRoot}/dist", "{projectRoot}/lib", "{projectRoot}/storybook"]
"outputs": [
"{projectRoot}/dist",
"{projectRoot}/generators",
"{projectRoot}/lib",
"{projectRoot}/storybook"
]
},
"test": {
"inputs": ["default", "^prod", "{workspaceRoot}/jest.base.js", "{projectRoot}/jest.config.js"],
Expand Down
7 changes: 7 additions & 0 deletions packages/create/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @sap-ux/create

## 0.8.36

### Patch Changes

- Updated dependencies [fd215c2]
- @sap-ux/preview-middleware@0.16.81

## 0.8.35

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/create/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sap-ux/create",
"description": "SAP Fiori tools module to add or remove features",
"version": "0.8.35",
"version": "0.8.36",
"repository": {
"type": "git",
"url": "https://github.com/SAP/open-ux-tools.git",
Expand Down
6 changes: 6 additions & 0 deletions packages/preview-middleware-client/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux-private/preview-middleware-client

## 0.11.13

### Patch Changes

- fd215c2: Fixed a bug - Add Custom Page Action is not shown on the Object Page in some cases

## 0.11.12

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/preview-middleware-client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sap-ux-private/preview-middleware-client",
"version": "0.11.12",
"version": "0.11.13",
"description": "Client-side coding hosted by the preview middleware",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,11 @@ export default class AddFragment extends BaseDialog<AddFragmentModel> {
* @returns true if control and aggregation combination allows to create custom action fragment
*/
private isCustomAction(currentControlName: string, targetAggregation: string): boolean {
if (currentControlName === 'sap.f.DynamicPageTitle' || currentControlName === 'sap.uxap.ObjectPageHeader') {
if (
['sap.f.DynamicPageTitle', 'sap.uxap.ObjectPageHeader', 'sap.uxap.ObjectPageDynamicHeaderTitle'].includes(
currentControlName
)
) {
return targetAggregation === 'actions';
} else if (currentControlName === 'sap.m.OverflowToolbar' || currentControlName === 'sap.m.Toolbar') {
return targetAggregation === 'content';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { QuickActionContext, SimpleQuickActionDefinition } from '../../../cpe/qu
import { SimpleQuickActionDefinitionBase } from '../simple-quick-action-base';

export const ADD_PAGE_ACTION = 'add-page-action';
const CONTROL_TYPES = ['sap.f.DynamicPageTitle', 'sap.uxap.ObjectPageHeader'];
const CONTROL_TYPES = ['sap.f.DynamicPageTitle', 'sap.uxap.ObjectPageHeader', 'sap.uxap.ObjectPageDynamicHeaderTitle'];

/**
* Quick Action for adding a custom page action.
Expand All @@ -26,4 +26,4 @@ export class AddPageActionQuickAction extends SimpleQuickActionDefinitionBase im
}
return [];
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1167,111 +1167,114 @@ describe('AddFragment', () => {
});
});

test('creates new custom action fragment and a change', async () => {
sapMock.ui.version = '1.71.62';
const executeSpy = jest.fn();
rtaMock.getCommandStack.mockReturnValue({
pushAndExecute: executeSpy
});
rtaMock.getFlexSettings.mockReturnValue({ projectId: 'adp.app' });

const overlays = {
getId: jest.fn().mockReturnValue('some-id')
};

const addFragment = new AddFragment(
'adp.extension.controllers.AddFragment',
overlays as unknown as UI5Element,
rtaMock as unknown as RuntimeAuthoring,
{
title: 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION',
aggregation: 'actions'
}
);

const event = {
getSource: jest.fn().mockReturnValue({
setEnabled: jest.fn()
})
};

const testModel = {
getProperty: jest
.fn()
.mockReturnValueOnce('Share')
.mockReturnValueOnce('0')
.mockReturnValueOnce('actions'),
setProperty: jest.fn()
} as unknown as JSONModel;
addFragment.model = testModel;

const dummyContent: AddFragmentChangeContentType = {
fragmentPath: 'dummyPath',
index: 1,
targetAggregation: 'actions'
};

const setContentSpy = jest.fn();
const commandForSpy = jest.fn().mockReturnValue({
_oPreparedChange: {
_oDefinition: { moduleName: 'adp/app/changes/fragments/Share.fragment.xml' },
setModuleName: jest.fn()
},
getPreparedChange: jest.fn().mockReturnValue({
getContent: jest.fn().mockReturnValue(dummyContent),
setContent: setContentSpy
})
});
CommandFactory.getCommandFor = commandForSpy;

fetchMock.mockResolvedValue({
json: jest.fn().mockReturnValue({
id: 'id',
reference: 'reference',
namespace: 'namespace',
layer: 'layer'
}),
text: jest.fn().mockReturnValue('XML Fragment was created!'),
ok: true
});

jest.spyOn(sap.ui, 'getCore').mockReturnValue({
byId: jest.fn().mockReturnValue({})
} as unknown as Core);

jest.spyOn(ControlUtils, 'getRuntimeControl').mockReturnValue({
getMetadata: jest.fn().mockReturnValue({
getAllAggregations: jest.fn().mockReturnValue({}),
getName: jest.fn().mockReturnValue('sap.uxap.ObjectPageHeader')
})
} as unknown as ManagedObject);

addFragment.handleDialogClose = jest.fn();
test.each(['sap.f.DynamicPageTitle', 'sap.uxap.ObjectPageHeader', 'sap.uxap.ObjectPageDynamicHeaderTitle'])(
'creates new custom action fragment and a change (%s)',
async (compType) => {
sapMock.ui.version = '1.71.62';
const executeSpy = jest.fn();
rtaMock.getCommandStack.mockReturnValue({
pushAndExecute: executeSpy
});
rtaMock.getFlexSettings.mockReturnValue({ projectId: 'adp.app' });

const overlays = {
getId: jest.fn().mockReturnValue('some-id')
};

const addFragment = new AddFragment(
'adp.extension.controllers.AddFragment',
overlays as unknown as UI5Element,
rtaMock as unknown as RuntimeAuthoring,
{
title: 'QUICK_ACTION_ADD_CUSTOM_PAGE_ACTION',
aggregation: 'actions'
}
);

const event = {
getSource: jest.fn().mockReturnValue({
setEnabled: jest.fn()
})
};

await addFragment.setup({
setEscapeHandler: jest.fn(),
destroy: jest.fn(),
setModel: jest.fn(),
open: jest.fn(),
close: jest.fn()
} as unknown as Dialog);
const testModel = {
getProperty: jest
.fn()
.mockReturnValueOnce('Share')
.mockReturnValueOnce('0')
.mockReturnValueOnce('actions'),
setProperty: jest.fn()
} as unknown as JSONModel;
addFragment.model = testModel;

const dummyContent: AddFragmentChangeContentType = {
fragmentPath: 'dummyPath',
index: 1,
targetAggregation: 'actions'
};

const setContentSpy = jest.fn();
const commandForSpy = jest.fn().mockReturnValue({
_oPreparedChange: {
_oDefinition: { moduleName: 'adp/app/changes/fragments/Share.fragment.xml' },
setModuleName: jest.fn()
},
getPreparedChange: jest.fn().mockReturnValue({
getContent: jest.fn().mockReturnValue(dummyContent),
setContent: setContentSpy
})
});
CommandFactory.getCommandFor = commandForSpy;

fetchMock.mockResolvedValue({
json: jest.fn().mockReturnValue({
id: 'id',
reference: 'reference',
namespace: 'namespace',
layer: 'layer'
}),
text: jest.fn().mockReturnValue('XML Fragment was created!'),
ok: true
});

await addFragment.onCreateBtnPress(event as unknown as Event);
jest.spyOn(sap.ui, 'getCore').mockReturnValue({
byId: jest.fn().mockReturnValue({})
} as unknown as Core);

expect(executeSpy).toHaveBeenCalledWith({
_oPreparedChange: {
_oDefinition: {
moduleName: 'adp/app/changes/fragments/Share.fragment.xml'
jest.spyOn(ControlUtils, 'getRuntimeControl').mockReturnValue({
getMetadata: jest.fn().mockReturnValue({
getAllAggregations: jest.fn().mockReturnValue({}),
getName: jest.fn().mockReturnValue(compType)
})
} as unknown as ManagedObject);

addFragment.handleDialogClose = jest.fn();

await addFragment.setup({
setEscapeHandler: jest.fn(),
destroy: jest.fn(),
setModel: jest.fn(),
open: jest.fn(),
close: jest.fn()
} as unknown as Dialog);

await addFragment.onCreateBtnPress(event as unknown as Event);

expect(executeSpy).toHaveBeenCalledWith({
_oPreparedChange: {
_oDefinition: {
moduleName: 'adp/app/changes/fragments/Share.fragment.xml'
},
setModuleName: expect.any(Function)
},
setModuleName: expect.any(Function)
},
getPreparedChange: expect.any(Function)
});

expect(setContentSpy).toHaveBeenCalledWith({
...dummyContent,
templateName: 'CUSTOM_ACTION'
});
});
getPreparedChange: expect.any(Function)
});

expect(setContentSpy).toHaveBeenCalledWith({
...dummyContent,
templateName: 'CUSTOM_ACTION'
});
}
);
});
});
6 changes: 6 additions & 0 deletions packages/preview-middleware/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/preview-middleware

## 0.16.81

### Patch Changes

- fd215c2: Fixed a bug - Add Custom Page Action is not shown on the Object Page in some cases

## 0.16.80

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/preview-middleware/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"bugs": {
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
},
"version": "0.16.80",
"version": "0.16.81",
"license": "Apache-2.0",
"author": "@SAP/ux-tools-team",
"main": "dist/index.js",
Expand Down
6 changes: 6 additions & 0 deletions packages/ui5-library-sub-generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/ui5-library-sub-generator

## 0.0.2

### Patch Changes

- 5684ba8: build & publish update

## 0.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/ui5-library-sub-generator/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@sap-ux/ui5-library-sub-generator",
"description": "Generator for creating UI5 libraries",
"version": "0.0.1",
"version": "0.0.2",
"repository": {
"type": "git",
"url": "https://github.com/SAP/open-ux-tools.git",
Expand Down

0 comments on commit df87e09

Please sign in to comment.