@integry/sdk 4.7.39 → 4.7.40

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 (267) hide show
  1. package/dist/esm/index.csm.js +1 -1
  2. package/dist/umd/index.umd.js +1 -1
  3. package/package.json +6 -1
  4. package/.eslintignore +0 -1
  5. package/.vscode/launch.json +0 -17
  6. package/CHANGELOG_INTERNAL.md +0 -134
  7. package/README_INTERNAL.md +0 -176
  8. package/THIRD_PARTY_LICENSES +0 -525
  9. package/generateTests.js +0 -80
  10. package/jest.config.cjs +0 -10
  11. package/src/components/AddTagButton/index.ts +0 -23
  12. package/src/components/BasicSelect/index.ts +0 -123
  13. package/src/components/BasicSelect/styles.module.scss +0 -44
  14. package/src/components/Button/index.ts +0 -97
  15. package/src/components/Button/styles.module.scss +0 -152
  16. package/src/components/CheckboxGroup/Checkbox.ts +0 -104
  17. package/src/components/CheckboxGroup/index.ts +0 -190
  18. package/src/components/CheckboxGroup/styles.module.scss +0 -63
  19. package/src/components/CollapsedMenu/index.ts +0 -104
  20. package/src/components/CollapsedMenu/styles.module.scss +0 -46
  21. package/src/components/ConfigureFieldWrapper/index.ts +0 -85
  22. package/src/components/ConfigureFieldWrapper/styles.module.scss +0 -57
  23. package/src/components/EditableText/index.ts +0 -121
  24. package/src/components/EditableText/styles.module.scss +0 -38
  25. package/src/components/EditableTextArea/index.ts +0 -143
  26. package/src/components/EditableTextArea/styles.module.scss +0 -91
  27. package/src/components/ErrorMessage/index.ts +0 -16
  28. package/src/components/ErrorMessage/styles.module.scss +0 -19
  29. package/src/components/ErrorPage/index.ts +0 -42
  30. package/src/components/ErrorPage/styles.module.scss +0 -26
  31. package/src/components/Footer/index.ts +0 -41
  32. package/src/components/Footer/styles.module.scss +0 -40
  33. package/src/components/HTMLContent/index.tsx +0 -205
  34. package/src/components/HTMLContent/styles.module.scss +0 -3
  35. package/src/components/InfoBox/index.ts +0 -48
  36. package/src/components/InfoBox/styles.module.scss +0 -21
  37. package/src/components/Input/BaseInput/index.ts +0 -170
  38. package/src/components/Input/BaseInput/styles.module.scss +0 -95
  39. package/src/components/Input/DateInput/index.ts +0 -103
  40. package/src/components/Input/DateInput/styles.module.scss +0 -50
  41. package/src/components/Input/Input/index.ts +0 -225
  42. package/src/components/Input/Input/styles.module.scss +0 -16
  43. package/src/components/Input/PasswordInput/index.ts +0 -164
  44. package/src/components/Input/PasswordInput/styles.module.scss +0 -37
  45. package/src/components/Input/index.ts +0 -7
  46. package/src/components/Label/index.ts +0 -61
  47. package/src/components/Label/styles.module.scss +0 -41
  48. package/src/components/LargeLoader/index.ts +0 -25
  49. package/src/components/LargeLoader/styles.module.scss +0 -16
  50. package/src/components/Listbox/ListBoxItem.ts +0 -57
  51. package/src/components/Listbox/index.ts +0 -488
  52. package/src/components/Listbox/styles.module.scss +0 -197
  53. package/src/components/Loader/index.ts +0 -25
  54. package/src/components/Loader/styles.module.scss +0 -16
  55. package/src/components/MediaGallery/MediaGalleryModal.ts +0 -82
  56. package/src/components/MediaGallery/MediaSlider.ts +0 -76
  57. package/src/components/MediaGallery/index.ts +0 -92
  58. package/src/components/MediaGallery/styles.module.scss +0 -156
  59. package/src/components/MediaUpload/index.ts +0 -233
  60. package/src/components/MediaUpload/styles.module.scss +0 -118
  61. package/src/components/Modal/index.ts +0 -87
  62. package/src/components/Modal/styles.module.scss +0 -441
  63. package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +0 -59
  64. package/src/components/MultipurposeField/Dropdown/index.tsx +0 -1202
  65. package/src/components/MultipurposeField/Dropdown/styles.module.scss +0 -215
  66. package/src/components/MultipurposeField/TagMenu/index.ts +0 -536
  67. package/src/components/MultipurposeField/TagMenu/styles.module.scss +0 -175
  68. package/src/components/MultipurposeField/TagOptions/index.tsx +0 -83
  69. package/src/components/MultipurposeField/TagOptions/styles.module.scss +0 -95
  70. package/src/components/MultipurposeField/index.tsx +0 -944
  71. package/src/components/MultipurposeField/styles.module.scss +0 -77
  72. package/src/components/NewModal/index.ts +0 -69
  73. package/src/components/NewModal/styles.module.scss +0 -70
  74. package/src/components/OverflowTooltip/index.tsx +0 -59
  75. package/src/components/PopUp/ConfirmationPopUp/index.ts +0 -58
  76. package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +0 -49
  77. package/src/components/PopUp/SuccessPopUp/index.ts +0 -62
  78. package/src/components/PopUp/SuccessPopUp/styles.module.scss +0 -38
  79. package/src/components/RadioGroup/Radio.ts +0 -128
  80. package/src/components/RadioGroup/index.ts +0 -169
  81. package/src/components/RadioGroup/styles.module.scss +0 -81
  82. package/src/components/Search/index.ts +0 -69
  83. package/src/components/Search/styles.module.scss +0 -149
  84. package/src/components/TabBar/Tab.ts +0 -33
  85. package/src/components/TabBar/index.ts +0 -64
  86. package/src/components/TabBar/styles.module.scss +0 -43
  87. package/src/components/Tag/index.ts +0 -29
  88. package/src/components/Tag/styles.module.scss +0 -57
  89. package/src/components/TagsMenu/index.ts +0 -1697
  90. package/src/components/TagsMenu/styles.module.scss +0 -350
  91. package/src/components/TestComponent/index.ts +0 -71
  92. package/src/components/TestComponent/styles.module.scss +0 -152
  93. package/src/components/TextArea/index.ts +0 -172
  94. package/src/components/TextArea/styles.module.scss +0 -72
  95. package/src/components/TextContent/index.tsx +0 -128
  96. package/src/components/TextContent/styles.module.scss +0 -6
  97. package/src/components/ThreeDotLoader/index.ts +0 -39
  98. package/src/components/ThreeDotLoader/styles.module.scss +0 -41
  99. package/src/components/TimeInput/index.ts +0 -129
  100. package/src/components/TimeInput/styles.module.scss +0 -16
  101. package/src/components/Toggle/index.ts +0 -34
  102. package/src/components/Toggle/styles.module.scss +0 -56
  103. package/src/components/Toggle-v2/index.ts +0 -40
  104. package/src/components/Toggle-v2/styles.module.scss +0 -86
  105. package/src/components/Tooltip/index.ts +0 -271
  106. package/src/components/Tooltip/styles.module.scss +0 -105
  107. package/src/components/form/FunctionField/index.ts +0 -816
  108. package/src/components/form/FunctionField/styles.module.scss +0 -478
  109. package/src/components/form/ObjectField/__snapshots__/index.ts.test.tsx.snap +0 -3
  110. package/src/components/form/ObjectField/index.ts +0 -593
  111. package/src/components/form/ObjectField/index.ts.test.tsx +0 -213
  112. package/src/components/form/ObjectField/styles.module.scss +0 -103
  113. package/src/components/form/index.ts +0 -4
  114. package/src/contexts/AppContext.ts +0 -12
  115. package/src/declaration.d.ts +0 -7
  116. package/src/extensions/HMAC.ts +0 -25
  117. package/src/extensions/IntegryAPIError.ts +0 -19
  118. package/src/features/common/AccountDropdown/index.ts +0 -291
  119. package/src/features/common/AccountDropdown/styles.module.scss +0 -19
  120. package/src/features/common/ActionForm/index.ts +0 -2602
  121. package/src/features/common/ActionForm/styles.module.scss +0 -35
  122. package/src/features/common/AppCard/index.ts +0 -207
  123. package/src/features/common/AppCard/styles.module.scss +0 -117
  124. package/src/features/common/AppCardCompact/index.ts +0 -189
  125. package/src/features/common/AppCardCompact/styles.module.scss +0 -141
  126. package/src/features/common/AuthSelector/index.ts +0 -537
  127. package/src/features/common/AuthSelector/styles.module.scss +0 -161
  128. package/src/features/common/AuthSelectorCompact/index.ts +0 -706
  129. package/src/features/common/AuthSelectorCompact/styles.module.scss +0 -219
  130. package/src/features/common/AuthSelectorDropdown/index.ts +0 -704
  131. package/src/features/common/AuthSelectorDropdown/styles.module.scss +0 -361
  132. package/src/features/common/AuthSelectorV2/index.ts +0 -336
  133. package/src/features/common/AuthSelectorV2/styles.module.scss +0 -235
  134. package/src/features/common/DynamicField/index.ts +0 -402
  135. package/src/features/common/DynamicField/styles.module.scss +0 -266
  136. package/src/features/common/DynamicTypedField/index.ts +0 -504
  137. package/src/features/common/DynamicTypedField/styles.module.scss +0 -135
  138. package/src/features/common/FunctionForm/index.ts +0 -1095
  139. package/src/features/common/FunctionForm/styles.module.scss +0 -225
  140. package/src/features/common/MappingUI/index.ts +0 -649
  141. package/src/features/common/MappingUI/styles.module.scss +0 -121
  142. package/src/features/common/MarketplaceAppCard/index.ts +0 -279
  143. package/src/features/common/MarketplaceAppCard/styles.module.scss +0 -231
  144. package/src/features/common/MarketplaceAppCardCompact/index.ts +0 -283
  145. package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +0 -255
  146. package/src/features/common/NewMappingUI/index.ts +0 -515
  147. package/src/features/common/NewMappingUI/styles.module.scss +0 -113
  148. package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +0 -67
  149. package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +0 -23
  150. package/src/features/common/RequestAppWidget/index.ts +0 -48
  151. package/src/features/common/RequestAppWidget/request-app-form.ts +0 -89
  152. package/src/features/common/RequestAppWidget/styles.module.scss +0 -43
  153. package/src/features/common/SectionField/index.ts +0 -272
  154. package/src/features/common/SectionField/styles.module.scss +0 -67
  155. package/src/features/common/Step/index.ts +0 -827
  156. package/src/features/common/Step/styles.module.scss +0 -12
  157. package/src/features/common/StepNavigation/CollapsedSteps.ts +0 -131
  158. package/src/features/common/StepNavigation/NavItem.ts +0 -111
  159. package/src/features/common/StepNavigation/index.ts +0 -261
  160. package/src/features/common/StepNavigation/styles.module.scss +0 -117
  161. package/src/features/common/Steps/index.ts +0 -1140
  162. package/src/features/common/Steps/styles.module.scss +0 -314
  163. package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +0 -404
  164. package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +0 -367
  165. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.test.tsx +0 -58
  166. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +0 -208
  167. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.test.tsx +0 -49
  168. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +0 -421
  169. package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +0 -577
  170. package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +0 -83
  171. package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +0 -233
  172. package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +0 -45
  173. package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +0 -1085
  174. package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +0 -465
  175. package/src/features/containers/AppFlowContainer/Authentication/index.ts +0 -610
  176. package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +0 -468
  177. package/src/features/containers/AppFlowContainer/index.ts +0 -114
  178. package/src/features/containers/AppPageContainer/AppPage/index.tsx +0 -262
  179. package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +0 -120
  180. package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +0 -165
  181. package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +0 -81
  182. package/src/features/containers/AppPageContainer/index.tsx +0 -93
  183. package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
  184. package/src/features/containers/AppsForFlows/index.ts +0 -161
  185. package/src/features/containers/AppsForFlows/styles.module.scss +0 -280
  186. package/src/features/containers/AppsForFlowsCompact/index.ts +0 -161
  187. package/src/features/containers/AppsForFlowsCompact/styles.module.scss +0 -279
  188. package/src/features/containers/AuthSetupContainer/AppSelection.ts +0 -73
  189. package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +0 -67
  190. package/src/features/containers/AuthSetupContainer/Footer.ts +0 -32
  191. package/src/features/containers/AuthSetupContainer/Header.ts +0 -39
  192. package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +0 -27
  193. package/src/features/containers/AuthSetupContainer/index.ts +0 -349
  194. package/src/features/containers/AuthSetupContainer/styles.module.scss +0 -229
  195. package/src/features/containers/FlowSetupContainer/index.ts +0 -391
  196. package/src/features/containers/FlowSetupContainer/styles.module.scss +0 -18
  197. package/src/features/containers/MarkeplaceApps/index.ts +0 -583
  198. package/src/features/containers/MarkeplaceApps/styles.module.scss +0 -558
  199. package/src/features/containers/MarketplaceAppsCompact/index.ts +0 -585
  200. package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +0 -563
  201. package/src/features/containers/MarketplaceAppsContainer/index.ts +0 -91
  202. package/src/features/containers/MarketplaceContainer/AppCard/index.ts +0 -91
  203. package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +0 -66
  204. package/src/features/containers/MarketplaceContainer/AppListing/index.ts +0 -34
  205. package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +0 -10
  206. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +0 -132
  207. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +0 -117
  208. package/src/features/containers/MarketplaceContainer/index.ts +0 -242
  209. package/src/features/containers/MarketplaceContainer/styles.module.scss +0 -84
  210. package/src/features/containers/SDKContainer/index.ts +0 -817
  211. package/src/features/containers/SDKContainer/styles.module.scss +0 -266
  212. package/src/features/containers/SDKDebugContainer/index.ts +0 -137
  213. package/src/features/containers/SDKDebugContainer/styles.module.scss +0 -37
  214. package/src/features/containers/SDKFailedContainer/index.ts +0 -117
  215. package/src/features/containers/SDKFailedContainer/styles.module.scss +0 -57
  216. package/src/features/integrations/IntegrationRow/Icons.ts +0 -77
  217. package/src/features/integrations/IntegrationRow/index.ts +0 -129
  218. package/src/features/integrations/IntegrationRow/styles.module.scss +0 -62
  219. package/src/features/integrations/IntegrationsHeader/index.ts +0 -34
  220. package/src/features/integrations/IntegrationsHeader/styles.module.scss +0 -47
  221. package/src/features/integrations/IntegrationsList/index.ts +0 -252
  222. package/src/features/integrations/IntegrationsList/styles.module.scss +0 -67
  223. package/src/features/templates/Template/index.ts +0 -295
  224. package/src/features/templates/Template/styles.module.scss +0 -226
  225. package/src/features/templates/TemplatesView/index.ts +0 -368
  226. package/src/features/templates/TemplatesView/styles.module.scss +0 -71
  227. package/src/features/templates/TemplatesViewCompact/index.ts +0 -364
  228. package/src/features/templates/TemplatesViewCompact/styles.module.scss +0 -141
  229. package/src/hooks/useAutosizeTextArea.ts +0 -22
  230. package/src/hooks/useCustomRef.ts +0 -13
  231. package/src/hooks/useDebounce.ts +0 -17
  232. package/src/hooks/useElementResize.ts +0 -40
  233. package/src/hooks/useEventListener.ts +0 -42
  234. package/src/hooks/useHover.ts +0 -40
  235. package/src/hooks/useOnClickOutside.ts +0 -32
  236. package/src/index.ts +0 -2244
  237. package/src/index.umd.ts +0 -13
  238. package/src/interfaces/index.ts +0 -938
  239. package/src/modules/api/index.ts +0 -1325
  240. package/src/modules/api/responseHandler.ts +0 -38
  241. package/src/modules/event-emitter/index.ts +0 -72
  242. package/src/modules/event-emitter/runners/abstract.ts +0 -21
  243. package/src/modules/event-emitter/runners/default.ts +0 -11
  244. package/src/modules/event-emitter/runners/ntimes.ts +0 -28
  245. package/src/modules/event-emitter/types.ts +0 -34
  246. package/src/store/actionFunctions.ts +0 -1578
  247. package/src/store/index.ts +0 -17
  248. package/src/store/initialState.ts +0 -58
  249. package/src/types/index.ts +0 -320
  250. package/src/types/preact-compat.d.ts +0 -4
  251. package/src/types/store.ts +0 -366
  252. package/src/types/utils.ts +0 -19
  253. package/src/utils/ActivityOutputUtils.ts +0 -176
  254. package/src/utils/common.ts +0 -20
  255. package/src/utils/copyToClipboard.ts +0 -24
  256. package/src/utils/datetime.ts +0 -101
  257. package/src/utils/getUrlParam.ts +0 -11
  258. package/src/utils/isAuthMessage.ts +0 -16
  259. package/src/utils/isBrowser.ts +0 -1
  260. package/src/utils/jsonEncodeDecode.ts +0 -15
  261. package/src/utils/objectUtils.ts +0 -117
  262. package/src/utils/popup.ts +0 -30
  263. package/src/utils/searchJson.ts +0 -51
  264. package/src/utils/stepUtils.ts +0 -45
  265. package/src/utils/truncate.ts +0 -6
  266. package/test/setup.ts +0 -1
  267. package/vitest.config.ts +0 -16
