@sap-ux/preview-middleware 0.18.16 → 0.18.17

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.
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
 
3
- sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../dialog-factory", "../../../cpe/quick-actions/utils", "../../../utils/core", "../simple-quick-action-base", "../dialog-enablement-validator"], function (OverlayRegistry, ____dialog_factory, _____cpe_quick_actions_utils, _____utils_core, ___simple_quick_action_base, ___dialog_enablement_validator) {
3
+ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../dialog-factory", "../../../utils/core", "../simple-quick-action-base", "../dialog-enablement-validator", "../../../i18n"], function (OverlayRegistry, ____dialog_factory, _____utils_core, ___simple_quick_action_base, ___dialog_enablement_validator, _____i18n) {
4
4
  "use strict";
5
5
 
6
6
  const DialogFactory = ____dialog_factory["DialogFactory"];
7
7
  const DialogNames = ____dialog_factory["DialogNames"];
8
- const getRelevantControlFromActivePage = _____cpe_quick_actions_utils["getRelevantControlFromActivePage"];
9
8
  const isA = _____utils_core["isA"];
10
9
  const SimpleQuickActionDefinitionBase = ___simple_quick_action_base["SimpleQuickActionDefinitionBase"];
11
10
  const DIALOG_ENABLEMENT_VALIDATOR = ___dialog_enablement_validator["DIALOG_ENABLEMENT_VALIDATOR"];
11
+ const getTextBundle = _____i18n["getTextBundle"];
12
12
  const OP_ADD_HEADER_FIELD_TYPE = 'op-add-header-field';
13
13
  const CONTROL_TYPES = ['sap.uxap.ObjectPageLayout'];
14
14
 
