Skip to content

Commit

Permalink
Merge branch 'main' into fix/cpe/quick-action-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
voicis authored Sep 20, 2024
2 parents 8c6c151 + ad54319 commit 44129fb
Show file tree
Hide file tree
Showing 56 changed files with 1,318 additions and 545 deletions.
8 changes: 8 additions & 0 deletions examples/prompting-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @sap-ux/fe-fpm-writer-ui

## 0.1.2

### Patch Changes

- Updated dependencies [15c57bc]
- @sap-ux/ui-components@1.18.1
- @sap-ux/ui-prompting@0.1.11

## 0.1.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/prompting-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sap-ux/prompting-ui",
"version": "0.1.1",
"version": "0.1.2",
"description": "This project contains UI storybook stories with exampleS with prompt ui and FPM based building blocks.",
"license": "Apache-2.0",
"private": true,
Expand Down
6 changes: 6 additions & 0 deletions packages/adp-tooling/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/adp-tooling

## 0.12.50

### Patch Changes

- 00e1835: Fixed manifest changes not visible in preview after reload

## 0.12.49

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/adp-tooling/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%3Aadp-tooling"
},
"version": "0.12.49",
"version": "0.12.50",
"license": "Apache-2.0",
"author": "@SAP/ux-tools-team",
"main": "dist/index.js",
Expand Down
46 changes: 36 additions & 10 deletions packages/adp-tooling/src/preview/adp-preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ import type { NextFunction, Request, Response, Router, RequestHandler } from 'ex
import type { Logger, ToolsLogger } from '@sap-ux/logger';
import type { UI5FlexLayer } from '@sap-ux/project-access';
import { createAbapServiceProvider } from '@sap-ux/system-access';
import type { MergedAppDescriptor } from '@sap-ux/axios-extension';
import type { LayeredRepositoryService, MergedAppDescriptor } from '@sap-ux/axios-extension';

import RoutesHandler from './routes-handler';
import type { AdpPreviewConfig, CommonChangeProperties, DescriptorVariant, OperationType } from '../types';
import type { Editor } from 'mem-fs-editor';
import { addXmlFragment, isAddXMLChange, moduleNameContentMap, tryFixChange } from './change-handler';

declare global {
// false positive, const can't be used here https://github.com/eslint/eslint/issues/15896
// eslint-disable-next-line no-var
var __SAP_UX_MANIFEST_SYNC_REQUIRED__: boolean | undefined;
}

