@zohodesk/library-platform 1.2.0-exp.3 → 1.2.0-exp.4

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 (92) hide show
  1. package/es/cc/date/Properties.js +15 -0
  2. package/es/cc/fields/field/Properties.js +8 -1
  3. package/es/cc/form/Properties.js +8 -0
  4. package/es/cc/label/Properties.js +12 -5
  5. package/es/cc/multi-select/Properties.js +8 -1
  6. package/es/cc/section/Properties.js +8 -1
  7. package/es/cc/select/Properties.js +8 -1
  8. package/es/cc/textarea/Properties.js +15 -0
  9. package/es/cc/textbox/Properties.js +8 -1
  10. package/es/index.js +4 -6
  11. package/es/library/dot/components/form/adapters/presenter/TransformState.js +3 -1
  12. package/es/library/dot/components/form/frameworks/ui/FormView.js +6 -3
  13. package/es/library/dot/components/form/frameworks/ui/sub-components/Footer.js +16 -6
  14. package/es/library/dot/components/form/frameworks/ui/sub-components/Header.js +16 -6
  15. package/es/library/dot/components/form/frameworks/ui/sub-components/Sections.js +4 -2
  16. package/es/library/dot/components/form-fields/checkbox/frameworks/ui/CheckboxView.js +6 -3
  17. package/es/library/dot/components/form-fields/currency/frameworks/ui/CurrencyView.js +6 -3
  18. package/es/library/dot/components/form-fields/date/frameworks/ui/DateView.js +6 -3
  19. package/es/library/dot/components/form-fields/datetime/frameworks/ui/DateTimeView.js +6 -3
  20. package/es/library/dot/components/form-fields/decimal/frameworks/ui/DecimalView.js +6 -3
  21. package/es/library/dot/components/form-fields/email/frameworks/ui/EmailView.js +6 -3
  22. package/es/library/dot/components/form-fields/field/FieldItem.js +4 -2
  23. package/es/library/dot/components/form-fields/lookup/frameworks/ui/LookupView.js +6 -3
  24. package/es/library/dot/components/form-fields/multi-select/frameworks/ui/MultiSelectView.js +7 -4
  25. package/es/library/dot/components/form-fields/number/frameworks/ui/NumberView.js +6 -3
  26. package/es/library/dot/components/form-fields/percentage/frameworks/ui/PercentageView.js +7 -4
  27. package/es/library/dot/components/form-fields/phone/frameworks/ui/PhoneView.js +6 -3
  28. package/es/library/dot/components/form-fields/pick-list/frameworks/ui/PickListView.js +7 -4
  29. package/es/library/dot/components/form-fields/textarea/frameworks/ui/TextAreaView.js +6 -3
  30. package/es/library/dot/components/form-fields/textbox/frameworks/ui/TextBoxView.js +6 -3
  31. package/es/library/dot/components/form-fields/url/frameworks/ui/UrlView.js +6 -3
  32. package/es/library/dot/components/section/frameworks/ui/RenderField.js +3 -1
  33. package/es/library/dot/components/section/frameworks/ui/SectionView.js +14 -8
  34. package/es/library/dot/components/table-list/frameworks/ui/TableListView.js +8 -4
  35. package/es/library/dot/components/table-list/frameworks/ui/sub-components/Header.js +6 -4
  36. package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/HeaderData.js +11 -5
  37. package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/MassAction.js +11 -5
  38. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Row.js +8 -4
  39. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowActions.js +12 -5
  40. package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowData.js +12 -4
  41. package/es/library/dot/legacy-to-new-arch/date/frameworks/ui/DateView.js +10 -4
  42. package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/LabelView.js +11 -5
  43. package/es/library/dot/legacy-to-new-arch/multi-select/frameworks/ui/MultiSelectView.js +21 -8
  44. package/es/library/dot/legacy-to-new-arch/select/frameworks/ui/SelectView.js +18 -8
  45. package/es/library/dot/legacy-to-new-arch/text-area/frameworks/ui/TextAreaView.js +10 -4
  46. package/es/library/dot/legacy-to-new-arch/textbox/frameworks/ui/TextBoxView.js +10 -4
  47. package/es/platform/client-actions/behaviour/zclient-actions/adapters/resources/__test__/ClientActionsFetchSDK.test.js +183 -0
  48. package/es/platform/client-actions/cc/action-event-mediator/Properties.js +0 -43
  49. package/es/platform/client-actions/cc/client-actions-renderer/Properties.js +58 -0
  50. package/es/platform/client-actions/cc/client-actions-renderer/ViewMetaSchema.js +17 -0
  51. package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/ClientActionsAdapter.js +1 -2
  52. package/es/platform/client-actions/components/client-actions-renderer/adapters/presenters/ClientActionsRendererTranslator.js +24 -0
  53. package/es/platform/client-actions/components/client-actions-renderer/domain/entities/ClientActionsRendererDatatype.js +1 -0
  54. package/es/platform/client-actions/components/client-actions-renderer/domain/entities/ClientActionsRendererViewProps.js +1 -0
  55. package/es/platform/client-actions/components/client-actions-renderer/domain/entities/Context.js +1 -0
  56. package/es/platform/client-actions/components/client-actions-renderer/domain/entities/State.js +8 -0
  57. package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRenderer.js +11 -0
  58. package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRenderer.module.css +23 -0
  59. package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRendererView.js +25 -0
  60. package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/views/DefaultActionsRendererView.js +66 -0
  61. package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/more-actions-renderer/MoreActionsRenderer.js +9 -0
  62. package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/more-actions-renderer/MoreActionsRendererView.js +81 -0
  63. package/es/platform/client-scripts/behaviour/zclient-scripts-fetch/adapters/resources/__test__/ClientScriptsFetchSDK.test.js +163 -0
  64. package/es/platform/client-scripts/cc/zclient-scripts-execution/clientScriptsSchema.js +4 -1
  65. package/es/platform/components/form-connected/frameworks/FormConnectedView.js +2 -0
  66. package/es/platform/components/smart-action-band/adapters/presenters/ActionBandTranslator.js +7 -10
  67. package/es/platform/components/smart-action-band/frameworks/SmartActionBandView.js +18 -5
  68. package/es/platform/zform/adapters/presenter/FormTranslator.js +8 -12
  69. package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +10 -14
  70. package/es/platform/zform/adapters/presenter/translators/fields/BooleanFieldTranslator.js +4 -2
  71. package/es/platform/zform/adapters/presenter/translators/fields/CurrencyFieldTranslator.js +2 -1
  72. package/es/platform/zform/adapters/presenter/translators/fields/DateFieldTranslator.js +4 -2
  73. package/es/platform/zform/adapters/presenter/translators/fields/DateTimeFieldTranslator.js +4 -2
  74. package/es/platform/zform/adapters/presenter/translators/fields/DecimalFieldTranslator.js +4 -2
  75. package/es/platform/zform/adapters/presenter/translators/fields/EmailFieldTranslator.js +4 -2
  76. package/es/platform/zform/adapters/presenter/translators/fields/LookUpFieldTranslator.js +4 -2
  77. package/es/platform/zform/adapters/presenter/translators/fields/MultiselectFieldTranslator.js +13 -8
  78. package/es/platform/zform/adapters/presenter/translators/fields/NumberFieldTranslator.js +4 -2
  79. package/es/platform/zform/adapters/presenter/translators/fields/PercentageFieldTranslator.js +4 -2
  80. package/es/platform/zform/adapters/presenter/translators/fields/PhoneFieldTranslator.js +4 -2
  81. package/es/platform/zform/adapters/presenter/translators/fields/PicklistFieldTranslator.js +11 -12
  82. package/es/platform/zform/adapters/presenter/translators/fields/TextAreaFieldTranslator.js +4 -2
  83. package/es/platform/zform/adapters/presenter/translators/fields/TextFieldTranslator.js +4 -2
  84. package/es/platform/zform/adapters/presenter/translators/fields/URLFieldTranslator.js +4 -2
  85. package/es/platform/zlist/adapters/presenters/SelectionTranslator.js +2 -4
  86. package/es/platform/zlist/adapters/presenters/TableTranslator.js +6 -1
  87. package/es/platform/zlist/adapters/presenters/translators/ColumnTranslator.js +7 -1
  88. package/es/platform/zlist/adapters/presenters/translators/Header.js +7 -6
  89. package/es/platform/zlist/adapters/presenters/translators/Row.js +6 -5
  90. package/package.json +2 -2
  91. package/es/.DS_Store +0 -0
  92. package/es/platform/.DS_Store +0 -0
