@zohodesk/library-platform 1.2.2-exp.2 → 1.2.2-exp.5

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.
Files changed (124) hide show
  1. package/es/cc/action-status/Constants.js +5 -0
  2. package/es/cc/action-status/Events.js +6 -0
  3. package/es/cc/action-status/Properties.js +29 -0
  4. package/es/cc/action-status/index.js +3 -0
  5. package/es/cc/button/Properties.js +28 -0
  6. package/es/cc/date/Properties.js +15 -0
  7. package/es/cc/fields/field/Events.js +8 -0
  8. package/es/cc/fields/field/Properties.js +8 -1
  9. package/es/cc/form/Properties.js +8 -0
  10. package/es/cc/highlighted-value/Properties.js +28 -0
  11. package/es/cc/index.js +1 -0
  12. package/es/cc/label/Properties.js +12 -5
  13. package/es/cc/multi-select/Properties.js +8 -1
  14. package/es/cc/radio-dropdown/Events.js +16 -0
  15. package/es/cc/section/Properties.js +8 -1
  16. package/es/cc/select/Properties.js +8 -1
  17. package/es/cc/table-column-filter/Properties.js +9 -0
  18. package/es/cc/table-list/Events.js +8 -0
  19. package/es/cc/textarea/Properties.js +15 -0
  20. package/es/cc/textbox/Properties.js +8 -1
  21. package/es/index.js +4 -6
  22. package/es/library/dot/components/action-location/frameworks/ui/ActionComponentMapping.js +3 -1
  23. package/es/library/dot/components/action-status/frameworks/ui/ActionStatus.js +12 -0
  24. package/es/library/dot/components/action-status/frameworks/ui/ActionStatusView.js +57 -0
  25. package/es/library/dot/components/action-status/frameworks/ui/css/ActionStatus.module.css +61 -0
  26. package/es/library/dot/components/form/adapters/presenter/TransformState.js +3 -1
  27. package/es/library/dot/components/form/frameworks/ui/FormView.js +6 -3
  28. package/es/library/dot/components/form/frameworks/ui/sub-components/Footer.js +16 -7
  29. package/es/library/dot/components/form/frameworks/ui/sub-components/Header.js +16 -7
  30. package/es/library/dot/components/form/frameworks/ui/sub-components/Sections.js +4 -2
  31. package/es/library/dot/components/form-fields/checkbox/frameworks/ui/CheckboxView.js +6 -3
  32. package/es/library/dot/components/form-fields/currency/frameworks/ui/CurrencyView.js +6 -3
  33. package/es/library/dot/components/form-fields/date/frameworks/ui/DateView.js +6 -3
  34. package/es/library/dot/components/form-fields/datetime/frameworks/ui/DateTimeView.js +6 -3
  35. package/es/library/dot/components/form-fields/decimal/frameworks/ui/DecimalView.js +6 -3
  36. package/es/library/dot/components/form-fields/email/frameworks/ui/EmailView.js +6 -3
  37. package/es/library/dot/components/form-fields/field/FieldItem.js +4 -2
  38. package/es/library/dot/components/form-fields/lookup/frameworks/ui/LookupView.js +6 -3
  39. package/es/library/dot/components/form-fields/multi-select/frameworks/ui/MultiSelectView.js +7 -4
  40. package/es/library/dot/components/form-fields/number/frameworks/ui/NumberView.js +6 -3
  41. package/es/library/dot/components/form-fields/percentage/frameworks/ui/PercentageView.js +7 -4
  42. package/es/library/dot/components/form-fields/phone/frameworks/ui/PhoneView.js +6 -3
  43. package/es/library/dot/components/form-fields/pick-list/frameworks/ui/PickListView.js +7 -4
  44. package/es/library/dot/components/form-fields/textarea/frameworks/ui/TextAreaView.js +6 -3
  45. package/es/library/dot/components/form-fields/textbox/frameworks/ui/TextBoxView.js +6 -3
  46. package/es/library/dot/components/form-fields/url/frameworks/ui/UrlView.js +6 -3
  47. package/es/library/dot/components/section/frameworks/ui/RenderField.js +3 -1
  48. package/es/library/dot/components/section/frameworks/ui/SectionView.js +11 -6
  49. package/es/library/dot/components/table-list/adapters/controllers/FieldChangeController.js +4 -2
  50. package/es/library/dot/components/table-list/frameworks/ui/TableListView.js +8 -4
  51. package/es/library/dot/components/table-list/frameworks/ui/sub-components/Header.js +6 -4
  52. package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/HeaderData.js +11 -6
  53. package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/MassAction.js +11 -5
  54. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Row.js +8 -4
  55. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowActions.js +12 -5
  56. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowData.js +12 -4
  57. package/es/library/dot/legacy-to-new-arch/button/frameworks/ui/ButtonView.js +17 -2
  58. package/es/library/dot/legacy-to-new-arch/date/frameworks/ui/DateView.js +10 -4
  59. package/es/library/dot/legacy-to-new-arch/highlighted-value/frameworks/ui/HighlightedValueView.js +13 -2
  60. package/es/library/dot/legacy-to-new-arch/highlighted-value/frameworks/ui/css/HighlightedValue.module.css +4 -0
  61. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/LabelView.js +11 -5
  62. package/es/library/dot/legacy-to-new-arch/multi-select/frameworks/ui/MultiSelectView.js +21 -8
  63. package/es/library/dot/legacy-to-new-arch/radio-dropdown/frameworks/ui/RadioDropdownView.js +3 -1
  64. package/es/library/dot/legacy-to-new-arch/select/frameworks/ui/SelectView.js +18 -8
  65. package/es/library/dot/legacy-to-new-arch/table-column-filter/frameworks/ui/EventHandlersFactory.js +26 -0
  66. package/es/library/dot/legacy-to-new-arch/table-column-filter/frameworks/ui/TableColumnFilter.js +19 -1
  67. package/es/library/dot/legacy-to-new-arch/table-column-filter/frameworks/ui/TableColumnFilterView.js +3 -1
  68. package/es/library/dot/legacy-to-new-arch/table-field-components/checkbox-field/frameworks/ui/EventHandlersFactory.js +2 -1
  69. package/es/library/dot/legacy-to-new-arch/table-field-components/highlighted-value-field/frameworks/ui/HighlightedValueFieldView.js +8 -2
  70. package/es/library/dot/legacy-to-new-arch/table-field-components/radio-dropdown-field/frameworks/ui/EventHandlersFactory.js +4 -2
  71. package/es/library/dot/legacy-to-new-arch/table-field-components/switch-field/frameworks/ui/EventHandlersFactory.js +2 -1
  72. package/es/library/dot/legacy-to-new-arch/text-area/frameworks/ui/TextAreaView.js +10 -4
  73. package/es/library/dot/legacy-to-new-arch/textbox/frameworks/ui/TextBoxView.js +11 -5
  74. package/es/platform/client-actions/behaviour/zclient-actions/adapters/resources/__test__/ClientActionsFetchSDK.test.js +183 -0
  75. package/es/platform/client-actions/cc/action-event-mediator/Properties.js +0 -43
  76. package/es/platform/client-actions/cc/client-actions-renderer/Properties.js +58 -0
  77. package/es/platform/client-actions/cc/client-actions-renderer/ViewMetaSchema.js +17 -0
  78. package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/ClientActionsAdapter.js +1 -2
  79. package/es/platform/client-actions/components/client-actions-renderer/adapters/presenters/ClientActionsRendererTranslator.js +24 -0
  80. package/es/platform/client-actions/components/client-actions-renderer/domain/entities/ClientActionsRendererDatatype.js +1 -0
  81. package/es/platform/client-actions/components/client-actions-renderer/domain/entities/ClientActionsRendererViewProps.js +1 -0
  82. package/es/platform/client-actions/components/client-actions-renderer/domain/entities/Context.js +1 -0
  83. package/es/platform/client-actions/components/client-actions-renderer/domain/entities/State.js +1 -0
  84. package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRenderer.js +11 -0
  85. package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRenderer.module.css +23 -0
  86. package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRendererView.js +25 -0
  87. package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/views/DefaultActionsRendererView.js +66 -0
  88. package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/more-actions-renderer/MoreActionsRenderer.js +9 -0
  89. package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/more-actions-renderer/MoreActionsRendererView.js +81 -0
  90. package/es/platform/client-actions/components/interfaces/ActionViewModel.js +7 -0
  91. package/es/platform/client-scripts/behaviour/zclient-scripts-fetch/adapters/resources/__test__/ClientScriptsFetchSDK.test.js +163 -0
  92. package/es/platform/client-scripts/cc/zclient-scripts-execution/clientScriptsSchema.js +4 -1
  93. package/es/platform/components/form-connected/frameworks/FormConnectedView.js +2 -0
  94. package/es/platform/components/smart-action-band/adapters/presenters/ActionBandTranslator.js +7 -10
  95. package/es/platform/components/smart-action-band/frameworks/SmartActionBandView.js +17 -5
  96. package/es/platform/data-source/http-template/getAvailableFields.js +4 -2
  97. package/es/platform/zform/adapters/presenter/FormTranslator.js +8 -12
  98. package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +10 -14
  99. package/es/platform/zform/adapters/presenter/translators/fields/BooleanFieldTranslator.js +4 -2
  100. package/es/platform/zform/adapters/presenter/translators/fields/CurrencyFieldTranslator.js +2 -1
  101. package/es/platform/zform/adapters/presenter/translators/fields/DateFieldTranslator.js +4 -2
  102. package/es/platform/zform/adapters/presenter/translators/fields/DateTimeFieldTranslator.js +4 -2
  103. package/es/platform/zform/adapters/presenter/translators/fields/DecimalFieldTranslator.js +4 -2
  104. package/es/platform/zform/adapters/presenter/translators/fields/EmailFieldTranslator.js +4 -2
  105. package/es/platform/zform/adapters/presenter/translators/fields/LookUpFieldTranslator.js +4 -2
  106. package/es/platform/zform/adapters/presenter/translators/fields/MultiselectFieldTranslator.js +13 -8
  107. package/es/platform/zform/adapters/presenter/translators/fields/NumberFieldTranslator.js +4 -2
  108. package/es/platform/zform/adapters/presenter/translators/fields/PercentageFieldTranslator.js +4 -2
  109. package/es/platform/zform/adapters/presenter/translators/fields/PhoneFieldTranslator.js +4 -2
  110. package/es/platform/zform/adapters/presenter/translators/fields/PicklistFieldTranslator.js +15 -12
  111. package/es/platform/zform/adapters/presenter/translators/fields/TextAreaFieldTranslator.js +4 -2
  112. package/es/platform/zform/adapters/presenter/translators/fields/TextFieldTranslator.js +4 -2
  113. package/es/platform/zform/adapters/presenter/translators/fields/URLFieldTranslator.js +4 -2
  114. package/es/platform/zform/domain/interfaces/IZForm.js +2 -5
  115. package/es/platform/zform/domain/interfaces/ValidationEvents.js +4 -0
  116. package/es/platform/zlist/adapters/presenters/SelectionTranslator.js +2 -4
  117. package/es/platform/zlist/adapters/presenters/TableTranslator.js +6 -1
  118. package/es/platform/zlist/adapters/presenters/translators/ColumnTranslator.js +7 -1
  119. package/es/platform/zlist/adapters/presenters/translators/Header.js +7 -6
  120. package/es/platform/zlist/adapters/presenters/translators/Row.js +6 -5
  121. package/es/platform/zlist/adapters/presenters/translators/fields/DateFieldTranslator.js +7 -3
  122. package/es/platform/zlist/adapters/presenters/translators/fields/DateTimeFieldTranslator.js +7 -3
  123. package/package.json +19 -6
  124. package/es/library/custom-component/frameworks/json-schema-validator/Validator.js +0 -1
