@zohodesk/library-platform 1.2.2-exp.2 → 1.2.2-exp.6
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.
- package/es/cc/action-status/Constants.js +5 -0
- package/es/cc/action-status/Events.js +6 -0
- package/es/cc/action-status/Properties.js +29 -0
- package/es/cc/action-status/index.js +3 -0
- package/es/cc/button/Properties.js +28 -0
- package/es/cc/date/Properties.js +15 -0
- package/es/cc/fields/field/Events.js +8 -0
- package/es/cc/fields/field/Properties.js +8 -1
- package/es/cc/form/Properties.js +8 -0
- package/es/cc/highlighted-value/Properties.js +28 -0
- package/es/cc/index.js +1 -0
- package/es/cc/label/Properties.js +12 -5
- package/es/cc/multi-select/Properties.js +8 -1
- package/es/cc/radio-dropdown/Events.js +16 -0
- package/es/cc/section/Properties.js +8 -1
- package/es/cc/select/Properties.js +8 -1
- package/es/cc/table-column-filter/Properties.js +9 -0
- package/es/cc/table-list/Events.js +8 -0
- package/es/cc/textarea/Properties.js +15 -0
- package/es/cc/textbox/Properties.js +8 -1
- package/es/index.js +4 -6
- package/es/library/dot/components/action-location/frameworks/ui/ActionComponentMapping.js +3 -1
- package/es/library/dot/components/action-status/frameworks/ui/ActionStatus.js +12 -0
- package/es/library/dot/components/action-status/frameworks/ui/ActionStatusView.js +57 -0
- package/es/library/dot/components/action-status/frameworks/ui/css/ActionStatus.module.css +61 -0
- package/es/library/dot/components/form/adapters/presenter/TransformState.js +3 -1
- package/es/library/dot/components/form/frameworks/ui/FormView.js +6 -3
- package/es/library/dot/components/form/frameworks/ui/css/Form.module.css +13 -13
- package/es/library/dot/components/form/frameworks/ui/sub-components/Footer.js +16 -7
- package/es/library/dot/components/form/frameworks/ui/sub-components/Header.js +16 -7
- package/es/library/dot/components/form/frameworks/ui/sub-components/Sections.js +4 -2
- package/es/library/dot/components/form-fields/checkbox/frameworks/ui/CheckboxView.js +6 -3
- package/es/library/dot/components/form-fields/currency/frameworks/ui/CurrencyView.js +6 -3
- package/es/library/dot/components/form-fields/date/frameworks/ui/DateView.js +6 -3
- package/es/library/dot/components/form-fields/datetime/frameworks/ui/DateTimeView.js +6 -3
- package/es/library/dot/components/form-fields/decimal/frameworks/ui/DecimalView.js +6 -3
- package/es/library/dot/components/form-fields/email/frameworks/ui/EmailView.js +6 -3
- package/es/library/dot/components/form-fields/field/FieldItem.js +4 -2
- package/es/library/dot/components/form-fields/field/css/FieldItem.module.css +2 -2
- package/es/library/dot/components/form-fields/lookup/frameworks/ui/LookupView.js +6 -3
- package/es/library/dot/components/form-fields/multi-select/frameworks/ui/MultiSelectView.js +7 -4
- package/es/library/dot/components/form-fields/number/frameworks/ui/NumberView.js +6 -3
- package/es/library/dot/components/form-fields/percentage/frameworks/ui/PercentageView.js +7 -4
- package/es/library/dot/components/form-fields/phone/frameworks/ui/PhoneView.js +6 -3
- package/es/library/dot/components/form-fields/pick-list/frameworks/ui/PickListView.js +7 -4
- package/es/library/dot/components/form-fields/textarea/frameworks/ui/TextAreaView.js +6 -3
- package/es/library/dot/components/form-fields/textbox/frameworks/ui/TextBoxView.js +6 -3
- package/es/library/dot/components/form-fields/url/frameworks/ui/UrlView.js +6 -3
- package/es/library/dot/components/section/frameworks/ui/RenderField.js +3 -1
- package/es/library/dot/components/section/frameworks/ui/SectionView.js +11 -6
- package/es/library/dot/components/section/frameworks/ui/css/Section.module.css +3 -3
- package/es/library/dot/components/table-list/adapters/controllers/FieldChangeController.js +4 -2
- package/es/library/dot/components/table-list/frameworks/ui/TableListView.js +8 -4
- package/es/library/dot/components/table-list/frameworks/ui/css/TableList.module.css +25 -25
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/Header.js +6 -4
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/HeaderData.js +11 -6
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/header/MassAction.js +11 -5
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/Row.js +8 -4
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowActions.js +12 -5
- package/es/library/dot/components/table-list/frameworks/ui/sub-components/row/RowData.js +12 -4
- package/es/library/dot/legacy-to-new-arch/breadcrumb/frameworks/ui/css/Breadcrumb.module.css +4 -4
- package/es/library/dot/legacy-to-new-arch/button/frameworks/ui/ButtonView.js +17 -2
- package/es/library/dot/legacy-to-new-arch/date/frameworks/ui/DateView.js +10 -4
- package/es/library/dot/legacy-to-new-arch/date/frameworks/ui/css/DateView.module.css +1 -1
- package/es/library/dot/legacy-to-new-arch/highlighted-value/frameworks/ui/HighlightedValueView.js +13 -2
- package/es/library/dot/legacy-to-new-arch/highlighted-value/frameworks/ui/css/HighlightedValue.module.css +4 -0
- package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/LabelView.js +11 -5
- package/es/library/dot/legacy-to-new-arch/label/frameworks/ui/css/Label.module.css +4 -4
- package/es/library/dot/legacy-to-new-arch/multi-select/frameworks/ui/MultiSelectView.js +21 -8
- package/es/library/dot/legacy-to-new-arch/multi-select/frameworks/ui/css/MultiSelectView.module.css +7 -7
- package/es/library/dot/legacy-to-new-arch/radio-dropdown/frameworks/ui/RadioDropdownView.js +3 -1
- package/es/library/dot/legacy-to-new-arch/radio-dropdown/frameworks/ui/css/RadioDropdown.module.css +4 -4
- package/es/library/dot/legacy-to-new-arch/select/frameworks/ui/SelectView.js +18 -8
- package/es/library/dot/legacy-to-new-arch/select/frameworks/ui/css/Select.module.css +2 -2
- package/es/library/dot/legacy-to-new-arch/table-column-chooser/frameworks/ui/css/TableColumnChooserView.module.css +1 -1
- package/es/library/dot/legacy-to-new-arch/table-column-filter/frameworks/ui/EventHandlersFactory.js +26 -0
- package/es/library/dot/legacy-to-new-arch/table-column-filter/frameworks/ui/TableColumnFilter.js +19 -1
- package/es/library/dot/legacy-to-new-arch/table-column-filter/frameworks/ui/TableColumnFilterView.js +3 -1
- package/es/library/dot/legacy-to-new-arch/table-field-components/checkbox-field/frameworks/ui/EventHandlersFactory.js +2 -1
- package/es/library/dot/legacy-to-new-arch/table-field-components/highlighted-value-field/frameworks/ui/HighlightedValueFieldView.js +8 -2
- package/es/library/dot/legacy-to-new-arch/table-field-components/radio-dropdown-field/frameworks/ui/EventHandlersFactory.js +4 -2
- package/es/library/dot/legacy-to-new-arch/table-field-components/radio-dropdown-field/frameworks/ui/css/RadioDropdownField.module.css +1 -1
- package/es/library/dot/legacy-to-new-arch/table-field-components/switch-field/frameworks/ui/EventHandlersFactory.js +2 -1
- package/es/library/dot/legacy-to-new-arch/text-area/frameworks/ui/TextAreaView.js +10 -4
- package/es/library/dot/legacy-to-new-arch/text-area/frameworks/ui/css/TextAreaView.module.css +3 -3
- package/es/library/dot/legacy-to-new-arch/textbox/frameworks/ui/TextBoxView.js +11 -5
- package/es/platform/client-actions/behaviour/zclient-actions/adapters/resources/__test__/ClientActionsFetchSDK.test.js +183 -0
- package/es/platform/client-actions/cc/action-event-mediator/Properties.js +0 -43
- package/es/platform/client-actions/cc/client-actions-renderer/Properties.js +58 -0
- package/es/platform/client-actions/cc/client-actions-renderer/ViewMetaSchema.js +17 -0
- package/es/platform/client-actions/components/action-event-mediator/frameworks/ui/ClientActionsAdapter.js +1 -2
- package/es/platform/client-actions/components/client-actions-renderer/adapters/presenters/ClientActionsRendererTranslator.js +24 -0
- package/es/platform/client-actions/components/client-actions-renderer/domain/entities/ClientActionsRendererViewProps.js +1 -0
- package/es/platform/client-actions/components/client-actions-renderer/domain/entities/Context.js +1 -0
- package/es/platform/client-actions/components/client-actions-renderer/domain/entities/State.js +1 -0
- package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRenderer.js +11 -0
- package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRenderer.module.css +23 -0
- package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRendererView.js +25 -0
- package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/views/DefaultActionsRendererView.js +66 -0
- package/es/platform/client-actions/components/{row-actions-renderer/frameworks/ui/MoreActions → client-actions-renderer/frameworks/ui/more-actions-renderer}/MoreActionsRenderer.js +3 -4
- package/es/platform/client-actions/components/{row-actions-renderer/frameworks/ui/MoreActions → client-actions-renderer/frameworks/ui/more-actions-renderer}/MoreActionsRendererView.js +32 -30
- package/es/platform/client-actions/components/interfaces/ActionViewModel.js +7 -0
- package/es/platform/client-scripts/behaviour/zclient-scripts-fetch/adapters/resources/__test__/ClientScriptsFetchSDK.test.js +163 -0
- package/es/platform/client-scripts/cc/zclient-scripts-execution/clientScriptsSchema.js +4 -1
- package/es/platform/components/form-connected/frameworks/FormConnectedView.js +2 -0
- package/es/platform/components/smart-action-band/adapters/presenters/ActionBandTranslator.js +7 -10
- package/es/platform/components/smart-action-band/frameworks/SmartActionBandView.js +17 -5
- package/es/platform/data-source/http-template/getAvailableFields.js +4 -2
- package/es/platform/zform/adapters/presenter/FormTranslator.js +8 -12
- package/es/platform/zform/adapters/presenter/translators/SectionTranslator.js +10 -14
- package/es/platform/zform/adapters/presenter/translators/fields/BooleanFieldTranslator.js +4 -2
- package/es/platform/zform/adapters/presenter/translators/fields/CurrencyFieldTranslator.js +2 -1
- package/es/platform/zform/adapters/presenter/translators/fields/DateFieldTranslator.js +4 -2
- package/es/platform/zform/adapters/presenter/translators/fields/DateTimeFieldTranslator.js +4 -2
- package/es/platform/zform/adapters/presenter/translators/fields/DecimalFieldTranslator.js +4 -2
- package/es/platform/zform/adapters/presenter/translators/fields/EmailFieldTranslator.js +4 -2
- package/es/platform/zform/adapters/presenter/translators/fields/LookUpFieldTranslator.js +4 -2
- package/es/platform/zform/adapters/presenter/translators/fields/MultiselectFieldTranslator.js +13 -8
- package/es/platform/zform/adapters/presenter/translators/fields/NumberFieldTranslator.js +4 -2
- package/es/platform/zform/adapters/presenter/translators/fields/PercentageFieldTranslator.js +4 -2
- package/es/platform/zform/adapters/presenter/translators/fields/PhoneFieldTranslator.js +4 -2
- package/es/platform/zform/adapters/presenter/translators/fields/PicklistFieldTranslator.js +15 -12
- package/es/platform/zform/adapters/presenter/translators/fields/TextAreaFieldTranslator.js +4 -2
- package/es/platform/zform/adapters/presenter/translators/fields/TextFieldTranslator.js +4 -2
- package/es/platform/zform/adapters/presenter/translators/fields/URLFieldTranslator.js +4 -2
- package/es/platform/zform/domain/interfaces/IZForm.js +2 -5
- package/es/platform/zform/domain/interfaces/ValidationEvents.js +4 -0
- package/es/platform/zlist/adapters/presenters/SelectionTranslator.js +2 -4
- package/es/platform/zlist/adapters/presenters/TableTranslator.js +6 -1
- package/es/platform/zlist/adapters/presenters/translators/ColumnTranslator.js +7 -1
- package/es/platform/zlist/adapters/presenters/translators/Header.js +7 -6
- package/es/platform/zlist/adapters/presenters/translators/Row.js +6 -5
- package/es/platform/zlist/adapters/presenters/translators/fields/DateFieldTranslator.js +7 -3
- package/es/platform/zlist/adapters/presenters/translators/fields/DateTimeFieldTranslator.js +7 -3
- package/package.json +19 -6
- package/es/.DS_Store +0 -0
- package/es/library/custom-component/frameworks/json-schema-validator/Validator.js +0 -1
- package/es/platform/.DS_Store +0 -0
- package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/AdaptiveRowActions/AdaptiveRowActionsRenderer.js +0 -12
- package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/AdaptiveRowActions/AdaptiveRowActionsRendererView.js +0 -42
- package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActions/RowActionsRenderer.js +0 -12
- package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActions/RowActionsRenderer.module.css +0 -23
- package/es/platform/client-actions/components/row-actions-renderer/frameworks/ui/RowActions/RowActionsRendererView.js +0 -37
- /package/es/platform/client-actions/components/{row-actions-renderer/domain/entities/interfaces/IState.js → client-actions-renderer/domain/entities/ClientActionsRendererDatatype.js} +0 -0
|
@@ -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: false,
|
|
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/interfaces/ActionViewModel";
|
|
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
|
-
|
|
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 @@
|
|
|
1
|
+
export {};
|
package/es/platform/client-actions/components/client-actions-renderer/domain/entities/Context.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/es/platform/client-actions/components/client-actions-renderer/domain/entities/State.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,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
|
+
location,
|
|
14
|
+
instanceName
|
|
15
|
+
} = state.properties;
|
|
16
|
+
const customView = location !== '' && instanceName !== '' ? ComponentRegistry.get(`${instanceName}_${location}_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
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import ActionEventMediator from "../../../../../action-event-mediator/frameworks/ui/ActionEventMediator";
|
|
2
|
+
import { findMappedClientScripts } from "../../../../../../../client-scripts/behaviour/zclient-scripts-execution/frameworks/ClientScriptsUtils";
|
|
3
|
+
import { ActionViewGap } from "../../../../../interfaces/ActionViewModel"; //@ts-ignore
|
|
4
|
+
|
|
5
|
+
import style from "../ClientActionsRenderer.module.css";
|
|
6
|
+
import MoreActionsRenderer from "../../more-actions-renderer/MoreActionsRenderer";
|
|
7
|
+
import Flex from '@zohodesk/layout/es/Flex/Flex';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { Layout } from "../../../../../interfaces/ActionViewModel";
|
|
10
|
+
const HORIZONTAL_LAYOUTS = [Layout.HORIZONTAL, Layout.HORIZONTAL_WITH_MORE_ACTIONS];
|
|
11
|
+
const MORE_ACTIONS_LAYOUTS = [Layout.VERTICAL_WITH_MORE_ACTIONS, Layout.HORIZONTAL_WITH_MORE_ACTIONS];
|
|
12
|
+
|
|
13
|
+
function renderAction(action, clientScripts) {
|
|
14
|
+
return /*#__PURE__*/React.createElement(ActionEventMediator, {
|
|
15
|
+
key: action.id //@ts-ignore - action property defined using ACA pattern
|
|
16
|
+
,
|
|
17
|
+
action: action,
|
|
18
|
+
clientScripts: findMappedClientScripts(action, clientScripts),
|
|
19
|
+
instanceName: action.instanceName
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getFlexDirection(layout) {
|
|
24
|
+
return HORIZONTAL_LAYOUTS.includes(layout) ? 'row' : 'column';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getGapClassName(gap) {
|
|
28
|
+
return gap !== ActionViewGap.NONE ? style[`gap_${gap}`] : '';
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function shouldShowMoreActions(actionsCount, layout) {
|
|
32
|
+
return actionsCount > 3 && MORE_ACTIONS_LAYOUTS.includes(layout);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getVisibleActions(showMore, firstAction, secondAction, allActions) {
|
|
36
|
+
return showMore ? [firstAction, secondAction] : allActions;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default function DefaultActionsRendererView(_ref) {
|
|
40
|
+
let {
|
|
41
|
+
clientActions,
|
|
42
|
+
clientScripts,
|
|
43
|
+
viewMeta,
|
|
44
|
+
getRef,
|
|
45
|
+
testId = ''
|
|
46
|
+
} = _ref;
|
|
47
|
+
const [firstAction, secondAction, ...moreActions] = clientActions;
|
|
48
|
+
const layout = viewMeta?.layout ?? Layout.HORIZONTAL;
|
|
49
|
+
const gap = viewMeta?.gap ?? ActionViewGap.NONE;
|
|
50
|
+
const showMore = shouldShowMoreActions(clientActions.length, layout);
|
|
51
|
+
const actionsList = getVisibleActions(showMore, firstAction, secondAction, clientActions);
|
|
52
|
+
return /*#__PURE__*/React.createElement(Flex, {
|
|
53
|
+
ref: getRef,
|
|
54
|
+
testId: testId,
|
|
55
|
+
$ui_direction: getFlexDirection(layout),
|
|
56
|
+
$ui_className: `${style.wrapper} ${getGapClassName(gap)}`,
|
|
57
|
+
$ui_displayMode: "inline",
|
|
58
|
+
$ui_alignItems: "center"
|
|
59
|
+
}, actionsList.map(action => renderAction(action, clientScripts)), showMore &&
|
|
60
|
+
/*#__PURE__*/
|
|
61
|
+
//@ts-ignore - action property defined using ACA pattern
|
|
62
|
+
React.createElement(MoreActionsRenderer, {
|
|
63
|
+
actions: moreActions,
|
|
64
|
+
clientScripts: clientScripts
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { createCustomComponent } from "../../../../../../../library/custom-component";
|
|
2
|
-
import RowActionsRendererProperties from "../../../../../cc/
|
|
2
|
+
import RowActionsRendererProperties from "../../../../../cc/client-actions-renderer/Properties";
|
|
3
3
|
import MoreActionsRendererView from "./MoreActionsRendererView";
|
|
4
|
-
|
|
4
|
+
export default createCustomComponent({
|
|
5
5
|
name: "MoreActionsRenderer",
|
|
6
6
|
eventHandlers: {},
|
|
7
7
|
properties: RowActionsRendererProperties,
|
|
8
8
|
View: MoreActionsRendererView
|
|
9
|
-
});
|
|
10
|
-
export default MoreActionsRenderer;
|
|
9
|
+
});
|
|
@@ -4,7 +4,8 @@ import CustomDropdown from '@zohodesk-private/desk-components/es/CustomDropdown/
|
|
|
4
4
|
import ListItemConstants from "../../../../../../../cc/list-item/Constants";
|
|
5
5
|
import IconButton from '@zohodesk/dot/es/IconButton/IconButton';
|
|
6
6
|
import { findMappedClientScripts } from "../../../../../../client-scripts/behaviour/zclient-scripts-execution/frameworks/ClientScriptsUtils";
|
|
7
|
-
export
|
|
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
|
|
8
9
|
const {
|
|
9
10
|
id,
|
|
10
11
|
properties: {
|
|
@@ -12,7 +13,8 @@ export const ListItemConvertor = action => {
|
|
|
12
13
|
},
|
|
13
14
|
eventMappings,
|
|
14
15
|
instanceName
|
|
15
|
-
} = action;
|
|
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
|
+
|
|
16
18
|
const label = action.properties.label ? action.properties.label : action.properties.text;
|
|
17
19
|
const updatedEventMappings = eventMappings.map(eventMapping => {
|
|
18
20
|
return { ...eventMapping,
|
|
@@ -31,34 +33,40 @@ export const ListItemConvertor = action => {
|
|
|
31
33
|
id,
|
|
32
34
|
instanceName
|
|
33
35
|
};
|
|
34
|
-
}
|
|
36
|
+
}
|
|
35
37
|
|
|
36
|
-
function
|
|
38
|
+
function renderTargetElement(_ref) {
|
|
37
39
|
let {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
+
handleTogglePopup,
|
|
41
|
+
isPopupOpen
|
|
40
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;
|
|
41
65
|
const {
|
|
42
66
|
actions,
|
|
43
67
|
clientScripts
|
|
44
68
|
} = state.properties;
|
|
45
|
-
const listItemActions = actions.map(action =>
|
|
46
|
-
return ListItemConvertor(action);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const renderTargetElement = _ref2 => {
|
|
50
|
-
let {
|
|
51
|
-
handleTogglePopup,
|
|
52
|
-
isPopupOpen
|
|
53
|
-
} = _ref2;
|
|
54
|
-
return /*#__PURE__*/React.createElement(IconButton, {
|
|
55
|
-
iconName: "ZD-GN-more",
|
|
56
|
-
iconSize: "16",
|
|
57
|
-
isActive: isPopupOpen,
|
|
58
|
-
onClick: handleTogglePopup
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
|
|
69
|
+
const listItemActions = actions.map(action => ListItemConvertor(action));
|
|
62
70
|
return /*#__PURE__*/React.createElement(CustomDropdown, {
|
|
63
71
|
$ui_boxSize: "medium",
|
|
64
72
|
$flag_padding: true,
|
|
@@ -67,13 +75,7 @@ function MoreActionsRendererView(_ref, ref) {
|
|
|
67
75
|
$customProps_dropbox: {
|
|
68
76
|
onClick: undefined
|
|
69
77
|
}
|
|
70
|
-
}, listItemActions.map(action =>
|
|
71
|
-
key: action.id,
|
|
72
|
-
action: action,
|
|
73
|
-
clientScripts: findMappedClientScripts(action, clientScripts),
|
|
74
|
-
instanceName: action.instanceName // getRef={ref}
|
|
75
|
-
|
|
76
|
-
})));
|
|
78
|
+
}, listItemActions.map(action => renderAction(action, clientScripts, action.instanceName)));
|
|
77
79
|
}
|
|
78
80
|
|
|
79
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
|
}({});
|