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