@integry/sdk 4.5.2 → 4.5.3

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 (279) hide show
  1. package/.vscode/launch.json +2 -2
  2. package/THIRD_PARTY_LICENSES +0 -37
  3. package/dist/esm/index.csm.d.ts +12 -2
  4. package/dist/esm/index.csm.js +7262 -1
  5. package/dist/umd/index.umd.d.ts +9 -1
  6. package/dist/umd/index.umd.js +7262 -1
  7. package/jest.config.cjs +10 -0
  8. package/package.json +10 -4
  9. package/src/components/AddTagButton/index.ts +23 -0
  10. package/src/components/BasicSelect/index.ts +114 -0
  11. package/src/components/BasicSelect/styles.module.scss +44 -0
  12. package/src/components/Button/index.ts +94 -0
  13. package/src/components/Button/styles.module.scss +152 -0
  14. package/src/components/CheckboxGroup/Checkbox.ts +104 -0
  15. package/src/components/CheckboxGroup/index.ts +190 -0
  16. package/src/components/CheckboxGroup/styles.module.scss +63 -0
  17. package/src/components/CollapsedMenu/index.ts +101 -0
  18. package/src/components/CollapsedMenu/styles.module.scss +46 -0
  19. package/src/components/ConfigureFieldWrapper/index.ts +85 -0
  20. package/src/components/ConfigureFieldWrapper/styles.module.scss +57 -0
  21. package/src/components/EditableText/index.ts +121 -0
  22. package/src/components/EditableText/styles.module.scss +38 -0
  23. package/src/components/EditableTextArea/index.ts +143 -0
  24. package/src/components/EditableTextArea/styles.module.scss +91 -0
  25. package/src/components/ErrorMessage/index.ts +16 -0
  26. package/src/components/ErrorMessage/styles.module.scss +19 -0
  27. package/src/components/ErrorPage/index.ts +42 -0
  28. package/src/components/ErrorPage/styles.module.scss +26 -0
  29. package/src/components/Footer/index.ts +41 -0
  30. package/src/components/Footer/styles.module.scss +40 -0
  31. package/src/components/HTMLContent/index.tsx +275 -0
  32. package/src/components/HTMLContent/styles.module.scss +3 -0
  33. package/src/components/InfoBox/index.ts +48 -0
  34. package/src/components/InfoBox/styles.module.scss +21 -0
  35. package/src/components/Input/BaseInput/index.ts +170 -0
  36. package/src/components/Input/BaseInput/styles.module.scss +94 -0
  37. package/src/components/Input/DateInput/index.ts +103 -0
  38. package/src/components/Input/DateInput/styles.module.scss +50 -0
  39. package/src/components/Input/Input/index.ts +206 -0
  40. package/src/components/Input/Input/styles.module.scss +14 -0
  41. package/src/components/Input/PasswordInput/index.ts +164 -0
  42. package/src/components/Input/PasswordInput/styles.module.scss +37 -0
  43. package/src/components/Input/index.ts +7 -0
  44. package/src/components/Label/index.ts +61 -0
  45. package/src/components/Label/styles.module.scss +41 -0
  46. package/src/components/LargeLoader/index.ts +25 -0
  47. package/src/components/LargeLoader/styles.module.scss +16 -0
  48. package/src/components/Listbox/ListBoxItem.ts +57 -0
  49. package/src/components/Listbox/index.ts +479 -0
  50. package/src/components/Listbox/styles.module.scss +197 -0
  51. package/src/components/Loader/index.ts +25 -0
  52. package/src/components/Loader/styles.module.scss +16 -0
  53. package/src/components/MediaGallery/MediaGalleryModal.ts +82 -0
  54. package/src/components/MediaGallery/MediaSlider.ts +76 -0
  55. package/src/components/MediaGallery/index.ts +92 -0
  56. package/src/components/MediaGallery/styles.module.scss +156 -0
  57. package/src/components/MediaUpload/index.ts +233 -0
  58. package/src/components/MediaUpload/styles.module.scss +118 -0
  59. package/src/components/Modal/index.ts +87 -0
  60. package/src/components/Modal/styles.module.scss +441 -0
  61. package/src/components/MultipurposeField/Dropdown/ListBoxItem.tsx +58 -0
  62. package/src/components/MultipurposeField/Dropdown/index.tsx +981 -0
  63. package/src/components/MultipurposeField/Dropdown/styles.module.scss +208 -0
  64. package/src/components/MultipurposeField/TagMenu/index.ts +384 -0
  65. package/src/components/MultipurposeField/TagMenu/styles.module.scss +136 -0
  66. package/src/components/MultipurposeField/TagOptions/index.tsx +83 -0
  67. package/src/components/MultipurposeField/TagOptions/styles.module.scss +95 -0
  68. package/src/components/MultipurposeField/index.tsx +687 -0
  69. package/src/components/MultipurposeField/styles.module.scss +56 -0
  70. package/src/components/NewModal/index.ts +69 -0
  71. package/src/components/NewModal/styles.module.scss +70 -0
  72. package/src/components/OverflowTooltip/index.tsx +59 -0
  73. package/src/components/PopUp/ConfirmationPopUp/index.ts +58 -0
  74. package/src/components/PopUp/ConfirmationPopUp/styles.module.scss +49 -0
  75. package/src/components/PopUp/SuccessPopUp/index.ts +62 -0
  76. package/src/components/PopUp/SuccessPopUp/styles.module.scss +38 -0
  77. package/src/components/RadioGroup/Radio.ts +129 -0
  78. package/src/components/RadioGroup/index.ts +169 -0
  79. package/src/components/RadioGroup/styles.module.scss +81 -0
  80. package/src/components/Search/index.ts +69 -0
  81. package/src/components/Search/styles.module.scss +149 -0
  82. package/src/components/TabBar/Tab.ts +33 -0
  83. package/src/components/TabBar/index.ts +64 -0
  84. package/src/components/TabBar/styles.module.scss +43 -0
  85. package/src/components/Tag/index.ts +29 -0
  86. package/src/components/Tag/styles.module.scss +57 -0
  87. package/src/components/TextArea/index.ts +172 -0
  88. package/src/components/TextArea/styles.module.scss +70 -0
  89. package/src/components/TextContent/index.tsx +128 -0
  90. package/src/components/TextContent/styles.module.scss +6 -0
  91. package/src/components/ThreeDotLoader/index.ts +39 -0
  92. package/src/components/ThreeDotLoader/styles.module.scss +41 -0
  93. package/src/components/TimeInput/index.ts +129 -0
  94. package/src/components/TimeInput/styles.module.scss +16 -0
  95. package/src/components/Toggle/index.ts +34 -0
  96. package/src/components/Toggle/styles.module.scss +56 -0
  97. package/src/components/Toggle-v2/index.ts +40 -0
  98. package/src/components/Toggle-v2/styles.module.scss +86 -0
  99. package/src/components/Tooltip/index.ts +271 -0
  100. package/src/components/Tooltip/styles.module.scss +105 -0
  101. package/src/components/form/ObjectField/index.ts +364 -0
  102. package/src/components/form/ObjectField/styles.module.scss +103 -0
  103. package/src/components/form/index.ts +3 -0
  104. package/src/contexts/AppContext.ts +12 -0
  105. package/src/declaration.d.ts +7 -0
  106. package/src/extensions/HMAC.ts +25 -0
  107. package/src/extensions/IntegryAPIError.ts +19 -0
  108. package/src/features/common/AccountDropdown/index.ts +291 -0
  109. package/src/features/common/AccountDropdown/styles.module.scss +19 -0
  110. package/src/features/common/ActionForm/index.ts +1790 -0
  111. package/src/features/common/ActionForm/styles.module.scss +23 -0
  112. package/src/features/common/AppCard/index.ts +207 -0
  113. package/src/features/common/AppCard/styles.module.scss +117 -0
  114. package/src/features/common/AppCardCompact/index.ts +189 -0
  115. package/src/features/common/AppCardCompact/styles.module.scss +141 -0
  116. package/src/features/common/AuthSelector/index.ts +537 -0
  117. package/src/features/common/AuthSelector/styles.module.scss +161 -0
  118. package/src/features/common/AuthSelectorCompact/index.ts +706 -0
  119. package/src/features/common/AuthSelectorCompact/styles.module.scss +219 -0
  120. package/src/features/common/AuthSelectorDropdown/index.ts +704 -0
  121. package/src/features/common/AuthSelectorDropdown/styles.module.scss +361 -0
  122. package/src/features/common/DynamicField/index.ts +229 -0
  123. package/src/features/common/DynamicField/styles.module.scss +67 -0
  124. package/src/features/common/DynamicTypedField/index.ts +217 -0
  125. package/src/features/common/DynamicTypedField/styles.module.scss +67 -0
  126. package/src/features/common/FunctionForm/index.ts +862 -0
  127. package/src/features/common/FunctionForm/styles.module.scss +163 -0
  128. package/src/features/common/MappingUI/index.ts +649 -0
  129. package/src/features/common/MappingUI/styles.module.scss +121 -0
  130. package/src/features/common/MarketplaceAppCard/index.ts +279 -0
  131. package/src/features/common/MarketplaceAppCard/styles.module.scss +231 -0
  132. package/src/features/common/MarketplaceAppCardCompact/index.ts +283 -0
  133. package/src/features/common/MarketplaceAppCardCompact/styles.module.scss +255 -0
  134. package/src/features/common/NewMappingUI/index.ts +515 -0
  135. package/src/features/common/NewMappingUI/styles.module.scss +113 -0
  136. package/src/features/common/RequestAppWidget/RequestAppModal/index.ts +67 -0
  137. package/src/features/common/RequestAppWidget/RequestAppModal/styles.module.scss +23 -0
  138. package/src/features/common/RequestAppWidget/index.ts +48 -0
  139. package/src/features/common/RequestAppWidget/request-app-form.ts +89 -0
  140. package/src/features/common/RequestAppWidget/styles.module.scss +43 -0
  141. package/src/features/common/SectionField/index.ts +272 -0
  142. package/src/features/common/SectionField/styles.module.scss +67 -0
  143. package/src/features/common/Step/index.ts +827 -0
  144. package/src/features/common/Step/styles.module.scss +12 -0
  145. package/src/features/common/StepNavigation/CollapsedSteps.ts +125 -0
  146. package/src/features/common/StepNavigation/NavItem.ts +111 -0
  147. package/src/features/common/StepNavigation/index.ts +257 -0
  148. package/src/features/common/StepNavigation/styles.module.scss +117 -0
  149. package/src/features/common/Steps/index.ts +1139 -0
  150. package/src/features/common/Steps/styles.module.scss +314 -0
  151. package/src/features/containers/AppFlowContainer/AppFlowListing/compactStyles.module.scss +383 -0
  152. package/src/features/containers/AppFlowContainer/AppFlowListing/flow-instance.tsx +367 -0
  153. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCard.tsx +194 -0
  154. package/src/features/containers/AppFlowContainer/AppFlowListing/flowCardCompact.tsx +389 -0
  155. package/src/features/containers/AppFlowContainer/AppFlowListing/flowInstanceCompact.tsx +577 -0
  156. package/src/features/containers/AppFlowContainer/AppFlowListing/index.tsx +83 -0
  157. package/src/features/containers/AppFlowContainer/AppFlowListing/styles.module.scss +212 -0
  158. package/src/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader.tsx +45 -0
  159. package/src/features/containers/AppFlowContainer/AppFlowWrap/index.tsx +1081 -0
  160. package/src/features/containers/AppFlowContainer/AppFlowWrap/styles.module.scss +452 -0
  161. package/src/features/containers/AppFlowContainer/Authentication/index.ts +610 -0
  162. package/src/features/containers/AppFlowContainer/Authentication/styles.module.scss +468 -0
  163. package/src/features/containers/AppFlowContainer/index.ts +114 -0
  164. package/src/features/containers/AppPageContainer/AppPage/index.tsx +262 -0
  165. package/src/features/containers/AppPageContainer/AppPage/styles.module.scss +120 -0
  166. package/src/features/containers/AppPageContainer/IntegrationCard/index.ts +165 -0
  167. package/src/features/containers/AppPageContainer/IntegrationCard/styles.module.scss +81 -0
  168. package/src/features/containers/AppPageContainer/index.tsx +93 -0
  169. package/src/features/containers/AppPageContainer/styles.module.scss +0 -0
  170. package/src/features/containers/AppsForFlows/index.ts +161 -0
  171. package/src/features/containers/AppsForFlows/styles.module.scss +280 -0
  172. package/src/features/containers/AppsForFlowsCompact/index.ts +161 -0
  173. package/src/features/containers/AppsForFlowsCompact/styles.module.scss +279 -0
  174. package/src/features/containers/AuthSetupContainer/AppSelection.ts +73 -0
  175. package/src/features/containers/AuthSetupContainer/AuthTypeSelection.ts +67 -0
  176. package/src/features/containers/AuthSetupContainer/Footer.ts +32 -0
  177. package/src/features/containers/AuthSetupContainer/Header.ts +39 -0
  178. package/src/features/containers/AuthSetupContainer/PostAdditionPopup.ts +27 -0
  179. package/src/features/containers/AuthSetupContainer/index.ts +349 -0
  180. package/src/features/containers/AuthSetupContainer/styles.module.scss +229 -0
  181. package/src/features/containers/FlowSetupContainer/index.ts +390 -0
  182. package/src/features/containers/FlowSetupContainer/styles.module.scss +18 -0
  183. package/src/features/containers/MarkeplaceApps/index.ts +574 -0
  184. package/src/features/containers/MarkeplaceApps/styles.module.scss +559 -0
  185. package/src/features/containers/MarketplaceAppsCompact/index.ts +576 -0
  186. package/src/features/containers/MarketplaceAppsCompact/styles.module.scss +546 -0
  187. package/src/features/containers/MarketplaceAppsContainer/index.ts +83 -0
  188. package/src/features/containers/MarketplaceContainer/AppCard/index.ts +91 -0
  189. package/src/features/containers/MarketplaceContainer/AppCard/styles.module.scss +66 -0
  190. package/src/features/containers/MarketplaceContainer/AppListing/index.ts +34 -0
  191. package/src/features/containers/MarketplaceContainer/AppListing/styles.module.scss +10 -0
  192. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/index.ts +132 -0
  193. package/src/features/containers/MarketplaceContainer/MarketplaceContentWrap/styles.module.scss +117 -0
  194. package/src/features/containers/MarketplaceContainer/index.ts +242 -0
  195. package/src/features/containers/MarketplaceContainer/styles.module.scss +84 -0
  196. package/src/features/containers/SDKContainer/index.ts +817 -0
  197. package/src/features/containers/SDKContainer/styles.module.scss +266 -0
  198. package/src/features/containers/SDKDebugContainer/index.ts +137 -0
  199. package/src/features/containers/SDKDebugContainer/styles.module.scss +37 -0
  200. package/src/features/containers/SDKFailedContainer/index.ts +117 -0
  201. package/src/features/containers/SDKFailedContainer/styles.module.scss +57 -0
  202. package/src/features/integrations/IntegrationRow/Icons.ts +77 -0
  203. package/src/features/integrations/IntegrationRow/index.ts +129 -0
  204. package/src/features/integrations/IntegrationRow/styles.module.scss +62 -0
  205. package/src/features/integrations/IntegrationsHeader/index.ts +34 -0
  206. package/src/features/integrations/IntegrationsHeader/styles.module.scss +47 -0
  207. package/src/features/integrations/IntegrationsList/index.ts +252 -0
  208. package/src/features/integrations/IntegrationsList/styles.module.scss +67 -0
  209. package/src/features/templates/Template/index.ts +295 -0
  210. package/src/features/templates/Template/styles.module.scss +226 -0
  211. package/src/features/templates/TemplatesView/index.ts +368 -0
  212. package/src/features/templates/TemplatesView/styles.module.scss +71 -0
  213. package/src/features/templates/TemplatesViewCompact/index.ts +364 -0
  214. package/src/features/templates/TemplatesViewCompact/styles.module.scss +141 -0
  215. package/src/hooks/useAutosizeTextArea.ts +22 -0
  216. package/src/hooks/useCustomRef.ts +13 -0
  217. package/src/hooks/useDebounce.ts +17 -0
  218. package/src/hooks/useElementResize.ts +40 -0
  219. package/src/hooks/useEventListener.ts +44 -0
  220. package/src/hooks/useHover.ts +40 -0
  221. package/src/hooks/useOnClickOutside.ts +32 -0
  222. package/src/index.ts +2051 -0
  223. package/src/index.umd.ts +13 -0
  224. package/src/interfaces/index.ts +924 -0
  225. package/src/modules/api/index.ts +1315 -0
  226. package/src/modules/api/responseHandler.ts +38 -0
  227. package/src/modules/event-emitter/index.ts +72 -0
  228. package/src/modules/event-emitter/runners/abstract.ts +21 -0
  229. package/src/modules/event-emitter/runners/default.ts +11 -0
  230. package/src/modules/event-emitter/runners/ntimes.ts +28 -0
  231. package/src/modules/event-emitter/types.ts +34 -0
  232. package/src/store/actionFunctions.ts +1573 -0
  233. package/src/store/index.ts +17 -0
  234. package/src/store/initialState.ts +58 -0
  235. package/src/stories/Button.stories.tsx +83 -0
  236. package/src/stories/Checkbox/Checkbox.stories.tsx +41 -0
  237. package/src/stories/Checkbox/CheckboxGroup.stories.tsx +46 -0
  238. package/src/stories/EditableText.stories.tsx +35 -0
  239. package/src/stories/Input/BaseInput.stories.tsx +48 -0
  240. package/src/stories/Input/DateInput.stories.tsx +28 -0
  241. package/src/stories/Input/Input.stories.tsx +24 -0
  242. package/src/stories/Input/PasswordInput.stories.tsx +26 -0
  243. package/src/stories/Introduction.stories.mdx +211 -0
  244. package/src/stories/Label.stories.tsx +27 -0
  245. package/src/stories/Listbox.stories.tsx +122 -0
  246. package/src/stories/Radio/Radio.stories.tsx +39 -0
  247. package/src/stories/Radio/RadioGroup.stories.tsx +46 -0
  248. package/src/stories/StepNavigation/NavItem.stories.tsx +31 -0
  249. package/src/stories/StepNavigation/StepNavigation.stories.tsx +50 -0
  250. package/src/stories/TabBar.stories.tsx +31 -0
  251. package/src/stories/TextArea.stories.tsx +23 -0
  252. package/src/stories/TimeInput.stories.tsx +37 -0
  253. package/src/stories/Toggle.stories.tsx +33 -0
  254. package/src/stories/assets/code-brackets.svg +1 -0
  255. package/src/stories/assets/colors.svg +1 -0
  256. package/src/stories/assets/comments.svg +1 -0
  257. package/src/stories/assets/direction.svg +1 -0
  258. package/src/stories/assets/flow.svg +1 -0
  259. package/src/stories/assets/plugin.svg +1 -0
  260. package/src/stories/assets/repo.svg +1 -0
  261. package/src/stories/assets/stackalt.svg +1 -0
  262. package/src/types/index.ts +293 -0
  263. package/src/types/store.ts +366 -0
  264. package/src/types/utils.ts +19 -0
  265. package/src/utils/ActivityOutputUtils.ts +163 -0
  266. package/src/utils/common.ts +20 -0
  267. package/src/utils/copyToClipboard.ts +24 -0
  268. package/src/utils/datetime.ts +101 -0
  269. package/src/utils/getUrlParam.ts +11 -0
  270. package/src/utils/isAuthMessage.ts +16 -0
  271. package/src/utils/isBrowser.ts +1 -0
  272. package/src/utils/jsonEncodeDecode.ts +15 -0
  273. package/src/utils/objectUtils.ts +116 -0
  274. package/src/utils/popup.ts +30 -0
  275. package/src/utils/searchJson.ts +51 -0
  276. package/src/utils/stepUtils.ts +45 -0
  277. package/src/utils/truncate.ts +6 -0
  278. package/test/setup.ts +1 -0
  279. package/vitest.config.ts +10 -0
