Skip to content

Commit 57204a7

Browse files
authored
Merge pull request #76 from ui5-community/fix/smaller_issues
Fix/smaller issues
2 parents 9afb553 + 2abc2c3 commit 57204a7

9 files changed

Lines changed: 330 additions & 91 deletions

File tree

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [0.3.5](https://ui5-community///compare/v0.3.4...v0.3.5) (2025-01-21)
6+
7+
8+
### Features
9+
10+
* **no-record:** automatic nav to main if no steps were recorded ([b433e54](https://ui5-community///commit/b433e54c47cef4aa758b907bdd13407d8653f02d))
11+
12+
13+
### Bug Fixes
14+
15+
* **chrome-130:** fixed the issue with dynamically loaded scripts ([0a1c18b](https://ui5-community///commit/0a1c18b73f719d7ee49b1fab9e166520a456a3af))
16+
* **code-gen:** fixed wrong indentation within generated sources ([446f72c](https://ui5-community///commit/446f72c6b2c56b93cf56b38fc303c74c786f2bf7))
17+
* **content-inject:** fixed src type within content-inject ([76107ca](https://ui5-community///commit/76107cad4514df1ec3e494b878f6a8977cb26f71))
18+
* **settings:** changed structure of settings dialog ([d5d0c6f](https://ui5-community///commit/d5d0c6f59c0327e70ae2d305b0c61d049e0643c3))
19+
* **ui5:** fixed Typos and misspellings after version upgrade ([5f25d78](https://ui5-community///commit/5f25d788833c2dc6c3099f320824c679febf9d06))
20+
* **unnecessary:** removed unnecessary type from style ([9afb553](https://ui5-community///commit/9afb553d3f5919ddaf5c3d70f777040ec853a9e9))
21+
522
### [0.3.4](https://ui5-community///compare/v0.3.1...v0.3.4) (2024-12-20)
623

724

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.ui5.journeyrecorder",
3-
"version": "0.3.4",
3+
"version": "0.3.5",
44
"description": "UI5 Application: com.ui5.journeyrecorder",
55
"author": "Adrian Marten",
66
"license": "Apache-2.0",
@@ -15,6 +15,7 @@
1515
"test": "npm run lint && npm run karma-ci-cov",
1616
"wdi5": "wdio run ./webapp/test/e2e/\\wdio.conf.ts",
1717
"deployBuild": "node ./utils/deployBuild.js",
18+
"deployBuild-keep": "node ./utils/deployBuild.js --keep",
1819
"prepare": "husky",
1920
"commit": "npx commit",
2021
"changelog": "standard-version"

webapp/controller/BaseController.ts

Lines changed: 92 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ import Router from "sap/ui/core/routing/Router";
88
import History from "sap/ui/core/routing/History";
99
import UI5Element from "sap/ui/core/Element";
1010
import Dialog from "sap/m/Dialog";
11+
import Fragment from "sap/ui/core/Fragment";
1112
import Event from "sap/ui/base/Event";
1213
import JSONModel from "sap/ui/model/json/JSONModel";
1314
import SettingsStorageService, { AppSettings } from "../service/SettingsStorage.service";
1415
import { TestFrameworks } from "../model/enum/TestFrameworks";
15-
import { Themes } from "../model/enum/Themes";
16-
import Theming from "sap/ui/core/Theming";
1716
import { ConnectionStatus } from "../model/enum/ConnectionStatus";
1817
import { IconColor, ValueState } from "sap/ui/core/library";
1918
import { ButtonType, DialogType } from "sap/m/library";
@@ -22,6 +21,7 @@ import Text from "sap/m/Text";
2221
import BusyIndicator from "sap/ui/core/BusyIndicator";
2322
import { ChromeExtensionService } from "../service/ChromeExtension.service";
2423
import MessageToast from "sap/m/MessageToast";
24+
import XMLView from "sap/ui/core/mvc/XMLView";
2525

2626
/**
2727
* @namespace com.ui5.journeyrecorder.controller
@@ -30,6 +30,14 @@ export default abstract class BaseController extends Controller {
3030
protected settingsDialog: UI5Element;
3131
protected _unsafeDialog: Dialog;
3232

33+
private _dialogs: Record<string, {
34+
dialog: Dialog,
35+
view: XMLView,
36+
controller: Controller & { settings?: { initialHeight?: string, initialWidth?: string } }
37+
}>;
38+
39+
private _fragments: Record<string, Dialog>;
40+
3341
/**
3442
* Convenience method for accessing the component of the controller's view.
3543
* @returns The component of the controller's view
@@ -101,79 +109,7 @@ export default abstract class BaseController extends Controller {
101109
}
102110

103111
async onOpenSettingsDialog() {
104-
if (!this.settingsDialog) {
105-
this.settingsDialog = await this.loadFragment({
106-
name: "com.ui5.journeyrecorder.fragment.SettingsDialog"
107-
}) as UI5Element;
108-
this.getView().addDependent(this.settingsDialog);
109-
}
110-
(this.settingsDialog as Dialog).open();
111-
}
112-
113-
onCloseDialog(oEvent: Event) {
114-
const closeReason = (oEvent.getSource() as unknown as { data: (s: string) => string }).data("settingsDialogClose");
115-
if (closeReason === 'save') {
116-
(this.getModel("settings") as JSONModel).getData();
117-
void SettingsStorageService.save((this.getModel("settings") as JSONModel).getData() as AppSettings);
118-
} else {
119-
void SettingsStorageService.getSettings().then((settings: AppSettings) => {
120-
(this.getModel("settings") as JSONModel).setData(settings);
121-
})
122-
}
123-
(this.settingsDialog as Dialog).close();
124-
}
125-
126-
onDelaySelect(oEvent: Event) {
127-
const index = oEvent.getParameter("selectedIndex" as never);
128-
switch (index) {
129-
case 0:
130-
(this.getModel("settings") as JSONModel).setProperty('/replayDelay', 0.5);
131-
break;
132-
case 1:
133-
(this.getModel("settings") as JSONModel).setProperty('/replayDelay', 1.0);
134-
break;
135-
case 2:
136-
(this.getModel("settings") as JSONModel).setProperty('/replayDelay', 2.0);
137-
break;
138-
default:
139-
(this.getModel("settings") as JSONModel).setProperty('/replayDelay', 0.5);
140-
}
141-
}
142-
143-
onFrameworkSelect(oEvent: Event) {
144-
const index = oEvent.getParameter("selectedIndex" as never);
145-
switch (index) {
146-
case 0:
147-
(this.getModel("settings") as JSONModel).setProperty('/testFramework', TestFrameworks.OPA5);
148-
break;
149-
case 1:
150-
(this.getModel("settings") as JSONModel).setProperty('/testFramework', TestFrameworks.WDI5);
151-
break;
152-
default:
153-
(this.getModel("settings") as JSONModel).setProperty('/testFramework', TestFrameworks.OPA5);
154-
}
155-
}
156-
157-
onThemeSelect(oEvent: Event) {
158-
const index = oEvent.getParameter("selectedIndex" as never);
159-
switch (index) {
160-
case 1:
161-
(this.getModel("settings") as JSONModel).setProperty('/theme', Themes.EVENING_HORIZON);
162-
break;
163-
case 2:
164-
(this.getModel("settings") as JSONModel).setProperty('/theme', Themes.QUARTZ_LIGHT);
165-
break;
166-
case 3:
167-
(this.getModel("settings") as JSONModel).setProperty('/theme', Themes.QUARTZ_DARK);
168-
break;
169-
default:
170-
(this.getModel("settings") as JSONModel).setProperty('/theme', Themes.MORNING_HORIZON);
171-
}
172-
Theming.setTheme((this.getModel("settings") as JSONModel).getProperty('/theme') as string);
173-
}
174-
175-
compareProps(args: unknown[]) {
176-
return args[0] === args[1];
112+
await this.openDialog("Settings");
177113
}
178114

179115
setConnecting() {
@@ -266,4 +202,85 @@ export default abstract class BaseController extends Controller {
266202
MessageToast.show('Disconnected', { duration: 500 });
267203
}
268204
}
205+
206+
protected openDialog(sDialogName: string, oData?: Record<string, unknown>): Promise<Record<string, unknown> | void> {
207+
if (!this._dialogs) {
208+
this._dialogs = {};
209+
}
210+
211+
return new Promise(async (resolve, reject) => {
212+
if (!this._dialogs[sDialogName]) {
213+
const oDialog = new Dialog({
214+
showHeader: false
215+
});
216+
this.getView().addDependent(oDialog);
217+
const oView = await this.getOwnerComponent().runAsOwner(async () => {
218+
return await XMLView.create({
219+
viewName: `com.ui5.journeyrecorder.view.dialogs.${sDialogName}`
220+
});
221+
});
222+
const oController = oView.getController();
223+
oDialog.addContent(oView);
224+
225+
this._dialogs[sDialogName] = {
226+
dialog: oDialog,
227+
view: oView,
228+
controller: oController
229+
}
230+
}
231+
const oDialogCompound = this._dialogs[sDialogName];
232+
if (oData) {
233+
oDialogCompound.view.setModel(new JSONModel(oData), "importData");
234+
}
235+
236+
if (oDialogCompound.controller.settings.initialHeight) {
237+
oDialogCompound.dialog.setContentHeight(oDialogCompound.controller.settings.initialHeight);
238+
}
239+
240+
if (oDialogCompound.controller.settings.initialWidth) {
241+
oDialogCompound.dialog.setContentWidth(oDialogCompound.controller.settings.initialWidth);
242+
}
243+
244+
const beforeClose = (oEvent: Event) => {
245+
oDialogCompound.dialog.detachBeforeClose(beforeClose);
246+
const pars = oEvent.getParameters() as Record<string, unknown>;
247+
oDialogCompound.dialog.close();
248+
249+
if (pars.status === "Success") {
250+
if (pars.data) {
251+
resolve(pars.data as Record<string, unknown>);
252+
} else {
253+
resolve();
254+
}
255+
} else {
256+
reject();
257+
}
258+
};
259+
260+
oDialogCompound.dialog.attachBeforeClose(beforeClose);
261+
262+
oDialogCompound.dialog.open();
263+
})
264+
}
265+
266+
protected async openFragment(sFragmentName: string, sFragmentId?: string): Promise<void> {
267+
if (!sFragmentName) {
268+
throw new Error("At least the Fragment-Name is needed!");
269+
}
270+
271+
if (!this._fragments) {
272+
this._fragments = {};
273+
}
274+
275+
if (!this._fragments[sFragmentName]) {
276+
const oFragmentDialog = await Fragment.load({
277+
id: sFragmentId || `${sFragmentName}_id`,
278+
name: `com.ui5.journeyrecorder.view.dialogs.${sFragmentName}`,
279+
controller: this
280+
})
281+
this.getView().addDependent(oFragmentDialog as UI5Element);
282+
}
283+
284+
this._fragments[sFragmentName].open();
285+
}
269286
}

webapp/controller/JourneyPage.controller.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -404,17 +404,23 @@ export default class JourneyPage extends BaseController {
404404
const ui5Version = await this._requestUI5Version();
405405
const data = this.model.getData() as Partial<Journey>;
406406
data.ui5Version = ui5Version;
407-
const journey = JourneyStorageService.createJourneyFromRecording(data);
408-
ChromeExtensionService.getInstance().unregisterRecordingWebsocket(
409-
// eslint-disable-next-line @typescript-eslint/unbound-method
410-
this._onStepRecord,
411-
this
412-
);
413-
await ChromeExtensionService.getInstance().disableRecording();
414-
BusyIndicator.hide();
415-
this.model.setData(journey);
416-
(this.getModel('journeyControl') as JSONModel).setProperty('/unsafed', true);
417-
this._generateCode(journey);
407+
if (data.steps && data.steps.length > 0) {
408+
const journey = JourneyStorageService.createJourneyFromRecording(data);
409+
ChromeExtensionService.getInstance().unregisterRecordingWebsocket(
410+
// eslint-disable-next-line @typescript-eslint/unbound-method
411+
this._onStepRecord,
412+
this
413+
);
414+
await ChromeExtensionService.getInstance().disableRecording();
415+
BusyIndicator.hide();
416+
this.model.setData(journey);
417+
(this.getModel('journeyControl') as JSONModel).setProperty('/unsafed', true);
418+
this._generateCode(journey);
419+
} else {
420+
await ChromeExtensionService.getInstance().disableRecording();
421+
BusyIndicator.hide();
422+
this.getRouter().navTo("main");
423+
}
418424
}
419425

420426
private _generateCode(journey: Journey) {
@@ -483,8 +489,12 @@ export default class JourneyPage extends BaseController {
483489
this.setConnected();
484490
void ChromeExtensionService.getInstance().focusTab(tab);
485491
BusyIndicator.hide();
486-
await this._openRecordingDialog();
487492
MessageToast.show('Connected');
493+
try {
494+
await this._openRecordingDialog();
495+
} catch (oError) {
496+
497+
}
488498
}).catch(() => {
489499
BusyIndicator.hide();
490500
});
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Event from "sap/ui/base/Event";
2+
import BaseController from "../BaseController";
3+
import Dialog from "sap/m/Dialog";
4+
5+
/**
6+
* @namespace com.ui5.journeyrecorder.controller.dialogs
7+
*/
8+
export default class BaseDialogController extends BaseController {
9+
closeBySuccess(oPressEvent: Event, data?: Record<string, unknown>) {
10+
const oResult: {
11+
origin: unknown,
12+
result: "Confirm" | "Abort",
13+
data?: Record<string, unknown>
14+
} = {
15+
origin: oPressEvent.getSource(),
16+
result: "Confirm",
17+
};
18+
if (data) {
19+
oResult.data = data;
20+
}
21+
(this.getView().getParent() as Dialog).fireBeforeClose(oResult)
22+
}
23+
24+
closeByAbort(oPressEvent: Event) {
25+
(this.getView().getParent() as Dialog).fireBeforeClose({
26+
origin: oPressEvent.getSource(),
27+
result: "Abort"
28+
})
29+
}
30+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import BaseDialogController from "./BaseDialogController";
2+
import { Themes } from "../../model/enum/Themes";
3+
import Theming from "sap/ui/core/Theming";
4+
import JSONModel from "sap/ui/model/json/JSONModel";
5+
import SettingsStorageService, { AppSettings } from "../../service/SettingsStorage.service";
6+
import ListItem from "sap/ui/core/ListItem";
7+
import Event from "sap/ui/base/Event";
8+
import Dialog from "sap/m/Dialog";
9+
10+
/**
11+
* @namespace com.ui5.journeyrecorder.controller.dialogs
12+
*/
13+
export default class Settings extends BaseDialogController {
14+
settings = {
15+
initialHeight: '91vh',
16+
initialWidth: '30rem'
17+
}
18+
19+
onThemeSelect(oEvent: Event) {
20+
const oItem = oEvent.getParameter("selectedItem" as never) as ListItem;
21+
const oModel = this.getModel("settings") as JSONModel;
22+
oModel.setProperty('/theme', oItem.getKey());
23+
Theming.setTheme(oItem.getKey());
24+
}
25+
26+
onCloseDialog(oEvent: Event, bSave: boolean) {
27+
if (bSave) {
28+
void SettingsStorageService.save((this.getModel("settings") as JSONModel).getData() as AppSettings);
29+
}
30+
(this.getView().getParent() as Dialog).fireBeforeClose({
31+
origin: oEvent.getSource(),
32+
result: bSave ? 'Confirm' : 'Reject'
33+
});
34+
}
35+
}

webapp/service/SettingsStorage.service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,10 @@ export default class SettingsStorageService {
3030

3131
public static async getSettings(): Promise<AppSettings> {
3232
const values = await chrome.storage.local.get('settings');
33-
if (values['settings']) {
33+
if (values['settings'] && typeof values['settings'] === 'string') {
3434
return JSON.parse(values.settings as string) as AppSettings;
35+
} else if (values['settings'] && typeof values['settings'] === 'object') {
36+
return values.settings as AppSettings;
3537
} else {
3638
return SettingsStorageService.getDefaults();
3739
}

0 commit comments

Comments
 (0)