@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.
- 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/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/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/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/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/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/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/multi-select/frameworks/ui/MultiSelectView.js +21 -8
- package/es/library/dot/legacy-to-new-arch/radio-dropdown/frameworks/ui/RadioDropdownView.js +3 -1
- package/es/library/dot/legacy-to-new-arch/select/frameworks/ui/SelectView.js +18 -8
- 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/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/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/ClientActionsRendererDatatype.js +1 -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/client-actions-renderer/frameworks/ui/more-actions-renderer/MoreActionsRenderer.js +9 -0
- package/es/platform/client-actions/components/client-actions-renderer/frameworks/ui/more-actions-renderer/MoreActionsRendererView.js +81 -0
- 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/library/custom-component/frameworks/json-schema-validator/Validator.js +0 -1
|
@@ -10,7 +10,10 @@ export default function HighlightedValueFieldView(_ref, ref) {
|
|
|
10
10
|
tooltip,
|
|
11
11
|
weight,
|
|
12
12
|
isDotted,
|
|
13
|
-
cursor
|
|
13
|
+
cursor,
|
|
14
|
+
iconName,
|
|
15
|
+
iconSize,
|
|
16
|
+
iconPosition
|
|
14
17
|
} = state.properties;
|
|
15
18
|
return /*#__PURE__*/React.createElement(HighlightedValue, {
|
|
16
19
|
getRef: ref,
|
|
@@ -19,6 +22,9 @@ export default function HighlightedValueFieldView(_ref, ref) {
|
|
|
19
22
|
tooltip: tooltip,
|
|
20
23
|
cursor: cursor,
|
|
21
24
|
weight: weight,
|
|
22
|
-
isDotted: isDotted
|
|
25
|
+
isDotted: isDotted,
|
|
26
|
+
iconName: iconName,
|
|
27
|
+
iconSize: iconSize,
|
|
28
|
+
iconPosition: iconPosition
|
|
23
29
|
});
|
|
24
30
|
}
|
|
@@ -15,13 +15,15 @@ export class EventHandlersFactory {
|
|
|
15
15
|
fieldType
|
|
16
16
|
} = state.properties;
|
|
17
17
|
const {
|
|
18
|
-
id
|
|
18
|
+
id,
|
|
19
|
+
previousId
|
|
19
20
|
} = action.payload;
|
|
20
21
|
dispatch({
|
|
21
22
|
type: FieldConstants.FIELD_CHANGED,
|
|
22
23
|
payload: {
|
|
23
24
|
fieldName,
|
|
24
|
-
value: fieldType === 'Boolean' ? id === 'true' : id
|
|
25
|
+
value: fieldType === 'Boolean' ? id === 'true' : id,
|
|
26
|
+
previousValue: fieldType === 'Boolean' ? previousId === 'true' : previousId
|
|
25
27
|
}
|
|
26
28
|
});
|
|
27
29
|
};
|
|
@@ -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/interfaces/ActionViewModel";
|
|
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(
|
|
69
|
+
}, /*#__PURE__*/React.createElement(ClientActionsRenderer, {
|
|
68
70
|
actions: actions,
|
|
69
71
|
clientScripts: clientScripts,
|
|
70
|
-
|
|
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
|
-
|
|
5
|
-
import { ActionViewGap } from "../../../../../../platform/client-actions/components/interfaces/ActionViewModel";
|
|
4
|
+
// eslint-disable-next-line @zohodesk/architecturerules/import-contract
|
|
5
|
+
import { ActionViewGap, Layout } from "../../../../../../platform/client-actions/components/interfaces/ActionViewModel";
|
|
6
|
+
import ClientActionsRenderer from "../../../../../../platform/client-actions/components/client-actions-renderer/frameworks/ui/client-actions-renderer/ClientActionsRenderer";
|
|
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(
|
|
32
|
+
return actions?.length ? /*#__PURE__*/React.createElement(ClientActionsRenderer, {
|
|
31
33
|
actions: actions,
|
|
32
34
|
clientScripts: clientScripts,
|
|
33
|
-
|
|
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: 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 {};
|
|
@@ -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,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
|
+
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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createCustomComponent } from "../../../../../../../library/custom-component";
|
|
2
|
+
import RowActionsRendererProperties from "../../../../../cc/client-actions-renderer/Properties";
|
|
3
|
+
import MoreActionsRendererView from "./MoreActionsRendererView";
|
|
4
|
+
export default createCustomComponent({
|
|
5
|
+
name: "MoreActionsRenderer",
|
|
6
|
+
eventHandlers: {},
|
|
7
|
+
properties: RowActionsRendererProperties,
|
|
8
|
+
View: MoreActionsRendererView
|
|
9
|
+
});
|