@@ -0,0 +1,1790 @@
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
+ TemplateField,
13
+ IncomingWebhookObject,
14
+ NestedObject,
15
+ } from '@/interfaces';
16
+ import { actionFunctions } from '@/store';
17
+ import MappingUI from '@/features/common/MappingUI';
18
+ import { Button } from '@/components/Button';
19
+ import { StoreType } from '@/types/store';
20
+ import { DateInput, Input, PasswordInput } from '@/components/Input';
21
+ import HTMLContent from '@/components/HTMLContent';
22
+ import TextContent from '@/components/TextContent';
23
+ // import { MappedField } from '@/components/MappedField/MappedField';
24
+ import { MultipurposeField } from '@/components/MultipurposeField';
25
+ import DynamicField from '@/features/common/DynamicField';
26
+ import SectionField from '@/features/common/SectionField';
27
+ import { TimeInput } from '@/components/TimeInput';
28
+ import NewMappingUI from '@/features/common/NewMappingUI';
29
+ import { ObjectField } from '@/components/form';
30
+ import { areParentValuesValid, getFieldLabelTags } from '@/utils/stepUtils';
31
+ import ConfigureFieldWrapper from '@/components/ConfigureFieldWrapper';
32
+ import {
33
+ JSONToActivityOutputData,
34
+ JSONToDynamicFieldData,
35
+ } from '@/utils/ActivityOutputUtils';
36
+
37
+ import styles from './styles.module.scss';
38
+
39
+ interface ActionFormPropsType extends StoreType {
40
+ step: IntegryStep;
41
+ stepType: 'AUTH' | 'CONFIGURATION' | 'SECTION';
42
+ showStepValidation: boolean;
43
+ apiHandler: IntegryAPI;
44
+ eventEmitter: EventEmitter<IntegrySDKEvents>;
45
+ isReadOnly?: boolean;
46
+ accountConnected: boolean;
47
+ }
48
+
49
+ interface ActionFormStateType {
50
+ loading: boolean;
51
+ dynamicFieldDataState: any;
52
+ }
53
+
54
+ interface StepDataMapping {
55
+ [key: string]: any;
56
+ }
57
+
58
+ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
59
+ constructor(props: ActionFormPropsType) {
60
+ super(props);
61
+ this.state = {
62
+ loading: false,
63
+ dynamicFieldDataState: {},
64
+ };
65
+ }
66
+
67
+ componentDidMount() {
68
+ const { step, verifyStepValidity } = this.props;
69
+ verifyStepValidity(step.id);
70
+ const triggerStep = this.props.genericData.stepWithActivityOutput;
71
+ if (triggerStep) {
72
+ const { id: triggerStepId } = triggerStep;
73
+ // eslint-disable-next-line no-use-before-define
74
+ const data = this.getVisibleFieldsDataOnRootStep(triggerStepId);
75
+ // eslint-disable-next-line no-use-before-define
76
+ this.setRootStepData(data);
77
+ } else {
78
+ this.setRootStepData({});
79
+ }
80
+ }
81
+
82
+ componentDidUpdate(prevProps: ActionFormPropsType) {
83
+ const { step, verifyStepValidity } = this.props;
84
+ if (prevProps.step.id !== step.id) {
85
+ verifyStepValidity(step.id);
86
+ const triggerStep = this.props.genericData.stepWithActivityOutput;
87
+ if (triggerStep) {
88
+ const { id: triggerStepId } = triggerStep;
89
+ // eslint-disable-next-line no-use-before-define
90
+ const data = this.getVisibleFieldsDataOnRootStep(triggerStepId);
91
+ // eslint-disable-next-line no-use-before-define
92
+ this.setRootStepData(data);
93
+ } else {
94
+ this.setRootStepData({});
95
+ }
96
+ }
97
+ }
98
+
99
+ getVisibleFieldsDataOnRootStep = (
100
+ stepId: number,
101
+ ): {
102
+ [machineName: string]: string;
103
+ } => {
104
+ const fields = this.props.stepDataMapping[stepId];
105
+ const requiredFieldsWithValues = Object.keys(fields)
106
+ .filter((el) => fields[Number(el)].value)
107
+ .reduce((prev, curr) => {
108
+ const currentItem = fields[Number(curr)];
109
+ return {
110
+ ...prev,
111
+ [currentItem.machineName]: currentItem.value,
112
+ };
113
+ }, {});
114
+
115
+ return requiredFieldsWithValues;
116
+ };
117
+
118
+ refreshRootStepData = async (callback?: any) => {
119
+ const triggerStep = this.props.genericData.stepWithActivityOutput;
120
+ if (triggerStep) {
121
+ const { id: triggerStepId } = triggerStep;
122
+ // eslint-disable-next-line no-use-before-define
123
+ const data = this.getVisibleFieldsDataOnRootStep(triggerStepId);
124
+ // eslint-disable-next-line no-use-before-define
125
+ this.setRootStepData(data, true, callback);
126
+ } else {
127
+ this.setRootStepData({}, true, callback);
128
+ }
129
+ };
130
+
131
+ setActivityOutputFromSourceStep = (
132
+ isRefresh?: boolean | false,
133
+ callback?: any,
134
+ integryObject?: any,
135
+ ) => {
136
+ const { setDynamicData } = this;
137
+ const setState = this.setState.bind(this);
138
+ const sourceSteps = this.props.step.source_steps;
139
+ const { stepMapping } = this.props;
140
+ const { props } = this;
141
+ Object.keys(sourceSteps).forEach((sourceStepKey) => {
142
+ const stepTagsSource = props.step.source_steps[sourceStepKey];
143
+ let hasSetData = false;
144
+ Object.keys(stepMapping).every((mappedStepIndex) => {
145
+ const stepIdOfSourceStep = stepMapping[mappedStepIndex].step.id;
146
+ if (
147
+ stepIdOfSourceStep &&
148
+ (stepMapping[stepIdOfSourceStep].step.machine_name ===
149
+ sourceStepKey ||
150
+ stepMapping[stepIdOfSourceStep].step.machine_name ===
151
+ stepTagsSource.form_step_machine_name) &&
152
+ !props.genericData.isTestIntegration
153
+ ) {
154
+ hasSetData = true;
155
+ if (stepTagsSource.activity_output_url) {
156
+ if (!isRefresh) {
157
+ setState({
158
+ loading: true,
159
+ });
160
+ }
161
+ const sourceStepData: NestedObject = {};
162
+ const stepDataMappingKeys = Object.keys(
163
+ props.stepDataMapping[stepIdOfSourceStep],
164
+ );
165
+ for (let i = 0; i < stepDataMappingKeys.length; i += 1) {
166
+ const stepDataMappingKey: string = stepDataMappingKeys[i];
167
+ const stepDataMapping: StepDataMapping =
168
+ props.stepDataMapping[stepIdOfSourceStep];
169
+ const stepDataMappingValue = stepDataMapping[stepDataMappingKey];
170
+ if (stepDataMappingValue.value) {
171
+ sourceStepData[stepDataMappingValue.machineName] =
172
+ stepDataMappingValue.value;
173
+ }
174
+ }
175
+
176
+ props.apiHandler
177
+ .callDynamicDataEndpoint<
178
+ {
179
+ text: string;
180
+ value: string;
181
+ }[]
182
+ >(new URL(stepTagsSource.activity_output_url), {
183
+ authorization_id: `${props.stepMapping[stepIdOfSourceStep].selectedAuthId}`,
184
+ ...sourceStepData,
185
+ })
186
+ .then((res) => {
187
+ setState({
188
+ loading: false,
189
+ });
190
+
191
+ let error = false;
192
+ if (res) {
193
+ props.setActivityOutputData({
194
+ activityOutputData: stepTagsSource.loop_variable_name
195
+ ? this.replaceContactPrefix(
196
+ res,
197
+ sourceStepKey,
198
+ stepTagsSource,
199
+ )
200
+ : res,
201
+ });
202
+ } else {
203
+ error = true;
204
+ }
205
+ if (callback) {
206
+ callback(error);
207
+ }
208
+ });
209
+ if (stepTagsSource.sample_data_endpoint_url && stepIdOfSourceStep) {
210
+ setDynamicData(
211
+ stepTagsSource.sample_data_endpoint_url,
212
+ stepIdOfSourceStep,
213
+ {
214
+ ...sourceStepData,
215
+ },
216
+ );
217
+ }
218
+ } else if (stepTagsSource.activity_output) {
219
+ setState({
220
+ loading: false,
221
+ });
222
+ if (callback) {
223
+ callback();
224
+ }
225
+ this.setActivityOutputFromIntegryObjectOrRawActivityOutput(
226
+ integryObject,
227
+ stepTagsSource,
228
+ sourceStepKey,
229
+ );
230
+ }
231
+ return false;
232
+ }
233
+
234
+ if (
235
+ (props.genericData.isTestIntegration ||
236
+ (!stepTagsSource.app_id &&
237
+ !this.canOverrideIntegryObject(integryObject))) &&
238
+ stepTagsSource.activity_output
239
+ ) {
240
+ setState({
241
+ loading: false,
242
+ });
243
+ if (callback) {
244
+ callback();
245
+ }
246
+ hasSetData = true;
247
+ this.setActivityOutputFromRawActivityOutput(
248
+ stepTagsSource,
249
+ sourceStepKey,
250
+ );
251
+ return false;
252
+ }
253
+ return true;
254
+ });
255
+
256
+ if (!hasSetData && stepTagsSource.activity_output) {
257
+ this.setActivityOutputFromIntegryObjectOrRawActivityOutput(
258
+ integryObject,
259
+ stepTagsSource,
260
+ sourceStepKey,
261
+ );
262
+ setState({
263
+ loading: false,
264
+ });
265
+ if (callback) {
266
+ callback();
267
+ }
268
+ hasSetData = true;
269
+
270
+ return false;
271
+ }
272
+ if (hasSetData) {
273
+ return false;
274
+ }
275
+ return true;
276
+ });
277
+ };
278
+
279
+ replaceContactPrefix = (
280
+ data: any,
281
+ sourceStepKey: any,
282
+ stepTagsSource: any,
283
+ ) => {
284
+ const replacementPrefix = `steps.${sourceStepKey}.out.${
285
+ stepTagsSource.loop_variable_name
286
+ ? `${stepTagsSource.loop_variable_name}`
287
+ : ''
288
+ }`;
289
+
290
+ return data.map((item: any) => ({
291
+ ...item,
292
+ value: item.value.replace('contact_v1', replacementPrefix),
293
+ }));
294
+ };
295
+
296
+ setActivityOutputFromRawActivityOutput = (
297
+ stepTagsSource: any,
298
+ sourceStepKey = '',
299
+ ) => {
300
+ try {
301
+ let objectPaylaod = {};
302
+ objectPaylaod = stepTagsSource.activity_output as IncomingWebhookObject;
303
+
304
+ const activityOutputData = JSONToActivityOutputData(
305
+ objectPaylaod,
306
+ '',
307
+ `steps.${sourceStepKey}.out.${
308
+ stepTagsSource.loop_variable_name
309
+ ? `${stepTagsSource.loop_variable_name}.`
310
+ : ''
311
+ }`,
312
+ );
313
+ const dynamicFieldData = JSONToDynamicFieldData(
314
+ objectPaylaod,
315
+ '',
316
+ `steps.${sourceStepKey}.out.${
317
+ stepTagsSource.loop_variable_name
318
+ ? `${stepTagsSource.loop_variable_name}.`
319
+ : ''
320
+ }`,
321
+ );
322
+ this.props.setIncomingWebhookPayload({
323
+ incomingWebhookPayload: objectPaylaod,
324
+ });
325
+ this.props.setActivityOutputData({
326
+ activityOutputData: activityOutputData || [],
327
+ });
328
+ this.props.setDynamicFieldData({
329
+ dynamicFieldData: dynamicFieldData || {},
330
+ });
331
+ this.setState({
332
+ dynamicFieldDataState: dynamicFieldData || {},
333
+ });
334
+ } catch (e) {
335
+ console.error(e);
336
+ }
337
+ };
338
+
339
+ setDynamicData = (url: string, stepId: number, data: any) => {
340
+ this.props.apiHandler
341
+ .callDynamicDataEndpoint<{
342
+ [fieldId: string]: (string | Record<string, string>)[];
343
+ }>(new URL(url), {
344
+ authorization_id: `${this.props.stepMapping[stepId].selectedAuthId}`,
345
+ ...data,
346
+ })
347
+ .then((res) => {
348
+ if (res) {
349
+ this.props.setDynamicFieldData({
350
+ dynamicFieldData: res,
351
+ });
352
+ this.setState({
353
+ dynamicFieldDataState: res,
354
+ });
355
+ }
356
+ });
357
+ };
358
+
359
+ canOverrideIntegryObject = (integryObject: any) => {
360
+ if (integryObject) {
361
+ try {
362
+ const parsedIntegryObject = JSON.parse(
363
+ integryObject,
364
+ ) as IncomingWebhookObject;
365
+
366
+ if (this.props.userConfig?.objects?.[parsedIntegryObject.name]) {
367
+ return true;
368
+ }
369
+ } catch (e) {
370
+ return false;
371
+ }
372
+ }
373
+ return false;
374
+ };
375
+
376
+ setActivityOutputFromIntegryObjectOrRawActivityOutput = (
377
+ integryObject: any,
378
+ stepTagsSource: any,
379
+ sourceStepKey = '',
380
+ ) => {
381
+ if (integryObject) {
382
+ try {
383
+ const parsedIntegryObject = JSON.parse(
384
+ integryObject,
385
+ ) as IncomingWebhookObject;
386
+ let objectPaylaod = {};
387
+ if (this.props.userConfig?.objects?.[parsedIntegryObject.name]) {
388
+ objectPaylaod = this.props.userConfig?.objects?.[
389
+ parsedIntegryObject.name
390
+ ];
391
+ } else {
392
+ objectPaylaod = JSON.parse(parsedIntegryObject.payload);
393
+ }
394
+ const activityOutputData = JSONToActivityOutputData(
395
+ objectPaylaod,
396
+ '',
397
+ `steps.${sourceStepKey}.out.${
398
+ stepTagsSource.loop_variable_name
399
+ ? `${stepTagsSource.loop_variable_name}.`
400
+ : ''
401
+ }`,
402
+ );
403
+ const dynamicFieldData = JSONToDynamicFieldData(
404
+ objectPaylaod,
405
+ '',
406
+ `steps.${sourceStepKey}.out.${
407
+ stepTagsSource.loop_variable_name
408
+ ? `${stepTagsSource.loop_variable_name}.`
409
+ : ''
410
+ }`,
411
+ );
412
+ this.props.setIncomingWebhookPayload({
413
+ incomingWebhookPayload: objectPaylaod,
414
+ });
415
+ this.props.setActivityOutputData({
416
+ activityOutputData: activityOutputData || [],
417
+ });
418
+ this.props.setDynamicFieldData({
419
+ dynamicFieldData: dynamicFieldData || {},
420
+ });
421
+ this.setState({
422
+ dynamicFieldDataState: dynamicFieldData || {},
423
+ });
424
+ } catch (e) {
425
+ console.error(e);
426
+ }
427
+ } else {
428
+ this.setActivityOutputFromRawActivityOutput(
429
+ stepTagsSource,
430
+ sourceStepKey,
431
+ );
432
+ }
433
+ };
434
+
435
+ setRootStepData = async (
436
+ additionalData: Record<string, string> | undefined,
437
+ isRefresh?: boolean | false,
438
+ callback?: any,
439
+ ) => {
440
+ const triggerStep = this.props.genericData.stepWithActivityOutput;
441
+ let integryObject = triggerStep?.template_fields.find(
442
+ (el) => el.activity_field?.machine_name === 'integry_webhook_object',
443
+ )?.default_value;
444
+
445
+ if (integryObject) {
446
+ let parsedIntegryObject = {};
447
+ try {
448
+ parsedIntegryObject = JSON.parse(integryObject || '{}');
449
+ } catch (e) {
450
+ parsedIntegryObject = {};
451
+ }
452
+
453
+ /**
454
+ * this is to handle the case where the integry object is not in the format
455
+ * { payload: {}, name: '' }
456
+ */
457
+ const payloadName = triggerStep?.template_fields.find(
458
+ (el) => el.activity_field?.machine_name === 'payload_name',
459
+ )?.default_value;
460
+ parsedIntegryObject = {
461
+ payload: integryObject || '{}',
462
+ name: payloadName || 'payload',
463
+ };
464
+ integryObject = JSON.stringify(parsedIntegryObject);
465
+ }
466
+ this.props.setActivityOutputData({
467
+ activityOutputData: [],
468
+ });
469
+ if (
470
+ this.props.step.source_steps &&
471
+ Object.keys(this.props.step.source_steps).length > 0
472
+ ) {
473
+ this.setActivityOutputFromSourceStep(isRefresh, callback, integryObject);
474
+ } else if (triggerStep) {
475
+ const { id: triggerStepId } = triggerStep;
476
+
477
+ if (triggerStep.activity.activity_output_url) {
478
+ if (!isRefresh) {
479
+ // we don't want to set loading when refreshing the data
480
+ this.setState({
481
+ loading: true,
482
+ });
483
+ }
484
+ // setRootDataLoading(true);
485
+ this.props.apiHandler
486
+ .callDynamicDataEndpoint<
487
+ {
488
+ text: string;
489
+ value: string;
490
+ }[]
491
+ >(new URL(triggerStep.activity.activity_output_url), {
492
+ authorization_id: `${this.props.stepMapping[triggerStepId].selectedAuthId}`,
493
+ ...additionalData,
494
+ })
495
+ .then((res) => {
496
+ // setRootDataLoading(false);
497
+ this.setState({
498
+ loading: false,
499
+ });
500
+ if (callback) {
501
+ callback();
502
+ }
503
+ if (res)
504
+ this.props.setActivityOutputData({
505
+ activityOutputData: res,
506
+ });
507
+ });
508
+ } else if (triggerStep.activity.activity_output) {
509
+ // setRootDataLoading(false);
510
+ this.setActivityOutputFromIntegryObjectOrRawActivityOutput(
511
+ integryObject,
512
+ triggerStep.activity,
513
+ );
514
+ this.setState({
515
+ loading: false,
516
+ });
517
+ if (callback) {
518
+ callback();
519
+ }
520
+ } else {
521
+ this.setState({
522
+ loading: false,
523
+ });
524
+ if (callback) {
525
+ callback();
526
+ }
527
+ }
528
+
529
+ if (triggerStep.activity.dynamic_field_data_endpoint) {
530
+ this.setDynamicData(
531
+ triggerStep.activity.dynamic_field_data_endpoint,
532
+ triggerStepId,
533
+ additionalData,
534
+ );
535
+ }
536
+ }
537
+ };
538
+
539
+ removeCurlyBraces = (value: string): string =>
540
+ value.replace(/^{(.*)}$/, '$1');
541
+
542
+ isNotJSON = (obj: any) => {
543
+ try {
544
+ if (Array.isArray(obj) && obj.length > 0 && typeof obj[0] === 'object') {
545
+ return false;
546
+ }
547
+ JSON.parse(obj);
548
+ if (Number(obj)) {
549
+ return true;
550
+ }
551
+ return false;
552
+ } catch (e) {
553
+ return true;
554
+ }
555
+ };
556
+
557
+ arrayToNestedJSONWithFirstValue = (array: any, valueObj: any) => {
558
+ let tempValueObj: any = {};
559
+ let arrayUpdated = [];
560
+ if (array && Array.isArray(array)) {
561
+ arrayUpdated = array;
562
+ }
563
+ Object.keys(valueObj || {}).forEach((i) => {
564
+ const key = this.removeCurlyBraces(i);
565
+ tempValueObj = {
566
+ ...tempValueObj,
567
+ [key]: valueObj[i] || '',
568
+ };
569
+ });
570
+ let flatForm = {};
571
+ (arrayUpdated || []).forEach((arr: any) => {
572
+ flatForm = {
573
+ ...flatForm,
574
+ [arr.text]: valueObj[arr.value] || '',
575
+ };
576
+ });
577
+
578
+ const result = {};
579
+ (arrayUpdated || []).forEach((item: any) => {
580
+ if (!item.text || !item.value) {
581
+ return;
582
+ }
583
+ const keys = item.text.split('.');
584
+ let currentLevel: any = result;
585
+ keys.forEach((key: any, index: any) => {
586
+ if (!currentLevel[key]) {
587
+ if (index === keys.length - 1) {
588
+ if (tempValueObj[item.value]) {
589
+ if (
590
+ tempValueObj[item.value][0] &&
591
+ this.isNotJSON(tempValueObj[item.value][0])
592
+ ) {
593
+ // eslint-disable-next-line prefer-destructuring
594
+ currentLevel[key] = tempValueObj[item.value][0] || '';
595
+ } else {
596
+ currentLevel[key] = '';
597
+ }
598
+ } else {
599
+ currentLevel[key] = '';
600
+ }
601
+ } else {
602
+ currentLevel[key] = {};
603
+ }
604
+ }
605
+ currentLevel = currentLevel[key];
606
+ });
607
+ });
608
+ return result;
609
+ };
610
+
611
+ getFieldValFromActivityOutputRaw = (array: any, val: string) => {
612
+ const results = val.match(/{([^}]+)}/g);
613
+ let valSubstituded = val;
614
+ (results || []).forEach((tag: string) => {
615
+ const tagCheck = tag.replace(/{|}/g, '');
616
+ (array || []).forEach((arr: any) => {
617
+ if (arr.text === tagCheck) {
618
+ valSubstituded = valSubstituded.replace(tag, `{${arr.value}}`);
619
+ }
620
+ });
621
+ });
622
+ return valSubstituded;
623
+ };
624
+
625
+ private getStepVisibleFieldsData = (
626
+ stepId: number,
627
+ ): {
628
+ [machineName: string]: string;
629
+ } => {
630
+ const fields = this.props.stepDataMapping[stepId];
631
+ const requiredFieldsWithValues = Object.keys(fields)
632
+ .filter((el) => fields[Number(el)].value)
633
+ .reduce((prev, curr) => {
634
+ const currentItem = fields[Number(curr)];
635
+ return {
636
+ ...prev,
637
+ [currentItem.machineName]: currentItem.value,
638
+ };
639
+ }, {});
640
+ return requiredFieldsWithValues;
641
+ };
642
+
643
+ private areParentValuesFilled = (stepId: number, parentFields: string[]) => {
644
+ let valid = true;
645
+ // check if all parent fields have their values set
646
+ for (let index = 0; index < parentFields.length; index += 1) {
647
+ const val = parentFields[index];
648
+ let fieldId = null;
649
+ if (this.props.parentChildMapping[stepId][val]) {
650
+ fieldId = this.props.parentChildMapping[stepId][val].fieldId;
651
+ }
652
+ const parentField =
653
+ fieldId &&
654
+ this.props.stepDataMapping[stepId] &&
655
+ this.props.stepDataMapping[stepId][fieldId];
656
+ if (!(parentField && parentField.value)) {
657
+ valid = false;
658
+ break;
659
+ }
660
+ }
661
+ return valid;
662
+ };
663
+
664
+ private doParentFieldsHaveValues = (stepId: number, machineName: string) => {
665
+ let valid = true;
666
+ const fieldInfo = this.props.parentChildMapping[stepId][machineName];
667
+ if (fieldInfo && fieldInfo.parentFields)
668
+ // check if all parent fields have their values set
669
+ for (let index = 0; index < fieldInfo.parentFields.length; index += 1) {
670
+ const parentField = this.props.parentChildMapping[stepId][
671
+ fieldInfo.parentFields[index]
672
+ ];
673
+ const parentFieldData =
674
+ parentField &&
675
+ this.props.stepDataMapping[stepId] &&
676
+ this.props.stepDataMapping[stepId][parentField.fieldId];
677
+ if (!(parentFieldData && parentFieldData.value)) {
678
+ valid = false;
679
+ break;
680
+ }
681
+ }
682
+ return valid;
683
+ };
684
+
685
+ private shouldShowStep = (field: TemplateField) => {
686
+ const stepId = this.props.step.id;
687
+ const stepObject = this.props.stepMapping && this.props.stepMapping[stepId];
688
+
689
+ if (
690
+ field.type === 'BUTTON' ||
691
+ field.type === 'HTML' ||
692
+ field.type === 'SECTION'
693
+ )
694
+ return true;
695
+
696
+ if (stepObject && field.activity_field) {
697
+ if (this.props.userConfig && this.props.userConfig.viewAsIU) return true;
698
+ const shouldBeShown = !field.is_hidden;
699
+ // const isAuthSelected = stepObject.selectedAuthId;
700
+ const isAuthSelected = true;
701
+
702
+ const { parentFields } = this.props.parentChildMapping[stepId][
703
+ field.activity_field.machine_name
704
+ ];
705
+
706
+ const fieldConditions = this.props.conditionalFieldMapping[stepId][
707
+ field.activity_field.machine_name
708
+ ];
709
+ let isParentFilled = true;
710
+ let isConditionValid = true;
711
+ if (parentFields) {
712
+ isParentFilled = this.areParentValuesFilled(stepId, parentFields);
713
+ }
714
+
715
+ if (fieldConditions) {
716
+ isConditionValid = areParentValuesValid(
717
+ stepId,
718
+ fieldConditions,
719
+ this.props.stepDataMapping,
720
+ );
721
+ }
722
+ const isValid = isParentFilled && isConditionValid;
723
+
724
+ return shouldBeShown && isAuthSelected && isValid;
725
+ }
726
+ return false;
727
+ };
728
+
729
+ private stepIsOfType = (fields: string[]) => {
730
+ const stepId = this.props.step.id;
731
+ const stepObject = this.props.stepMapping && this.props.stepMapping[stepId];
732
+ return fields.indexOf(stepObject.step.activity.type) > -1;
733
+ };
734
+
735
+ private textFieldParentHasValues = (currentField: any) => {
736
+ const stepId = this.props.step.id;
737
+ const stepObject = this.props.stepMapping && this.props.stepMapping[stepId];
738
+
739
+ const anyVisibleFields = stepObject.step.template_fields.filter(
740
+ (el) => el.is_visible,
741
+ );
742
+
743
+ // ignore auth incase of configMode, or viewAsIU
744
+ const isAuthSelected =
745
+ this.props?.userConfig && this.props?.userConfig.viewAsIU
746
+ ? true
747
+ : stepObject.selectedAuthId;
748
+
749
+ const dynamicField = anyVisibleFields.filter(
750
+ (el) => el.activity_field && el.activity_field.type === 'DYNAMIC',
751
+ )[0];
752
+ if (!dynamicField) {
753
+ return true;
754
+ }
755
+
756
+ let isFieldChild = false;
757
+ anyVisibleFields.forEach((field) => {
758
+ const { activity_field } = field;
759
+ const { activity_field: current_activity_field } = currentField;
760
+ if (
761
+ activity_field?.child_fields?.includes(
762
+ current_activity_field.machine_name,
763
+ )
764
+ ) {
765
+ isFieldChild = true;
766
+ }
767
+ });
768
+
769
+ if (!isFieldChild) {
770
+ return true;
771
+ }
772
+
773
+ if (
774
+ anyVisibleFields.length > 0 &&
775
+ currentField &&
776
+ currentField.activity_field &&
777
+ isAuthSelected &&
778
+ this.doParentFieldsHaveValues(
779
+ stepId,
780
+ currentField.activity_field.machine_name,
781
+ )
782
+ ) {
783
+ return true;
784
+ }
785
+ return false;
786
+ };
787
+
788
+ private shouldShowOldMapping = () => {
789
+ const stepId = this.props.step.id;
790
+ const stepObject = this.props.stepMapping && this.props.stepMapping[stepId];
791
+ if (this.stepIsOfType(['ADAPTER', 'ACTION'])) {
792
+ const anyVisibleFields = stepObject.step.template_fields.filter(
793
+ (el) => el.is_visible,
794
+ );
795
+
796
+ const anyVisibleTextFields = stepObject.step.template_fields.filter(
797
+ (el) => el.is_visible && el.activity_field?.type === 'TEXTFIELD',
798
+ );
799
+
800
+ const isAuthSelected = stepObject.selectedAuthId;
801
+
802
+ const dynamicField = anyVisibleFields.filter(
803
+ (el) => el.activity_field && el.activity_field.type === 'DYNAMIC',
804
+ )[0];
805
+
806
+ // show mapping whenever we have visible text fields and a selected auth
807
+ if (
808
+ anyVisibleTextFields.length > 0 &&
809
+ isAuthSelected &&
810
+ !dynamicField &&
811
+ !this.shouldShowNewMapping()
812
+ )
813
+ return true;
814
+
815
+ // in case we dont have visible text fields and no dynamic fields, dont show mapping
816
+ if (!dynamicField) {
817
+ return false;
818
+ }
819
+
820
+ if (
821
+ anyVisibleFields.length > 0 &&
822
+ isAuthSelected &&
823
+ dynamicField &&
824
+ dynamicField.activity_field &&
825
+ this.doParentFieldsHaveValues(
826
+ stepId,
827
+ dynamicField.activity_field.machine_name,
828
+ )
829
+ ) {
830
+ const fieldConditions = this.props.conditionalFieldMapping[stepId][
831
+ dynamicField.activity_field.machine_name
832
+ ];
833
+ if (fieldConditions) {
834
+ return areParentValuesValid(
835
+ stepId,
836
+ fieldConditions,
837
+ this.props.stepDataMapping,
838
+ );
839
+ }
840
+ return true;
841
+ }
842
+ return false;
843
+ }
844
+ return false;
845
+ };
846
+
847
+ private shouldShowNewMapping = () => {
848
+ const { step, stepMapping } = this.props;
849
+ const stepObject = stepMapping[step.id];
850
+
851
+ if (this.stepIsOfType(['ADAPTER', 'ACTION'])) {
852
+ const anyVisibleFields = stepObject.step.template_fields.filter(
853
+ (el) => el.is_visible,
854
+ );
855
+
856
+ if (anyVisibleFields) {
857
+ const fieldMappingField = anyVisibleFields.filter(
858
+ (el) =>
859
+ el.activity_field && el.activity_field.type === 'FIELD_MAPPING',
860
+ )[0];
861
+ if (fieldMappingField) {
862
+ return true;
863
+ }
864
+ }
865
+ }
866
+ return false;
867
+ };
868
+
869
+ private getMappingDataInput = () => {
870
+ const stepId = this.props.step.id;
871
+ const stepObject = this.props.stepMapping && this.props.stepMapping[stepId];
872
+ const payload = {
873
+ authId: stepObject.selectedAuthId,
874
+ fieldsData: this.getStepVisibleFieldsData(stepId),
875
+ };
876
+ return payload;
877
+ };
878
+
879
+ private onFieldChange = ({
880
+ stepId,
881
+ fieldId,
882
+ value,
883
+ isRequired,
884
+ }: {
885
+ stepId: number;
886
+ fieldId: number;
887
+ value: string;
888
+ isRequired: boolean;
889
+ }) => {
890
+ this.props.setStepFieldData({
891
+ stepId: `${stepId}`,
892
+ fieldId: `${fieldId}`,
893
+ value,
894
+ isRequired,
895
+ });
896
+ this.props.clearChildFields({ stepId, fieldId });
897
+ this.props.verifyStepValidity(Number(stepId));
898
+ };
899
+
900
+ private fieldDynamicData = (field: TemplateField) => {
901
+ const stepId = this.props.step.id;
902
+ const stepObject = this.props.stepMapping && this.props.stepMapping[stepId];
903
+ if (stepObject && field.activity_field) {
904
+ const parentFields =
905
+ this.props.parentChildMapping[stepId][field.activity_field.machine_name]
906
+ ?.parentFields || null;
907
+ if (parentFields) {
908
+ const endpointData = parentFields.reduce((prev, next) => {
909
+ const { fieldId } = this.props.parentChildMapping[stepId][next];
910
+ if (fieldId)
911
+ return {
912
+ ...prev,
913
+ [next]: this.props.stepDataMapping[stepId][fieldId].value,
914
+ };
915
+ return prev;
916
+ }, {});
917
+ return endpointData;
918
+ }
919
+ }
920
+ return null;
921
+ };
922
+
923
+ private sourceFlowData = (field: TemplateField) => {
924
+ if (field.source_flow_integration_invocation_url) {
925
+ // when source_flow_integration_invocation_url is present, we will pass all steps data to the endpoint
926
+ const { stepMapping, stepDataMapping } = this.props;
927
+ const endpointData = Object.keys(stepMapping).reduce((prev, next) => {
928
+ const { machine_name, id: stepId } = stepMapping[next].step;
929
+ if (machine_name)
930
+ return {
931
+ ...prev,
932
+ [machine_name]: {
933
+ in: Object.keys(stepDataMapping[stepId]).reduce(
934
+ (prevFieldObj, nextFieldId) => {
935
+ const fieldId = parseInt(nextFieldId, 10);
936
+ if (stepDataMapping[stepId][fieldId]) {
937
+ const { value, machineName } = stepDataMapping[stepId][
938
+ fieldId
939
+ ];
940
+ return {
941
+ ...prevFieldObj,
942
+ [machineName]: value,
943
+ };
944
+ }
945
+ return prevFieldObj;
946
+ },
947
+ {},
948
+ ),
949
+ },
950
+ };
951
+ return prev;
952
+ }, {});
953
+ return {
954
+ steps: {
955
+ ...endpointData,
956
+ },
957
+ };
958
+ }
959
+ return null;
960
+ };
961
+
962
+ private isHTML = (value: string): boolean => {
963
+ if (/<\/?[a-z][\s\S]*>/i.test(value)) {
964
+ return true;
965
+ }
966
+ return false;
967
+ };
968
+
969
+ private getPlaceholder = (field: TemplateField) => {
970
+ let appName =
971
+ this.props.genericData.stepWithActivityOutput?.activity?.app?.name ===
972
+ 'Incoming Webhook'
973
+ ? this.props.genericData.selfAppName
974
+ : this.props.genericData.stepWithActivityOutput?.activity?.app?.name ||
975
+ '';
976
+ // this.props.genericData.marketplaceDetail?.app_instance?.account?.name ||
977
+ // '';
978
+ if (!appName || appName.includes('Webhook')) {
979
+ const sourceSteps = this.props.step.source_steps;
980
+ const { stepMapping } = this.props;
981
+ const { props } = this;
982
+ let sourceStepAppId = null;
983
+ Object.keys(sourceSteps).forEach((sourceStepKey) => {
984
+ const stepTagsSource = props.step.source_steps[sourceStepKey];
985
+ sourceStepAppId = stepTagsSource.app_id;
986
+ if (stepTagsSource.app_name) {
987
+ appName = stepTagsSource.app_name;
988
+ } else {
989
+ Object.keys(stepMapping).every((mappedStepIndex) => {
990
+ if (
991
+ stepMapping[mappedStepIndex].step.authorization_type.app.id ===
992
+ stepTagsSource.app_id
993
+ ) {
994
+ appName = stepMapping[mappedStepIndex].step.activity.app.name;
995
+ }
996
+ return true;
997
+ });
998
+ }
999
+ });
1000
+ if (appName?.includes('Incoming Webhook') && sourceStepAppId === null) {
1001
+ appName = 'Webhook';
1002
+ }
1003
+ }
1004
+ if (
1005
+ field.activity_field?.type === 'TEXTAREA' ||
1006
+ field.activity_field?.type === 'TEXTFIELD' ||
1007
+ field.activity_field?.type === 'DYNAMIC'
1008
+ ) {
1009
+ return field.is_editable &&
1010
+ !field.is_mappable &&
1011
+ !field.allow_tags_in_text
1012
+ ? 'Enter text...'
1013
+ : !field.is_editable && field.is_mappable
1014
+ ? `Map to a ${appName} field...`
1015
+ : field.is_editable && (field.is_mappable || field.allow_tags_in_text)
1016
+ ? `Enter text or map to a ${appName} field...`
1017
+ : 'Please enter a value';
1018
+ }
1019
+ if (
1020
+ field.activity_field?.type === 'CHECKBOX' ||
1021
+ field.activity_field?.type === 'SELECT' ||
1022
+ field.activity_field?.type === 'RADIO'
1023
+ ) {
1024
+ return field.is_editable &&
1025
+ !field.is_mappable &&
1026
+ !field.allow_tags_in_text
1027
+ ? 'Enter text or select a value...'
1028
+ : !field.is_editable && field.is_mappable
1029
+ ? `Select a value or map to a ${appName} field...`
1030
+ : field.is_editable && field.allow_tags_in_text
1031
+ ? `Enter text with ${appName} fields or select a value...`
1032
+ : field.is_editable && field.is_mappable
1033
+ ? `Enter text, select a value or map to a ${appName} field...`
1034
+ : 'Select a value...';
1035
+ }
1036
+ return field.activity_field?.type === 'TEXTAREA' ||
1037
+ field.activity_field?.type === 'TEXTFIELD'
1038
+ ? 'Enter text...'
1039
+ : field.activity_field?.type === 'CHECKBOX' ||
1040
+ field.activity_field?.type === 'SELECT' ||
1041
+ field.activity_field?.type === 'RADIO'
1042
+ ? 'Select a value...'
1043
+ : '';
1044
+ };
1045
+
1046
+ private replacePlaceholders = (
1047
+ templateObj: { [key: string]: any },
1048
+ dictionary: { [key: string]: any },
1049
+ ): { [key: string]: any } => {
1050
+ const updatedObj: { [key: string]: any } = {};
1051
+
1052
+ // Use Object.entries to iterate over keys and values
1053
+ Object.entries(templateObj).forEach(([key, value]) => {
1054
+ // If the value is a string and contains a placeholder, replace it
1055
+ if (typeof value === 'string' && value.includes('{')) {
1056
+ // Extract the placeholder key between `{}` and use it to replace with the dictionary value
1057
+ const placeholderKey = value.match(/{(.*?)}/);
1058
+
1059
+ if (placeholderKey && placeholderKey[1]) {
1060
+ const keyPath = placeholderKey[1]; // Extract full key path from the placeholder
1061
+ const lastPartKey = keyPath.split('.').pop(); // Get the last part of the key path
1062
+
1063
+ // Check if dictionary has an exact match for the full path or the last part of the path
1064
+ if (dictionary[keyPath] !== undefined) {
1065
+ // Replace using the exact match
1066
+ updatedObj[key] = value.replace(
1067
+ placeholderKey[0],
1068
+ dictionary[keyPath],
1069
+ );
1070
+ } else if (lastPartKey && dictionary[lastPartKey] !== undefined) {
1071
+ // Replace using the last part match
1072
+ updatedObj[key] = value.replace(
1073
+ placeholderKey[0],
1074
+ dictionary[lastPartKey],
1075
+ );
1076
+ }
1077
+ }
1078
+ } else if (typeof value === 'string' && value) {
1079
+ // If the value is a string but doesn't contain placeholders, retain it as is
1080
+ updatedObj[key] = value;
1081
+ }
1082
+ });
1083
+
1084
+ // Return the updated object containing only keys with replaced values
1085
+ return updatedObj;
1086
+ };
1087
+
1088
+ render() {
1089
+ const {
1090
+ step,
1091
+ stepMapping,
1092
+ stepDataMapping,
1093
+ setStepFieldData,
1094
+ showStepValidation,
1095
+ isReadOnly,
1096
+ accountConnected,
1097
+ } = this.props;
1098
+ const selectedStep = stepMapping[step.id] && stepMapping[step.id].step;
1099
+ const selectedStepData = stepDataMapping && stepDataMapping[step.id];
1100
+ const actionConfigPayload = {};
1101
+ // userConfig?.objects && genericData.directActionPayloadName
1102
+ // ? embedConfig?.objects[genericData.directActionPayloadName]
1103
+ // : embedConfig?.actionsPayload && genericData.directActionPayloadName
1104
+ // ? embedConfig?.actionsPayload[genericData.directActionPayloadName]
1105
+ // : null;
1106
+ const activityOutputData =
1107
+ actionConfigPayload || this.props.activityOutputData || {};
1108
+ const noStepFields =
1109
+ selectedStep.template_fields.length === 0 ||
1110
+ (!(this.props.userConfig && this.props.userConfig.viewAsIU) &&
1111
+ selectedStep.template_fields.filter((field) => field.is_visible)
1112
+ .length === 0);
1113
+ return html`
1114
+ ${this.state.loading
1115
+ ? html`<div class=${styles.actionFormLoader}><${Loader} /></div>`
1116
+ : html`
1117
+ ${selectedStep
1118
+ ? html`
1119
+ <div class=${styles.actionFormWrap}>
1120
+ ${noStepFields
1121
+ ? html`<span class=${styles.noStepFields}
1122
+ >There’s nothing to configure, please proceed.</span
1123
+ >`
1124
+ : selectedStep.template_fields.map((el) => {
1125
+ if (
1126
+ this.shouldShowStep(el) &&
1127
+ (el.activity_field || el.type === 'SECTION')
1128
+ ) {
1129
+ const selectedStepElementData =
1130
+ (selectedStepData && selectedStepData[el.id]) ||
1131
+ null;
1132
+ const elDescription =
1133
+ el.description && !this.isHTML(el.description)
1134
+ ? el.description
1135
+ : el.activity_field?.description &&
1136
+ !this.isHTML(el.activity_field?.description)
1137
+ ? el.activity_field?.description
1138
+ : '';
1139
+ let fieldType = el.activity_field?.type || el.type;
1140
+ const uiField = el.ui_field;
1141
+ const uiFieldSourceURL =
1142
+ uiField?.data_source.url || '';
1143
+ if (el.data_type === 'OBJECT') {
1144
+ fieldType = 'OBJECT';
1145
+ } else if (el.data_type === 'OBJECT[]') {
1146
+ fieldType = 'OBJECT[]';
1147
+ }
1148
+
1149
+ switch (fieldType) {
1150
+ case 'CHECKBOX':
1151
+ case 'RADIO':
1152
+ case 'SELECT': {
1153
+ return html`
1154
+ <div key=${
1155
+ el.id
1156
+ } class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}>
1157
+ <${ConfigureFieldWrapper}
1158
+ field=${el}
1159
+ stepId=${step.id}
1160
+ templateId=${this.props.genericData?.templateId}
1161
+ >
1162
+ <${ListBox}
1163
+ key=${el.activity_field?.id}
1164
+ fieldId=${el.activity_field?.id || el.id}
1165
+ apiHandler=${this.props.apiHandler}
1166
+ title=${el.title || el.activity_field?.title}
1167
+ description=${elDescription}
1168
+ showStepValidation=${showStepValidation}
1169
+ placeholder=${this.getPlaceholder(el)}
1170
+ isRequired=${el.is_required}
1171
+ isHidden=${el.is_hidden}
1172
+ isSearchable=${
1173
+ true
1174
+ // el.activity_field.is_searchable TODO: enable this when Serach is added for mulipurposes field
1175
+ }
1176
+ value=${
1177
+ (selectedStepData &&
1178
+ selectedStepData[el.id] &&
1179
+ selectedStepData[el.id].value) ||
1180
+ el.default_value ||
1181
+ ''
1182
+ }
1183
+ onChange=${(val: string) => {
1184
+ this.onFieldChange({
1185
+ stepId: step.id,
1186
+ fieldId: el.id,
1187
+ value: val,
1188
+ isRequired: el.is_required,
1189
+ });
1190
+ }}
1191
+ endpointUrl=${
1192
+ uiFieldSourceURL ||
1193
+ el.source_flow_integration_invocation_url ||
1194
+ el.activity_field?.data_src
1195
+ }
1196
+ isDynamic=${el.activity_field?.is_dynamic}
1197
+ endpointData=${JSON.stringify({
1198
+ authorization_id:
1199
+ this.props.stepMapping &&
1200
+ this.props.stepMapping[this.props.step.id]
1201
+ ?.selectedAuthId,
1202
+ ...this.fieldDynamicData(el),
1203
+ })}
1204
+ isReadOnly=${isReadOnly}
1205
+ isChanged=${
1206
+ selectedStepElementData &&
1207
+ selectedStepElementData.isChanged
1208
+ }
1209
+ activityOutputData=${activityOutputData}
1210
+ }
1211
+ type=${el.activity_field?.type}
1212
+ selectedAuthId=${`${
1213
+ this.props.stepMapping[this.props.step.id]
1214
+ ?.selectedAuthId || ''
1215
+ }`}
1216
+ disabled=${!this.props.stepMapping[
1217
+ this.props.step.id
1218
+ ]?.isAuthVerified}
1219
+ sourceFlowData=${this.sourceFlowData(el)}
1220
+ sourceFlowIntegrataionInvocationUrl=${
1221
+ el.source_flow_integration_invocation_url
1222
+ }
1223
+ skipOptionFetch=${
1224
+ this.props.userConfig?.viewAsIU
1225
+ }
1226
+ isMappable=${el.is_mappable}
1227
+ isEditable=${true}
1228
+ allowTagsInText=${el.allow_tags_in_text}
1229
+ accountConnected=${accountConnected}
1230
+ labelTags=${getFieldLabelTags(el, false)}
1231
+ appName=${this.props.step.activity.app.name}
1232
+ isMultiSelect=${el.is_multiselect}
1233
+ dataSourceBody=${this.replacePlaceholders(
1234
+ uiField?.data_source.body || {},
1235
+ this.fieldDynamicData(el) || {},
1236
+ )}
1237
+ optionKeyPath=${uiField?.value_key_path || ''}
1238
+ valueKeyPath=${uiField?.option_key_path || ''}
1239
+ ><//>
1240
+ </${ConfigureFieldWrapper}>
1241
+ </div>`;
1242
+ }
1243
+ case 'TIME':
1244
+ return html` <div
1245
+ key=${el.id}
1246
+ class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}
1247
+ >
1248
+ <${TimeInput}
1249
+ title=${el.title ||
1250
+ el.activity_field?.title}
1251
+ description=${elDescription}
1252
+ value=${(selectedStepData &&
1253
+ selectedStepData[el.id] &&
1254
+ selectedStepData[el.id].value) ||
1255
+ ''}
1256
+ placeholder=${el.placeholder ||
1257
+ 'Please enter a value'}
1258
+ showStepValidation=${showStepValidation}
1259
+ isRequired=${el.is_required}
1260
+ onChange=${(val: string) => {
1261
+ this.onFieldChange({
1262
+ stepId: step.id,
1263
+ fieldId: el.id,
1264
+ value: val,
1265
+ isRequired: el.is_required,
1266
+ });
1267
+ }}
1268
+ isReadOnly=${isReadOnly}
1269
+ isChanged=${selectedStepElementData &&
1270
+ selectedStepElementData.isChanged}
1271
+ />
1272
+ </div>`;
1273
+ case 'TEXTFIELD':
1274
+ return (
1275
+ (this.textFieldParentHasValues(el) ||
1276
+ (this.props.userConfig || {}).viewAsIU) &&
1277
+ !el.added_in_mapping &&
1278
+ html`
1279
+ <div class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}>
1280
+ <${ConfigureFieldWrapper}
1281
+ field=${el}
1282
+ stepId=${step.id}
1283
+ templateId=${this.props.genericData?.templateId}
1284
+ >
1285
+ <${MultipurposeField}
1286
+ id=${el.activity_field?.id}
1287
+ title=${
1288
+ el.title || el.activity_field?.title
1289
+ }
1290
+ activityOutputData=${this.arrayToNestedJSONWithFirstValue(
1291
+ this.props.activityOutputData,
1292
+ this.props.dynamicFieldData ||
1293
+ this.state.dynamicFieldDataState ||
1294
+ {},
1295
+ )}
1296
+ activityOutputDataRaw=${
1297
+ this.props.activityOutputData
1298
+ }
1299
+ description=${elDescription}
1300
+ value=${
1301
+ (selectedStepData &&
1302
+ selectedStepData[el.id] &&
1303
+ selectedStepData[el.id].value &&
1304
+ selectedStepData[el.id].value !==
1305
+ 'x-integry-skipped-field' &&
1306
+ selectedStepData[el.id].value) ||
1307
+ el.default_value ||
1308
+ ''
1309
+ }
1310
+ placeholder=${this.getPlaceholder(el)}
1311
+ showStepValidation=${showStepValidation}
1312
+ regex=${selectedStepData[el.id].regex}
1313
+ regexErrorMessage=${
1314
+ selectedStepData[el.id].regexErrorMessage
1315
+ }
1316
+ isRequired=${el.is_required}
1317
+ isHidden=${el.is_hidden}
1318
+ onChange=${(
1319
+ val: string,
1320
+ passesRegexTest?: boolean,
1321
+ ) => {
1322
+ setStepFieldData({
1323
+ stepId: `${step.id}`,
1324
+ fieldId: `${el.id}`,
1325
+ value: this.getFieldValFromActivityOutputRaw(
1326
+ this.props.activityOutputData,
1327
+ val,
1328
+ ),
1329
+ isRequired: el.is_required,
1330
+ passesRegexTest,
1331
+ });
1332
+ this.props.verifyStepValidity(step.id);
1333
+ }}
1334
+ isReadOnly=${isReadOnly}
1335
+ isChanged=${
1336
+ selectedStepElementData &&
1337
+ selectedStepElementData.isChanged
1338
+ }
1339
+ type=${el.activity_field?.type}
1340
+ isMappable=${el.is_mappable}
1341
+ isEditable=${el.is_editable}
1342
+ allowTagsInText=${el.allow_tags_in_text}
1343
+ labelTags=${getFieldLabelTags(el, false)}
1344
+ fieldId=${
1345
+ el.activity_field?.id ||
1346
+ el.activity_field?.machine_name ||
1347
+ el.id
1348
+ }
1349
+ refreshRootStepData=${
1350
+ this.refreshRootStepData
1351
+ }
1352
+ isButtonEnabled=${
1353
+ el.is_button_enabled || false
1354
+ }
1355
+ buttonText=${el.button_text || ''}
1356
+ onButtonClickScript=${
1357
+ el.on_button_click_script
1358
+ }
1359
+ buttonScriptRequiresAuthToken=${
1360
+ el.button_script_requires_auth_token
1361
+ }
1362
+ apiHandler=${this.props.apiHandler}
1363
+ isArray=${!!(
1364
+ el.data_type === 'STRING[]' ||
1365
+ el.data_type === 'NUMBER[]'
1366
+ )}
1367
+ ><//>
1368
+ </${ConfigureFieldWrapper}>
1369
+ </div>
1370
+ `
1371
+ );
1372
+
1373
+ case 'OBJECT':
1374
+ case 'OBJECT[]':
1375
+ return (
1376
+ (this.textFieldParentHasValues(el) ||
1377
+ (this.props.userConfig || {}).viewAsIU) &&
1378
+ !el.added_in_mapping &&
1379
+ html`
1380
+ <div class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}>
1381
+ <${ConfigureFieldWrapper}
1382
+ field=${el}
1383
+ stepId=${step.id}
1384
+ templateId=${
1385
+ this.props.genericData?.templateId
1386
+ }
1387
+ >
1388
+ <${ObjectField}
1389
+ field=${el}
1390
+ onChange=${this.onFieldChange}
1391
+ apiHandler=${this.props.apiHandler}
1392
+ isArray=${fieldType === 'OBJECT[]'}
1393
+ activityOutputData=${this.arrayToNestedJSONWithFirstValue(
1394
+ this.props.activityOutputData,
1395
+ this.props.dynamicFieldData ||
1396
+ this.state.dynamicFieldDataState ||
1397
+ {},
1398
+ )}
1399
+ activityOutputDataRaw=${
1400
+ this.props.activityOutputData
1401
+ }
1402
+ />
1403
+ </${ConfigureFieldWrapper}>
1404
+ </div>
1405
+ `
1406
+ );
1407
+ case 'FILE':
1408
+ return html`
1409
+ <div
1410
+ class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}
1411
+ >
1412
+ <${Input}
1413
+ id=${el.activity_field?.id}
1414
+ title=${el.title ||
1415
+ el.activity_field?.title}
1416
+ description=${elDescription}
1417
+ value=${(selectedStepData &&
1418
+ selectedStepData[el.id] &&
1419
+ selectedStepData[el.id].value) ||
1420
+ ''}
1421
+ placeholder=${el.placeholder ||
1422
+ 'Please enter a URL'}
1423
+ showStepValidation=${showStepValidation}
1424
+ regex=${selectedStepData[el.id].regex}
1425
+ regexErrorMessage=${selectedStepData[
1426
+ el.id
1427
+ ].regexErrorMessage}
1428
+ isRequired=${el.is_required}
1429
+ onChange=${(
1430
+ val: string,
1431
+ passesRegexTest?: boolean,
1432
+ ) => {
1433
+ setStepFieldData({
1434
+ stepId: `${step.id}`,
1435
+ fieldId: `${el.id}`,
1436
+ value: val,
1437
+ isRequired: el.is_required,
1438
+ passesRegexTest,
1439
+ });
1440
+ this.props.verifyStepValidity(step.id);
1441
+ }}
1442
+ isReadOnly=${isReadOnly}
1443
+ isChanged=${selectedStepElementData &&
1444
+ selectedStepElementData.isChanged}
1445
+ ><//>
1446
+ </div>
1447
+ `;
1448
+ case 'DYNAMIC':
1449
+ return html`
1450
+ <div
1451
+ key=${el.id}
1452
+ class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}
1453
+ >
1454
+ <${DynamicField}
1455
+ stepId=${selectedStep.id}
1456
+ dynamicField=${el}
1457
+ endpointData=${JSON.stringify({
1458
+ authorization_id:
1459
+ this.props.stepMapping &&
1460
+ this.props.stepMapping[
1461
+ this.props.step.id
1462
+ ]?.selectedAuthId,
1463
+ ...this.fieldDynamicData(el),
1464
+ })}
1465
+ activityOutputData=${this.arrayToNestedJSONWithFirstValue(
1466
+ this.props.activityOutputData,
1467
+ this.props.dynamicFieldData ||
1468
+ this.state.dynamicFieldDataState ||
1469
+ {},
1470
+ )}
1471
+ activityOutputDataRaw=${this.props
1472
+ .activityOutputData}
1473
+ placeHolder=${this.getPlaceholder(el)}
1474
+ appName=${this.props.step.activity.app
1475
+ .name}
1476
+ selectedAuthId=${`${
1477
+ this.props.stepMapping[
1478
+ this.props.step.id
1479
+ ]?.selectedAuthId || ''
1480
+ }`}
1481
+ sourceFlowData=${this.sourceFlowData(el)}
1482
+ sourceFlowIntegrataionInvocationUrl=${el.source_flow_integration_invocation_url}
1483
+ isMappable=${el.is_mappable}
1484
+ isEditable=${el.is_editable}
1485
+ allowTagsInText=${el.allow_tags_in_text}
1486
+ refreshRootStepData=${this
1487
+ .refreshRootStepData}
1488
+ />
1489
+ </div>
1490
+ `;
1491
+ case 'SECTION':
1492
+ return html`
1493
+ <div
1494
+ key=${el.id}
1495
+ class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}
1496
+ >
1497
+ <${SectionField}
1498
+ stepId=${selectedStep.id}
1499
+ sectionField=${el}
1500
+ endpointData=${JSON.stringify({
1501
+ authorization_id:
1502
+ this.props.stepMapping &&
1503
+ this.props.stepMapping[
1504
+ this.props.step.id
1505
+ ]?.selectedAuthId,
1506
+ ...this.fieldDynamicData(el),
1507
+ })}
1508
+ activityOutputData=${this.arrayToNestedJSONWithFirstValue(
1509
+ this.props.activityOutputData,
1510
+ {},
1511
+ )}
1512
+ activityOutputDataRaw=${this.props
1513
+ .activityOutputData}
1514
+ placeHolder=${this.getPlaceholder(el)}
1515
+ appName=${this.props.step.activity.app
1516
+ .name}
1517
+ selectedAuthId=${`${
1518
+ this.props.stepMapping[
1519
+ this.props.step.id
1520
+ ]?.selectedAuthId || ''
1521
+ }`}
1522
+ sourceFlowData=${this.sourceFlowData(el)}
1523
+ sourceFlowIntegrataionInvocationUrl=${el.source_flow_integration_invocation_url}
1524
+ isMappable=${el.is_mappable}
1525
+ isEditable=${el.is_editable}
1526
+ allowTagsInText=${el.allow_tags_in_text}
1527
+ refreshRootStepData=${this
1528
+ .refreshRootStepData}
1529
+ description=${elDescription}
1530
+ showStepValidation=${showStepValidation}
1531
+ placeholder=${this.getPlaceholder(el)}
1532
+ selectedStepData=${selectedStepData}
1533
+ onFieldChange=${this.onFieldChange}
1534
+ selectedStepElementData=${selectedStepElementData}
1535
+ sourceFlowData=${this.sourceFlowData}
1536
+ accountConnected=${accountConnected}
1537
+ getFieldLabelTags=${getFieldLabelTags}
1538
+ appName=${this.props.step.activity.app}
1539
+ fieldDynamicData=${this.fieldDynamicData}
1540
+ apiHandler=${this.props.apiHandler}
1541
+ />
1542
+ </div>
1543
+ `;
1544
+ case 'PASSWORD':
1545
+ return html`
1546
+ <div
1547
+ key=${el.id}
1548
+ class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}
1549
+ >
1550
+ <${PasswordInput}
1551
+ title=${el.title ||
1552
+ el.activity_field?.title}
1553
+ description=${elDescription}
1554
+ value=${(selectedStepData &&
1555
+ selectedStepData[el.id] &&
1556
+ selectedStepData[el.id].value) ||
1557
+ ''}
1558
+ placeholder=${el.placeholder ||
1559
+ el.activity_field?.placeholder ||
1560
+ 'Please enter a value'}
1561
+ regex=${selectedStepData[el.id].regex}
1562
+ regexErrorMessage=${selectedStepData[
1563
+ el.id
1564
+ ].regexErrorMessage}
1565
+ showStepValidation=${showStepValidation}
1566
+ isRequired=${el.is_required}
1567
+ onChange=${(val: string) => {
1568
+ setStepFieldData({
1569
+ stepId: `${step.id}`,
1570
+ fieldId: `${el.id}`,
1571
+ value: val,
1572
+ isRequired: el.is_required,
1573
+ });
1574
+ this.props.verifyStepValidity(step.id);
1575
+ }}
1576
+ isReadOnly=${isReadOnly}
1577
+ isChanged=${selectedStepElementData &&
1578
+ selectedStepElementData.isChanged}
1579
+ />
1580
+ </div>
1581
+ `;
1582
+ case 'TEXTAREA':
1583
+ return html`
1584
+ <div key=${
1585
+ el.id
1586
+ } class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}>
1587
+ <${ConfigureFieldWrapper}
1588
+ field=${el}
1589
+ stepId=${step.id}
1590
+ templateId=${this.props.genericData?.templateId}
1591
+ >
1592
+ <${MultipurposeField}
1593
+ title=${el.title || el.activity_field?.title}
1594
+ description=${elDescription}
1595
+ value=${
1596
+ (selectedStepData &&
1597
+ selectedStepData[el.id] &&
1598
+ selectedStepData[el.id].value &&
1599
+ selectedStepData[el.id].value !==
1600
+ 'x-integry-skipped-field' &&
1601
+ selectedStepData[el.id].value) ||
1602
+ el.default_value ||
1603
+ ''
1604
+ }
1605
+ placeholder=${this.getPlaceholder(el)}
1606
+ regex=${selectedStepData[el.id].regex}
1607
+ regexErrorMessage=${
1608
+ selectedStepData[el.id].regexErrorMessage
1609
+ }
1610
+ showStepValidation=${showStepValidation}
1611
+ isRequired=${el.is_required}
1612
+ isHidden=${el.is_hidden}
1613
+ onChange=${(
1614
+ val: string,
1615
+ passesRegexTest?: boolean,
1616
+ ) => {
1617
+ setStepFieldData({
1618
+ stepId: `${step.id}`,
1619
+ fieldId: `${el.id}`,
1620
+ value: val,
1621
+ isRequired: el.is_required,
1622
+ passesRegexTest,
1623
+ });
1624
+ this.props.verifyStepValidity(step.id);
1625
+ }}
1626
+ isReadOnly=${isReadOnly}
1627
+ isChanged=${
1628
+ selectedStepElementData &&
1629
+ selectedStepElementData.isChanged
1630
+ }
1631
+ type=${el.activity_field?.type}
1632
+ labelTags=${getFieldLabelTags(el, false)}
1633
+ activityOutputData=${this.arrayToNestedJSONWithFirstValue(
1634
+ this.props.activityOutputData,
1635
+ this.props.dynamicFieldData ||
1636
+ this.state.dynamicFieldDataState ||
1637
+ {},
1638
+ )}
1639
+ activityOutputDataRaw=${
1640
+ this.props.activityOutputData
1641
+ }
1642
+ isMappable=${el.is_mappable}
1643
+ isEditable=${el.is_editable}
1644
+ allowTagsInText=${el.allow_tags_in_text}
1645
+ fieldId=${el.activity_field?.id || el.id}
1646
+ refreshRootStepData=${
1647
+ this.refreshRootStepData
1648
+ }
1649
+ />
1650
+
1651
+ </${ConfigureFieldWrapper}>
1652
+ </div>
1653
+ `;
1654
+ case 'DATE':
1655
+ return html`
1656
+ <div
1657
+ key=${el.id}
1658
+ class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}
1659
+ >
1660
+ <${DateInput}
1661
+ title=${el.title ||
1662
+ el.activity_field?.title}
1663
+ description=${elDescription}
1664
+ value=${(selectedStepData &&
1665
+ selectedStepData[el.id] &&
1666
+ selectedStepData[el.id].value) ||
1667
+ ''}
1668
+ placeholder=${el.placeholder ||
1669
+ 'Please enter a value'}
1670
+ showStepValidation=${showStepValidation}
1671
+ isRequired=${el.is_required}
1672
+ onChange=${(val: string) => {
1673
+ setStepFieldData({
1674
+ stepId: `${step.id}`,
1675
+ fieldId: `${el.id}`,
1676
+ value: val,
1677
+ isRequired: el.is_required,
1678
+ });
1679
+ this.props.verifyStepValidity(step.id);
1680
+ }}
1681
+ isReadOnly=${isReadOnly}
1682
+ isChanged=${selectedStepElementData &&
1683
+ selectedStepElementData.isChanged}
1684
+ />
1685
+ </div>
1686
+ `;
1687
+ case 'FIELD_LIST':
1688
+ return html``;
1689
+ case 'FIELD_MAPPING':
1690
+ return html`
1691
+ <div
1692
+ class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}
1693
+ >
1694
+ <${NewMappingUI}
1695
+ stepId=${selectedStep.id}
1696
+ templateFields=${selectedStep.template_fields}
1697
+ showStepValidation=${showStepValidation}
1698
+ ><//>
1699
+ </div>
1700
+ `;
1701
+ case 'HTML':
1702
+ return html` <${HTMLContent}
1703
+ htmlContent=${el.default_value}
1704
+ />`;
1705
+ return html`
1706
+ <div
1707
+ dangerouslySetInnerHTML=${{
1708
+ __html: el.default_value,
1709
+ }}
1710
+ />
1711
+ `;
1712
+ case 'TEXT_CONTENT':
1713
+ return html` <${TextContent}
1714
+ textContent=${el.default_value}
1715
+ />`;
1716
+
1717
+ default:
1718
+ // return html``;
1719
+ return html` <div
1720
+ class=${`${styles.actionStepFieldWrap} ${styles.unsupported}`}
1721
+ >
1722
+ Field: ${el.activity_field?.type} is currently
1723
+ not supported
1724
+ </div>`;
1725
+ }
1726
+ } else {
1727
+ switch (el.type) {
1728
+ case 'HTML':
1729
+ return html`
1730
+ <div
1731
+ style="margin-bottom: 2rem;"
1732
+ dangerouslySetInnerHTML=${{
1733
+ __html: el.default_value,
1734
+ }}
1735
+ />
1736
+ `;
1737
+ case 'BUTTON':
1738
+ return html`
1739
+ <div style="margin-bottom: 2rem;">
1740
+ <${Button} label=${el.title} />
1741
+ </div>
1742
+ `;
1743
+ default:
1744
+ break;
1745
+ }
1746
+ }
1747
+ return html``;
1748
+ })}
1749
+ <!-- ${this.shouldShowOldMapping() &&
1750
+ !this.shouldShowNewMapping() &&
1751
+ html`
1752
+ <div class=${styles.actionStepFieldWrap}>
1753
+ <${MappingUI}
1754
+ stepId=${selectedStep.id}
1755
+ templateFields=${selectedStep.template_fields}
1756
+ showStepValidation=${showStepValidation}
1757
+ endpointData=${this.getMappingDataInput()}
1758
+ key=${`mapping_ui_${selectedStep.id}`}
1759
+ ><//>
1760
+ </div>
1761
+ `} -->
1762
+ </div>
1763
+ `
1764
+ : html`Step data could not be loaded`}
1765
+ `}
1766
+ `;
1767
+ }
1768
+ }
1769
+
1770
+ export default connect<
1771
+ ActionFormPropsType,
1772
+ ActionFormStateType,
1773
+ StoreType,
1774
+ unknown
1775
+ >(
1776
+ [
1777
+ 'stepState',
1778
+ 'stepMapping',
1779
+ 'stepDataMapping',
1780
+ 'parentChildMapping',
1781
+ 'fieldListMapping',
1782
+ 'conditionalFieldMapping',
1783
+ 'embedConfig',
1784
+ 'activityOutputData',
1785
+ 'genericData',
1786
+ 'userConfig',
1787
+ 'authMapping',
1788
+ ],
1789
+ actionFunctions,
1790
+ )(ActionForm);