@@ -0,0 +1,81 @@
1
+ import React from 'react';
2
+ import ActionEventMediator from "../../../../action-event-mediator/frameworks/ui/ActionEventMediator";
3
+ import CustomDropdown from '@zohodesk-private/desk-components/es/CustomDropdown/CustomDropdown';
4
+ import ListItemConstants from "../../../../../../../cc/list-item/Constants";
5
+ import IconButton from '@zohodesk/dot/es/IconButton/IconButton';
6
+ import { findMappedClientScripts } from "../../../../../../client-scripts/behaviour/zclient-scripts-execution/frameworks/ClientScriptsUtils";
7
+ export function ListItemConvertor(action) {
8
+ // @ts-ignore - properties from ActionViewModel are being used to convert the action to ListItem compatible action, which is then used for rendering the ListItem in MoreActionsRenderer
9
+ const {
10
+ id,
11
+ properties: {
12
+ icon
13
+ },
14
+ eventMappings,
15
+ instanceName
16
+ } = action; // @ts-ignore - properties from ActionViewModel are being used to convert the action to ListItem compatible action, which is then used for rendering the ListItem in MoreActionsRenderer
17
+
18
+ const label = action.properties.label ? action.properties.label : action.properties.text;
19
+ const updatedEventMappings = eventMappings.map(eventMapping => {
20
+ return { ...eventMapping,
21
+ sourceEvent: ListItemConstants.LISTITEM_CLICKED
22
+ };
23
+ });
24
+ return {
25
+ component: 'ListItem',
26
+ properties: {
27
+ text: label,
28
+ tooltip: label,
29
+ icon,
30
+ id
31
+ },
32
+ eventMappings: updatedEventMappings,
33
+ id,
34
+ instanceName
35
+ };
36
+ }
37
+
38
+ function renderTargetElement(_ref) {
39
+ let {
40
+ handleTogglePopup,
41
+ isPopupOpen
42
+ } = _ref;
43
+ return /*#__PURE__*/React.createElement(IconButton, {
44
+ iconName: "ZD-GN-more",
45
+ iconSize: "16",
46
+ isActive: isPopupOpen,
47
+ onClick: handleTogglePopup
48
+ });
49
+ }
50
+
51
+ function renderAction(action, clientScripts, instanceName) {
52
+ const mappedClientScripts = findMappedClientScripts(action, clientScripts);
53
+ return /*#__PURE__*/React.createElement(ActionEventMediator //@ts-ignore - property defined in ACA component
54
+ , {
55
+ action: action,
56
+ clientScripts: mappedClientScripts,
57
+ instanceName: instanceName
58
+ });
59
+ }
60
+
61
+ function MoreActionsRendererView(_ref2, ref) {
62
+ let {
63
+ state
64
+ } = _ref2;
65
+ const {
66
+ actions,
67
+ clientScripts
68
+ } = state.properties;
69
+ const listItemActions = actions.map(action => ListItemConvertor(action));
70
+ return /*#__PURE__*/React.createElement(CustomDropdown, {
71
+ $ui_boxSize: "medium",
72
+ $flag_padding: true,
73
+ $render_targetElement: renderTargetElement,
74
+ $method_getRef: ref,
75
+ $customProps_dropbox: {
76
+ onClick: undefined
77
+ }
78
+ }, listItemActions.map(action => renderAction(action, clientScripts, action.instanceName)));
79
+ }
80
+
81
+ export default MoreActionsRendererView;
@@ -6,4 +6,11 @@ export let ActionViewGap = /*#__PURE__*/function (ActionViewGap) {
6
6
  ActionViewGap["LARGE"] = "large";
7
7
  ActionViewGap["XLARGE"] = "xlarge";
8
8
  return ActionViewGap;
9
+ }({});
10
+ export let Layout = /*#__PURE__*/function (Layout) {
11
+ Layout["HORIZONTAL"] = "horizontal";
12
+ Layout["VERTICAL"] = "vertical";
13
+ Layout["HORIZONTAL_WITH_MORE_ACTIONS"] = "horizontal-with-more-actions";
14
+ Layout["VERTICAL_WITH_MORE_ACTIONS"] = "vertical-with-more-actions";
15
+ return Layout;
9
16
  }({});