@@ -17,11 +17,24 @@ sap.ui.define(["sap/ui/dt/OverlayRegistry", "../../dialog-factory", "../../../cp
17
17
  */
18
18
  class AddHeaderFieldQuickAction extends SimpleQuickActionDefinitionBase {
19
19
  constructor(context) {
20
- super(OP_ADD_HEADER_FIELD_TYPE, CONTROL_TYPES, 'QUICK_ACTION_OP_ADD_HEADER_FIELD', context, [DIALOG_ENABLEMENT_VALIDATOR]);
20
+ super(OP_ADD_HEADER_FIELD_TYPE, CONTROL_TYPES, 'QUICK_ACTION_OP_ADD_HEADER_FIELD', context, [DIALOG_ENABLEMENT_VALIDATOR, {
21
+ run: async () => {
22
+ const i18n = await getTextBundle();
23
+ if (!this.control?.getShowHeaderContent()) {
24
+ return {
25
+ type: 'error',
26
+ message: i18n.getText('DISABLE_SHOW_HEADER_CONTENT')
27
+ };
28
+ }
29
+ return undefined;
30
+ }
31
+ }]);
21
32
  }
22
33
  async execute() {
23
- const objectPageLayout = getRelevantControlFromActivePage(this.context.controlIndex, this.context.view, CONTROL_TYPES)[0];
24
- const headerContent = objectPageLayout.getHeaderContent();
34
+ if (!this.control) {
35
+ return [];
36
+ }
37
+ const headerContent = this.control.getHeaderContent();
25
38
 
26
39
  // check if only flex box exist in the headerContent.
27
40
  if (headerContent.length === 1 && isA('sap.m.FlexBox', headerContent[0])) {
@@ -4,11 +4,12 @@ import ObjectPageLayout from 'sap/uxap/ObjectPageLayout';
4
4
  import FlexBox from 'sap/m/FlexBox';
5
5
 
6
6
  import { DialogFactory, DialogNames } from '../../dialog-factory';
7
- import { getRelevantControlFromActivePage } from '../../../cpe/quick-actions/utils';
8
7
  import { QuickActionContext, SimpleQuickActionDefinition } from '../../../cpe/quick-actions/quick-action-definition';
9
8
  import { isA } from '../../../utils/core';
10
9
  import { SimpleQuickActionDefinitionBase } from '../simple-quick-action-base';
11
10
  import { DIALOG_ENABLEMENT_VALIDATOR } from '../dialog-enablement-validator';
11
+ import { EnablementValidatorResult } from '../enablement-validator';
12
+ import { getTextBundle } from '../../../i18n';
12
13
 
13
14
  export const OP_ADD_HEADER_FIELD_TYPE = 'op-add-header-field';
14
15
  const CONTROL_TYPES = ['sap.uxap.ObjectPageLayout'];
@@ -16,21 +17,33 @@ const CONTROL_TYPES = ['sap.uxap.ObjectPageLayout'];
16
17
  /**
17
18
  * Quick Action for adding a Header Field to an Object Page.
18
19
  */
19
- export class AddHeaderFieldQuickAction extends SimpleQuickActionDefinitionBase implements SimpleQuickActionDefinition {
20
+ export class AddHeaderFieldQuickAction
21
+ extends SimpleQuickActionDefinitionBase<ObjectPageLayout>
22
+ implements SimpleQuickActionDefinition
23
+ {
20
24
  constructor(context: QuickActionContext) {
21
25
  super(OP_ADD_HEADER_FIELD_TYPE, CONTROL_TYPES, 'QUICK_ACTION_OP_ADD_HEADER_FIELD', context, [
22
- DIALOG_ENABLEMENT_VALIDATOR
26
+ DIALOG_ENABLEMENT_VALIDATOR,
27
+ {
28
+ run: async (): Promise<EnablementValidatorResult> => {
29
+ const i18n = await getTextBundle();
30
+ if (!this.control?.getShowHeaderContent()) {
31
+ return {
32
+ type: 'error',
33
+ message: i18n.getText('DISABLE_SHOW_HEADER_CONTENT')
34
+ };
35
+ }
36
+ return undefined;
37
+ }
38
+ }
23
39
  ]);
24
40
  }
25
41
 
26
42
  async execute(): Promise<FlexCommand[]> {
27
- const objectPageLayout = getRelevantControlFromActivePage(
28
- this.context.controlIndex,
29
- this.context.view,
30
- CONTROL_TYPES
31
- )[0] as ObjectPageLayout;
32
-
33
- const headerContent = objectPageLayout.getHeaderContent();
43
+ if (!this.control) {
44
+ return [];
45
+ }
46
+ const headerContent = this.control.getHeaderContent();
34
47
 
35
48
  // check if only flex box exist in the headerContent.
36
49
  if (headerContent.length === 1 && isA<FlexBox>('sap.m.FlexBox', headerContent[0])) {
@@ -52,7 +52,7 @@ VARIANT_MANAGEMENT_FOR_PAGE_CONTROLS_IS_ALREADY_ENABLED=This option has been dis
52
52
  VARIANT_MANAGEMENT_FOR_TABLE_CONTROLS_IS_ALREADY_ENABLED=This option has been disabled because variant management is already enabled for the ''{0}''
53
53
  VARIANT_MANAGEMENT_FOR_CUSTOM_TABLES_NOT_SUPPORTED=Variant management cannot be set for custom table ''{0}''
54
54
  NO_TABLE_HEADER_TOOLBAR=This option has been disabled because the table does not have a header toolbar.
55
-
55
+ DISABLE_SHOW_HEADER_CONTENT=This option has been disabled because the "Show Header Content" page property is set to false.
56
56
  ADD_ANNOTATION_FILE=Add Annotation File for ''{0}''
57
57
  SHOW_ANNOTATION_FILE=Show Annotation File for ''{0}''
58
58
  EXTEND_WITH_ANNOTATION=Extend With Annotation
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.18.16",
12
+ "version": "0.18.17",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -26,12 +26,12 @@
26
26
  "mem-fs": "2.1.0",
27
27
  "mem-fs-editor": "9.4.0",
28
28
  "@sap-ux/adp-tooling": "0.13.14",
29
- "@sap-ux/btp-utils": "1.0.2",
30
29
  "@sap-ux/feature-toggle": "0.2.3",
31
- "@sap-ux/logger": "0.6.0",
30
+ "@sap-ux/btp-utils": "1.0.2",
32
31
  "@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.6.1",
33
- "@sap-ux/system-access": "0.5.33",
34
- "@sap-ux/project-access": "1.29.16"
32
+ "@sap-ux/logger": "0.6.0",
33
+ "@sap-ux/project-access": "1.29.16",
34
+ "@sap-ux/system-access": "0.5.33"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@sap-ux-private/playwright": "0.1.0",
@@ -49,8 +49,8 @@
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.2",
53
52
  "@sap-ux/axios-extension": "1.19.1",
53
+ "@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.13.3",
54
54
  "@sap-ux/i18n": "0.2.3",
55
55
  "@sap-ux/store": "1.0.0",
56
56
  "@sap-ux/ui5-info": "0.9.1"