@sap-ux/preview-middleware 0.16.66 → 0.16.68

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.
@@ -4,8 +4,10 @@ sap.ui.define([
4
4
  './flex-change',
5
5
  'sap/base/Log',
6
6
  '../rta-service',
7
- '../../utils/error'
8
- ], function (___sap_ux_private_control_property_editor_common, ___flex_change, Log, ___rta_service, ____utils_error) {
7
+ '../../utils/error',
8
+ 'sap/m/MessageToast',
9
+ '../../i18n'
10
+ ], function (___sap_ux_private_control_property_editor_common, ___flex_change, Log, ___rta_service, ____utils_error, MessageToast, ____i18n) {
9
11
  'use strict';
10
12
  const changeProperty = ___sap_ux_private_control_property_editor_common['changeProperty'];
11
13
  const changeStackModified = ___sap_ux_private_control_property_editor_common['changeStackModified'];
@@ -13,9 +15,12 @@ sap.ui.define([
13
15
  const propertyChangeFailed = ___sap_ux_private_control_property_editor_common['propertyChangeFailed'];
14
16
  const FlexChangesEndPoints = ___sap_ux_private_control_property_editor_common['FlexChangesEndPoints'];
15
17
  const reloadApplication = ___sap_ux_private_control_property_editor_common['reloadApplication'];
18
+ const numberOfChangesRequiringReloadChanged = ___sap_ux_private_control_property_editor_common['numberOfChangesRequiringReloadChanged'];
19
+ const save = ___sap_ux_private_control_property_editor_common['save'];
16
20
  const applyChange = ___flex_change['applyChange'];
17
21
  const modeAndStackChangeHandler = ___rta_service['modeAndStackChangeHandler'];
18
22
  const getError = ____utils_error['getError'];
23
+ const getTextBundle = ____i18n['getTextBundle'];
19
24
  function assertProperties(properties, target) {
20
25
  for (const property of properties) {
21
26
  const value = target[property];
@@ -39,6 +44,7 @@ sap.ui.define([
39
44
  }
40
45
  class ChangeService {
41
46
  savedChanges = [];
47
+ changesRequiringReload = 0;
42
48
  constructor(options, selectionService) {
43
49
  this.options = options;
44
50
  this.selectionService = selectionService;
@@ -69,14 +75,14 @@ sap.ui.define([
69
75
  } else if (deletePropertyChanges.match(action)) {
70
76
  await this.deleteChange(action.payload.controlId, action.payload.propertyName, action.payload.fileName);
71
77
  } else if (reloadApplication.match(action)) {
72
- await this.options.rta.stop(false, true);
78
+ this.sendAction(numberOfChangesRequiringReloadChanged(0));
79
+ } else if (save.match(action)) {
80
+ this.changesRequiringReload = 0;
81
+ this.sendAction(numberOfChangesRequiringReloadChanged(0));
73
82
  }
74
83
  });
75
84
  await this.fetchSavedChanges();
76
85
  this.updateStack();
77
- this.options.rta.attachStop(() => {
78
- location.reload();
79
- });
80
86
  this.options.rta.attachUndoRedoStackModified(this.createOnStackChangeHandler());
81
87
  }
82
88
  updateStack() {
@@ -171,6 +177,13 @@ sap.ui.define([
171
177
  }
172
178
  });
173
179
  activeChanges = activeChanges.filter(change => !!change);
180
+ const changesRequiringReload = activeChanges.reduce((sum, change) => change.changeType === 'appdescr_fe_changePageConfiguration' ? sum + 1 : sum, 0);
181
+ if (changesRequiringReload > this.changesRequiringReload) {
182
+ const resourceBundle = await getTextBundle();
183
+ MessageToast.show(resourceBundle.getText('CPE_CHANGES_VISIBLE_AFTER_SAVE_AND_RELOAD_MESSAGE'), { duration: 8000 });
184
+ this.sendAction(numberOfChangesRequiringReloadChanged(changesRequiringReload));
185
+ }
186
+ this.changesRequiringReload = changesRequiringReload;
174
187
  if (Array.isArray(allCommands) && allCommands.length === 0) {
175
188
  await this.fetchSavedChanges();
176
189
  }
@@ -10,7 +10,9 @@ import {
10
10
  deletePropertyChanges,
11
11
  propertyChangeFailed,
12
12
  FlexChangesEndPoints,
13
- reloadApplication
13
+ reloadApplication,
14
+ numberOfChangesRequiringReloadChanged,
15
+ save
14
16
  } from '@sap-ux-private/control-property-editor-common';
15
17
  import { applyChange } from './flex-change';
16
18
  import type { SelectionService } from '../selection';
@@ -21,6 +23,8 @@ import type FlexCommand from 'sap/ui/rta/command/FlexCommand';
21
23
  import Log from 'sap/base/Log';
22
24
  import { modeAndStackChangeHandler } from '../rta-service';
23
25
  import { getError } from '../../utils/error';
26
+ import MessageToast from 'sap/m/MessageToast';
27
+ import { getTextBundle } from '../../i18n';
24
28
 
25
29
  interface ChangeContent {
26
30
  property: string;
@@ -91,6 +95,7 @@ function modifyRTAErrorMessage(errorMessage: string, id: string, type: string):
91
95
  */
92
96
  export class ChangeService {
93
97
  private savedChanges: SavedPropertyChange[] = [];
98
+ private changesRequiringReload = 0;
94
99
  private sendAction: (action: ExternalAction) => void;
95
100
  /**
96
101
  *
@@ -136,16 +141,16 @@ export class ChangeService {
136
141
  } else if (deletePropertyChanges.match(action)) {
137
142
  await this.deleteChange(action.payload.controlId, action.payload.propertyName, action.payload.fileName);
138
143
  } else if (reloadApplication.match(action)) {
139
- await this.options.rta.stop(false, true);
144
+ this.sendAction(numberOfChangesRequiringReloadChanged(0));
145
+ } else if (save.match(action)) {
146
+ this.changesRequiringReload = 0;
147
+ this.sendAction(numberOfChangesRequiringReloadChanged(0));
140
148
  }
141
149
  });
142
150
 
143
151
  await this.fetchSavedChanges();
144
152
  this.updateStack();
145
- this.options.rta.attachStop(() => {
146
- // eslint-disable-next-line fiori-custom/sap-no-location-reload
147
- location.reload();
148
- });
153
+
149
154
  this.options.rta.attachUndoRedoStackModified(this.createOnStackChangeHandler());
150
155
  }
151
156
 
@@ -284,6 +289,18 @@ export class ChangeService {
284
289
  });
285
290
 
286
291
  activeChanges = activeChanges.filter((change): boolean => !!change);
292
+ const changesRequiringReload = activeChanges.reduce(
293
+ (sum, change) => (change.changeType === 'appdescr_fe_changePageConfiguration' ? sum + 1 : sum),
294
+ 0
295
+ );
296
+ if (changesRequiringReload > this.changesRequiringReload) {
297
+ const resourceBundle = await getTextBundle();
298
+ MessageToast.show(resourceBundle.getText('CPE_CHANGES_VISIBLE_AFTER_SAVE_AND_RELOAD_MESSAGE'), {
299
+ duration: 8000
300
+ });
301
+ this.sendAction(numberOfChangesRequiringReloadChanged(changesRequiringReload));
302
+ }
303
+ this.changesRequiringReload = changesRequiringReload;
287
304
 
288
305
  if (Array.isArray(allCommands) && allCommands.length === 0) {
289
306
  await this.fetchSavedChanges();
@@ -17,29 +17,35 @@ sap.ui.define([
17
17
  });
18
18
  });
19
19
  }
20
+ const reloadApplication = ___sap_ux_private_control_property_editor_common['reloadApplication'];
20
21
  const storageFileChanged = ___sap_ux_private_control_property_editor_common['storageFileChanged'];
21
22
  const getUi5Version = ___utils_version['getUi5Version'];
22
23
  const isLowerThanMinimalUi5Version = ___utils_version['isLowerThanMinimalUi5Version'];
23
24
  class WorkspaceConnectorService {
24
- async init(sendAction) {
25
+ isReloadPending = false;
26
+ async init(sendAction, subscribe) {
27
+ this.sendAction = sendAction;
28
+ subscribe(action => {
29
+ if (reloadApplication.match(action)) {
30
+ this.isReloadPending = true;
31
+ }
32
+ });
25
33
  if (isLowerThanMinimalUi5Version(await getUi5Version(), {
26
34
  major: 1,
27
35
  minor: 73
28
36
  })) {
29
37
  const FakeLrepConnector = (await __ui5_require_async('sap/ui/fl/FakeLrepConnector')).default;
30
- FakeLrepConnector.fileChangeRequestNotifier = notifier(sendAction);
38
+ FakeLrepConnector.fileChangeRequestNotifier = this.onChangeSaved.bind(this);
31
39
  } else {
32
40
  const connector = (await __ui5_require_async('open/ux/preview/client/flp/WorkspaceConnector')).default;
33
- connector.storage.fileChangeRequestNotifier = notifier(sendAction);
41
+ connector.storage.fileChangeRequestNotifier = this.onChangeSaved.bind(this);
34
42
  }
35
43
  }
36
- }
37
- function notifier(sendAction) {
38
- return (fileName, kind, changeType) => {
39
- if (changeType && changeType !== 'appdescr_fe_changePageConfiguration' || kind === 'delete') {
40
- sendAction(storageFileChanged(fileName?.replace('sap.ui.fl.', '')));
44
+ onChangeSaved(fileName, kind, changeType) {
45
+ if (changeType && changeType !== 'appdescr_fe_changePageConfiguration' || kind === 'delete' || this.isReloadPending) {
46
+ this.sendAction(storageFileChanged(fileName?.replace('sap.ui.fl.', '')));
41
47
  }
42
- };
48
+ }
43
49
  }
44
50
  var __exports = { __esModule: true };
45
51
  __exports.WorkspaceConnectorService = WorkspaceConnectorService;
@@ -1,32 +1,47 @@
1
- import { ExternalAction, storageFileChanged } from '@sap-ux-private/control-property-editor-common';
2
- import { ActionSenderFunction } from './types';
1
+ import { ExternalAction, reloadApplication, storageFileChanged } from '@sap-ux-private/control-property-editor-common';
2
+ import { ActionSenderFunction, SubscribeFunction } from './types';
3
3
  import { getUi5Version, isLowerThanMinimalUi5Version } from '../utils/version';
4
4
 
5
5
  /**
6
6
  * A Class of WorkspaceConnectorService
7
7
  */
8
8
  export class WorkspaceConnectorService {
9
+ /**
10
+ * When save and reload is triggered, we do not need special handling for changes that are not directly visible in preview.
11
+ */
12
+ private isReloadPending = false;
13
+ private sendAction: (action: ExternalAction) => void;
9
14
  /**
10
15
  * Initializes connector service.
11
16
  *
12
17
  * @param sendAction action sender function
18
+ * @param subscribe subscriber function
13
19
  */
14
- public async init(sendAction: ActionSenderFunction): Promise<void> {
20
+ public async init(sendAction: ActionSenderFunction, subscribe: SubscribeFunction): Promise<void> {
21
+ this.sendAction = sendAction;
22
+ subscribe((action): void => {
23
+ if (reloadApplication.match(action)) {
24
+ this.isReloadPending = true;
25
+ }
26
+ });
27
+
15
28
  if (isLowerThanMinimalUi5Version(await getUi5Version(), { major: 1, minor: 73 })) {
16
29
  const FakeLrepConnector = (await import('sap/ui/fl/FakeLrepConnector')).default;
17
- FakeLrepConnector.fileChangeRequestNotifier = notifier(sendAction);
30
+ FakeLrepConnector.fileChangeRequestNotifier = this.onChangeSaved.bind(this);
18
31
  } else {
19
32
  const connector = (await import('open/ux/preview/client/flp/WorkspaceConnector')).default;
20
33
  // hook the file deletion listener to the UI5 workspace connector
21
- connector.storage.fileChangeRequestNotifier = notifier(sendAction);
34
+ connector.storage.fileChangeRequestNotifier = this.onChangeSaved.bind(this);
22
35
  }
23
36
  }
24
- }
25
37
 
26
- function notifier(sendAction: (action: ExternalAction) => void) {
27
- return (fileName: string, kind: 'delete' | 'create', changeType?: string) => {
28
- if ((changeType && changeType !== 'appdescr_fe_changePageConfiguration') || kind === 'delete') {
29
- sendAction(storageFileChanged(fileName?.replace('sap.ui.fl.', '')));
38
+ private onChangeSaved(fileName: string, kind: 'delete' | 'create', changeType?: string) {
39
+ if (
40
+ (changeType && changeType !== 'appdescr_fe_changePageConfiguration') ||
41
+ kind === 'delete' ||
42
+ this.isReloadPending
43
+ ) {
44
+ this.sendAction(storageFileChanged(fileName?.replace('sap.ui.fl.', '')));
30
45
  }
31
- };
46
+ }
32
47
  }
@@ -46,9 +46,9 @@ sap.ui.define([
46
46
  const outlineService = new OutlineService(rta);
47
47
  const quickActionService = new QuickActionService(rta, outlineService, registries);
48
48
  const services = [
49
+ connectorService,
49
50
  selectionService,
50
51
  changesService,
51
- connectorService,
52
52
  outlineService,
53
53
  rtaService,
54
54
  quickActionService
@@ -51,9 +51,9 @@ export default function init(
51
51
  const outlineService = new OutlineService(rta);
52
52
  const quickActionService = new QuickActionService(rta, outlineService, registries);
53
53
  const services: Service[] = [
54
+ connectorService,
54
55
  selectionService,
55
56
  changesService,
56
- connectorService,
57
57
  outlineService,
58
58
  rtaService,
59
59
  quickActionService
@@ -7,6 +7,7 @@ sap.ui.define(['open/ux/preview/client/thirdparty/@sap-ux-private/control-proper
7
7
  const undo = ___sap_ux_private_control_property_editor_common['undo'];
8
8
  const redo = ___sap_ux_private_control_property_editor_common['redo'];
9
9
  const save = ___sap_ux_private_control_property_editor_common['save'];
10
+ const reloadApplication = ___sap_ux_private_control_property_editor_common['reloadApplication'];
10
11
  class RtaService {
11
12
  constructor(rta) {
12
13
  this.rta = rta;
@@ -22,17 +23,29 @@ sap.ui.define(['open/ux/preview/client/thirdparty/@sap-ux-private/control-proper
22
23
  if (redo.match(action)) {
23
24
  this.rta.redo();
24
25
  }
25
- if (save.match(action)) {
26
- if (this.rta.save) {
27
- this.rta.save();
28
- } else {
29
- this.rta?._serializeToLrep();
26
+ if (reloadApplication.match(action)) {
27
+ if (action.payload.save === true) {
28
+ await this.save();
30
29
  }
30
+ await this.rta.stop(false, true);
31
+ }
32
+ if (save.match(action)) {
33
+ await this.save();
31
34
  }
32
35
  return Promise.resolve();
33
36
  });
37
+ this.rta.attachStop(() => {
38
+ location.reload();
39
+ });
34
40
  this.rta.attachModeChanged(modeAndStackChangeHandler(sendAction, this.rta));
35
41
  }
42
+ save() {
43
+ if (this.rta.save) {
44
+ return this.rta.save();
45
+ } else {
46
+ return this.rta?._serializeToLrep();
47
+ }
48
+ }
36
49
  }
37
50
  function modeAndStackChangeHandler(sendAction, rta) {
38
51
  return () => {
@@ -5,7 +5,8 @@ import {
5
5
  undo,
6
6
  redo,
7
7
  save,
8
- ExternalAction
8
+ ExternalAction,
9
+ reloadApplication
9
10
  } from '@sap-ux-private/control-property-editor-common';
10
11
  import { ActionSenderFunction, SubscribeFunction } from './types';
11
12
  import RuntimeAuthoring from 'sap/ui/rta/RuntimeAuthoring';
@@ -37,20 +38,35 @@ export class RtaService {
37
38
  if (redo.match(action)) {
38
39
  this.rta.redo();
39
40
  }
41
+ if (reloadApplication.match(action)) {
42
+ if (action.payload.save === true) {
43
+ await this.save();
44
+ }
45
+ await this.rta.stop(false, true);
46
+ }
40
47
 
41
48
  if (save.match(action)) {
42
- if (this.rta.save) {
43
- // v1.107.x and above
44
- this.rta.save();
45
- } else {
46
- // v1.71.x and above
47
- this.rta?._serializeToLrep();
48
- }
49
+ await this.save();
49
50
  }
50
51
  return Promise.resolve();
51
52
  });
53
+
54
+ this.rta.attachStop(() => {
55
+ // eslint-disable-next-line fiori-custom/sap-no-location-reload
56
+ location.reload();
57
+ });
52
58
  this.rta.attachModeChanged(modeAndStackChangeHandler(sendAction, this.rta));
53
59
  }
60
+
61
+ private save(): Promise<void> {
62
+ if (this.rta.save) {
63
+ // v1.107.x and above
64
+ return this.rta.save();
65
+ } else {
66
+ // v1.71.x and above
67
+ return this.rta?._serializeToLrep();
68
+ }
69
+ }
54
70
  }
55
71
 
56
72
  export function modeAndStackChangeHandler(sendAction: (action: ExternalAction) => void, rta: RuntimeAuthoring) {
@@ -32,7 +32,7 @@ export interface UI5ControlData {
32
32
  type: string;
33
33
  }
34
34
 
35
- export type ActionHandler = (action: ExternalAction) => Promise<void>;
35
+ export type ActionHandler = (action: ExternalAction) => void | Promise<void>;
36
36
  export type ActionSenderFunction = (action: ExternalAction) => void;
37
37
  export type SubscribeFunction = (handler: ActionHandler) => void;
38
38
  export type UnSubscribeFunction = (handler: ActionHandler) => void;
@@ -16,3 +16,5 @@ V4_QUICK_ACTION_LR_DISABLE_CLEAR_FILTER_BAR=Disable "Clear" Button in Filter Bar
16
16
 
17
17
  ADP_SYNC_VIEWS_MESSAGE = Have in mind that synchronous views are detected for this application and controller extensions are not supported for such views. Controller extension functionality on these views will be disabled.
18
18
  ADP_REUSE_COMPONENTS_MESSAGE = Have in mind that reuse components are detected for some views in this application and controller extensions and adding fragments are not supported for such views. Controller extension and adding fragment functionality on these views will be disabled.
19
+
20
+ CPE_CHANGES_VISIBLE_AFTER_SAVE_AND_RELOAD_MESSAGE = Note: The change will be visible after save and reload.
@@ -8,7 +8,7 @@ sap.ui.define((function () { 'use strict';
8
8
 
9
9
  (function (exports) {
10
10
  Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.executeQuickAction = exports.updateQuickAction = exports.quickActionListChanged = exports.save = exports.redo = exports.undo = exports.appLoaded = exports.setSaveEnablement = exports.setUndoRedoEnablement = exports.setAppMode = exports.storageFileChanged = exports.reloadApplication = exports.showMessage = exports.changeStackModified = exports.propertyChangeFailed = exports.propertyChanged = exports.changeProperty = exports.outlineChanged = exports.deletePropertyChanges = exports.addExtensionPoint = exports.selectControl = exports.controlSelected = exports.iconsLoaded = exports.EXTERNAL_ACTION_PREFIX = exports.NESTED_QUICK_ACTION_KIND = exports.SIMPLE_QUICK_ACTION_KIND = exports.UNKNOWN_CHANGE_KIND = exports.PROPERTY_CHANGE_KIND = exports.SAVED_CHANGE_TYPE = exports.PENDING_CHANGE_TYPE = exports.SCENARIO = exports.CHECKBOX_EDITOR_TYPE = exports.DROPDOWN_EDITOR_TYPE = exports.INPUT_EDITOR_TYPE = exports.STRING_VALUE_TYPE = exports.FLOAT_VALUE_TYPE = exports.INTEGER_VALUE_TYPE = exports.BOOLEAN_VALUE_TYPE = void 0;
11
+ exports.numberOfChangesRequiringReloadChanged = exports.executeQuickAction = exports.updateQuickAction = exports.quickActionListChanged = exports.save = exports.redo = exports.undo = exports.appLoaded = exports.setSaveEnablement = exports.setUndoRedoEnablement = exports.setAppMode = exports.storageFileChanged = exports.reloadApplication = exports.showMessage = exports.changeStackModified = exports.propertyChangeFailed = exports.propertyChanged = exports.changeProperty = exports.outlineChanged = exports.deletePropertyChanges = exports.addExtensionPoint = exports.selectControl = exports.controlSelected = exports.iconsLoaded = exports.EXTERNAL_ACTION_PREFIX = exports.NESTED_QUICK_ACTION_KIND = exports.SIMPLE_QUICK_ACTION_KIND = exports.UNKNOWN_CHANGE_KIND = exports.PROPERTY_CHANGE_KIND = exports.SAVED_CHANGE_TYPE = exports.PENDING_CHANGE_TYPE = exports.SCENARIO = exports.CHECKBOX_EDITOR_TYPE = exports.DROPDOWN_EDITOR_TYPE = exports.INPUT_EDITOR_TYPE = exports.STRING_VALUE_TYPE = exports.FLOAT_VALUE_TYPE = exports.INTEGER_VALUE_TYPE = exports.BOOLEAN_VALUE_TYPE = void 0;
12
12
  exports.BOOLEAN_VALUE_TYPE = 'boolean';
13
13
  exports.INTEGER_VALUE_TYPE = 'integer';
14
14
  exports.FLOAT_VALUE_TYPE = 'float';
@@ -90,6 +90,7 @@ sap.ui.define((function () { 'use strict';
90
90
  exports.quickActionListChanged = createExternalAction('quick-action-list-changed');
91
91
  exports.updateQuickAction = createExternalAction('update-quick-action');
92
92
  exports.executeQuickAction = createExternalAction('execute-quick-action');
93
+ exports.numberOfChangesRequiringReloadChanged = createExternalAction('number-of-changes-requiring-reload-changed');
93
94
 
94
95
  } (api));
95
96
 
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.16.66",
12
+ "version": "0.16.68",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -25,10 +25,10 @@
25
25
  "ejs": "3.1.10",
26
26
  "mem-fs": "2.1.0",
27
27
  "mem-fs-editor": "9.4.0",
28
- "@sap-ux/btp-utils": "0.15.2",
29
28
  "@sap-ux/logger": "0.6.0",
30
- "@sap-ux/adp-tooling": "0.12.49",
31
- "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.5",
29
+ "@sap-ux/btp-utils": "0.15.2",
30
+ "@sap-ux/adp-tooling": "0.12.50",
31
+ "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.5.7",
32
32
  "@sap-ux/project-access": "1.27.3"
33
33
  },
34
34
  "devDependencies": {
@@ -45,7 +45,7 @@
45
45
  "supertest": "6.3.3",
46
46
  "@sap-ux-private/playwright": "0.1.0",
47
47
  "dotenv": "16.3.1",
48
- "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.4",
48
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.11.5",
49
49
  "@sap-ux/axios-extension": "1.16.6",
50
50
  "@sap-ux/store": "0.9.1",
51
51
  "@sap-ux/ui5-info": "0.8.1",