@@ -1,10 +1,11 @@
1
1
  import React from "react";
2
2
  import MultiSelect from "@zohodesk/components/es/MultiSelect/MultiSelect";
3
3
  import { MultiSelectConstants } from "../../../../../../cc/multi-select";
4
- import RowActionsRenderer from "../../../../../../platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActions/RowActionsRenderer";
5
4
  import { ActionViewGap } from "../../../../../../platform/client-actions/components/interfaces/ActionViewModel"; // @ts-ignore
6
5
 
7
6
  import style from "./css/MultiSelectView.module.css";
7
+ import ClientActionsRenderer from "../../../../../../platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRenderer";
8
+ import { Layout } from "../../../../../../platform/client-actions/components/client-actions-renderer/domain/entities/State";
8
9
 
9
10
  function MultiSelectView(_ref, ref) {
10
11
  let {
@@ -24,18 +25,26 @@ function MultiSelectView(_ref, ref) {
24
25
  disabled,
25
26
  readonly,
26
27
  actions,
27
- clientScripts
28
+ clientScripts,
29
+ context
28
30
  } = state.properties;
29
31
  const transformedOptions = options.map(option => {
32
+ const {
33
+ context
34
+ } = option;
30
35
  const baseOption = option;
31
36
 
32
37
  if (option.optionActions && option.optionActions.length !== 0) {
33
38
  return { ...option,
34
39
  listItemCustomProps: {
35
- renderValueRightPlaceholderNode: () => /*#__PURE__*/React.createElement(RowActionsRenderer, {
40
+ renderValueRightPlaceholderNode: () => /*#__PURE__*/React.createElement(ClientActionsRenderer, {
36
41
  actions: option.optionActions,
37
- gap: ActionViewGap.SMALL,
38
- clientScripts: clientScripts
42
+ clientScripts: clientScripts,
43
+ context: context,
44
+ viewMeta: {
45
+ layout: Layout.HORIZONTAL,
46
+ gap: ActionViewGap.SMALL
47
+ }
39
48
  }),
40
49
  customClass: {
41
50
  customValueRightPlaceholder: style.optionActionsContainer
@@ -51,10 +60,14 @@ function MultiSelectView(_ref, ref) {
51
60
  if (!actions?.length) return null;
52
61
  return /*#__PURE__*/React.createElement("div", {
53
62
  className: style.fieldActionsContainer
54
- }, /*#__PURE__*/React.createElement(RowActionsRenderer, {
63
+ }, /*#__PURE__*/React.createElement(ClientActionsRenderer, {
55
64
  actions: actions,
56
- gap: ActionViewGap.SMALL,
57
- clientScripts: clientScripts
65
+ clientScripts: clientScripts,
66
+ context: context,
67
+ viewMeta: {
68
+ layout: Layout.HORIZONTAL,
69
+ gap: ActionViewGap.SMALL
70
+ }
58
71
  }));
59
72
  };
60
73
 
@@ -1,10 +1,11 @@
1
1
  import React from "react";
2
2
  import Select from '@zohodesk/components/es/Select/Select';
3
3
  import SelectConstants from "../../../../../../cc/select/Constants";
4
- import RowActionsRenderer from "../../../../../../platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActions/RowActionsRenderer";
5
4
  import { ActionViewGap } from "../../../../../../platform/client-actions/components/interfaces/ActionViewModel"; // @ts-ignore
6
5
 
7
6
  import style from "./css/Select.module.css";
7
+ import ClientActionsRenderer from "../../../../../../platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRenderer";
8
+ import { Layout } from "../../../../../../platform/client-actions/components/client-actions-renderer/domain/entities/State";
8
9
 
9
10
  function SelectView(_ref, ref) {
10
11
  let {
@@ -23,7 +24,8 @@ function SelectView(_ref, ref) {
23
24
  disabled,
24
25
  readonly,
25
26
  actions,
26
- clientScripts
27
+ clientScripts,
28
+ context
27
29
  } = state.properties;
28
30
  const transformedOptions = options.map(option => {
29
31
  const baseOption = {
@@ -34,10 +36,14 @@ function SelectView(_ref, ref) {
34
36
  if (option.optionActions && option.optionActions.length !== 0) {
35
37
  return { ...baseOption,
36
38
  listItemCustomProps: {
37
- renderValueRightPlaceholderNode: () => /*#__PURE__*/React.createElement(RowActionsRenderer, {
39
+ renderValueRightPlaceholderNode: () => /*#__PURE__*/React.createElement(ClientActionsRenderer, {
38
40
  actions: option.optionActions,
39
- gap: ActionViewGap.SMALL,
40
- clientScripts: clientScripts
41
+ clientScripts: clientScripts,
42
+ context: context,
43
+ viewMeta: {
44
+ layout: Layout.HORIZONTAL,
45
+ gap: ActionViewGap.SMALL
46
+ }
41
47
  }),
42
48
  customClass: {
43
49
  customValueRightPlaceholder: style.optionActionsContainer
@@ -50,10 +56,14 @@ function SelectView(_ref, ref) {
50
56
  });
51
57
 
52
58
  const renderRightFieldActions = () => {
53
- return actions?.length ? /*#__PURE__*/React.createElement(RowActionsRenderer, {
59
+ return actions?.length ? /*#__PURE__*/React.createElement(ClientActionsRenderer, {
54
60
  actions: actions,
55
- gap: ActionViewGap.SMALL,
56
- clientScripts: clientScripts
61
+ clientScripts: clientScripts,
62
+ context: context,
63
+ viewMeta: {
64
+ layout: Layout.HORIZONTAL,
65
+ gap: ActionViewGap.SMALL
66
+ }
57
67
  }) : null;
58
68
  };
59
69
 
@@ -3,8 +3,9 @@ import Textarea from '@zohodesk/components/es/Textarea/Textarea';
3
3
  import TextAreaConstants from "../../../../../../cc/textarea/Constants"; // @ts-ignore
4
4
 
5
5
  import style from "./css/TextAreaView.module.css";
6
- import RowActionsRenderer from "../../../../../../platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActions/RowActionsRenderer";
7
6
  import { ActionViewGap } from "../../../../../../platform/client-actions/components/interfaces/ActionViewModel";
7
+ import ClientActionsRenderer from "../../../../../../platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRenderer";
8
+ import { Layout } from "../../../../../../platform/client-actions/components/client-actions-renderer/domain/entities/State";
8
9
 
9
10
  function TextAreaView(_ref, ref) {
10
11
  let {
@@ -23,7 +24,8 @@ function TextAreaView(_ref, ref) {
23
24
  disabled,
24
25
  readonly,
25
26
  actions,
26
- clientScripts
27
+ clientScripts,
28
+ context
27
29
  } = state.properties;
28
30
  const textAreaRenderer = /*#__PURE__*/React.createElement(Textarea, {
29
31
  getRef: ref,
@@ -64,10 +66,14 @@ function TextAreaView(_ref, ref) {
64
66
  className: style.hasChildren
65
67
  }, textAreaRenderer, /*#__PURE__*/React.createElement("div", {
66
68
  className: style.rightPlaceholder
67
- }, /*#__PURE__*/React.createElement(RowActionsRenderer, {
69
+ }, /*#__PURE__*/React.createElement(ClientActionsRenderer, {
68
70
  actions: actions,
69
71
  clientScripts: clientScripts,
70
- gap: ActionViewGap.SMALL
72
+ context: context,
73
+ viewMeta: {
74
+ layout: Layout.HORIZONTAL,
75
+ gap: ActionViewGap.SMALL
76
+ }
71
77
  })));
72
78
  }
73
79
 
@@ -1,8 +1,9 @@
1
1
  import React from "react";
2
2
  import TextBox from "@zohodesk/components/es/TextBoxIcon/TextBoxIcon";
3
3
  import TextBoxConstants from "../../../../../../cc/textbox/Constants";
4
- import RowActionsRenderer from "../../../../../../platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActions/RowActionsRenderer";
5
4
  import { ActionViewGap } from "../../../../../../platform/client-actions/components/interfaces/ActionViewModel";
5
+ import ClientActionsRenderer from "../../../../../../platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRenderer";
6
+ import { Layout } from "../../../../../../platform/client-actions/components/client-actions-renderer/domain/entities/State";
6
7
 
7
8
  function TextBoxView(_ref, ref) {
8
9
  let {
@@ -23,14 +24,19 @@ function TextBoxView(_ref, ref) {
23
24
  disabled,
24
25
  readonly,
25
26
  actions,
26
- clientScripts
27
+ clientScripts,
28
+ context
27
29
  } = state.properties;
28
30
 
29
31
  const renderRightFieldActions = () => {
30
- return actions?.length ? /*#__PURE__*/React.createElement(RowActionsRenderer, {
32
+ return actions?.length ? /*#__PURE__*/React.createElement(ClientActionsRenderer, {
31
33
  actions: actions,
32
34
  clientScripts: clientScripts,
33
- gap: ActionViewGap.SMALL
35
+ context: context,
36
+ viewMeta: {
37
+ layout: Layout.HORIZONTAL,
38
+ gap: ActionViewGap.SMALL
39
+ }
34
40
  }) : null;
35
41
  };
36
42
 
@@ -0,0 +1,183 @@
1
+ import ClientActionsFetchSDK from "../ClientActionsFetchSDK";
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 createAction = function () {
11
+ let overrides = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
12
+ return {
13
+ id: 'action-1',
14
+ name: 'test-action',
15
+ location: 'module.instance.header_actions',
16
+ component: 'smartTable',
17
+ ...overrides
18
+ };
19
+ };
20
+
21
+ describe('ClientActionsFetchSDK', () => {
22
+ let sdk;
23
+ const originalWindow = global.window;
24
+ beforeEach(() => {
25
+ getApiDetailsMock.mockReturnValue({
26
+ url: '/supportapi/zd/acme/api/v1/clientActions?from=0&limit=50',
27
+ method: 'GET',
28
+ options: {
29
+ method: 'GET'
30
+ }
31
+ });
32
+ global.window = {
33
+ currentOrg: {
34
+ portalName: 'acme',
35
+ id: '1001'
36
+ },
37
+ fetch: jest.fn()
38
+ };
39
+ sdk = new ClientActionsFetchSDK();
40
+ });
41
+ afterEach(() => {
42
+ jest.clearAllMocks();
43
+ global.window = originalWindow;
44
+ });
45
+ describe('getClientActionsAPIDetails', () => {
46
+ test('builds API details with org context and headers', () => {
47
+ const details = sdk.getClientActionsAPIDetails({
48
+ from: 0,
49
+ limit: 50
50
+ });
51
+ expect(getApiDetailsMock).toHaveBeenCalledWith(expect.objectContaining({
52
+ from: 0,
53
+ limit: 50,
54
+ servicePrefix: 'supportapi/zd',
55
+ orgName: 'acme'
56
+ }));
57
+ expect(details.url).toContain('/supportapi/zd/acme/api/v1/clientActions');
58
+ expect(details.method).toBe('GET');
59
+ expect(details.options.method).toBe('GET');
60
+ expect(details.options.headers.orgId).toBe('1001');
61
+ });
62
+ test('handles boundary pagination values without failing', () => {
63
+ const details = sdk.getClientActionsAPIDetails({
64
+ from: 0,
65
+ limit: 0
66
+ });
67
+ expect(details.url).toContain('/supportapi/zd/acme/api/v1/clientActions');
68
+ expect(details.options.method).toBe(details.method);
69
+ });
70
+ test('throws when currentOrg is missing', () => {
71
+ delete global.window.currentOrg;
72
+ expect(() => sdk.getClientActionsAPIDetails({
73
+ from: 0,
74
+ limit: 50
75
+ })).toThrow();
76
+ });
77
+ });
78
+ describe('mapClientActionsByInstanceLocation', () => {
79
+ test('returns empty map for empty list', () => {
80
+ const result = sdk.mapClientActionsByInstanceLocation([]);
81
+ expect(result.size).toBe(0);
82
+ });
83
+ test('groups actions by instance and location for dotted location path', () => {
84
+ const action = createAction({
85
+ location: 'module.table.header_actions',
86
+ component: 'smartTable'
87
+ });
88
+ const result = sdk.mapClientActionsByInstanceLocation([action]);
89
+ expect(result.has('table')).toBe(true);
90
+ expect(result.get('table')?.header_actions).toEqual([action]);
91
+ });
92
+ test('falls back to component and full location when location has no dot path', () => {
93
+ const action = createAction({
94
+ location: 'row_actions',
95
+ component: 'smartTable'
96
+ });
97
+ const result = sdk.mapClientActionsByInstanceLocation([action]);
98
+ expect(result.has('smartTable')).toBe(true);
99
+ expect(result.get('smartTable')?.row_actions).toEqual([action]);
100
+ });
101
+ test('keeps duplicates under same instance/location', () => {
102
+ const first = createAction({
103
+ id: '1',
104
+ location: 'module.table.row_actions'
105
+ });
106
+ const second = createAction({
107
+ id: '2',
108
+ location: 'module.table.row_actions'
109
+ });
110
+ const result = sdk.mapClientActionsByInstanceLocation([first, second]);
111
+ expect(result.get('table')?.row_actions).toHaveLength(2);
112
+ expect(result.get('table')?.row_actions).toEqual([first, second]);
113
+ });
114
+ test('uses second and third segments for multi-segment location', () => {
115
+ const action = createAction({
116
+ location: 'a.b.c.d',
117
+ component: 'fallbackComponent'
118
+ });
119
+ const result = sdk.mapClientActionsByInstanceLocation([action]);
120
+ expect(result.has('b')).toBe(true);
121
+ expect(result.get('b')?.c).toEqual([action]);
122
+ });
123
+ test('throws for malformed action location', () => {
124
+ const malformed = createAction({
125
+ location: undefined
126
+ });
127
+ expect(() => sdk.mapClientActionsByInstanceLocation([malformed])).toThrow();
128
+ });
129
+ });
130
+ describe('fetchClientActions', () => {
131
+ const validParams = {
132
+ from: 0,
133
+ limit: 50,
134
+ components: 'smartTable',
135
+ modules: 'tickets',
136
+ page: 'list'
137
+ };
138
+ test('resolves grouped map on successful fetch', async () => {
139
+ const payload = [createAction({
140
+ location: 'module.table.header_actions',
141
+ component: 'smartTable'
142
+ }), createAction({
143
+ id: '2',
144
+ location: 'row_actions',
145
+ component: 'smartTable'
146
+ })];
147
+ global.window.fetch.mockResolvedValue({
148
+ json: jest.fn().mockResolvedValue(payload)
149
+ });
150
+ const result = await sdk.fetchClientActions(validParams);
151
+ expect(global.window.fetch).toHaveBeenCalledTimes(1);
152
+ const [url, options] = global.window.fetch.mock.calls[0];
153
+ expect(url).toContain('/supportapi/zd/acme/api/v1/clientActions');
154
+ expect(options.headers.orgId).toBe('1001');
155
+ expect(result.get('table')?.header_actions).toHaveLength(1);
156
+ expect(result.get('smartTable')?.row_actions).toHaveLength(1);
157
+ });
158
+ test('resolves empty map when response payload is empty list', async () => {
159
+ global.window.fetch.mockResolvedValue({
160
+ json: jest.fn().mockResolvedValue([])
161
+ });
162
+ const result = await sdk.fetchClientActions(validParams);
163
+ expect(result.size).toBe(0);
164
+ });
165
+ test('rejects when fetch fails', async () => {
166
+ const networkError = new Error('Network down');
167
+ global.window.fetch.mockRejectedValue(networkError);
168
+ await expect(sdk.fetchClientActions(validParams)).rejects.toThrow('Network down');
169
+ });
170
+ test('rejects when response json parsing fails', async () => {
171
+ global.window.fetch.mockResolvedValue({
172
+ json: jest.fn().mockRejectedValue(new Error('Invalid JSON'))
173
+ });
174
+ await expect(sdk.fetchClientActions(validParams)).rejects.toThrow('Invalid JSON');
175
+ });
176
+ test('rejects when json payload is non-iterable', async () => {
177
+ global.window.fetch.mockResolvedValue({
178
+ json: jest.fn().mockResolvedValue(null)
179
+ });
180
+ await expect(sdk.fetchClientActions(validParams)).rejects.toThrow();
181
+ });
182
+ });
183
+ });
@@ -1,4 +1,3 @@
1
- import { ActionViewGap } from "../../components/interfaces/ActionViewModel";
2
1
  import { clientScriptsSchema } from "../../../client-scripts/cc/zclient-scripts-execution/clientScriptsSchema";
3
2
  export const actionSchema = {
4
3
  type: 'object',
@@ -70,46 +69,4 @@ export const ActionEventMediatorProperties = {
70
69
  }
71
70
  }
72
71
  }
73
- };
74
- export default {
75
- testId: {
76
- required: false,
77
- typeMetadata: {
78
- schema: {
79
- type: 'string'
80
- }
81
- },
82
- defaultValue: ''
83
- },
84
- actions: {
85
- required: true,
86
- typeMetadata: {
87
- schema: actionsSchema
88
- }
89
- },
90
- clientScripts: {
91
- required: false,
92
- typeMetadata: {
93
- schema: clientScriptsSchema
94
- }
95
- },
96
- renderComponentType: {
97
- required: false,
98
- typeMetadata: {
99
- schema: {
100
- type: 'string'
101
- }
102
- },
103
- defaultValue: ''
104
- },
105
- gap: {
106
- required: false,
107
- defaultValue: ActionViewGap.NONE,
108
- typeMetadata: {
109
- schema: {
110
- type: 'string',
111
- enum: Object.values(ActionViewGap)
112
- }
113
- }
114
- }
115
72
  };
@@ -0,0 +1,58 @@
1
+ import { clientScriptsSchema } from "../../../client-scripts/cc/zclient-scripts-execution/clientScriptsSchema";
2
+ import { actionsSchema } from "../action-event-mediator/Properties";
3
+ import viewMetaSchema from "./ViewMetaSchema";
4
+ export default {
5
+ location: {
6
+ required: false,
7
+ typeMetadata: {
8
+ schema: {
9
+ type: 'string'
10
+ }
11
+ },
12
+ defaultValue: ''
13
+ },
14
+ instanceName: {
15
+ required: false,
16
+ typeMetadata: {
17
+ schema: {
18
+ type: 'string'
19
+ }
20
+ },
21
+ defaultValue: ''
22
+ },
23
+ testId: {
24
+ required: false,
25
+ typeMetadata: {
26
+ schema: {
27
+ type: 'string'
28
+ }
29
+ },
30
+ defaultValue: ''
31
+ },
32
+ actions: {
33
+ required: true,
34
+ typeMetadata: {
35
+ schema: actionsSchema
36
+ }
37
+ },
38
+ clientScripts: {
39
+ required: false,
40
+ typeMetadata: {
41
+ schema: clientScriptsSchema
42
+ }
43
+ },
44
+ context: {
45
+ required: false,
46
+ typeMetadata: {
47
+ schema: {
48
+ type: 'object'
49
+ }
50
+ }
51
+ },
52
+ viewMeta: {
53
+ required: false,
54
+ typeMetadata: {
55
+ schema: viewMetaSchema
56
+ }
57
+ }
58
+ };
@@ -0,0 +1,17 @@
1
+ import { Layout } from "../../components/client-actions-renderer/domain/entities/State";
2
+ import { ActionViewGap } from "../../components/interfaces/ActionViewModel";
3
+ export default {
4
+ type: 'object',
5
+ properties: {
6
+ layout: {
7
+ type: 'string',
8
+ enum: [Layout.HORIZONTAL, Layout.VERTICAL, Layout.HORIZONTAL_WITH_MORE_ACTIONS, Layout.VERTICAL_WITH_MORE_ACTIONS],
9
+ default: Layout.HORIZONTAL
10
+ },
11
+ gap: {
12
+ type: 'string',
13
+ enum: [ActionViewGap.NONE, ActionViewGap.SMALL, ActionViewGap.MEDIUM, ActionViewGap.LARGE, ActionViewGap.XLARGE, ActionViewGap.XMEDIUM],
14
+ default: ActionViewGap.NONE
15
+ }
16
+ }
17
+ };
@@ -40,8 +40,7 @@ const ClientActionsAdapter = {
40
40
  if (response.errorCode) {
41
41
  return Promise.reject(response);
42
42
  } else {
43
- const actions = ClientActionsAdapterUtils.transform(response);
44
- return Promise.resolve(actions);
43
+ return Promise.resolve(response);
45
44
  }
46
45
  });
47
46
  }
@@ -0,0 +1,24 @@
1
+ import ClientActionsTranslator from "../../../../translators/client-actions-translator";
2
+ export default class ClientActionsRendererTranslator {
3
+ // eslint-disable-next-line complexity -- Need this complexity to transform client actions to action view model which is used for rendering client actions in UI
4
+ static transformState(state) {
5
+ let actions = state.properties.actions;
6
+ const {
7
+ context,
8
+ location,
9
+ instanceName
10
+ } = state.properties;
11
+
12
+ if ((!actions || actions.length === 0) && location && instanceName) {
13
+ actions = []; //TODO: Need to update this logic to use platformBridge SDK to use fetched client actions at page level
14
+ }
15
+
16
+ const resolvedActions = ClientActionsTranslator.transform(actions, context.instanceName, context.moduleName, context);
17
+ return { ...state,
18
+ properties: { ...state.properties,
19
+ actions: resolvedActions
20
+ }
21
+ };
22
+ }
23
+
24
+ }
@@ -0,0 +1,8 @@
1
+ export let Layout = /*#__PURE__*/function (Layout) {
2
+ Layout["HORIZONTAL"] = "horizontal";
3
+ Layout["VERTICAL"] = "vertical";
4
+ Layout["HORIZONTAL_WITH_MORE_ACTIONS"] = "horizontal-with-more-actions";
5
+ Layout["VERTICAL_WITH_MORE_ACTIONS"] = "vertical-with-more-actions";
6
+ return Layout;
7
+ }({});
8
+ ;
@@ -0,0 +1,11 @@
1
+ import { createCustomComponent } from "../../../../../../../library/custom-component";
2
+ import ClientActionsRendererProperties from "../../../../../cc/client-actions-renderer/Properties";
3
+ import ClientActionsRendererTranslator from "../../../adapters/presenters/ClientActionsRendererTranslator";
4
+ import ClientActionsRendererView from "./ClientActionsRendererView";
5
+ export default createCustomComponent({
6
+ name: 'ClientActionsRenderer',
7
+ properties: ClientActionsRendererProperties,
8
+ transformState: ClientActionsRendererTranslator.transformState,
9
+ eventHandlers: {},
10
+ View: ClientActionsRendererView
11
+ });
@@ -0,0 +1,23 @@
1
+ .wrapper {
2
+ max-width: 100%
3
+ }
4
+
5
+ .gap_small {
6
+ gap: var(--zd_size4)
7
+ }
8
+
9
+ .gap_xmedium {
10
+ gap: var(--zd_size6)
11
+ }
12
+
13
+ .gap_medium {
14
+ gap: var(--zd_size8)
15
+ }
16
+
17
+ .gap_large {
18
+ gap: var(--zd_size10)
19
+ }
20
+
21
+ .gap_xlarge {
22
+ gap: var(--zd_size12)
23
+ }
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import DefaultActionsRendererView from "./views/DefaultActionsRendererView";
3
+ import ComponentRegistry from "../../../../../../../library/custom-component/frameworks/ui/ComponentRegistry";
4
+ export default function ClientActionsRendererView(_ref, ref) {
5
+ let {
6
+ state
7
+ } = _ref;
8
+ const {
9
+ actions,
10
+ clientScripts,
11
+ viewMeta,
12
+ testId,
13
+ slotName,
14
+ instanceName
15
+ } = state.properties;
16
+ const customView = slotName !== '' && instanceName !== '' ? ComponentRegistry.get(`${instanceName}_${slotName}_renderer`) : null;
17
+ const View = customView ? customView : DefaultActionsRendererView;
18
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(View, {
19
+ clientActions: actions,
20
+ clientScripts: clientScripts,
21
+ viewMeta: viewMeta,
22
+ getRef: ref,
23
+ testId: testId
24
+ }));
25
+ }