@@ -0,0 +1,163 @@
1
+ import ClientScriptsFetchSDK from "../ClientScriptsFetchSDK";
2
+ const getApiDetailsMock = jest.fn();
3
+ jest.mock("../../../../../../zdata-source/domain/entities/APITemplate", () => ({
4
+ __esModule: true,
5
+ default: jest.fn().mockImplementation(() => ({
6
+ getApiDetails: getApiDetailsMock
7
+ }))
8
+ }));
9
+
10
+ const createScript = function () {
11
+ let overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
12
+ return {
13
+ id: 'script-1',
14
+ name: 'sample-script',
15
+ ...overrides
16
+ };
17
+ };
18
+
19
+ describe('ClientScriptsFetchSDK', () => {
20
+ let sdk;
21
+ const originalWindow = global.window;
22
+ beforeEach(() => {
23
+ getApiDetailsMock.mockReturnValue({
24
+ url: '/supportapi/zd/acme/api/v1/clientScripts?from=0&limit=50',
25
+ method: 'GET',
26
+ options: {
27
+ method: 'GET'
28
+ }
29
+ });
30
+ global.window = {
31
+ currentOrg: {
32
+ portalName: 'acme',
33
+ id: '1001'
34
+ },
35
+ fetch: jest.fn()
36
+ };
37
+ sdk = new ClientScriptsFetchSDK();
38
+ });
39
+ afterEach(() => {
40
+ jest.clearAllMocks();
41
+ global.window = originalWindow;
42
+ });
43
+ describe('getClientScriptsAPIDetails', () => {
44
+ test('builds API details with org context and headers', () => {
45
+ const details = sdk.getClientScriptsAPIDetails({
46
+ from: 0,
47
+ limit: 50
48
+ });
49
+ expect(getApiDetailsMock).toHaveBeenCalledWith(expect.objectContaining({
50
+ from: 0,
51
+ limit: 50,
52
+ servicePrefix: 'supportapi/zd',
53
+ orgName: 'acme'
54
+ }));
55
+ expect(details.url).toContain('/supportapi/zd/acme/api/v1/clientScripts');
56
+ expect(details.method).toBe('GET');
57
+ expect(details.options.method).toBe('GET');
58
+ expect(details.options.headers.orgId).toBe('1001');
59
+ });
60
+ test('handles boundary pagination values without failing', () => {
61
+ const details = sdk.getClientScriptsAPIDetails({
62
+ from: 0,
63
+ limit: 0
64
+ });
65
+ expect(details.url).toContain('/supportapi/zd/acme/api/v1/clientScripts');
66
+ expect(details.options.method).toBe(details.method);
67
+ });
68
+ test('handles large pagination values without failing', () => {
69
+ const details = sdk.getClientScriptsAPIDetails({
70
+ from: 999999,
71
+ limit: 100000
72
+ });
73
+ expect(details.method).toBe('GET');
74
+ expect(details.options.headers.orgId).toBe('1001');
75
+ });
76
+ test('throws when currentOrg is missing', () => {
77
+ delete global.window.currentOrg;
78
+ expect(() => sdk.getClientScriptsAPIDetails({
79
+ from: 0,
80
+ limit: 50
81
+ })).toThrow();
82
+ });
83
+ });
84
+ describe('fetchClientScripts', () => {
85
+ const validParams = {
86
+ from: 0,
87
+ limit: 50,
88
+ components: 'smartTable',
89
+ modules: 'tickets'
90
+ };
91
+ test('resolves scripts array on successful fetch/json', async () => {
92
+ const payload = [createScript(), createScript({
93
+ id: 'script-2'
94
+ })];
95
+ global.window.fetch.mockResolvedValue({
96
+ json: jest.fn().mockResolvedValue(payload)
97
+ });
98
+ const result = await sdk.fetchClientScripts(validParams);
99
+ expect(global.window.fetch).toHaveBeenCalledTimes(1);
100
+ const [url, options] = global.window.fetch.mock.calls[0];
101
+ expect(url).toContain('/supportapi/zd/acme/api/v1/clientScripts');
102
+ expect(options.headers.orgId).toBe('1001');
103
+ expect(result).toEqual(payload);
104
+ });
105
+ test('passes through API details returned by getClientScriptsAPIDetails', async () => {
106
+ const detailsSpy = jest.spyOn(sdk, 'getClientScriptsAPIDetails').mockReturnValue({
107
+ url: '/custom-client-scripts-url',
108
+ method: 'POST',
109
+ options: {
110
+ method: 'POST',
111
+ headers: {
112
+ orgId: 'custom-org'
113
+ }
114
+ }
115
+ });
116
+ global.window.fetch.mockResolvedValue({
117
+ json: jest.fn().mockResolvedValue([])
118
+ });
119
+ await sdk.fetchClientScripts(validParams);
120
+ expect(detailsSpy).toHaveBeenCalledWith(validParams);
121
+ expect(global.window.fetch).toHaveBeenCalledWith('/custom-client-scripts-url', expect.objectContaining({
122
+ method: 'POST'
123
+ }));
124
+ });
125
+ test('resolves empty array for empty payload', async () => {
126
+ global.window.fetch.mockResolvedValue({
127
+ json: jest.fn().mockResolvedValue([])
128
+ });
129
+ const result = await sdk.fetchClientScripts(validParams);
130
+ expect(result).toEqual([]);
131
+ });
132
+ test('rejects when fetch fails', async () => {
133
+ const error = new Error('Network down');
134
+ global.window.fetch.mockRejectedValue(error);
135
+ await expect(sdk.fetchClientScripts(validParams)).rejects.toThrow('Network down');
136
+ });
137
+ test('rejects when response json parsing fails', async () => {
138
+ global.window.fetch.mockResolvedValue({
139
+ json: jest.fn().mockRejectedValue(new Error('Invalid JSON'))
140
+ });
141
+ await expect(sdk.fetchClientScripts(validParams)).rejects.toThrow('Invalid JSON');
142
+ });
143
+ test('resolves non-array payload as-is (current behavior)', async () => {
144
+ const payload = {
145
+ unsupported: true
146
+ };
147
+ global.window.fetch.mockResolvedValue({
148
+ json: jest.fn().mockResolvedValue(payload)
149
+ });
150
+ const result = await sdk.fetchClientScripts(validParams);
151
+ expect(result).toEqual(payload);
152
+ });
153
+ test('throws when window.fetch is missing', async () => {
154
+ delete global.window.fetch;
155
+ await expect(sdk.fetchClientScripts(validParams)).rejects.toThrow();
156
+ });
157
+ test('rejects when getClientScriptsAPIDetails throws', async () => {
158
+ delete global.window.currentOrg;
159
+ await expect(sdk.fetchClientScripts(validParams)).rejects.toThrow();
160
+ expect(global.window.fetch).not.toHaveBeenCalled();
161
+ });
162
+ });
163
+ });
@@ -4,11 +4,14 @@ export const clientScriptsSchema = {
4
4
  items: {
5
5
  type: 'object',
6
6
  properties: {
7
- targetEventName: {
7
+ targetEvent: {
8
8
  type: 'string'
9
9
  },
10
10
  clientScript: {
11
11
  type: 'string'
12
+ },
13
+ type: {
14
+ type: 'string'
12
15
  }
13
16
  }
14
17
  }
@@ -16,6 +16,7 @@ function View(_ref, ref) {
16
16
  headerRightActions,
17
17
  footerLeftActions,
18
18
  footerRightActions,
19
+ context,
19
20
  clientScripts
20
21
  } = state.viewModel;
21
22
  return /*#__PURE__*/React.createElement(Form, {
@@ -28,6 +29,7 @@ function View(_ref, ref) {
28
29
  headerRightActions: headerRightActions,
29
30
  footerLeftActions: footerLeftActions,
30
31
  footerRightActions: footerRightActions,
32
+ context: context,
31
33
  rightPanel: rightPanel,
32
34
  clientScripts: clientScripts
33
35
  });
@@ -1,4 +1,3 @@
1
- import ClientActionsTranslator from "../../../../client-actions/translators/client-actions-translator";
2
1
  import DefaultClientActions from "./utils/DefaultClientActions";
3
2
  import { ActionBandLocations } from "../../../../../bc/action-band/Constants";
4
3
  import { i18NProviderUtils } from '@zohodesk/i18n';
@@ -56,14 +55,11 @@ export default class ActionBandTranslator {
56
55
  }
57
56
 
58
57
  const mappedClientActions = mapper(combinedClientActions || []);
59
- const transformedClientActions = {};
60
- Object.entries(mappedClientActions).forEach(_ref => {
61
- let [key, value] = _ref;
62
- let bandActions = ClientActionsTranslator.transform(value, instanceName, moduleName, { ...context,
63
- defaultSortField: sortConfig.defaultSortField
64
- });
65
- transformedClientActions[key] = bandActions;
66
- });
58
+ const clientActionsContext = { ...context,
59
+ defaultSortField: sortConfig.defaultSortField,
60
+ instanceName,
61
+ moduleName
62
+ };
67
63
  const {
68
64
  clientScripts,
69
65
  isFetching: isClientScriptsFetching
@@ -71,9 +67,10 @@ export default class ActionBandTranslator {
71
67
  const {
72
68
  actionBandLeftActions,
73
69
  actionBandRightActions
74
- } = transformedClientActions;
70
+ } = mappedClientActions;
75
71
  return { ...state,
76
72
  ...zclientAction,
73
+ context: clientActionsContext,
77
74
  viewModel: {
78
75
  actionBandLeftActions,
79
76
  actionBandRightActions,
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import ActionBand from '@zohodesk-private/desk-components/es/ActionBand/ActionBand';
4
- import RowActionsRenderer from "../../../client-actions/components/row-actions-renderer/frameworks/ui/RowActions/RowActionsRenderer";
4
+ import ClientActionsRenderer from "../../../client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRenderer";
5
+ import { ActionViewGap, Layout } from "../../../client-actions/components/interfaces/ActionViewModel";
5
6
 
6
7
  function View(_ref, ref) {
7
8
  let {
@@ -12,20 +13,31 @@ function View(_ref, ref) {
12
13
  actionBandRightActions,
13
14
  clientScripts
14
15
  } = state.viewModel;
16
+ const {
17
+ context
18
+ } = state;
15
19
 
16
20
  const renderLeftActions = () => {
17
- return /*#__PURE__*/React.createElement(RowActionsRenderer, {
21
+ return /*#__PURE__*/React.createElement(ClientActionsRenderer, {
18
22
  actions: actionBandLeftActions,
19
23
  clientScripts: clientScripts,
20
- gap: "xlarge"
24
+ context: context,
25
+ viewMeta: {
26
+ layout: Layout.HORIZONTAL,
27
+ gap: ActionViewGap.XLARGE
28
+ }
21
29
  });
22
30
  };
23
31
 
24
32
  const renderRightActions = () => {
25
- return /*#__PURE__*/React.createElement(RowActionsRenderer, {
33
+ return /*#__PURE__*/React.createElement(ClientActionsRenderer, {
26
34
  actions: actionBandRightActions,
27
35
  clientScripts: clientScripts,
28
- gap: "xlarge"
36
+ context: context,
37
+ viewMeta: {
38
+ layout: Layout.HORIZONTAL,
39
+ gap: ActionViewGap.XLARGE
40
+ }
29
41
  });
30
42
  };
31
43
 
@@ -39,13 +39,15 @@ let getAvailableFields = {
39
39
  const res = await fetch(availableFieldsUrl, {
40
40
  method: 'GET',
41
41
  headers
42
- });
42
+ }); // fetch-ignore
43
+
43
44
  const availableFields = await getValidJsonResArray(res, 'fields');
44
45
  const organizationFieldsUrl = `/${servicePrefix}/${orgName}/api/v1/organizationFields?departmentId=${departmentId}&module=${module}`;
45
46
  const ores = await fetch(organizationFieldsUrl, {
46
47
  method: 'GET',
47
48
  headers
48
- });
49
+ }); // fetch-ignore
50
+
49
51
  const organizationFields = await getValidJsonResArray(ores, 'data');
50
52
  return {
51
53
  fields: availableFields.map(field => {
@@ -1,4 +1,3 @@
1
- import ClientActionsTranslator from "../../../client-actions/translators/client-actions-translator";
2
1
  import SectionTranslator from "./translators/SectionTranslator";
3
2
  import DefaultFormClientActions from "./utils/DefaultClientActions";
4
3
  import { filterClientActionsByLocation } from "../../../client-actions/behaviour/zclient-actions/adapters/presenters/FilterUtils";
@@ -19,7 +18,7 @@ export default class FormTranslator {
19
18
  zclientAction,
20
19
  zclientScriptsEventMapping
21
20
  } = state.behaviours;
22
- const {
21
+ let {
23
22
  context
24
23
  } = state.behaviours.appContext;
25
24
  const {
@@ -46,6 +45,11 @@ export default class FormTranslator {
46
45
  };
47
46
  const initialRecordData = zform.initialRecordData ? zform.initialRecordData : {
48
47
  cf: {}
48
+ }; // @ts-ignore
49
+
50
+ context = { ...context,
51
+ instanceName,
52
+ moduleName
49
53
  };
50
54
  const actionContext = { ...context,
51
55
  mode: zform.mode,
@@ -56,16 +60,7 @@ export default class FormTranslator {
56
60
  };
57
61
  Object.entries(mappedClientActions).forEach(_ref => {
58
62
  let [key, value] = _ref;
59
-
60
- if (isFooterEnabled && (key === 'footerLeftActions' || key === 'footerRightActions')) {
61
- let footerActions = ClientActionsTranslator.transform(value, instanceName, moduleName, actionContext);
62
- transformedClientActions[key] = footerActions;
63
- }
64
-
65
- if (isHeaderEnabled && (key === 'headerLeftActions' || key === 'headerRightActions')) {
66
- let headerActions = ClientActionsTranslator.transform(value, instanceName, moduleName, actionContext);
67
- transformedClientActions[key] = headerActions;
68
- }
63
+ transformedClientActions[key] = value;
69
64
  });
70
65
  const {
71
66
  clientScripts,
@@ -143,6 +138,7 @@ export default class FormTranslator {
143
138
  headerRightActions,
144
139
  footerLeftActions,
145
140
  footerRightActions,
141
+ context: actionContext,
146
142
  isLoading: false,
147
143
  rightPanel,
148
144
  clientScripts
@@ -1,6 +1,5 @@
1
1
  import { DefaultFormSectionUIType, fieldTypeToUIType } from "../../../../../cc/fields/field/FormDefaultUIType";
2
2
  import * as FieldTranslators from "./fields";
3
- import ClientActionsTranslator from "../../../../client-actions/translators/client-actions-translator";
4
3
  import { getDefaultFieldEphiActionTemplate, getDefaultFieldInfoActionTemplate } from "../utils/DefaultClientActions";
5
4
  import sanitizeHtmlString from "../utils/sanitizeHtmlString";
6
5
 
@@ -30,10 +29,7 @@ function SectionTranslator(_ref) {
30
29
  const transformedClientActions = {};
31
30
  Object.entries(sectionFieldOptionActions).forEach(_ref2 => {
32
31
  let [key, value] = _ref2;
33
- let headerActions = ClientActionsTranslator.transform(value, instanceName, moduleName, { ...context,
34
- ...section
35
- });
36
- transformedClientActions[key] = headerActions;
32
+ transformedClientActions[key] = value;
37
33
  });
38
34
  const defaultViewModel = {
39
35
  type: mapping?.UIComponentName ? mapping.UIComponentName : DefaultFormSectionUIType,
@@ -45,6 +41,9 @@ function SectionTranslator(_ref) {
45
41
  }),
46
42
  headerActions: transformedClientActions.sectionHeaderRightActions,
47
43
  titleActions: transformedClientActions.sectionTitleRightActions,
44
+ context: { ...context,
45
+ ...section
46
+ },
48
47
  // headerLeftActions: sectionFieldOptionActions.sectionHeaderLeftActions,
49
48
  // headerRightActions: sectionFieldOptionActions.sectionHeaderRightActions,
50
49
  // titleLeftActions: sectionFieldOptionActions.sectionTitleLeftActions,
@@ -89,19 +88,14 @@ function SectionTranslator(_ref) {
89
88
  const transformedDefaultActions = createEmptyActions();
90
89
  Object.entries(defaultActions).forEach(_ref3 => {
91
90
  let [key, value] = _ref3;
92
- let transformedDefaultAction = ClientActionsTranslator.transform(value, instanceName, moduleName, { ...context,
93
- ...field
94
- });
95
- transformedDefaultActions[key] = transformedDefaultAction;
91
+ transformedDefaultActions[key] = value;
96
92
  }); // Transform client actions
97
93
 
98
94
  const transformedActions = createEmptyActions();
99
95
  Object.entries(fieldLevelActions).forEach(_ref4 => {
100
96
  let [key, value] = _ref4;
101
- let transformedAction = ClientActionsTranslator.transform(value, instanceName, moduleName, { ...context,
102
- ...field
103
- });
104
- transformedActions[key] = transformedAction;
97
+ // let transformedAction = ClientActionsTranslator.transform(value, instanceName, moduleName, { ...context, ...field });
98
+ transformedActions[key] = value;
105
99
  }); // Initialize fieldPreModified
106
100
 
107
101
  const fieldPreModified = {};
@@ -123,7 +117,9 @@ function SectionTranslator(_ref) {
123
117
  type,
124
118
  fieldPreModified,
125
119
  uiConfig,
126
- context,
120
+ context: { ...context,
121
+ ...field
122
+ },
127
123
  preferences,
128
124
  fieldOptionActions,
129
125
  instanceName,
@@ -3,7 +3,8 @@ const BooleanFieldTranslator = _ref => {
3
3
  field,
4
4
  type,
5
5
  uiConfig,
6
- fieldPreModified
6
+ fieldPreModified,
7
+ context
7
8
  } = _ref;
8
9
  const fieldModified = { ...fieldPreModified,
9
10
  id: field.id,
@@ -16,7 +17,8 @@ const BooleanFieldTranslator = _ref => {
16
17
  required: field.isMandatory,
17
18
  readonly: field.isReadOnly,
18
19
  // visibility: field.isVisible
19
- isVisible: field.isVisible
20
+ isVisible: field.isVisible,
21
+ context
20
22
  };
21
23
  return fieldModified;
22
24
  };
@@ -26,7 +26,8 @@ const CurrencyFieldTranslator = _ref => {
26
26
  isVisible: field.isVisible,
27
27
  currencyLocale: prefCurrencyLocale || contextCurrencyLocale,
28
28
  currencySymbol: prefCurrencySymbol || contextCurrencySymbol,
29
- errorMessage: field.errorMessage || ''
29
+ errorMessage: field.errorMessage || '',
30
+ context
30
31
  };
31
32
  return fieldModified;
32
33
  };
@@ -3,7 +3,8 @@ const DateFieldTranslator = _ref => {
3
3
  field,
4
4
  type,
5
5
  uiConfig,
6
- fieldPreModified
6
+ fieldPreModified,
7
+ context
7
8
  } = _ref;
8
9
  const fieldModified = { ...fieldPreModified,
9
10
  id: field.id,
@@ -16,7 +17,8 @@ const DateFieldTranslator = _ref => {
16
17
  errorMessage: field.errorMessage || '',
17
18
  required: field.isMandatory,
18
19
  readonly: field.isReadOnly,
19
- isVisible: field.isVisible
20
+ isVisible: field.isVisible,
21
+ context
20
22
  };
21
23
  return fieldModified;
22
24
  };
@@ -3,7 +3,8 @@ const DateTimeFieldTranslator = _ref => {
3
3
  field,
4
4
  type,
5
5
  uiConfig,
6
- fieldPreModified
6
+ fieldPreModified,
7
+ context
7
8
  } = _ref;
8
9
  const fieldModified = { ...fieldPreModified,
9
10
  id: field.id,
@@ -17,7 +18,8 @@ const DateTimeFieldTranslator = _ref => {
17
18
  required: field.isMandatory,
18
19
  readonly: field.isReadOnly,
19
20
  // visibility: field.isVisible
20
- isVisible: field.isVisible
21
+ isVisible: field.isVisible,
22
+ context
21
23
  };
22
24
  return fieldModified;
23
25
  };
@@ -3,7 +3,8 @@ const DecimalFieldTranslator = _ref => {
3
3
  field,
4
4
  type,
5
5
  fieldPreModified,
6
- uiConfig
6
+ uiConfig,
7
+ context
7
8
  } = _ref;
8
9
  const fieldModified = {
9
10
  type,
@@ -19,7 +20,8 @@ const DecimalFieldTranslator = _ref => {
19
20
  maxLength: field.maxLength,
20
21
  readonly: field.isReadOnly,
21
22
  isVisible: field.isVisible,
22
- errorMessage: field.errorMessage || ''
23
+ errorMessage: field.errorMessage || '',
24
+ context
23
25
  };
24
26
  return fieldModified;
25
27
  };
@@ -3,7 +3,8 @@ const EmailFieldTranslator = _ref => {
3
3
  field,
4
4
  type,
5
5
  fieldPreModified,
6
- uiConfig
6
+ uiConfig,
7
+ context
7
8
  } = _ref;
8
9
  const fieldModified = {
9
10
  type,
@@ -20,7 +21,8 @@ const EmailFieldTranslator = _ref => {
20
21
  readonly: field.isReadOnly,
21
22
  // visibility: field.isVisible,
22
23
  isVisible: field.isVisible,
23
- errorMessage: field.errorMessage || ''
24
+ errorMessage: field.errorMessage || '',
25
+ context
24
26
  };
25
27
  return fieldModified;
26
28
  };
@@ -3,7 +3,8 @@ const LookUpFieldTranslator = _ref => {
3
3
  field,
4
4
  type,
5
5
  fieldPreModified,
6
- uiConfig
6
+ uiConfig,
7
+ context
7
8
  } = _ref;
8
9
  const fieldModified = {
9
10
  // Need to check if value is an object or string (ID)
@@ -23,7 +24,8 @@ const LookUpFieldTranslator = _ref => {
23
24
  required: field.isMandatory,
24
25
  isCustomField: field.isCustomField,
25
26
  maxLength: field.maxLength,
26
- lookup: field.lookup
27
+ lookup: field.lookup,
28
+ context
27
29
  };
28
30
  return fieldModified;
29
31
  };