export const enum ApiRoutes {
FRAGMENT = '/adp/api/fragment',
CONTROLLER = '/adp/api/controller',
Expand All @@ -32,10 +38,13 @@ export class AdpPreview {
*/
private routesHandler: RoutesHandler;

private lrep: LayeredRepositoryService | undefined;
private descriptorVariantId: string | undefined;

/**
* @returns merged manifest.
*/
get descriptor() {
get descriptor(): MergedAppDescriptor {
if (this.mergedDescriptor) {
return this.mergedDescriptor;
} else {
Expand All @@ -46,7 +55,9 @@ export class AdpPreview {
/**
* @returns a list of resources required to the adaptation project as well as the original app.
*/
get resources() {
get resources(): {
[name: string]: string;
} {
if (this.mergedDescriptor) {
const resources = {
[this.mergedDescriptor.name]: this.mergedDescriptor.url
Expand Down Expand Up @@ -91,26 +102,37 @@ export class AdpPreview {
* @returns the UI5 flex layer for which editing is enabled
*/
async init(descriptorVariant: DescriptorVariant): Promise<UI5FlexLayer> {
this.descriptorVariantId = descriptorVariant.id;
const provider = await createAbapServiceProvider(
this.config.target,
{ ignoreCertErrors: this.config.ignoreCertErrors },
true,
this.logger
);
const lrep = provider.getLayeredRepository();
this.lrep = provider.getLayeredRepository();
// fetch a merged descriptor from the backend
await this.lrep.getCsrfToken();

await this.sync();
return descriptorVariant.layer;
}

/**
* Synchronize local changes with the backend.
*
*/
async sync(): Promise<void> {
if (!this.lrep || !this.descriptorVariantId) {
throw new Error('Not initialized');
}
const zip = new ZipFile();
const files = await this.project.byGlob('**/*.*');
for (const file of files) {
zip.addFile(file.getPath().substring(1), await file.getBuffer());
}
const buffer = zip.toBuffer();

// fetch a merged descriptor from the backend
await lrep.getCsrfToken();
this.mergedDescriptor = (await lrep.mergeAppDescriptorVariant(buffer))[descriptorVariant.id];

return descriptorVariant.layer;
this.mergedDescriptor = (await this.lrep.mergeAppDescriptorVariant(buffer))[this.descriptorVariantId];
}

/**
Expand All @@ -120,8 +142,12 @@ export class AdpPreview {
* @param res outgoing response object
* @param next next middleware that is to be called if the request cannot be handled
*/
async proxy(req: Request, res: Response, next: NextFunction) {
async proxy(req: Request, res: Response, next: NextFunction): Promise<void> {
if (req.path === '/manifest.json') {
if (global.__SAP_UX_MANIFEST_SYNC_REQUIRED__) {
await this.sync();
global.__SAP_UX_MANIFEST_SYNC_REQUIRED__ = false;
}
res.status(200);
res.send(JSON.stringify(this.descriptor.manifest, undefined, 2));
} else if (req.path === '/Component-preload.js') {
Expand Down
38 changes: 38 additions & 0 deletions packages/adp-tooling/test/unit/preview/adp-preview.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,32 @@ describe('AdaptationProject', () => {

expect(() => adp.descriptor).toThrowError();
expect(() => adp.resources).toThrowError();
await expect(() => adp.sync()).rejects.toEqual(Error('Not initialized'));
});
});
describe('sync', () => {
test('updates merged descriptor', async () => {
const adp = new AdpPreview(
{
target: {
url: backend
}
},
mockProject as unknown as ReaderCollection,
middlewareUtil,
logger
);

mockProject.byGlob.mockResolvedValueOnce([
{
getPath: () => '/manifest.appdescr_variant',
getBuffer: () => Buffer.from(descriptorVariant)
}
]);
await adp.init(JSON.parse(descriptorVariant));
(adp as any).mergedDescriptor = undefined;
await adp.sync();
expect(adp.descriptor).toBeDefined();
});
});
describe('proxy', () => {
Expand Down Expand Up @@ -209,6 +235,18 @@ describe('AdaptationProject', () => {
server = supertest(app);
});

afterEach(() => {
global.__SAP_UX_MANIFEST_SYNC_REQUIRED__ = false;
});

test('/manifest.json with sync', async () => {
global.__SAP_UX_MANIFEST_SYNC_REQUIRED__ = true;
const syncSpy = jest.spyOn(AdpPreview.prototype, 'sync').mockImplementation(() => Promise.resolve());
const response = await server.get('/my/adaptation/manifest.json').expect(200);
expect(syncSpy).toHaveBeenCalledTimes(1);
expect(JSON.parse(response.text)).toEqual(mockMergedDescriptor.manifest);
});

test('/manifest.json', async () => {
const response = await server.get('/my/adaptation/manifest.json').expect(200);
expect(JSON.parse(response.text)).toEqual(mockMergedDescriptor.manifest);
Expand Down
6 changes: 6 additions & 0 deletions packages/control-property-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @sap-ux/control-property-editor

## 0.5.8

### Patch Changes

- e12dd50: Added hover over theme picker and border for Callout

## 0.5.7

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/control-property-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "Control Property Editor",
"description": "Control Property Editor",
"license": "Apache-2.0",
"version": "0.5.7",
"version": "0.5.8",
"main": "dist/app.js",
"repository": {
"type": "git",
Expand Down
5 changes: 2 additions & 3 deletions packages/control-property-editor/src/Workarounds.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
}
}

// Callout
.ms-Callout-main {
border: 1px solid var(--vscode-contrastBorder);
.ms-Callout {
border: 1px solid var(--vscode-widget-border);
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
background-color: var(--vscode-progressBar-background);
}

.theme-child:hover:not(.selected) {
background-color: var(--vscode-toolbar-hoverBackground, var(--vscode-menubar-selectionBackground));
outline: 1px dashed var(--vscode-contrastActiveBorder);
}

div#theme-light-modern {
margin-left: 3px;
margin-bottom: 3px;
Expand Down
8 changes: 8 additions & 0 deletions packages/create/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# @sap-ux/create

## 0.8.20

### Patch Changes

- Updated dependencies [00e1835]
- @sap-ux/preview-middleware@0.16.68
- @sap-ux/adp-tooling@0.12.50

## 0.8.19

### 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.19",
"version": "0.8.20",
"repository": {
"type": "git",
"url": "https://github.com/SAP/open-ux-tools.git",
Expand Down
2 changes: 2 additions & 0 deletions packages/fiori-tools-settings/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/test/test-output/
dist
7 changes: 7 additions & 0 deletions packages/fiori-tools-settings/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
extends: ['../../.eslintrc'],
parserOptions: {
project: './tsconfig.eslint.json',
tsconfigRootDir: __dirname
}
};
7 changes: 7 additions & 0 deletions packages/fiori-tools-settings/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @sap-ux/fiori-tools-settings

## 0.1.0

### Minor Changes

- 04b3e6c: Added app info file handling logic to .fioritools folder
Loading

0 comments on commit 44129fb

Please sign in to comment.