@@ -1,2602 +0,0 @@
1
- /* eslint-disable no-nested-ternary */
2
- import { html, Component } from 'htm/preact';
3
- import { connect } from 'unistore/preact';
4
- // import DOMPurify from 'dompurify';
5
- import { IntegrySDKEvents } from '@/types';
6
- import { IntegryAPI } from '@/modules/api';
7
- import { EventEmitter } from '@/modules/event-emitter';
8
- import { ListBox } from '@/components/MultipurposeField/Dropdown';
9
- import { Loader } from '@/components/Loader';
10
- import {
11
- IntegryStep,
12
- TemplateStep,
13
- TemplateField,
14
- IncomingWebhookObject,
15
- NestedObject,
16
- } from '@/interfaces';
17
- import { actionFunctions } from '@/store';
18
- import MappingUI from '@/features/common/MappingUI';
19
- import { Button } from '@/components/Button';
20
- import { StoreType } from '@/types/store';
21
- import { DateInput, Input, PasswordInput } from '@/components/Input';
22
- import HTMLContent from '@/components/HTMLContent';
23
- import TextContent from '@/components/TextContent';
24
- // import { MappedField } from '@/components/MappedField/MappedField';
25
- import { MultipurposeField } from '@/components/MultipurposeField';
26
- import DynamicField from '@/features/common/DynamicField';
27
- import DynamicTypedField from '@/features/common/DynamicTypedField';
28
- import SectionField from '@/features/common/SectionField';
29
- import { TimeInput } from '@/components/TimeInput';
30
- import NewMappingUI from '@/features/common/NewMappingUI';
31
- import { ObjectField, FunctionField } from '@/components/form';
32
- import { areParentValuesValid, getFieldLabelTags } from '@/utils/stepUtils';
33
- import ConfigureFieldWrapper from '@/components/ConfigureFieldWrapper';
34
- import {
35
- JSONToActivityOutputData,
36
- JSONToDynamicFieldData,
37
- } from '@/utils/ActivityOutputUtils';
38
-
39
- import styles from './styles.module.scss';
40
-
41
- interface ActionFormPropsType extends StoreType {
42
- step: IntegryStep;
43
- stepType: 'AUTH' | 'CONFIGURATION' | 'SECTION';
44
- showStepValidation: boolean;
45
- apiHandler: IntegryAPI;
46
- eventEmitter: EventEmitter<IntegrySDKEvents>;
47
- isReadOnly?: boolean;
48
- accountConnected: boolean;
49
- selectedAuthId: string;
50
- onFieldChangeCallback?: (fieldId: string, value: string) => void;
51
- tagsComponent?: any;
52
- tagsTree?: any;
53
- showMappingMenu: boolean;
54
- showMenuOnLeft: boolean;
55
- tagsTreeActivityOutput?: any;
56
- }
57
-
58
- interface ActionFormStateType {
59
- loading: boolean;
60
- dynamicFieldDataState: any;
61
- parentChildMapping: any;
62
- dynamicFieldsData: any;
63
- parentFieldChanged: any;
64
- changedParentMachineName: string;
65
- }
66
-
67
- interface StepDataMapping {
68
- [key: string]: any;
69
- }
70
-
71
- type FieldMapping = {
72
- [key: string]: {
73
- fieldId: number;
74
- childFields: any[] | null;
75
- parentFields: any[] | null;
76
- };
77
- };
78
-
79
- type Mapping = Record<number, any>;
80
-
81
- class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
82
- constructor(props: ActionFormPropsType) {
83
- super(props);
84
- const templateStep: any = props.step;
85
- this.state = {
86
- loading: false,
87
- dynamicFieldDataState: {},
88
- parentChildMapping: this.setParentChildMapping([templateStep]),
89
- dynamicFieldsData: {},
90
- parentFieldChanged: [],
91
- changedParentMachineName: '',
92
- };
93
- }
94
-
95
- componentDidMount() {
96
- const { step, verifyStepValidity } = this.props;
97
- verifyStepValidity(step.id);
98
- const triggerStep = this.props.genericData.stepWithActivityOutput;
99
- if (triggerStep) {
100
- const { id: triggerStepId } = triggerStep;
101
- // eslint-disable-next-line no-use-before-define
102
- const data = this.getVisibleFieldsDataOnRootStep(triggerStepId);
103
- // eslint-disable-next-line no-use-before-define
104
- this.setRootStepData(data);
105
- } else {
106
- this.setRootStepData({});
107
- }
108
- }
109
-
110
- componentDidUpdate(prevProps: ActionFormPropsType) {
111
- const { step, verifyStepValidity } = this.props;
112
- if (prevProps.step.id !== step.id) {
113
- verifyStepValidity(step.id);
114
- const triggerStep = this.props.genericData.stepWithActivityOutput;
115
- if (triggerStep) {
116
- const { id: triggerStepId } = triggerStep;
117
- // eslint-disable-next-line no-use-before-define
118
- const data = this.getVisibleFieldsDataOnRootStep(triggerStepId);
119
- // eslint-disable-next-line no-use-before-define
120
- this.setRootStepData(data);
121
- } else {
122
- this.setRootStepData({});
123
- }
124
- }
125
- }
126
-
127
- setParentChildMapping(steps: TemplateStep[]) {
128
- this.setState((prevState) => {
129
- const parentChildMapping = steps.reduce((mapping: Mapping, step) => {
130
- const stepMapping = step.template_fields.reduce(
131
- (fields: FieldMapping, field) => {
132
- const activityField = field.activity_field;
133
-
134
- if (activityField) {
135
- // Create a copy of the fields object to avoid mutating it
136
- const updatedFields = { ...fields };
137
-
138
- updatedFields[activityField.machine_name] = {
139
- fieldId: field.id,
140
- childFields: activityField.child_fields
141
- ? JSON.parse(activityField.child_fields)
142
- : null,
143
- parentFields: activityField.parent_fields
144
- ? JSON.parse(activityField.parent_fields)
145
- : null,
146
- };
147
-
148
- return updatedFields;
149
- }
150
-
151
- return fields;
152
- },
153
- {}, // Initial empty object
154
- );
155
- // Create a new object for `mapping` to avoid mutation
156
- return {
157
- ...mapping, // Spread the existing mapping to preserve the previous entries
158
- [step.id]: {
159
- ...(prevState.parentChildMapping?.[step.id] || {}), // Ensure it starts with the previous state or empty object
160
- ...stepMapping, // Merge the new step mapping
161
- },
162
- };
163
- }, {});
164
-
165
- return {
166
- parentChildMapping: {
167
- ...prevState.parentChildMapping, // Spread the previous state to preserve other data
168
- ...parentChildMapping, // Add the newly calculated `parentChildMapping`
169
- },
170
- };
171
- });
172
- }
173
-
174
- getVisibleFieldsDataOnRootStep = (
175
- stepId: number,
176
- ): {
177
- [machineName: string]: string;
178
- } => {
179
- const fields = this.props.stepDataMapping[stepId];
180
- const requiredFieldsWithValues = Object.keys(fields)
181
- .filter((el) => fields[Number(el)].value)
182
- .reduce((prev, curr) => {
183
- const currentItem = fields[Number(curr)];
184
- return {
185
- ...prev,
186
- [currentItem.machineName]: currentItem.value,
187
- };
188
- }, {});
189
-
190
- return requiredFieldsWithValues;
191
- };
192
-
193
- makeTagSourceFunctionBody = (
194
- obj: any,
195
- sourceData: any,
196
- sourceStepName: string,
197
- ): any => {
198
- if (typeof obj === 'string') {
199
- return obj.replace(
200
- new RegExp(`{[^}]*\\.${sourceStepName}\\.([a-zA-Z0-9_]+)}`, 'g'),
201
- (_, key) => sourceData[key] ?? `{${sourceStepName}.${key}}`, // Preserve if not found
202
- );
203
- }
204
- if (Array.isArray(obj)) {
205
- return obj.map((item) =>
206
- this.makeTagSourceFunctionBody(item, sourceData, sourceStepName),
207
- );
208
- }
209
- if (typeof obj === 'object' && obj !== null) {
210
- return Object.fromEntries(
211
- Object.entries(obj).map(([key, value]) => [
212
- key,
213
- this.makeTagSourceFunctionBody(value, sourceData, sourceStepName),
214
- ]),
215
- );
216
- }
217
-
218
- return obj; // Default return for non-string, non-object, non-array types
219
- };
220
-
221
- refreshRootStepData = async (callback?: any) => {
222
- const triggerStep = this.props.genericData.stepWithActivityOutput;
223
- if (triggerStep) {
224
- const { id: triggerStepId } = triggerStep;
225
- // eslint-disable-next-line no-use-before-define
226
- const data = this.getVisibleFieldsDataOnRootStep(triggerStepId);
227
- // eslint-disable-next-line no-use-before-define
228
- this.setRootStepData(data, true, callback);
229
- } else {
230
- this.setRootStepData({}, true, callback);
231
- }
232
- };
233
-
234
- setActivityOutputFromSourceStep = (
235
- isRefresh?: boolean | false,
236
- callback?: any,
237
- integryObject?: any,
238
- ) => {
239
- const { setDynamicData } = this;
240
- const setState = this.setState.bind(this);
241
- const sourceSteps = this.props.step.source_steps;
242
- const { stepMapping } = this.props;
243
- const { props } = this;
244
- Object.keys(sourceSteps).forEach((sourceStepKey) => {
245
- const stepTagsSource = props.step.source_steps[sourceStepKey];
246
- let hasSetData = false;
247
- Object.keys(stepMapping).every((mappedStepIndex) => {
248
- const stepIdOfSourceStep = stepMapping[mappedStepIndex].step.id;
249
- if (
250
- stepIdOfSourceStep &&
251
- (stepMapping[stepIdOfSourceStep].step.machine_name ===
252
- sourceStepKey ||
253
- stepMapping[stepIdOfSourceStep].step.machine_name ===
254
- stepTagsSource.form_step_machine_name ||
255
- (stepTagsSource.tag_source_function_invocation_details &&
256
- stepTagsSource.app_id ===
257
- stepMapping[stepIdOfSourceStep].step?.authorization_type?.app
258
- ?.id)) &&
259
- !props.genericData.isTestIntegration
260
- ) {
261
- hasSetData = true;
262
- if (stepTagsSource.activity_output_url) {
263
- if (!isRefresh) {
264
- setState({
265
- loading: true,
266
- });
267
- }
268
- const sourceStepData: NestedObject = {};
269
- const stepDataMappingKeys = Object.keys(
270
- props.stepDataMapping[stepIdOfSourceStep],
271
- );
272
- for (let i = 0; i < stepDataMappingKeys.length; i += 1) {
273
- const stepDataMappingKey: string = stepDataMappingKeys[i];
274
- const stepDataMapping: StepDataMapping =
275
- props.stepDataMapping[stepIdOfSourceStep];
276
- const stepDataMappingValue = stepDataMapping[stepDataMappingKey];
277
- if (stepDataMappingValue.value) {
278
- sourceStepData[stepDataMappingValue.machineName] =
279
- stepDataMappingValue.value;
280
- }
281
- }
282
-
283
- const isFunctionSource = stepTagsSource?.activity_output_url.includes(
284
- 'functions/',
285
- );
286
- const isFunctionActivity =
287
- stepTagsSource?.activity_type === 'FUNCTION';
288
- const tagSourceFunctionInvocationDetails =
289
- stepTagsSource.tag_source_function_invocation_details;
290
- const tagSourceFunctionBody =
291
- isFunctionSource && tagSourceFunctionInvocationDetails
292
- ? this.makeTagSourceFunctionBody(
293
- tagSourceFunctionInvocationDetails.body,
294
- sourceStepData,
295
- stepMapping[stepIdOfSourceStep].step.machine_name || '',
296
- )
297
- : {};
298
- const callDynamicDataEndpointMethod = isFunctionSource
299
- ? tagSourceFunctionInvocationDetails
300
- ? tagSourceFunctionInvocationDetails.method
301
- : 'POST'
302
- : 'GET';
303
-
304
- props.apiHandler
305
- .callDynamicDataEndpoint<
306
- {
307
- text: string;
308
- value: string;
309
- }[]
310
- >(
311
- new URL(stepTagsSource.activity_output_url),
312
- {
313
- authorization_id: `${props.stepMapping[stepIdOfSourceStep].selectedAuthId}`,
314
- connected_account_id: `${props.stepMapping[stepIdOfSourceStep].selectedAuthId}`,
315
- ...sourceStepData,
316
- ...tagSourceFunctionBody,
317
- },
318
- callDynamicDataEndpointMethod,
319
- )
320
- .then((res) => {
321
- setState({
322
- loading: false,
323
- });
324
-
325
- let error = false;
326
- if (res) {
327
- const functionResponse: any = res;
328
-
329
- if (isFunctionSource && 'output' in functionResponse) {
330
- this.setActivityOutputFromIntegryObjectOrRawActivityOutput(
331
- functionResponse.output,
332
- stepTagsSource,
333
- sourceStepKey,
334
- true,
335
- isFunctionActivity,
336
- );
337
- } else {
338
- props.setActivityOutputData({
339
- activityOutputData: stepTagsSource.loop_variable_name
340
- ? this.replaceContactPrefix(
341
- res,
342
- sourceStepKey,
343
- stepTagsSource,
344
- )
345
- : res,
346
- });
347
- }
348
- } else {
349
- error = true;
350
- }
351
- if (callback) {
352
- callback(error);
353
- }
354
- });
355
- if (stepTagsSource.sample_data_endpoint_url && stepIdOfSourceStep) {
356
- setDynamicData(
357
- stepTagsSource.sample_data_endpoint_url,
358
- stepIdOfSourceStep,
359
- {
360
- ...sourceStepData,
361
- },
362
- );
363
- }
364
- } else if (stepTagsSource.activity_output) {
365
- setState({
366
- loading: false,
367
- });
368
- if (callback) {
369
- callback();
370
- }
371
- this.setActivityOutputFromIntegryObjectOrRawActivityOutput(
372
- integryObject,
373
- stepTagsSource,
374
- sourceStepKey,
375
- );
376
- }
377
- return false;
378
- }
379
-
380
- if (
381
- (props.genericData.isTestIntegration ||
382
- (!stepTagsSource.app_id &&
383
- !this.canOverrideIntegryObject(integryObject))) &&
384
- stepTagsSource.activity_output
385
- ) {
386
- setState({
387
- loading: false,
388
- });
389
- if (callback) {
390
- callback();
391
- }
392
- hasSetData = true;
393
- this.setActivityOutputFromRawActivityOutput(
394
- stepTagsSource,
395
- sourceStepKey,
396
- );
397
- return false;
398
- }
399
- return true;
400
- });
401
-
402
- if (!hasSetData && stepTagsSource.activity_output) {
403
- this.setActivityOutputFromIntegryObjectOrRawActivityOutput(
404
- integryObject,
405
- stepTagsSource,
406
- sourceStepKey,
407
- );
408
- setState({
409
- loading: false,
410
- });
411
- if (callback) {
412
- callback();
413
- }
414
- hasSetData = true;
415
-
416
- return false;
417
- }
418
- if (hasSetData) {
419
- return false;
420
- }
421
- return true;
422
- });
423
- };
424
-
425
- replaceContactPrefix = (
426
- data: any,
427
- sourceStepKey: any,
428
- stepTagsSource: any,
429
- ) => {
430
- const replacementPrefix = `steps.${sourceStepKey}.out.${
431
- stepTagsSource.loop_variable_name
432
- ? `${stepTagsSource.loop_variable_name}`
433
- : ''
434
- }`;
435
-
436
- return data.map((item: any) => ({
437
- ...item,
438
- value: item.value.replace('contact_v1', replacementPrefix),
439
- }));
440
- };
441
-
442
- setActivityOutputFromRawActivityOutput = (
443
- stepTagsSource: any,
444
- sourceStepKey = '',
445
- ) => {
446
- try {
447
- let objectPaylaod = {};
448
- objectPaylaod = stepTagsSource.activity_output as IncomingWebhookObject;
449
-
450
- const activityOutputData = JSONToActivityOutputData(
451
- objectPaylaod,
452
- '',
453
- `steps.${sourceStepKey}.out.${
454
- stepTagsSource.loop_variable_name
455
- ? `${stepTagsSource.loop_variable_name}.`
456
- : ''
457
- }`,
458
- );
459
- const dynamicFieldData = JSONToDynamicFieldData(
460
- objectPaylaod,
461
- '',
462
- `steps.${sourceStepKey}.out.${
463
- stepTagsSource.loop_variable_name
464
- ? `${stepTagsSource.loop_variable_name}.`
465
- : ''
466
- }`,
467
- );
468
- this.props.setIncomingWebhookPayload({
469
- incomingWebhookPayload: objectPaylaod,
470
- });
471
- this.props.setActivityOutputData({
472
- activityOutputData: activityOutputData || [],
473
- });
474
- this.props.setDynamicFieldData({
475
- dynamicFieldData: dynamicFieldData || {},
476
- });
477
- this.setState({
478
- dynamicFieldDataState: dynamicFieldData || {},
479
- });
480
- } catch (e) {
481
- console.error(e);
482
- }
483
- };
484
-
485
- setDynamicData = (url: string, stepId: number, data: any) => {
486
- this.props.apiHandler
487
- .callDynamicDataEndpoint<{
488
- [fieldId: string]: (string | Record<string, string>)[];
489
- }>(new URL(url), {
490
- authorization_id: `${this.props.stepMapping[stepId].selectedAuthId}`,
491
- ...data,
492
- })
493
- .then((res) => {
494
- if (res) {
495
- this.props.setDynamicFieldData({
496
- dynamicFieldData: res,
497
- });
498
- this.setState({
499
- dynamicFieldDataState: res,
500
- });
501
- }
502
- });
503
- };
504
-
505
- canOverrideIntegryObject = (integryObject: any) => {
506
- if (integryObject) {
507
- try {
508
- const parsedIntegryObject = JSON.parse(
509
- integryObject,
510
- ) as IncomingWebhookObject;
511
-
512
- if (this.props.userConfig?.objects?.[parsedIntegryObject.name]) {
513
- return true;
514
- }
515
- } catch (e) {
516
- return false;
517
- }
518
- }
519
- return false;
520
- };
521
-
522
- setActivityOutputFromIntegryObjectOrRawActivityOutput = (
523
- integryObject: any,
524
- stepTagsSource: any,
525
- sourceStepKey = '',
526
- isFunctionSource = false,
527
- isFunctionActivity = false,
528
- ) => {
529
- if (integryObject) {
530
- const outputPrefix = isFunctionActivity ? 'output' : 'out';
531
- try {
532
- let objectPaylaod = {};
533
- if (isFunctionSource) {
534
- objectPaylaod = integryObject;
535
- } else {
536
- const parsedIntegryObject = JSON.parse(
537
- integryObject,
538
- ) as IncomingWebhookObject;
539
- if (this.props.userConfig?.objects?.[parsedIntegryObject.name]) {
540
- objectPaylaod = this.props.userConfig?.objects?.[
541
- parsedIntegryObject.name
542
- ];
543
- } else {
544
- objectPaylaod = JSON.parse(parsedIntegryObject.payload);
545
- }
546
- }
547
-
548
- const activityOutputData = JSONToActivityOutputData(
549
- objectPaylaod,
550
- '',
551
- `steps.${sourceStepKey}.${outputPrefix}.${
552
- stepTagsSource.loop_variable_name
553
- ? `${stepTagsSource.loop_variable_name}.`
554
- : ''
555
- }`,
556
- );
557
- const dynamicFieldData = JSONToDynamicFieldData(
558
- objectPaylaod,
559
- '',
560
- `steps.${sourceStepKey}.${outputPrefix}.${
561
- stepTagsSource.loop_variable_name
562
- ? `${stepTagsSource.loop_variable_name}.`
563
- : ''
564
- }`,
565
- );
566
- this.props.setIncomingWebhookPayload({
567
- incomingWebhookPayload: objectPaylaod,
568
- });
569
- this.props.setActivityOutputData({
570
- activityOutputData: activityOutputData || [],
571
- });
572
- this.props.setDynamicFieldData({
573
- dynamicFieldData: dynamicFieldData || {},
574
- });
575
- this.setState({
576
- dynamicFieldDataState: dynamicFieldData || {},
577
- });
578
- } catch (e) {
579
- console.error(e);
580
- }
581
- } else {
582
- this.setActivityOutputFromRawActivityOutput(
583
- stepTagsSource,
584
- sourceStepKey,
585
- );
586
- }
587
- };
588
-
589
- setRootStepData = async (
590
- additionalData: Record<string, string> | undefined,
591
- isRefresh?: boolean | false,
592
- callback?: any,
593
- ) => {
594
- const triggerStep = this.props.genericData.stepWithActivityOutput;
595
- let integryObject = triggerStep?.template_fields.find(
596
- (el) => el.activity_field?.machine_name === 'integry_webhook_object',
597
- )?.default_value;
598
-
599
- if (integryObject) {
600
- let parsedIntegryObject = {};
601
- try {
602
- parsedIntegryObject = JSON.parse(integryObject || '{}');
603
- } catch (e) {
604
- parsedIntegryObject = {};
605
- }
606
-
607
- /**
608
- * this is to handle the case where the integry object is not in the format
609
- * { payload: {}, name: '' }
610
- */
611
- const payloadName = triggerStep?.template_fields.find(
612
- (el) => el.activity_field?.machine_name === 'payload_name',
613
- )?.default_value;
614
- parsedIntegryObject = {
615
- payload: integryObject || '{}',
616
- name: payloadName || 'payload',
617
- };
618
- integryObject = JSON.stringify(parsedIntegryObject);
619
- }
620
- this.props.setActivityOutputData({
621
- activityOutputData: [],
622
- });
623
- if (
624
- this.props.step.source_steps &&
625
- Object.keys(this.props.step.source_steps).length > 0
626
- ) {
627
- this.setActivityOutputFromSourceStep(isRefresh, callback, integryObject);
628
- } else if (triggerStep) {
629
- const { id: triggerStepId } = triggerStep;
630
-
631
- if (triggerStep.activity.activity_output_url) {
632
- if (!isRefresh) {
633
- // we don't want to set loading when refreshing the data
634
- this.setState({
635
- loading: true,
636
- });
637
- }
638
- // setRootDataLoading(true);
639
- this.props.apiHandler
640
- .callDynamicDataEndpoint<
641
- {
642
- text: string;
643
- value: string;
644
- }[]
645
- >(new URL(triggerStep.activity.activity_output_url), {
646
- authorization_id: `${this.props.stepMapping[triggerStepId].selectedAuthId}`,
647
- ...additionalData,
648
- })
649
- .then((res) => {
650
- // setRootDataLoading(false);
651
- this.setState({
652
- loading: false,
653
- });
654
- if (callback) {
655
- callback();
656
- }
657
- if (res)
658
- this.props.setActivityOutputData({
659
- activityOutputData: res,
660
- });
661
- });
662
- } else if (triggerStep.activity.activity_output || integryObject) {
663
- // setRootDataLoading(false);
664
- this.setActivityOutputFromIntegryObjectOrRawActivityOutput(
665
- integryObject,
666
- triggerStep.activity,
667
- );
668
- this.setState({
669
- loading: false,
670
- });
671
- if (callback) {
672
- callback();
673
- }
674
- } else {
675
- this.setState({
676
- loading: false,
677
- });
678
- if (callback) {
679
- callback();
680
- }
681
- }
682
-
683
- if (triggerStep.activity.dynamic_field_data_endpoint) {
684
- this.setDynamicData(
685
- triggerStep.activity.dynamic_field_data_endpoint,
686
- triggerStepId,
687
- additionalData,
688
- );
689
- }
690
- }
691
- };
692
-
693
- removeCurlyBraces = (value: string): string =>
694
- value.replace(/^{(.*)}$/, '$1');
695
-
696
- isNotJSON = (obj: any) => {
697
- try {
698
- if (Array.isArray(obj) && obj.length > 0 && typeof obj[0] === 'object') {
699
- return false;
700
- }
701
- JSON.parse(obj);
702
- if (Number(obj)) {
703
- return true;
704
- }
705
- return false;
706
- } catch (e) {
707
- return true;
708
- }
709
- };
710
-
711
- arrayToNestedJSONWithFirstValue = (array: any, valueObj: any) => {
712
- let tempValueObj: any = {};
713
- let arrayUpdated = [];
714
- if (array && Array.isArray(array)) {
715
- arrayUpdated = array;
716
- }
717
- Object.keys(valueObj || {}).forEach((i) => {
718
- const key = this.removeCurlyBraces(i);
719
- tempValueObj = {
720
- ...tempValueObj,
721
- [key]: valueObj[i] || '',
722
- };
723
- });
724
- let flatForm = {};
725
- (arrayUpdated || []).forEach((arr: any) => {
726
- flatForm = {
727
- ...flatForm,
728
- [arr.text]: valueObj[arr.value] || '',
729
- };
730
- });
731
-
732
- const result = {};
733
- (arrayUpdated || []).forEach((item: any) => {
734
- if (!item.text || !item.value) {
735
- return;
736
- }
737
- const keys = item.text.split('.');
738
- let currentLevel: any = result;
739
- keys.forEach((key: any, index: any) => {
740
- if (!currentLevel[key]) {
741
- if (index === keys.length - 1) {
742
- if (tempValueObj[item.value]) {
743
- if (
744
- tempValueObj[item.value][0] &&
745
- this.isNotJSON(tempValueObj[item.value][0])
746
- ) {
747
- // eslint-disable-next-line prefer-destructuring
748
- currentLevel[key] = tempValueObj[item.value][0] || '';
749
- } else {
750
- currentLevel[key] = '';
751
- }
752
- } else {
753
- currentLevel[key] = '';
754
- }
755
- } else {
756
- currentLevel[key] = {};
757
- }
758
- }
759
- currentLevel = currentLevel[key];
760
- });
761
- });
762
- return result;
763
- };
764
-
765
- getFieldValFromActivityOutputRaw = (array: any, val: string) => {
766
- const results = val.match(/{([^}]+)}/g);
767
- let valSubstituded = val;
768
- (results || []).forEach((tag: string) => {
769
- const tagCheck = tag.replace(/{|}/g, '');
770
- (array || []).forEach((arr: any) => {
771
- if (arr.text === tagCheck) {
772
- valSubstituded = valSubstituded.replace(tag, `{${arr.value}}`);
773
- }
774
- });
775
- });
776
- return valSubstituded;
777
- };
778
-
779
- private getStepVisibleFieldsData = (
780
- stepId: number,
781
- ): {
782
- [machineName: string]: string;
783
- } => {
784
- const fields = this.props.stepDataMapping[stepId];
785
- const requiredFieldsWithValues = Object.keys(fields)
786
- .filter((el) => fields[Number(el)].value)
787
- .reduce((prev, curr) => {
788
- const currentItem = fields[Number(curr)];
789
- return {
790
- ...prev,
791
- [currentItem.machineName]: currentItem.value,
792
- };
793
- }, {});
794
- return requiredFieldsWithValues;
795
- };
796
-
797
- private areParentValuesFilled = (stepId: number, parentFields: string[]) => {
798
- let valid = true;
799
- // check if all parent fields have their values set
800
- for (let index = 0; index < parentFields.length; index += 1) {
801
- const val = parentFields[index];
802
- let fieldId = null;
803
- if (this.props.parentChildMapping[stepId][val]) {
804
- fieldId = this.props.parentChildMapping[stepId][val].fieldId;
805
- }
806
- const parentField =
807
- fieldId &&
808
- this.props.stepDataMapping[stepId] &&
809
- this.props.stepDataMapping[stepId][fieldId];
810
- if (!(parentField && parentField.value)) {
811
- valid = false;
812
- break;
813
- }
814
- }
815
- return valid;
816
- };
817
-
818
- private doParentFieldsHaveValues = (stepId: number, machineName: string) => {
819
- let valid = true;
820
- const fieldInfo = this.props.parentChildMapping[stepId][machineName];
821
- if (fieldInfo && fieldInfo.parentFields)
822
- // check if all parent fields have their values set
823
- for (let index = 0; index < fieldInfo.parentFields.length; index += 1) {
824
- const parentField = this.props.parentChildMapping[stepId][
825
- fieldInfo.parentFields[index]
826
- ];
827
- const parentFieldData =
828
- parentField &&
829
- this.props.stepDataMapping[stepId] &&
830
- this.props.stepDataMapping[stepId][parentField.fieldId];
831
- if (!(parentFieldData && parentFieldData.value)) {
832
- valid = false;
833
- break;
834
- }
835
- }
836
- return valid;
837
- };
838
-
839
- private shouldShowStep = (field: TemplateField) => {
840
- if (!this.props.showStepValidation) {
841
- return true;
842
- }
843
- const stepId = this.props.step.id;
844
- const stepObject = this.props.stepMapping && this.props.stepMapping[stepId];
845
-
846
- if (
847
- field.type === 'BUTTON' ||
848
- field.type === 'HTML' ||
849
- field.type === 'SECTION'
850
- )
851
- return true;
852
-
853
- if (stepObject && field.activity_field) {
854
- if (this.props.userConfig && this.props.userConfig.viewAsIU) return true;
855
- const shouldBeShown = !field.is_hidden;
856
- // const isAuthSelected = stepObject.selectedAuthId;
857
- const isAuthSelected = true;
858
-
859
- const { parentFields } = this.props.parentChildMapping[stepId][
860
- field.activity_field.machine_name
861
- ];
862
-
863
- const fieldConditions = this.props.conditionalFieldMapping[stepId][
864
- field.activity_field.machine_name
865
- ];
866
- let isParentFilled = true;
867
- let isConditionValid = true;
868
- if (parentFields) {
869
- isParentFilled = this.areParentValuesFilled(stepId, parentFields);
870
- }
871
-
872
- if (fieldConditions) {
873
- isConditionValid = areParentValuesValid(
874
- stepId,
875
- fieldConditions,
876
- this.props.stepDataMapping,
877
- );
878
- }
879
- const isValid = isParentFilled && isConditionValid;
880
-
881
- return shouldBeShown && isAuthSelected && isValid;
882
- }
883
- return false;
884
- };
885
-
886
- private stepIsOfType = (fields: string[]) => {
887
- const stepId = this.props.step.id;
888
- const stepObject = (this.props.stepMapping &&
889
- this.props.stepMapping[stepId]) || { step: this.props.step };
890
- return fields.indexOf(stepObject.step.activity?.type) > -1;
891
- };
892
-
893
- private textFieldParentHasValues = (currentField: any) => {
894
- const stepId = this.props.step.id;
895
- const stepObject = (this.props.stepMapping &&
896
- this.props.stepMapping[stepId]) || { step: this.props.step };
897
-
898
- const anyVisibleFields = stepObject.step.template_fields.filter(
899
- (el) => el.is_visible,
900
- );
901
-
902
- // ignore auth incase of configMode, or viewAsIU
903
- const isAuthSelected =
904
- this.props?.userConfig && this.props?.userConfig.viewAsIU
905
- ? true
906
- : stepObject.selectedAuthId;
907
-
908
- const dynamicField = anyVisibleFields.filter(
909
- (el) => el.activity_field && el.activity_field.type === 'DYNAMIC',
910
- )[0];
911
- if (!dynamicField) {
912
- return true;
913
- }
914
-
915
- let isFieldChild = false;
916
- anyVisibleFields.forEach((field) => {
917
- const { activity_field } = field;
918
- const { activity_field: current_activity_field } = currentField;
919
- if (
920
- activity_field?.child_fields?.includes(
921
- current_activity_field.machine_name,
922
- )
923
- ) {
924
- isFieldChild = true;
925
- }
926
- });
927
-
928
- if (!isFieldChild) {
929
- return true;
930
- }
931
-
932
- if (
933
- anyVisibleFields.length > 0 &&
934
- currentField &&
935
- currentField.activity_field &&
936
- isAuthSelected &&
937
- this.doParentFieldsHaveValues(
938
- stepId,
939
- currentField.activity_field.machine_name,
940
- )
941
- ) {
942
- return true;
943
- }
944
- return false;
945
- };
946
-
947
- private shouldShowOldMapping = () => {
948
- const stepId = this.props.step.id;
949
- const stepObject = (this.props.stepMapping &&
950
- this.props.stepMapping[stepId]) || { step: this.props.step };
951
- if (this.stepIsOfType(['ADAPTER', 'ACTION'])) {
952
- const anyVisibleFields = stepObject.step.template_fields.filter(
953
- (el) => el.is_visible,
954
- );
955
-
956
- const anyVisibleTextFields = stepObject.step.template_fields.filter(
957
- (el) => el.is_visible && el.activity_field?.type === 'TEXTFIELD',
958
- );
959
-
960
- const isAuthSelected = stepObject.selectedAuthId;
961
-
962
- const dynamicField = anyVisibleFields.filter(
963
- (el) => el.activity_field && el.activity_field.type === 'DYNAMIC',
964
- )[0];
965
-
966
- // show mapping whenever we have visible text fields and a selected auth
967
- if (
968
- anyVisibleTextFields.length > 0 &&
969
- isAuthSelected &&
970
- !dynamicField &&
971
- !this.shouldShowNewMapping()
972
- )
973
- return true;
974
-
975
- // in case we dont have visible text fields and no dynamic fields, dont show mapping
976
- if (!dynamicField) {
977
- return false;
978
- }
979
-
980
- if (
981
- anyVisibleFields.length > 0 &&
982
- isAuthSelected &&
983
- dynamicField &&
984
- dynamicField.activity_field &&
985
- this.doParentFieldsHaveValues(
986
- stepId,
987
- dynamicField.activity_field.machine_name,
988
- )
989
- ) {
990
- const fieldConditions = this.props.conditionalFieldMapping[stepId][
991
- dynamicField.activity_field.machine_name
992
- ];
993
- if (fieldConditions) {
994
- return areParentValuesValid(
995
- stepId,
996
- fieldConditions,
997
- this.props.stepDataMapping,
998
- );
999
- }
1000
- return true;
1001
- }
1002
- return false;
1003
- }
1004
- return false;
1005
- };
1006
-
1007
- private shouldShowNewMapping = () => {
1008
- const { step, stepMapping } = this.props;
1009
- const stepObject = stepMapping[step.id];
1010
-
1011
- if (this.stepIsOfType(['ADAPTER', 'ACTION'])) {
1012
- const anyVisibleFields = stepObject.step.template_fields.filter(
1013
- (el) => el.is_visible,
1014
- );
1015
-
1016
- if (anyVisibleFields) {
1017
- const fieldMappingField = anyVisibleFields.filter(
1018
- (el) =>
1019
- el.activity_field && el.activity_field.type === 'FIELD_MAPPING',
1020
- )[0];
1021
- if (fieldMappingField) {
1022
- return true;
1023
- }
1024
- }
1025
- }
1026
- return false;
1027
- };
1028
-
1029
- private getMappingDataInput = () => {
1030
- const stepId = this.props.step.id;
1031
- const stepObject = this.props.stepMapping && this.props.stepMapping[stepId];
1032
- const payload = {
1033
- authId: stepObject.selectedAuthId,
1034
- fieldsData: this.getStepVisibleFieldsData(stepId),
1035
- };
1036
- return payload;
1037
- };
1038
-
1039
- private isParentField = (
1040
- mapping: Record<string, Record<string, any>>,
1041
- machineName: string,
1042
- ): boolean =>
1043
- Object.values(mapping).some((fields) =>
1044
- Object.values(fields).some(
1045
- (field) =>
1046
- Array.isArray(field.parentFields) &&
1047
- field.parentFields.includes(machineName),
1048
- ),
1049
- );
1050
-
1051
- private getParentDynamicFields = (machineName: string, stepId: number) => {
1052
- const parentFields =
1053
- this.state.parentChildMapping?.[stepId]?.[machineName]?.parentFields ||
1054
- [];
1055
-
1056
- return parentFields.reduce((acc: Record<string, unknown>, key: string) => {
1057
- const dynamicData = this.state.dynamicFieldsData as Record<
1058
- string,
1059
- unknown
1060
- >;
1061
-
1062
- if (key in dynamicData) {
1063
- acc[key] = dynamicData[key];
1064
- }
1065
-
1066
- return acc;
1067
- }, {});
1068
- };
1069
-
1070
- private onFieldChange = ({
1071
- stepId,
1072
- fieldId,
1073
- value,
1074
- isRequired,
1075
- machineName,
1076
- computeValueUsingActivityOutput,
1077
- }: {
1078
- stepId: number;
1079
- fieldId: number;
1080
- value: string;
1081
- isRequired: boolean;
1082
- machineName?: string;
1083
- computeValueUsingActivityOutput?: boolean;
1084
- }) => {
1085
- // we want to check if callback function is passed in props, if yes then call it
1086
- if (this.props.onFieldChangeCallback) {
1087
- this.setState((prevState) => ({
1088
- dynamicFieldsData: {
1089
- ...prevState.dynamicFieldsData,
1090
- [machineName || '']: value,
1091
- },
1092
- }));
1093
-
1094
- if (
1095
- this.isParentField(this.state.parentChildMapping, machineName || '')
1096
- ) {
1097
- this.setState((prevState) => ({
1098
- parentFieldChanged: {
1099
- ...prevState.parentFieldChanged,
1100
- [machineName as string]: !prevState.parentFieldChanged?.[
1101
- machineName as string
1102
- ],
1103
- },
1104
- }));
1105
- this.setState({ changedParentMachineName: machineName });
1106
- }
1107
-
1108
- this.props.onFieldChangeCallback(machineName || '', value);
1109
- } else {
1110
- const valueToUse = !computeValueUsingActivityOutput
1111
- ? value
1112
- : this.getFieldValFromActivityOutputRaw(
1113
- this.props.activityOutputData,
1114
- value,
1115
- );
1116
- this.props.setStepFieldData({
1117
- stepId: `${stepId}`,
1118
- fieldId: `${fieldId}`,
1119
- value: valueToUse,
1120
- isRequired,
1121
- });
1122
- this.setState({ changedParentMachineName: machineName });
1123
- this.setState((prevState) => ({
1124
- dynamicFieldsData: {
1125
- ...prevState.dynamicFieldsData,
1126
- [machineName || '']: value,
1127
- },
1128
- }));
1129
- this.props.clearChildFields({ stepId, fieldId });
1130
- this.props.verifyStepValidity(Number(stepId));
1131
- }
1132
- };
1133
-
1134
- private hasParent = (
1135
- fieldId: string,
1136
- data: Record<string, { parentFields: string[] | null }>,
1137
- ): boolean => {
1138
- const parentFields = data?.[fieldId]?.parentFields;
1139
- return Array.isArray(parentFields) && parentFields.length > 0;
1140
- };
1141
-
1142
- private fieldDynamicData = (field: TemplateField) => {
1143
- const stepId = this.props.step.id;
1144
- const stepObject = this.props.stepMapping && this.props.stepMapping[stepId];
1145
- if ((stepObject || this.props.tagsTree) && field.activity_field) {
1146
- const parentFields =
1147
- this.props.parentChildMapping[stepId]?.[
1148
- field.activity_field.machine_name
1149
- ]?.parentFields || null;
1150
- if (parentFields) {
1151
- const endpointData = parentFields.reduce((prev, next) => {
1152
- const { fieldId } = this.props.parentChildMapping[stepId][next];
1153
- if (fieldId)
1154
- return {
1155
- ...prev,
1156
- [next]: this.props.stepDataMapping[stepId][fieldId].value,
1157
- };
1158
- return prev;
1159
- }, {});
1160
- return endpointData;
1161
- }
1162
- if (
1163
- this.state.parentChildMapping &&
1164
- this.hasParent(
1165
- field.activity_field.machine_name,
1166
- this.state.parentChildMapping[stepId],
1167
- )
1168
- ) {
1169
- const selfParentFields =
1170
- this.state.parentChildMapping[stepId][
1171
- field.activity_field.machine_name
1172
- ]?.parentFields || [];
1173
- const result = selfParentFields.reduce(
1174
- (acc: Record<string, unknown>, parent: any) => {
1175
- if (this.state.dynamicFieldsData?.[parent]) {
1176
- acc[parent] = this.state.dynamicFieldsData[parent];
1177
- }
1178
- return acc;
1179
- },
1180
- {},
1181
- );
1182
- return result;
1183
- }
1184
- }
1185
- return null;
1186
- };
1187
-
1188
- private sourceFlowData = (field: TemplateField) => {
1189
- if (field.source_flow_integration_invocation_url) {
1190
- // when source_flow_integration_invocation_url is present, we will pass all steps data to the endpoint
1191
- const { stepMapping, stepDataMapping } = this.props;
1192
- const endpointData = Object.keys(stepMapping).reduce((prev, next) => {
1193
- const { machine_name, id: stepId } = stepMapping[next].step;
1194
- if (machine_name)
1195
- return {
1196
- ...prev,
1197
- [machine_name]: {
1198
- in: Object.keys(stepDataMapping[stepId]).reduce(
1199
- (prevFieldObj, nextFieldId) => {
1200
- const fieldId = parseInt(nextFieldId, 10);
1201
- if (stepDataMapping[stepId][fieldId]) {
1202
- const { value, machineName } = stepDataMapping[stepId][
1203
- fieldId
1204
- ];
1205
- return {
1206
- ...prevFieldObj,
1207
- [machineName]: value,
1208
- };
1209
- }
1210
- return prevFieldObj;
1211
- },
1212
- {},
1213
- ),
1214
- },
1215
- };
1216
- return prev;
1217
- }, {});
1218
- return {
1219
- steps: {
1220
- ...endpointData,
1221
- },
1222
- };
1223
- }
1224
- return null;
1225
- };
1226
-
1227
- private isHTML = (value: string): boolean => {
1228
- if (/<\/?[a-z][\s\S]*>/i.test(value)) {
1229
- return true;
1230
- }
1231
- return false;
1232
- };
1233
-
1234
- private getPlaceholder = (field: TemplateField) => {
1235
- let appName =
1236
- this.props.genericData.stepWithActivityOutput?.activity?.app?.name ===
1237
- 'Incoming Webhook'
1238
- ? this.props.genericData.selfAppName
1239
- : this.props.genericData.stepWithActivityOutput?.activity?.app?.name ||
1240
- '';
1241
- // this.props.genericData.marketplaceDetail?.app_instance?.account?.name ||
1242
- // '';
1243
- if (!appName || appName.includes('Webhook')) {
1244
- const sourceSteps = this.props.step.source_steps;
1245
- const { stepMapping } = this.props;
1246
- const { props } = this;
1247
- let sourceStepAppId = null;
1248
- Object.keys(sourceSteps).forEach((sourceStepKey) => {
1249
- const stepTagsSource = props.step.source_steps[sourceStepKey];
1250
- sourceStepAppId = stepTagsSource.app_id;
1251
- if (stepTagsSource.app_name) {
1252
- appName = stepTagsSource.app_name;
1253
- } else {
1254
- Object.keys(stepMapping).every((mappedStepIndex) => {
1255
- if (
1256
- stepMapping[mappedStepIndex].step.authorization_type.app.id ===
1257
- stepTagsSource.app_id
1258
- ) {
1259
- appName = stepMapping[mappedStepIndex].step.activity.app.name;
1260
- }
1261
- return true;
1262
- });
1263
- }
1264
- });
1265
- if (appName?.includes('Incoming Webhook') && sourceStepAppId === null) {
1266
- appName = 'Webhook';
1267
- }
1268
- }
1269
- if (
1270
- field.activity_field?.type === 'TEXTAREA' ||
1271
- field.activity_field?.type === 'TEXTFIELD' ||
1272
- field.activity_field?.type === 'DYNAMIC'
1273
- ) {
1274
- return field.is_editable &&
1275
- !field.is_mappable &&
1276
- !field.allow_tags_in_text
1277
- ? 'Enter text...'
1278
- : !field.is_editable && field.is_mappable
1279
- ? `Map to a ${appName} field...`
1280
- : field.is_editable && (field.is_mappable || field.allow_tags_in_text)
1281
- ? `Enter text or map to a ${appName} field...`
1282
- : 'Please enter a value';
1283
- }
1284
- if (
1285
- field.activity_field?.type === 'CHECKBOX' ||
1286
- field.activity_field?.type === 'SELECT' ||
1287
- field.activity_field?.type === 'RADIO'
1288
- ) {
1289
- return field.is_editable &&
1290
- !field.is_mappable &&
1291
- !field.allow_tags_in_text
1292
- ? 'Enter text or select a value...'
1293
- : !field.is_editable && field.is_mappable
1294
- ? `Select a value or map to a ${appName} field...`
1295
- : field.is_editable && field.allow_tags_in_text
1296
- ? `Enter text with ${appName} fields or select a value...`
1297
- : field.is_editable && field.is_mappable
1298
- ? `Enter text, select a value or map to a ${appName} field...`
1299
- : 'Select a value...';
1300
- }
1301
- return field.activity_field?.type === 'TEXTAREA' ||
1302
- field.activity_field?.type === 'TEXTFIELD'
1303
- ? 'Enter text...'
1304
- : field.activity_field?.type === 'CHECKBOX' ||
1305
- field.activity_field?.type === 'SELECT' ||
1306
- field.activity_field?.type === 'RADIO'
1307
- ? 'Select a value...'
1308
- : '';
1309
- };
1310
-
1311
- private replacePlaceholders = (
1312
- templateObj: { [key: string]: any },
1313
- dictionary: { [key: string]: any },
1314
- ): { [key: string]: any } => {
1315
- const updatedObj: { [key: string]: any } = {};
1316
-
1317
- // Use Object.entries to iterate over keys and values
1318
- Object.entries(templateObj).forEach(([key, value]) => {
1319
- // If the value is a string and contains a placeholder, replace it
1320
- if (typeof value === 'string' && value.includes('{')) {
1321
- // Extract the placeholder key between `{}` and use it to replace with the dictionary value
1322
- const placeholderKey = value.match(/{(.*?)}/);
1323
-
1324
- if (placeholderKey && placeholderKey[1]) {
1325
- const keyPath = placeholderKey[1]; // Extract full key path from the placeholder
1326
- const lastPartKey = keyPath.split('.').pop(); // Get the last part of the key path
1327
-
1328
- // Check if dictionary has an exact match for the full path or the last part of the path
1329
- if (dictionary?.[keyPath] !== undefined) {
1330
- // Replace using the exact match
1331
- updatedObj[key] = value.replace(
1332
- placeholderKey[0],
1333
- dictionary[keyPath],
1334
- );
1335
- } else if (lastPartKey && dictionary?.[lastPartKey] !== undefined) {
1336
- // Replace using the last part match
1337
- updatedObj[key] = value.replace(
1338
- placeholderKey[0],
1339
- dictionary[lastPartKey],
1340
- );
1341
- }
1342
- }
1343
- } else if (typeof value === 'string' && value) {
1344
- // If the value is a string but doesn't contain placeholders, retain it as is
1345
- updatedObj[key] = value;
1346
- }
1347
- });
1348
-
1349
- // Return the updated object containing only keys with replaced values
1350
- return updatedObj;
1351
- };
1352
-
1353
- private findFieldByMachineName = (machineName: string) => {
1354
- const { stepMapping, step } = this.props;
1355
- const selectedStep =
1356
- (stepMapping[step.id] && stepMapping[step.id].step) || step;
1357
- return selectedStep.template_fields.find(
1358
- (el) => el.activity_field?.machine_name === machineName,
1359
- );
1360
- };
1361
-
1362
- private checkIfAllParentFieldsHaveDefaultValue = (
1363
- parentFields: string[],
1364
- ): boolean =>
1365
- parentFields.every((parentField) => {
1366
- const field = this.findFieldByMachineName(parentField);
1367
- return (
1368
- field &&
1369
- field.default_value &&
1370
- field.default_value !== '' &&
1371
- field.default_value !== 'null' &&
1372
- field.default_value !== 'undefined'
1373
- );
1374
- });
1375
-
1376
- render() {
1377
- const {
1378
- step,
1379
- stepMapping,
1380
- stepDataMapping,
1381
- setStepFieldData,
1382
- showStepValidation,
1383
- isReadOnly,
1384
- accountConnected,
1385
- } = this.props;
1386
- const selectedStep =
1387
- (stepMapping[step.id] && stepMapping[step.id].step) || step;
1388
- const selectedStepData =
1389
- (stepDataMapping && stepDataMapping[step.id]) || {};
1390
- const actionConfigPayload = {};
1391
- // userConfig?.objects && genericData.directActionPayloadName
1392
- // ? embedConfig?.objects[genericData.directActionPayloadName]
1393
- // : embedConfig?.actionsPayload && genericData.directActionPayloadName
1394
- // ? embedConfig?.actionsPayload[genericData.directActionPayloadName]
1395
- // : null;
1396
- const activityOutputData =
1397
- actionConfigPayload || this.props.activityOutputData || {};
1398
- const noStepFields =
1399
- selectedStep.template_fields?.length === 0 ||
1400
- (!(this.props.userConfig && this.props.userConfig.viewAsIU) &&
1401
- selectedStep.template_fields?.filter((field) => field.is_visible)
1402
- .length === 0);
1403
- return html`
1404
- ${this.state.loading
1405
- ? html`<div class=${styles.actionFormLoader}><${Loader} /></div>`
1406
- : html`
1407
- ${selectedStep
1408
- ? html`
1409
- <div
1410
- class=${`${styles.actionFormWrap} ${
1411
- this.props.selectedAuthId && this.props.accountConnected
1412
- ? `${styles.actionFormWrapAutoWidth}`
1413
- : ``
1414
- }`}
1415
- >
1416
- ${noStepFields
1417
- ? html`<span class=${styles.noStepFields}
1418
- >There’s nothing to configure, please proceed.</span
1419
- >`
1420
- : selectedStep.template_fields?.map((el) => {
1421
- if (
1422
- this.shouldShowStep(el) &&
1423
- (el.activity_field || el.type === 'SECTION')
1424
- ) {
1425
- const selectedStepElementData =
1426
- (selectedStepData && selectedStepData[el.id]) ||
1427
- null;
1428
- const elDescription =
1429
- el.description && !this.isHTML(el.description)
1430
- ? el.description
1431
- : el.activity_field?.description &&
1432
- !this.isHTML(el.activity_field?.description)
1433
- ? el.activity_field?.description
1434
- : '';
1435
- let fieldType = el.activity_field?.type || el.type;
1436
- const uiField = el.ui_field;
1437
- const uiFieldSourceURL =
1438
- uiField?.data_source?.url || '';
1439
- if (
1440
- el.data_type === 'OBJECT' &&
1441
- el.type !== 'FUNCTION_FIELD'
1442
- ) {
1443
- if (
1444
- el.type === 'DYNAMIC' &&
1445
- uiField?.type === 'CUSTOM_FIELDS'
1446
- ) {
1447
- fieldType = 'CUSTOM_FIELDS';
1448
- } else {
1449
- fieldType = 'OBJECT';
1450
- }
1451
- } else if (
1452
- el.data_type === 'OBJECT[]' &&
1453
- el.type !== 'FUNCTION_FIELD'
1454
- ) {
1455
- if (
1456
- el.type === 'DYNAMIC' &&
1457
- uiField?.type === 'CUSTOM_FIELDS'
1458
- ) {
1459
- fieldType = 'CUSTOM_FIELDS';
1460
- } else {
1461
- fieldType = 'OBJECT[]';
1462
- }
1463
- }
1464
-
1465
- switch (fieldType) {
1466
- case 'CHECKBOX':
1467
- case 'RADIO':
1468
- case 'SELECT': {
1469
- let fieldVal = null;
1470
- let elParentFields = [];
1471
- if (
1472
- el.activity_field?.parent_fields &&
1473
- el.activity_field?.parent_fields !== '' &&
1474
- el.activity_field?.parent_fields !== 'null'
1475
- ) {
1476
- try {
1477
- elParentFields = JSON.parse(
1478
- el.activity_field?.parent_fields,
1479
- );
1480
- } catch (e) {
1481
- elParentFields = [];
1482
- }
1483
- }
1484
- if (this.props.onFieldChangeCallback) {
1485
- if (
1486
- Object.prototype.hasOwnProperty.call(
1487
- this.state.dynamicFieldsData || {},
1488
- el.activity_field?.machine_name || '',
1489
- )
1490
- ) {
1491
- fieldVal = this.state.dynamicFieldsData[
1492
- el.activity_field?.machine_name || ''
1493
- ];
1494
- } else {
1495
- fieldVal = el.default_value;
1496
- }
1497
- }
1498
- const parentFieldsHaveDefaultValues = this.checkIfAllParentFieldsHaveDefaultValue(
1499
- elParentFields,
1500
- );
1501
- return html`
1502
- <div key=${
1503
- el.id
1504
- } id=${`integry-action-field-wrap-${
1505
- el?.activity_field?.machine_name || ''
1506
- }`} class=${`integry-action-field-wrap ${
1507
- el.is_visible ? '' : styles.fNotVisible
1508
- }`}>
1509
- <${ConfigureFieldWrapper}
1510
- field=${el}
1511
- stepId=${step.id}
1512
- templateId=${this.props.genericData?.templateId}
1513
- >
1514
- <${ListBox}
1515
- key=${el.activity_field?.id}
1516
- fieldId=${
1517
- el.activity_field?.id ||
1518
- el.id ||
1519
- el?.activity_field?.machine_name
1520
- }
1521
- apiHandler=${this.props.apiHandler}
1522
- title=${el.title || el.activity_field?.title}
1523
- description=${elDescription}
1524
- showStepValidation=${showStepValidation}
1525
- placeholder=${this.getPlaceholder(el)}
1526
- isRequired=${el.is_required}
1527
- isHidden=${el.is_hidden}
1528
- isSearchable=${
1529
- true
1530
- // el.activity_field.is_searchable TODO: enable this when Serach is added for mulipurposes field
1531
- }
1532
- value=${
1533
- fieldVal ||
1534
- (selectedStepData &&
1535
- selectedStepData[el.id] &&
1536
- selectedStepData[el.id].value) ||
1537
- (this.props.onFieldChangeCallback
1538
- ? ''
1539
- : el.default_value) ||
1540
- ''
1541
- }
1542
- onChange=${(val: string) => {
1543
- this.onFieldChange({
1544
- stepId: step.id,
1545
- fieldId: el.id,
1546
- value: val,
1547
- isRequired: el.is_required,
1548
- machineName:
1549
- el.activity_field?.machine_name,
1550
- });
1551
- }}
1552
- endpointUrl=${
1553
- uiFieldSourceURL ||
1554
- el.source_flow_integration_invocation_url ||
1555
- el.activity_field?.data_src
1556
- }
1557
- isDynamic=${el.activity_field?.is_dynamic}
1558
- endpointData=${JSON.stringify({
1559
- authorization_id:
1560
- this.props.stepMapping &&
1561
- this.props.stepMapping[this.props.step.id]
1562
- ?.selectedAuthId,
1563
- ...this.fieldDynamicData(el),
1564
- })}
1565
- isReadOnly=${isReadOnly}
1566
- isChanged=${
1567
- selectedStepElementData &&
1568
- selectedStepElementData.isChanged
1569
- }
1570
- activityOutputData=${activityOutputData}
1571
- }
1572
- type=${el.activity_field?.type}
1573
- selectedAuthId=${`${
1574
- this.props.stepMapping[this.props.step.id]
1575
- ?.selectedAuthId ||
1576
- this.props.selectedAuthId ||
1577
- ''
1578
- }`}
1579
- disabled=${
1580
- !this.props.stepMapping[this.props.step.id]
1581
- ?.isAuthVerified &&
1582
- !this.props.accountConnected
1583
- }
1584
- sourceFlowData=${this.sourceFlowData(el)}
1585
- sourceFlowIntegrataionInvocationUrl=${
1586
- el.source_flow_integration_invocation_url
1587
- }
1588
- skipOptionFetch=${
1589
- this.props.userConfig?.viewAsIU
1590
- }
1591
- isMappable=${el.is_mappable}
1592
- isEditable=${true}
1593
- allowTagsInText=${el.allow_tags_in_text}
1594
- accountConnected=${accountConnected}
1595
- labelTags=${getFieldLabelTags(el, false)}
1596
- appName=${this.props.step.activity.app.name}
1597
- isMultiSelect=${el.is_multiselect}
1598
- dataSourceBody=${this.replacePlaceholders(
1599
- uiField?.data_source?.body || {},
1600
- this.fieldDynamicData(el) || {},
1601
- )}
1602
- optionKeyPath=${uiField?.value_key_path || ''}
1603
- valueKeyPath=${uiField?.option_key_path || ''}
1604
- parentFieldChanged=${elParentFields.includes(
1605
- this.state.changedParentMachineName,
1606
- )}
1607
- allowWorkspaceConnectedAccounts=${!!this.props
1608
- .onFieldChangeCallback}
1609
- tagsTree=${
1610
- this.props.showMappingMenu
1611
- ? this.props.tagsTree
1612
- : null
1613
- }
1614
- showMenuOnLeft=${
1615
- this.props.showMenuOnLeft || false
1616
- }
1617
- skipInitialLoad=${
1618
- (elParentFields.length ?? 0) > 0 &&
1619
- !elParentFields?.some(
1620
- (parentField: any) =>
1621
- parentField &&
1622
- this.state.dynamicFieldsData?.[
1623
- parentField
1624
- ],
1625
- ) &&
1626
- !parentFieldsHaveDefaultValues
1627
- }
1628
-
1629
- ><//>
1630
- </${ConfigureFieldWrapper}>
1631
- </div>`;
1632
- }
1633
- case 'TIME':
1634
- return html` <div
1635
- key=${el.id}
1636
- id=${`integry-action-field-wrap-${
1637
- el?.activity_field?.machine_name || ''
1638
- }`}
1639
- class=${`integry-action-field-wrap ${
1640
- el.is_visible ? '' : styles.fNotVisible
1641
- }`}
1642
- >
1643
- <${TimeInput}
1644
- title=${el.title ||
1645
- el.activity_field?.title}
1646
- description=${elDescription}
1647
- value=${(selectedStepData &&
1648
- selectedStepData[el.id] &&
1649
- selectedStepData[el.id].value) ||
1650
- ''}
1651
- placeholder=${el.placeholder ||
1652
- 'Please enter a value'}
1653
- showStepValidation=${showStepValidation}
1654
- isRequired=${el.is_required}
1655
- onChange=${(val: string) => {
1656
- this.onFieldChange({
1657
- stepId: step.id,
1658
- fieldId: el.id,
1659
- value: val,
1660
- isRequired: el.is_required,
1661
- });
1662
- }}
1663
- isReadOnly=${isReadOnly}
1664
- isChanged=${selectedStepElementData &&
1665
- selectedStepElementData.isChanged}
1666
- />
1667
- </div>`;
1668
- case 'TEXTFIELD':
1669
- case 'HIDDEN': {
1670
- let fieldVal = null;
1671
- if (this.props.onFieldChangeCallback) {
1672
- if (
1673
- Object.prototype.hasOwnProperty.call(
1674
- this.state.dynamicFieldsData || {},
1675
- el.activity_field?.machine_name || '',
1676
- )
1677
- ) {
1678
- fieldVal = this.state.dynamicFieldsData[
1679
- el.activity_field?.machine_name || ''
1680
- ];
1681
- } else {
1682
- fieldVal = el.default_value;
1683
- }
1684
- }
1685
- const isArray = !!(
1686
- el.data_type === 'STRING[]' ||
1687
- el.data_type === 'NUMBER[]'
1688
- );
1689
- return (
1690
- (this.textFieldParentHasValues(el) ||
1691
- (this.props.userConfig || {}).viewAsIU) &&
1692
- !el.added_in_mapping &&
1693
- html`
1694
- <div id=${`integry-action-field-wrap-${
1695
- el?.activity_field?.machine_name || ''
1696
- }`} class=${`integry-action-field-wrap ${
1697
- el.is_visible ? '' : styles.fNotVisible
1698
- }`}>
1699
- <${ConfigureFieldWrapper}
1700
- field=${el}
1701
- stepId=${step.id}
1702
- templateId=${this.props.genericData?.templateId}
1703
- >
1704
- <${MultipurposeField}
1705
- id=${el.activity_field?.id}
1706
- title=${
1707
- el.title || el.activity_field?.title
1708
- }
1709
- activityOutputData=${
1710
- this.props.showMappingMenu
1711
- ? this.props.tagsTreeActivityOutput
1712
- : this.arrayToNestedJSONWithFirstValue(
1713
- this.props.activityOutputData ||
1714
- JSONToActivityOutputData(
1715
- this.props.tagsTree || {},
1716
- ),
1717
- this.props.dynamicFieldData ||
1718
- this.state
1719
- .dynamicFieldDataState ||
1720
- {},
1721
- )
1722
- }
1723
- activityOutputDataRaw=${
1724
- this.props.activityOutputData ||
1725
- JSONToActivityOutputData(
1726
- this.props.tagsTree || {},
1727
- )
1728
- }
1729
- description=${elDescription}
1730
- value=${
1731
- fieldVal ||
1732
- (selectedStepData &&
1733
- selectedStepData[el.id] &&
1734
- selectedStepData[el.id].value &&
1735
- selectedStepData[el.id].value !==
1736
- 'x-integry-skipped-field' &&
1737
- selectedStepData[el.id].value) ||
1738
- el.default_value ||
1739
- ''
1740
- }
1741
- placeholder=${this.getPlaceholder(el)}
1742
- showStepValidation=${showStepValidation}
1743
- regex=${
1744
- selectedStepData[el.id]
1745
- ? selectedStepData[el.id].regex
1746
- : ''
1747
- }
1748
- regexErrorMessage=${
1749
- selectedStepData[el.id]
1750
- ? selectedStepData[el.id]
1751
- .regexErrorMessage
1752
- : ''
1753
- }
1754
- isRequired=${el.is_required}
1755
- isHidden=${el.is_hidden}
1756
- onChange=${(val: string) => {
1757
- this.onFieldChange({
1758
- stepId: step.id,
1759
- fieldId: el.id,
1760
- value: val,
1761
- isRequired: el.is_required,
1762
- machineName:
1763
- el.activity_field?.machine_name,
1764
- computeValueUsingActivityOutput: true,
1765
- });
1766
- }}
1767
- isReadOnly=${isReadOnly}
1768
- isChanged=${
1769
- selectedStepElementData &&
1770
- selectedStepElementData.isChanged
1771
- }
1772
- type=${el.activity_field?.type}
1773
- isMappable=${el.is_mappable}
1774
- isEditable=${el.is_editable}
1775
- allowTagsInText=${el.allow_tags_in_text}
1776
- labelTags=${getFieldLabelTags(el, false)}
1777
- fieldId=${
1778
- el.activity_field?.machine_name ||
1779
- el.activity_field?.id ||
1780
- el.id
1781
- }
1782
- refreshRootStepData=${
1783
- this.refreshRootStepData
1784
- }
1785
- isButtonEnabled=${
1786
- el.is_button_enabled || false
1787
- }
1788
- buttonText=${el.button_text || ''}
1789
- onButtonClickScript=${
1790
- el.on_button_click_script
1791
- }
1792
- buttonScriptRequiresAuthToken=${
1793
- el.button_script_requires_auth_token
1794
- }
1795
- apiHandler=${this.props.apiHandler}
1796
- isArray=${!!(
1797
- el.data_type === 'STRING[]' ||
1798
- el.data_type === 'NUMBER[]'
1799
- )}
1800
- tagsComponent=${this.props.tagsComponent}
1801
- tagsTree=${
1802
- this.props.showMappingMenu
1803
- ? this.props.tagsTree
1804
- : null
1805
- }
1806
- showMenuOnLeft=${
1807
- this.props.showMenuOnLeft || false
1808
- }
1809
- ><//>
1810
- </${ConfigureFieldWrapper}>
1811
- </div>
1812
- `
1813
- );
1814
- }
1815
- case 'OBJECT':
1816
- case 'OBJECT[]':
1817
- return (
1818
- (this.textFieldParentHasValues(el) ||
1819
- (this.props.userConfig || {}).viewAsIU) &&
1820
- !el.added_in_mapping &&
1821
- html`
1822
- <div id=${`integry-action-field-wrap-${
1823
- el?.activity_field?.machine_name || ''
1824
- }`} class=${`integry-action-field-wrap ${
1825
- el.is_visible ? '' : styles.fNotVisible
1826
- }`}>
1827
- <${ConfigureFieldWrapper}
1828
- field=${el}
1829
- stepId=${step.id}
1830
- templateId=${
1831
- this.props.genericData?.templateId
1832
- }
1833
- >
1834
- <${ObjectField}
1835
- field=${el}
1836
- onChange=${this.onFieldChange}
1837
- onChangeInFlow=${(val: string) => {
1838
- this.onFieldChange({
1839
- stepId: step.id,
1840
- fieldId: el.id,
1841
- value: val,
1842
- isRequired: el.is_required,
1843
- machineName:
1844
- el.activity_field?.machine_name,
1845
- });
1846
- }}
1847
- apiHandler=${this.props.apiHandler}
1848
- isArray=${fieldType === 'OBJECT[]'}
1849
- activityOutputData=${
1850
- this.props.showMappingMenu
1851
- ? this.props.tagsTreeActivityOutput
1852
- : this.arrayToNestedJSONWithFirstValue(
1853
- this.props.activityOutputData,
1854
- this.props.dynamicFieldData ||
1855
- this.state
1856
- .dynamicFieldDataState ||
1857
- {},
1858
- )
1859
- }
1860
- activityOutputDataRaw=${
1861
- this.props.activityOutputData
1862
- }
1863
- objectValue=${
1864
- (selectedStepData &&
1865
- selectedStepData[el.id] &&
1866
- selectedStepData[el.id].objectValue &&
1867
- selectedStepData[el.id].objectValue) ||
1868
- el.default_value ||
1869
- ''
1870
- }
1871
- tagsTree=${
1872
- this.props.showMappingMenu
1873
- ? this.props.tagsTree
1874
- : null
1875
- }
1876
- showMenuOnLeft=${
1877
- this.props.showMenuOnLeft || false
1878
- }
1879
- />
1880
- </${ConfigureFieldWrapper}>
1881
- </div>
1882
- `
1883
- );
1884
- case 'FILE':
1885
- return html`
1886
- <div
1887
- id=${`integry-action-field-wrap-${
1888
- el?.activity_field?.machine_name || ''
1889
- }`}
1890
- class=${`integry-action-field-wrap ${
1891
- el.is_visible ? '' : styles.fNotVisible
1892
- }`}
1893
- >
1894
- <${Input}
1895
- id=${el.activity_field?.id}
1896
- title=${el.title ||
1897
- el.activity_field?.title}
1898
- description=${elDescription}
1899
- value=${(selectedStepData &&
1900
- selectedStepData[el.id] &&
1901
- selectedStepData[el.id].value) ||
1902
- ''}
1903
- placeholder=${el.placeholder ||
1904
- 'Please enter a URL'}
1905
- showStepValidation=${showStepValidation}
1906
- regex=${selectedStepData[el.id]
1907
- ? selectedStepData[el.id].regex
1908
- : ''}
1909
- regexErrorMessage=${selectedStepData[
1910
- el.id
1911
- ]
1912
- ? selectedStepData[el.id]
1913
- .regexErrorMessage
1914
- : ''}
1915
- isRequired=${el.is_required}
1916
- onChange=${(
1917
- val: string,
1918
- passesRegexTest?: boolean,
1919
- ) => {
1920
- setStepFieldData({
1921
- stepId: `${step.id}`,
1922
- fieldId: `${el.id}`,
1923
- value: val,
1924
- isRequired: el.is_required,
1925
- passesRegexTest,
1926
- });
1927
- this.props.verifyStepValidity(step.id);
1928
- }}
1929
- isReadOnly=${isReadOnly}
1930
- isChanged=${selectedStepElementData &&
1931
- selectedStepElementData.isChanged}
1932
- ><//>
1933
- </div>
1934
- `;
1935
- case 'DYNAMIC': {
1936
- let fieldVal = null;
1937
- if (this.props.onFieldChangeCallback) {
1938
- if (
1939
- Object.prototype.hasOwnProperty.call(
1940
- this.state.dynamicFieldsData || {},
1941
- el.activity_field?.machine_name || '',
1942
- )
1943
- ) {
1944
- fieldVal = this.state.dynamicFieldsData[
1945
- el.activity_field?.machine_name || ''
1946
- ];
1947
- } else {
1948
- fieldVal = el.default_value;
1949
- }
1950
- }
1951
- return html`
1952
- <div
1953
- key=${el.id}
1954
- id=${`integry-action-field-wrap-${
1955
- el?.activity_field?.machine_name || ''
1956
- }`}
1957
- class=${`integry-action-field-wrap ${
1958
- el.is_visible ? '' : styles.fNotVisible
1959
- }`}
1960
- >
1961
- <${DynamicField}
1962
- stepId=${selectedStep.id}
1963
- dynamicField=${el}
1964
- objectValue=${fieldVal}
1965
- endpointData=${JSON.stringify({
1966
- authorization_id:
1967
- (this.props.stepMapping &&
1968
- this.props.stepMapping[
1969
- this.props.step.id
1970
- ]?.selectedAuthId) ||
1971
- this.props.selectedAuthId,
1972
- ...this.fieldDynamicData(el),
1973
- ...this.state.dynamicFieldsData,
1974
- })}
1975
- activityOutputData=${this.props
1976
- .showMappingMenu
1977
- ? this.props.tagsTreeActivityOutput
1978
- : this.arrayToNestedJSONWithFirstValue(
1979
- this.props.activityOutputData ||
1980
- JSONToActivityOutputData(
1981
- this.props.tagsTree || {},
1982
- ),
1983
- this.props.dynamicFieldData ||
1984
- this.state
1985
- .dynamicFieldDataState ||
1986
- {},
1987
- )}
1988
- activityOutputDataRaw=${this.props
1989
- .activityOutputData ||
1990
- JSONToActivityOutputData(
1991
- this.props.tagsTree || {},
1992
- )}
1993
- placeHolder=${this.getPlaceholder(el)}
1994
- appName=${this.props.step.activity.app
1995
- .name}
1996
- selectedAuthId=${`${
1997
- this.props.stepMapping[
1998
- this.props.step.id
1999
- ]?.selectedAuthId ||
2000
- this.props.selectedAuthId ||
2001
- ''
2002
- }`}
2003
- sourceFlowData=${this.sourceFlowData(el)}
2004
- sourceFlowIntegrataionInvocationUrl=${el.source_flow_integration_invocation_url}
2005
- isMappable=${el.is_mappable}
2006
- isEditable=${el.is_editable}
2007
- allowTagsInText=${el.allow_tags_in_text}
2008
- refreshRootStepData=${this
2009
- .refreshRootStepData}
2010
- parentFieldChanged=${this.state
2011
- .parentFieldChanged?.[
2012
- this.state.changedParentMachineName
2013
- ]}
2014
- onChangeCallback=${this.props
2015
- .onFieldChangeCallback
2016
- ? (val: any) => {
2017
- if (
2018
- this.props.onFieldChangeCallback
2019
- ) {
2020
- this.onFieldChange({
2021
- stepId: step.id,
2022
- fieldId: el.id,
2023
- value: val,
2024
- isRequired: el.is_required,
2025
- machineName:
2026
- el.activity_field
2027
- ?.machine_name,
2028
- });
2029
- }
2030
- }
2031
- : null}
2032
- tagsTree=${this.props.showMappingMenu
2033
- ? this.props.tagsTree
2034
- : null}
2035
- showMenuOnLeft=${this.props
2036
- .showMenuOnLeft || false}
2037
- showFieldsLimit=${5}
2038
- />
2039
- </div>
2040
- `;
2041
- }
2042
- case 'CUSTOM_FIELDS': {
2043
- let fieldVal = null;
2044
- let fieldMappedVal = null;
2045
- let elParentFields = [];
2046
- if (
2047
- el.activity_field?.parent_fields &&
2048
- el.activity_field?.parent_fields !== ''
2049
- ) {
2050
- try {
2051
- elParentFields = JSON.parse(
2052
- el.activity_field?.parent_fields,
2053
- );
2054
- } catch (e) {
2055
- elParentFields = [];
2056
- }
2057
- }
2058
- if (this.props.onFieldChangeCallback) {
2059
- if (
2060
- Object.prototype.hasOwnProperty.call(
2061
- this.state.dynamicFieldsData || {},
2062
- el.activity_field?.machine_name || '',
2063
- )
2064
- ) {
2065
- fieldVal = this.state.dynamicFieldsData[
2066
- el.activity_field?.machine_name || ''
2067
- ];
2068
- } else {
2069
- fieldVal = el.default_value;
2070
- }
2071
- } else {
2072
- fieldMappedVal = this.props.stepDataMapping[
2073
- selectedStep.id
2074
- ]
2075
- ? this.props.stepDataMapping[
2076
- selectedStep.id
2077
- ][el.id]
2078
- : ({} as {
2079
- objectValue: Record<
2080
- string,
2081
- string | number
2082
- >;
2083
- });
2084
- fieldMappedVal = fieldMappedVal?.objectValue;
2085
- }
2086
-
2087
- return html`
2088
- <div
2089
- key=${el.id}
2090
- id=${`integry-action-field-wrap-${
2091
- el?.activity_field?.machine_name || ''
2092
- }`}
2093
- class=${`integry-action-field-wrap ${
2094
- el.is_visible ? '' : styles.fNotVisible
2095
- }`}
2096
- >
2097
- <${DynamicTypedField}
2098
- stepId=${selectedStep.id}
2099
- dynamicField=${el}
2100
- endpointData=${JSON.stringify({
2101
- authorization_id:
2102
- (this.props.stepMapping &&
2103
- this.props.stepMapping[
2104
- this.props.step.id
2105
- ]?.selectedAuthId) ||
2106
- this.props.selectedAuthId,
2107
- })}
2108
- placeHolder=${this.getPlaceholder(el)}
2109
- appName=${this.props.step.activity.app
2110
- .name}
2111
- selectedAuthId=${`${
2112
- this.props.stepMapping[
2113
- this.props.step.id
2114
- ]?.selectedAuthId ||
2115
- this.props.selectedAuthId ||
2116
- ''
2117
- }`}
2118
- sourceFlowIntegrataionInvocationUrl=${uiField
2119
- ?.data_source?.url}
2120
- isMappable=${this.props.showMappingMenu}
2121
- isDisabled=${false}
2122
- isEditable=${false}
2123
- allowTagsInText=${true}
2124
- apiHandler=${this.props.apiHandler}
2125
- idKeyPath=${uiField?.id_key_path}
2126
- typeKeyPath=${uiField?.type_key_path}
2127
- titleKeyPath=${uiField?.title_key_path}
2128
- isRequiredKeyPath=${uiField?.is_required_key_path}
2129
- onChangeCallback=${this.props
2130
- .onFieldChangeCallback
2131
- ? (val: any) => {
2132
- if (
2133
- this.props.onFieldChangeCallback
2134
- ) {
2135
- this.onFieldChange({
2136
- stepId: step.id,
2137
- fieldId: el.id,
2138
- value: val,
2139
- isRequired: el.is_required,
2140
- machineName:
2141
- el.activity_field
2142
- ?.machine_name,
2143
- });
2144
- }
2145
- }
2146
- : null}
2147
- tagsTree=${this.props.showMappingMenu
2148
- ? this.props.tagsTree
2149
- : null}
2150
- showMenuOnLeft=${this.props
2151
- .showMenuOnLeft || false}
2152
- dataSourceBody=${this.replacePlaceholders(
2153
- uiField?.data_source?.body || {},
2154
- this.state.dynamicFieldsData,
2155
- )}
2156
- parentFieldsChanged=${this.state
2157
- .parentFieldChanged?.[
2158
- this.state.changedParentMachineName
2159
- ] &&
2160
- elParentFields.includes(
2161
- this.state.changedParentMachineName,
2162
- )}
2163
- activityOutputData=${this.props
2164
- .showMappingMenu
2165
- ? this.props.tagsTreeActivityOutput
2166
- : this.arrayToNestedJSONWithFirstValue(
2167
- this.props.activityOutputData ||
2168
- JSONToActivityOutputData(
2169
- this.props.tagsTree || {},
2170
- ),
2171
- this.props.dynamicFieldData ||
2172
- this.state
2173
- .dynamicFieldDataState ||
2174
- {},
2175
- )}
2176
- activityOutputDataRaw=${this.props
2177
- .activityOutputData ||
2178
- JSONToActivityOutputData(
2179
- this.props.tagsTree || {},
2180
- )}
2181
- value=${fieldVal || fieldMappedVal}
2182
- allowWorkspaceConnectedAccounts=${!!this
2183
- .props.onFieldChangeCallback}
2184
- />
2185
- </div>
2186
- `;
2187
- }
2188
- case 'SECTION':
2189
- return html`
2190
- <div
2191
- key=${el.id}
2192
- id=${`integry-action-field-wrap-${
2193
- el?.activity_field?.machine_name || ''
2194
- }`}
2195
- class=${`integry-action-field-wrap`}
2196
- >
2197
- <${SectionField}
2198
- stepId=${selectedStep.id}
2199
- sectionField=${el}
2200
- endpointData=${JSON.stringify({
2201
- authorization_id:
2202
- this.props.stepMapping &&
2203
- this.props.stepMapping[
2204
- this.props.step.id
2205
- ]?.selectedAuthId,
2206
- ...this.fieldDynamicData(el),
2207
- })}
2208
- activityOutputData=${this.arrayToNestedJSONWithFirstValue(
2209
- this.props.activityOutputData,
2210
- {},
2211
- )}
2212
- activityOutputDataRaw=${this.props
2213
- .activityOutputData}
2214
- placeHolder=${this.getPlaceholder(el)}
2215
- appName=${this.props.step.activity.app
2216
- .name}
2217
- selectedAuthId=${`${
2218
- this.props.stepMapping[
2219
- this.props.step.id
2220
- ]?.selectedAuthId || ''
2221
- }`}
2222
- sourceFlowData=${this.sourceFlowData(el)}
2223
- sourceFlowIntegrataionInvocationUrl=${el.source_flow_integration_invocation_url}
2224
- isMappable=${el.is_mappable}
2225
- isEditable=${el.is_editable}
2226
- allowTagsInText=${el.allow_tags_in_text}
2227
- refreshRootStepData=${this
2228
- .refreshRootStepData}
2229
- description=${elDescription}
2230
- showStepValidation=${showStepValidation}
2231
- placeholder=${this.getPlaceholder(el)}
2232
- selectedStepData=${selectedStepData}
2233
- onFieldChange=${this.onFieldChange}
2234
- selectedStepElementData=${selectedStepElementData}
2235
- sourceFlowData=${this.sourceFlowData}
2236
- accountConnected=${accountConnected}
2237
- getFieldLabelTags=${getFieldLabelTags}
2238
- appName=${this.props.step.activity.app}
2239
- fieldDynamicData=${this.fieldDynamicData}
2240
- apiHandler=${this.props.apiHandler}
2241
- />
2242
- </div>
2243
- `;
2244
- case 'PASSWORD':
2245
- return html`
2246
- <div
2247
- key=${el.id}
2248
- id=${`integry-action-field-wrap-${
2249
- el?.activity_field?.machine_name || ''
2250
- }`}
2251
- class=${`integry-action-field-wrap ${
2252
- el.is_visible ? '' : styles.fNotVisible
2253
- }`}
2254
- >
2255
- <${PasswordInput}
2256
- title=${el.title ||
2257
- el.activity_field?.title}
2258
- description=${elDescription}
2259
- value=${(selectedStepData &&
2260
- selectedStepData[el.id] &&
2261
- selectedStepData[el.id].value) ||
2262
- ''}
2263
- placeholder=${el.placeholder ||
2264
- el.activity_field?.placeholder ||
2265
- 'Please enter a value'}
2266
- regex=${selectedStepData[el.id]
2267
- ? selectedStepData[el.id].regex
2268
- : ''}
2269
- regexErrorMessage=${selectedStepData[
2270
- el.id
2271
- ]
2272
- ? selectedStepData[el.id]
2273
- .regexErrorMessage
2274
- : ''}
2275
- showStepValidation=${showStepValidation}
2276
- isRequired=${el.is_required}
2277
- onChange=${(val: string) => {
2278
- setStepFieldData({
2279
- stepId: `${step.id}`,
2280
- fieldId: `${el.id}`,
2281
- value: val,
2282
- isRequired: el.is_required,
2283
- });
2284
- this.props.verifyStepValidity(step.id);
2285
- }}
2286
- isReadOnly=${isReadOnly}
2287
- isChanged=${selectedStepElementData &&
2288
- selectedStepElementData.isChanged}
2289
- />
2290
- </div>
2291
- `;
2292
- case 'TEXTAREA': {
2293
- let fieldVal = null;
2294
- if (this.props.onFieldChangeCallback) {
2295
- if (
2296
- Object.prototype.hasOwnProperty.call(
2297
- this.state.dynamicFieldsData || {},
2298
- el.activity_field?.machine_name || '',
2299
- )
2300
- ) {
2301
- fieldVal = this.state.dynamicFieldsData[
2302
- el.activity_field?.machine_name || ''
2303
- ];
2304
- } else {
2305
- fieldVal = el.default_value;
2306
- }
2307
- }
2308
- return html`
2309
- <div key=${
2310
- el.id
2311
- } id=${`integry-action-field-wrap-${
2312
- el?.activity_field?.machine_name || ''
2313
- }`} class=${`integry-action-field-wrap ${
2314
- el.is_visible ? '' : styles.fNotVisible
2315
- }`}>
2316
- <${ConfigureFieldWrapper}
2317
- field=${el}
2318
- stepId=${step.id}
2319
- templateId=${this.props.genericData?.templateId}
2320
- >
2321
- <${MultipurposeField}
2322
- title=${el.title || el.activity_field?.title}
2323
- description=${elDescription}
2324
- value=${
2325
- fieldVal ||
2326
- (selectedStepData &&
2327
- selectedStepData[el.id] &&
2328
- selectedStepData[el.id].value &&
2329
- selectedStepData[el.id].value !==
2330
- 'x-integry-skipped-field' &&
2331
- selectedStepData[el.id].value) ||
2332
- el.default_value ||
2333
- ''
2334
- }
2335
- placeholder=${this.getPlaceholder(el)}
2336
- regex=${
2337
- selectedStepData[el.id]
2338
- ? selectedStepData[el.id].regex
2339
- : ''
2340
- }
2341
- regexErrorMessage=${
2342
- selectedStepData[el.id]
2343
- ? selectedStepData[el.id]
2344
- .regexErrorMessage
2345
- : ''
2346
- }
2347
- showStepValidation=${showStepValidation}
2348
- isRequired=${el.is_required}
2349
- isHidden=${el.is_hidden}
2350
- onChange=${(
2351
- val: string,
2352
- passesRegexTest?: boolean,
2353
- ) => {
2354
- if (this.props.onFieldChangeCallback) {
2355
- this.onFieldChange({
2356
- stepId: step.id,
2357
- fieldId: el.id,
2358
- value: val,
2359
- isRequired: el.is_required,
2360
- machineName:
2361
- el.activity_field?.machine_name,
2362
- });
2363
- } else {
2364
- setStepFieldData({
2365
- stepId: `${step.id}`,
2366
- fieldId: `${el.id}`,
2367
- value: val,
2368
- isRequired: el.is_required,
2369
- passesRegexTest,
2370
- });
2371
- this.props.verifyStepValidity(step.id);
2372
- }
2373
- }}
2374
- isReadOnly=${isReadOnly}
2375
- isChanged=${
2376
- selectedStepElementData &&
2377
- selectedStepElementData.isChanged
2378
- }
2379
- type=${el.activity_field?.type}
2380
- labelTags=${getFieldLabelTags(el, false)}
2381
- activityOutputData=${
2382
- this.props.showMappingMenu
2383
- ? this.props.tagsTreeActivityOutput
2384
- : this.arrayToNestedJSONWithFirstValue(
2385
- this.props.activityOutputData ||
2386
- JSONToActivityOutputData(
2387
- this.props.tagsTree || {},
2388
- ),
2389
- this.props.dynamicFieldData ||
2390
- this.state.dynamicFieldDataState ||
2391
- {},
2392
- )
2393
- }
2394
- activityOutputDataRaw=${
2395
- this.props.activityOutputData ||
2396
- JSONToActivityOutputData(
2397
- this.props.tagsTree || {},
2398
- )
2399
- }
2400
- isMappable=${el.is_mappable}
2401
- isEditable=${el.is_editable}
2402
- allowTagsInText=${el.allow_tags_in_text}
2403
- fieldId=${
2404
- el?.activity_field?.machine_name ||
2405
- el.activity_field?.id ||
2406
- el.id
2407
- }
2408
- refreshRootStepData=${
2409
- this.refreshRootStepData
2410
- }
2411
- tagsComponent=${this.props.tagsComponent}
2412
- tagsTree=${
2413
- this.props.showMappingMenu
2414
- ? this.props.tagsTree
2415
- : null
2416
- }
2417
- showMenuOnLeft=${
2418
- this.props.showMenuOnLeft || false
2419
- }
2420
- />
2421
-
2422
- </${ConfigureFieldWrapper}>
2423
- </div>
2424
- `;
2425
- }
2426
- case 'DATE':
2427
- return html`
2428
- <div
2429
- key=${el.id}
2430
- id=${`integry-action-field-wrap-${
2431
- el?.activity_field?.machine_name || ''
2432
- }`}
2433
- class=${`integry-action-field-wrap ${
2434
- el.is_visible ? '' : styles.fNotVisible
2435
- }`}
2436
- >
2437
- <${DateInput}
2438
- title=${el.title ||
2439
- el.activity_field?.title}
2440
- description=${elDescription}
2441
- value=${(selectedStepData &&
2442
- selectedStepData[el.id] &&
2443
- selectedStepData[el.id].value) ||
2444
- ''}
2445
- placeholder=${el.placeholder ||
2446
- 'Please enter a value'}
2447
- showStepValidation=${showStepValidation}
2448
- isRequired=${el.is_required}
2449
- onChange=${(val: string) => {
2450
- setStepFieldData({
2451
- stepId: `${step.id}`,
2452
- fieldId: `${el.id}`,
2453
- value: val,
2454
- isRequired: el.is_required,
2455
- });
2456
- this.props.verifyStepValidity(step.id);
2457
- }}
2458
- isReadOnly=${isReadOnly}
2459
- isChanged=${selectedStepElementData &&
2460
- selectedStepElementData.isChanged}
2461
- />
2462
- </div>
2463
- `;
2464
- case 'FIELD_LIST':
2465
- return html``;
2466
- case 'FIELD_MAPPING':
2467
- return html`
2468
- <div
2469
- class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}
2470
- >
2471
- <${NewMappingUI}
2472
- stepId=${selectedStep.id}
2473
- templateFields=${selectedStep.template_fields}
2474
- showStepValidation=${showStepValidation}
2475
- ><//>
2476
- </div>
2477
- `;
2478
- case 'HTML':
2479
- return html` <${HTMLContent}
2480
- htmlContent=${el.default_value}
2481
- />`;
2482
-
2483
- case 'TEXT_CONTENT':
2484
- return html` <${TextContent}
2485
- textContent=${el.default_value}
2486
- />`;
2487
-
2488
- case 'FUNCTION_FIELD':
2489
- return html`
2490
- <${FunctionField}
2491
- field=${el}
2492
- name="${el.activity_field?.machine_name ||
2493
- 'function_field'}"
2494
- description=${elDescription}
2495
- label="${el.title}"
2496
- value=${el.default_value}
2497
- apiHandler=${this.props.apiHandler}
2498
- isArray=${!!(el.data_type === 'OBJECT[]')}
2499
- onChange=${(
2500
- val: string,
2501
- passesRegexTest?: boolean,
2502
- ) => {
2503
- if (this.props.onFieldChangeCallback) {
2504
- this.props.onFieldChangeCallback(
2505
- el.activity_field?.machine_name || '',
2506
- val,
2507
- );
2508
- } else {
2509
- setStepFieldData({
2510
- stepId: `${step.id}`,
2511
- fieldId: `${el.id}`,
2512
- value: this.getFieldValFromActivityOutputRaw(
2513
- this.props.activityOutputData,
2514
- val,
2515
- ),
2516
- isRequired: el.is_required,
2517
- passesRegexTest,
2518
- });
2519
- this.props.verifyStepValidity(step.id);
2520
- }
2521
- }}
2522
- tagsTree=${this.props.showMappingMenu
2523
- ? this.props.tagsTree
2524
- : null}
2525
- isReadOnly=${isReadOnly}
2526
- />
2527
- `;
2528
-
2529
- default:
2530
- // return html``;
2531
- return html` <div
2532
- class=${`${styles.actionStepFieldWrap} ${styles.unsupported}`}
2533
- >
2534
- Field: ${el.activity_field?.type} is currently
2535
- not supported
2536
- </div>`;
2537
- }
2538
- } else {
2539
- switch (el.type) {
2540
- case 'HTML':
2541
- return html`
2542
- <div
2543
- style="margin-bottom: 2rem;"
2544
- dangerouslySetInnerHTML=${{
2545
- __html: el.default_value,
2546
- }}
2547
- />
2548
- `;
2549
- case 'BUTTON':
2550
- return html`
2551
- <div style="margin-bottom: 2rem;">
2552
- <${Button} label=${el.title} />
2553
- </div>
2554
- `;
2555
- default:
2556
- break;
2557
- }
2558
- }
2559
- return html``;
2560
- })}
2561
- <!-- ${this.shouldShowOldMapping() &&
2562
- !this.shouldShowNewMapping() &&
2563
- html`
2564
- <div class=${styles.actionStepFieldWrap}>
2565
- <${MappingUI}
2566
- stepId=${selectedStep.id}
2567
- templateFields=${selectedStep.template_fields}
2568
- showStepValidation=${showStepValidation}
2569
- endpointData=${this.getMappingDataInput()}
2570
- key=${`mapping_ui_${selectedStep.id}`}
2571
- ><//>
2572
- </div>
2573
- `} -->
2574
- </div>
2575
- `
2576
- : html`Step data could not be loaded`}
2577
- `}
2578
- `;
2579
- }
2580
- }
2581
-
2582
- export default connect<
2583
- ActionFormPropsType,
2584
- ActionFormStateType,
2585
- StoreType,
2586
- unknown
2587
- >(
2588
- [
2589
- 'stepState',
2590
- 'stepMapping',
2591
- 'stepDataMapping',
2592
- 'parentChildMapping',
2593
- 'fieldListMapping',
2594
- 'conditionalFieldMapping',
2595
- 'embedConfig',
2596
- 'activityOutputData',
2597
- 'genericData',
2598
- 'userConfig',
2599
- 'authMapping',
2600
- ],
2601
- actionFunctions,
2602
- )(ActionForm);