@sap-ux/preview-middleware 0.19.35 → 0.19.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -124,7 +124,11 @@ sap.ui.define(["../utils/error"], function (___utils_error) {
124
124
  * @returns {CodeExtResponse} Returns path to existing controller if found
125
125
  */
126
126
  async function getExistingController(controllerName) {
127
- return request(`${ApiEndpoints.CODE_EXT}/${controllerName}`, RequestMethod.GET);
127
+ const params = new URLSearchParams({
128
+ name: controllerName
129
+ });
130
+ const url = `${ApiEndpoints.CODE_EXT}?${params.toString()}`;
131
+ return request(url, RequestMethod.GET);
128
132
  }
129
133
 
130
134
  /**
@@ -171,7 +171,9 @@ export async function getDataSourceAnnotationFileMap(): Promise<AnnotationDataSo
171
171
  * @returns {CodeExtResponse} Returns path to existing controller if found
172
172
  */
173
173
  export async function getExistingController(controllerName: string): Promise<CodeExtResponse> {
174
- return request<CodeExtResponse>(`${ApiEndpoints.CODE_EXT}/${controllerName}` as ApiEndpoints, RequestMethod.GET);
174
+ const params = new URLSearchParams({ name: controllerName });
175
+ const url = `${ApiEndpoints.CODE_EXT}?${params.toString()}` as ApiEndpoints;
176
+ return request<CodeExtResponse>(url, RequestMethod.GET);
175
177
  }
176
178
 
177
179
  /**
@@ -57,7 +57,7 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/library", "sap/ui/model/json/J
57
57
  this.model.setProperty('/newControllerName', null);
58
58
  return;
59
59
  }
60
- const fileExists = controllerList.some(f => f.controllerName === `${controllerName}.js`);
60
+ const fileExists = controllerList.some(f => f.controllerName === controllerName);
61
61
  if (fileExists) {
62
62
  updateDialogState(ValueState.Error, 'Enter a different name. The controller name that you entered already exists in your project.');
63
63
  return;
@@ -33,8 +33,15 @@ interface ControllerExtensionService {
33
33
  add: (codeRef: string, viewId: string) => Promise<{ creation: string }>;
34
34
  }
35
35
 
36
+ type ControllerList = {
37
+ /**
38
+ * File name without extension
39
+ */
40
+ controllerName: string;
41
+ }[];
42
+
36
43
  type ControllerModel = JSONModel & {
37
- getProperty(sPath: '/controllersList'): { controllerName: string }[];
44
+ getProperty(sPath: '/controllersList'): ControllerList;
38
45
  getProperty(sPath: '/controllerExists'): boolean;
39
46
  getProperty(sPath: '/newControllerName'): string;
40
47
  getProperty(sPath: '/viewId'): string;
@@ -93,7 +100,7 @@ export default class ControllerExtension extends BaseDialog<ControllerModel> {
93
100
  return;
94
101
  }
95
102
 
96
- const fileExists = controllerList.some((f) => f.controllerName === `${controllerName}.js`);
103
+ const fileExists = controllerList.some((f) => f.controllerName === controllerName);
97
104
 
98
105
  if (fileExists) {
99
106
  updateDialogState(
@@ -136,10 +136,10 @@ sap.ui.define(["sap/m/MessageToast", "sap/ui/core/Element", "sap/base/Log", "sap
136
136
  * @param control UI5 control.
137
137
  * @returns The controller name and view ID.
138
138
  */
139
-
140
139
  function getControllerInfoForControl(control) {
141
140
  const view = FlexUtils.getViewForControl(control);
142
- const controllerName = view.getController().getMetadata().getName();
141
+ const moduleName = view?.getControllerModuleName?.();
142
+ const controllerName = moduleName ? `module:${moduleName}` : view.getController()?.getMetadata().getName();
143
143
  const viewId = view.getId();
144
144
  return {
145
145
  controllerName,
@@ -141,10 +141,10 @@ interface ControllerInfo {
141
141
  * @param control UI5 control.
142
142
  * @returns The controller name and view ID.
143
143
  */
144
-
145
144
  export function getControllerInfoForControl(control: ManagedObject): ControllerInfo {
146
145
  const view = FlexUtils.getViewForControl(control);
147
- const controllerName = view.getController().getMetadata().getName();
146
+ const moduleName = view?.getControllerModuleName?.();
147
+ const controllerName = moduleName ? `module:${moduleName}` : view.getController()?.getMetadata().getName();
148
148
  const viewId = view.getId();
149
149
  return { controllerName, viewId };
150
150
  }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
11
11
  },
12
- "version": "0.19.35",
12
+ "version": "0.19.37",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -25,13 +25,13 @@
25
25
  "ejs": "3.1.10",
26
26
  "mem-fs": "2.1.0",
27
27
  "mem-fs-editor": "9.4.0",
28
- "@sap-ux/adp-tooling": "0.13.39",
28
+ "@sap-ux/adp-tooling": "0.13.41",
29
29
  "@sap-ux/btp-utils": "1.0.3",
30
30
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.6.4",
31
31
  "@sap-ux/feature-toggle": "0.2.3",
32
32
  "@sap-ux/logger": "0.6.0",
33
33
  "@sap-ux/project-access": "1.29.21",
34
- "@sap-ux/system-access": "0.5.37"
34
+ "@sap-ux/system-access": "0.5.38"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@sap-ux-private/playwright": "0.1.0",
@@ -49,11 +49,11 @@
49
49
  "nock": "13.4.0",
50
50
  "npm-run-all2": "6.2.0",
51
51
  "supertest": "6.3.3",
52
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.13.19",
53
- "@sap-ux/axios-extension": "1.20.1",
52
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.13.20",
53
+ "@sap-ux/axios-extension": "1.20.2",
54
+ "@sap-ux/i18n": "0.2.3",
54
55
  "@sap-ux/store": "1.0.0",
55
- "@sap-ux/ui5-info": "0.10.1",
56
- "@sap-ux/i18n": "0.2.3"
56
+ "@sap-ux/ui5-info": "0.10.1"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "express": "4"