@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,862 @@
|
|
|
1
|
+
/* eslint-disable no-nested-ternary */
|
|
2
|
+
import { html, Component } from 'htm/preact';
|
|
3
|
+
import { connect } from 'unistore/preact';
|
|
4
|
+
import { useContext } from 'preact/hooks';
|
|
5
|
+
// import DOMPurify from 'dompurify';
|
|
6
|
+
import { ListBox } from '@/components/MultipurposeField/Dropdown';
|
|
7
|
+
import AppPageLoader from '@/features/containers/AppFlowContainer/AppFlowWrap/app-page-loader';
|
|
8
|
+
import { actionFunctions } from '@/store';
|
|
9
|
+
import MappingUI from '@/features/common/MappingUI';
|
|
10
|
+
import { Button } from '@/components/Button';
|
|
11
|
+
import { StoreType } from '@/types/store';
|
|
12
|
+
import { DateInput, Input, PasswordInput } from '@/components/Input';
|
|
13
|
+
import HTMLContent from '@/components/HTMLContent';
|
|
14
|
+
import TextContent from '@/components/TextContent';
|
|
15
|
+
import { MultipurposeField } from '@/components/MultipurposeField';
|
|
16
|
+
import DynamicTypedField from '@/features/common/DynamicTypedField';
|
|
17
|
+
import SectionField from '@/features/common/SectionField';
|
|
18
|
+
import { TimeInput } from '@/components/TimeInput';
|
|
19
|
+
import NewMappingUI from '@/features/common/NewMappingUI';
|
|
20
|
+
import { areParentValuesValid, getFieldLabelTags } from '@/utils/stepUtils';
|
|
21
|
+
import ConfigureFieldWrapper from '@/components/ConfigureFieldWrapper';
|
|
22
|
+
import { TextArea } from '@/components/TextArea';
|
|
23
|
+
import { CheckboxGroup } from '@/components/CheckboxGroup';
|
|
24
|
+
import AppContext from '@/contexts/AppContext';
|
|
25
|
+
import { ObjectField } from '@/components/form';
|
|
26
|
+
import {
|
|
27
|
+
JSONToActivityOutputData,
|
|
28
|
+
JSONToDynamicFieldData,
|
|
29
|
+
arrayToNestedJSONWithFirstValue,
|
|
30
|
+
} from '@/utils/ActivityOutputUtils';
|
|
31
|
+
|
|
32
|
+
import styles from './styles.module.scss';
|
|
33
|
+
|
|
34
|
+
interface FunctionFormPropsType extends StoreType {
|
|
35
|
+
functionName: string;
|
|
36
|
+
connectedAccountId: string;
|
|
37
|
+
functionArguments: any;
|
|
38
|
+
variables: any;
|
|
39
|
+
autoMapVars: boolean;
|
|
40
|
+
onClose: (response: any) => void;
|
|
41
|
+
apiHandler: any;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface ActionFormStateType {
|
|
45
|
+
loading: boolean;
|
|
46
|
+
dynamicFieldDataState: any;
|
|
47
|
+
isSubmitting: boolean;
|
|
48
|
+
functionDetails: any;
|
|
49
|
+
invalidFields: any;
|
|
50
|
+
parentFields: any;
|
|
51
|
+
parentFieldsChanged: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface StepDataMapping {
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type Option = {
|
|
59
|
+
id: any;
|
|
60
|
+
value: string;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
class FunctionForm extends Component<
|
|
64
|
+
FunctionFormPropsType,
|
|
65
|
+
ActionFormStateType
|
|
66
|
+
> {
|
|
67
|
+
constructor(props: FunctionFormPropsType) {
|
|
68
|
+
super(props);
|
|
69
|
+
this.state = {
|
|
70
|
+
loading: false,
|
|
71
|
+
dynamicFieldDataState: {},
|
|
72
|
+
isSubmitting: false,
|
|
73
|
+
functionDetails: {},
|
|
74
|
+
invalidFields: [],
|
|
75
|
+
parentFields: [],
|
|
76
|
+
parentFieldsChanged: false,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
getMethod = () => 'POST';
|
|
81
|
+
|
|
82
|
+
getBaseUrl = () => 'https://api.integry.io/functions';
|
|
83
|
+
|
|
84
|
+
getHeaders = () => ({
|
|
85
|
+
'Content-Type': 'application/json',
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
componentDidMount() {
|
|
89
|
+
this.setState({ loading: true });
|
|
90
|
+
this.props.apiHandler
|
|
91
|
+
.getFunctionDetails(
|
|
92
|
+
this.props.functionName,
|
|
93
|
+
this.props.autoMapVars ? this.props.variables : {},
|
|
94
|
+
)
|
|
95
|
+
.then((response: any) => {
|
|
96
|
+
this.setState({ functionDetails: response });
|
|
97
|
+
|
|
98
|
+
const { functionArguments } = this.props;
|
|
99
|
+
const predictedArguments = this.props.autoMapVars
|
|
100
|
+
? response.arguments
|
|
101
|
+
: {};
|
|
102
|
+
const argumentsData = response.parameters.properties;
|
|
103
|
+
const args: { [key: string]: any } = {};
|
|
104
|
+
|
|
105
|
+
Object.keys(argumentsData).forEach((key: string) => {
|
|
106
|
+
args[key] =
|
|
107
|
+
predictedArguments[key] ||
|
|
108
|
+
functionArguments[key] ||
|
|
109
|
+
argumentsData[key].meta.ui.default_value ||
|
|
110
|
+
'';
|
|
111
|
+
|
|
112
|
+
if (argumentsData[key].meta.is_required && !args[key]) {
|
|
113
|
+
this.setState((prevState) => ({
|
|
114
|
+
invalidFields: prevState.invalidFields.includes(key)
|
|
115
|
+
? prevState.invalidFields
|
|
116
|
+
: [...prevState.invalidFields, key],
|
|
117
|
+
}));
|
|
118
|
+
}
|
|
119
|
+
if (argumentsData[key].meta.ui.ui_field?.data_source?.body) {
|
|
120
|
+
// Extract all the keys in the body
|
|
121
|
+
const bodyKeys = Object.keys(
|
|
122
|
+
argumentsData[key].meta.ui.ui_field.data_source.body,
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
// Iterate through the keys and check if the value matches the format {parameters.<parent-field-name>}
|
|
126
|
+
bodyKeys.forEach((bodyKey) => {
|
|
127
|
+
const value =
|
|
128
|
+
argumentsData[key].meta.ui.ui_field.data_source.body[bodyKey];
|
|
129
|
+
|
|
130
|
+
// Check if the value matches the format {parameters.<parent-field-name>}
|
|
131
|
+
const match = value && value.match(/{parameters\.(.*?)}/);
|
|
132
|
+
|
|
133
|
+
if (match && match[1]) {
|
|
134
|
+
const parentField = match[1]; // Extract the parent field name
|
|
135
|
+
|
|
136
|
+
// Add the parent field to the parentFields array
|
|
137
|
+
this.setState((prevState) => ({
|
|
138
|
+
parentFields: [...prevState.parentFields, parentField],
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
this.setState({
|
|
145
|
+
dynamicFieldDataState: args,
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
this.setState({ loading: false });
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
private removeLastIfEmpty = (arr: any) => {
|
|
153
|
+
if (
|
|
154
|
+
arr.length > 0 &&
|
|
155
|
+
(arr[arr.length - 1] === '' || arr[arr.length - 1] == null)
|
|
156
|
+
) {
|
|
157
|
+
arr.pop(); // Remove the last item if it is empty or null
|
|
158
|
+
}
|
|
159
|
+
return arr;
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
private onSubmit = () => {
|
|
163
|
+
this.setState({ isSubmitting: true });
|
|
164
|
+
const { functionName } = this.props;
|
|
165
|
+
const { functionDetails } = this.state;
|
|
166
|
+
const args: { [key: string]: any } = {};
|
|
167
|
+
const { dynamicFieldDataState } = this.state;
|
|
168
|
+
|
|
169
|
+
Object.keys(dynamicFieldDataState).forEach((key: string) => {
|
|
170
|
+
const fieldDetails = functionDetails.parameters.properties[key];
|
|
171
|
+
let value = dynamicFieldDataState[key] || '';
|
|
172
|
+
|
|
173
|
+
// Check for field type and cast value
|
|
174
|
+
if (fieldDetails) {
|
|
175
|
+
switch (fieldDetails.type) {
|
|
176
|
+
case 'boolean':
|
|
177
|
+
value =
|
|
178
|
+
value === 'true' ||
|
|
179
|
+
value === true ||
|
|
180
|
+
value === '1' ||
|
|
181
|
+
value === 1;
|
|
182
|
+
break;
|
|
183
|
+
case 'number':
|
|
184
|
+
value = Number(value);
|
|
185
|
+
break;
|
|
186
|
+
case 'string':
|
|
187
|
+
value = String(value);
|
|
188
|
+
break;
|
|
189
|
+
case 'array':
|
|
190
|
+
value = this.removeLastIfEmpty(value);
|
|
191
|
+
value = value === '' || value === '[]' ? [] : value;
|
|
192
|
+
if (fieldDetails.items && fieldDetails.items.type === 'number') {
|
|
193
|
+
value = value.map((item: string) => Number(item));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
break;
|
|
197
|
+
case 'object':
|
|
198
|
+
if (typeof value === 'object' && value !== null) {
|
|
199
|
+
// If it's already an object, do nothing
|
|
200
|
+
break;
|
|
201
|
+
} else {
|
|
202
|
+
// If it's a string that can be parsed into an object
|
|
203
|
+
try {
|
|
204
|
+
value = JSON.parse(value);
|
|
205
|
+
// Ensure the parsed value is an object
|
|
206
|
+
} catch (e) {
|
|
207
|
+
value = {};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
break;
|
|
211
|
+
default:
|
|
212
|
+
value = String(value);
|
|
213
|
+
break;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Assign the correctly cast value to args
|
|
218
|
+
args[key] = value;
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
this.props.onClose(args);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
parseJsonArray = (input: string): any[] => {
|
|
225
|
+
// First, try to parse the input as a JSON array
|
|
226
|
+
try {
|
|
227
|
+
const parsed = JSON.parse(input);
|
|
228
|
+
if (Array.isArray(parsed)) {
|
|
229
|
+
return parsed; // Return the valid array
|
|
230
|
+
}
|
|
231
|
+
} catch (error) {
|
|
232
|
+
// If parsing fails, continue to the next check
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// If the input is a comma-separated string (e.g., "1,2,3")
|
|
236
|
+
let trimmedInput = '';
|
|
237
|
+
try {
|
|
238
|
+
trimmedInput = input.trim();
|
|
239
|
+
} catch (error) {
|
|
240
|
+
// If the input is not a string, return an empty array
|
|
241
|
+
trimmedInput = '';
|
|
242
|
+
}
|
|
243
|
+
if (trimmedInput.includes(',')) {
|
|
244
|
+
// Split by commas and return the values as an array
|
|
245
|
+
return trimmedInput.split(',').map((item) => item.trim());
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// If the input is a single value (e.g., "yasir@integry.io" or "1")
|
|
249
|
+
return [trimmedInput];
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
onFieldChange = (
|
|
253
|
+
fieldId: string,
|
|
254
|
+
value: any,
|
|
255
|
+
dataType: string,
|
|
256
|
+
isRequired?: boolean,
|
|
257
|
+
parentFieldId?: string | null,
|
|
258
|
+
index = -1,
|
|
259
|
+
stopChangePropagation = false,
|
|
260
|
+
) => {
|
|
261
|
+
this.setState((prevState) => {
|
|
262
|
+
const newState = { ...prevState.dynamicFieldDataState };
|
|
263
|
+
|
|
264
|
+
if (parentFieldId) {
|
|
265
|
+
// If parentFieldId is not empty, ensure the parent field exists
|
|
266
|
+
if (!newState[parentFieldId]) {
|
|
267
|
+
if (index !== -1) {
|
|
268
|
+
newState[parentFieldId] = [];
|
|
269
|
+
newState[parentFieldId][index] = {};
|
|
270
|
+
} else {
|
|
271
|
+
newState[parentFieldId] = {}; // Create an object if it doesn't exist
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
// Add the fieldId and value inside the parentFieldId
|
|
275
|
+
if (index !== -1) {
|
|
276
|
+
newState[parentFieldId] = value;
|
|
277
|
+
} else {
|
|
278
|
+
newState[parentFieldId][fieldId] = value;
|
|
279
|
+
}
|
|
280
|
+
} else {
|
|
281
|
+
// If parentFieldId is empty, add the fieldId and value directly
|
|
282
|
+
newState[fieldId] = value;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
return {
|
|
286
|
+
dynamicFieldDataState: newState,
|
|
287
|
+
};
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
let isValid = false;
|
|
291
|
+
if (dataType === 'number') {
|
|
292
|
+
isValid = !Number.isNaN(Number(value));
|
|
293
|
+
} else if (dataType === 'boolean') {
|
|
294
|
+
isValid =
|
|
295
|
+
value === 'true' ||
|
|
296
|
+
value === 'false' ||
|
|
297
|
+
value === '1' ||
|
|
298
|
+
value === '0' ||
|
|
299
|
+
value === true ||
|
|
300
|
+
value === false ||
|
|
301
|
+
value === 1 ||
|
|
302
|
+
value === 0;
|
|
303
|
+
} else if (dataType === 'string') {
|
|
304
|
+
isValid = true;
|
|
305
|
+
} else {
|
|
306
|
+
isValid = true;
|
|
307
|
+
}
|
|
308
|
+
if (value && isValid) {
|
|
309
|
+
this.setState({
|
|
310
|
+
invalidFields: this.state.invalidFields.filter(
|
|
311
|
+
(field: string) => field !== fieldId,
|
|
312
|
+
),
|
|
313
|
+
});
|
|
314
|
+
} else if (isRequired) {
|
|
315
|
+
this.setState((prevState) => ({
|
|
316
|
+
invalidFields: prevState.invalidFields.includes(fieldId)
|
|
317
|
+
? prevState.invalidFields
|
|
318
|
+
: [...prevState.invalidFields, fieldId],
|
|
319
|
+
}));
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Check if the field is a parent field
|
|
323
|
+
if (this.state.parentFields.includes(fieldId)) {
|
|
324
|
+
this.setState({ parentFieldsChanged: !this.state.parentFieldsChanged });
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
replacePlaceholders = (
|
|
329
|
+
templateObj: { [key: string]: any },
|
|
330
|
+
dictionary: { [key: string]: any },
|
|
331
|
+
): { [key: string]: any } => {
|
|
332
|
+
const updatedObj: { [key: string]: any } = {};
|
|
333
|
+
|
|
334
|
+
// Use Object.entries to iterate over keys and values
|
|
335
|
+
Object.entries(templateObj).forEach(([key, value]) => {
|
|
336
|
+
// If the value is a string and contains a placeholder, replace it
|
|
337
|
+
if (typeof value === 'string' && value.includes('{parameters.')) {
|
|
338
|
+
// Extract the placeholder key between `{parameters.}` and use it to replace with the dictionary value
|
|
339
|
+
const placeholderKey = value.match(/{parameters\.(.*?)}/);
|
|
340
|
+
|
|
341
|
+
if (placeholderKey && placeholderKey[1]) {
|
|
342
|
+
const keyToReplace = placeholderKey[1]; // Extract key name from the placeholder
|
|
343
|
+
|
|
344
|
+
// Replace the placeholder with the corresponding value from the dictionary
|
|
345
|
+
if (dictionary[keyToReplace] !== undefined) {
|
|
346
|
+
updatedObj[key] = value.replace(
|
|
347
|
+
placeholderKey[0],
|
|
348
|
+
dictionary[keyToReplace],
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
} else if (typeof value === 'string' && value) {
|
|
353
|
+
updatedObj[key] = value;
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
// Return the updated object containing only keys with replaced values
|
|
358
|
+
return updatedObj;
|
|
359
|
+
};
|
|
360
|
+
|
|
361
|
+
getRegex: any = (field: any) => {
|
|
362
|
+
if (field.type === 'boolean') {
|
|
363
|
+
return '^(true|false)$'; // Matches "true" or "false" as strings
|
|
364
|
+
}
|
|
365
|
+
if (field.type === 'number') {
|
|
366
|
+
return '^\\d+$'; // Matches numeric values only
|
|
367
|
+
}
|
|
368
|
+
if (
|
|
369
|
+
field.type === 'array' &&
|
|
370
|
+
field.items &&
|
|
371
|
+
field.items.type === 'number'
|
|
372
|
+
) {
|
|
373
|
+
return '^\\d+$'; // Matches numeric values only
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
return ''; // Default to empty string
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
getRegexErrorMessage: any = (field: any) => {
|
|
380
|
+
if (field.type === 'boolean') {
|
|
381
|
+
return 'Please enter "true" or "false".'; // Error message for boolean fields
|
|
382
|
+
}
|
|
383
|
+
if (field.type === 'number') {
|
|
384
|
+
return 'Please enter a valid number.'; // Error message for number fields
|
|
385
|
+
}
|
|
386
|
+
if (
|
|
387
|
+
field.type === 'array' &&
|
|
388
|
+
field.items &&
|
|
389
|
+
field.items.type === 'number'
|
|
390
|
+
) {
|
|
391
|
+
return 'Please enter a valid number.'; // Error message for number fields
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
return 'Invalid input.'; // Default error message
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
fetchDynamicData = (field: any) => {
|
|
398
|
+
const { functionDetails } = this.state;
|
|
399
|
+
const { connectedAccountId } = this.props;
|
|
400
|
+
const { properties } = functionDetails.parameters;
|
|
401
|
+
const { depends_on } = properties[field.id].meta.ui || [];
|
|
402
|
+
|
|
403
|
+
const data: { [key: string]: any } = {};
|
|
404
|
+
|
|
405
|
+
// Iterate through the dependsOn array and add the corresponding values to the data object
|
|
406
|
+
depends_on.forEach((fieldId: string) => {
|
|
407
|
+
data[fieldId] = this.state.dynamicFieldDataState[fieldId];
|
|
408
|
+
});
|
|
409
|
+
return data;
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
renderFields = (
|
|
413
|
+
properties: any,
|
|
414
|
+
functionArguments: any,
|
|
415
|
+
connectedAccount: string,
|
|
416
|
+
appName: string,
|
|
417
|
+
parentFieldId?: string,
|
|
418
|
+
): any => {
|
|
419
|
+
const fields = Object.entries(properties).map(
|
|
420
|
+
([fieldName, fieldDetails]: [string, any], index) => ({
|
|
421
|
+
id: fieldName, // assign unique id for each field
|
|
422
|
+
title: fieldDetails.meta.title,
|
|
423
|
+
type: fieldDetails.meta.ui.ui_field?.type || 'TEXTFIELD',
|
|
424
|
+
endpointURL:
|
|
425
|
+
fieldDetails.meta.ui.ui_field?.type === 'DYNAMIC_DROPDOWN' ||
|
|
426
|
+
fieldDetails.meta.ui.ui_field?.type === 'CUSTOM_FIELDS'
|
|
427
|
+
? fieldDetails.meta.ui.ui_field.data_source?.url || ''
|
|
428
|
+
: undefined, // Set endpoint URL for DYNAMIC_DROPDOWN
|
|
429
|
+
optionKeyPath:
|
|
430
|
+
fieldDetails.meta.ui.ui_field?.type === 'DYNAMIC_DROPDOWN'
|
|
431
|
+
? fieldDetails.meta.ui.ui_field.option_key_path || ''
|
|
432
|
+
: undefined,
|
|
433
|
+
valueKeyPath:
|
|
434
|
+
fieldDetails.meta.ui.ui_field?.type === 'DYNAMIC_DROPDOWN'
|
|
435
|
+
? fieldDetails.meta.ui.ui_field.value_key_path || ''
|
|
436
|
+
: undefined,
|
|
437
|
+
isMultiSelect:
|
|
438
|
+
fieldDetails.meta.ui.ui_field?.type === 'DYNAMIC_DROPDOWN'
|
|
439
|
+
? fieldDetails.meta.ui.ui_field.is_multiselect || false
|
|
440
|
+
: false,
|
|
441
|
+
idKeyPath:
|
|
442
|
+
fieldDetails.meta.ui.ui_field?.type === 'CUSTOM_FIELDS'
|
|
443
|
+
? fieldDetails.meta.ui.ui_field.id_key_path || ''
|
|
444
|
+
: undefined,
|
|
445
|
+
typeKeyPath:
|
|
446
|
+
fieldDetails.meta.ui.ui_field?.type === 'CUSTOM_FIELDS'
|
|
447
|
+
? fieldDetails.meta.ui.ui_field.type_key_path || ''
|
|
448
|
+
: undefined,
|
|
449
|
+
titleKeyPath:
|
|
450
|
+
fieldDetails.meta.ui.ui_field?.type === 'CUSTOM_FIELDS'
|
|
451
|
+
? fieldDetails.meta.ui.ui_field.title_key_path || ''
|
|
452
|
+
: undefined,
|
|
453
|
+
dataSourceBody:
|
|
454
|
+
fieldDetails.meta.ui.ui_field?.type === 'DYNAMIC_DROPDOWN' ||
|
|
455
|
+
fieldDetails.meta.ui.ui_field?.type === 'CUSTOM_FIELDS'
|
|
456
|
+
? fieldDetails.meta.ui.ui_field.data_source?.body || {}
|
|
457
|
+
: {}, // Set endpoint URL for DYNAMIC_DROPDOWN
|
|
458
|
+
defaultValue: functionArguments[fieldName] || '',
|
|
459
|
+
description:
|
|
460
|
+
fieldDetails.meta.description_for_users ||
|
|
461
|
+
fieldDetails.description ||
|
|
462
|
+
'',
|
|
463
|
+
is_required: fieldDetails.meta.is_required || false,
|
|
464
|
+
is_editable: true,
|
|
465
|
+
is_mappable: true,
|
|
466
|
+
regex: fieldDetails.meta.ui.regex || this.getRegex(fieldDetails),
|
|
467
|
+
regexErrorMessage:
|
|
468
|
+
fieldDetails.meta.ui.regex_error_message ||
|
|
469
|
+
this.getRegexErrorMessage(fieldDetails),
|
|
470
|
+
placeholder:
|
|
471
|
+
fieldDetails.meta.ui.placeholder ||
|
|
472
|
+
(['DYNAMIC_DROPDOWN', 'STATIC_DROPDOWN'].includes(
|
|
473
|
+
fieldDetails.meta.ui.ui_field?.type,
|
|
474
|
+
)
|
|
475
|
+
? `Select or enter a value here...`
|
|
476
|
+
: `Enter value here...`),
|
|
477
|
+
dataType: fieldDetails.type,
|
|
478
|
+
options: fieldDetails.meta.ui.ui_field.options || [],
|
|
479
|
+
properties:
|
|
480
|
+
fieldDetails.type === 'array' && fieldDetails.items.type === 'object'
|
|
481
|
+
? fieldDetails.items.properties || {}
|
|
482
|
+
: fieldDetails.properties || {},
|
|
483
|
+
dependsOn: fieldDetails.meta.ui?.depends_on || [],
|
|
484
|
+
}),
|
|
485
|
+
);
|
|
486
|
+
|
|
487
|
+
// Render fields
|
|
488
|
+
return fields.map((field) => {
|
|
489
|
+
let fieldElement;
|
|
490
|
+
let isDynamic = false;
|
|
491
|
+
let fieldType = field.type;
|
|
492
|
+
if (field.type === 'DYNAMIC_DROPDOWN') {
|
|
493
|
+
fieldType = 'SELECT';
|
|
494
|
+
}
|
|
495
|
+
const options: Option[] = field.options.map((option: any) => ({
|
|
496
|
+
id: field.type === 'CHECKBOX' ? (option.id ? '1' : '0') : option.id, // Assign '1'/'0' only if field.type is 'CHECKBOX'
|
|
497
|
+
value: option.value,
|
|
498
|
+
}));
|
|
499
|
+
|
|
500
|
+
switch (field.type) {
|
|
501
|
+
case 'TEXTFIELD':
|
|
502
|
+
fieldElement = html`
|
|
503
|
+
<div class="${styles.functionFieldWrap} integry-action-field-wrap">
|
|
504
|
+
<${ConfigureFieldWrapper} field=${field}>
|
|
505
|
+
<${MultipurposeField}
|
|
506
|
+
id="${field.id}"
|
|
507
|
+
title="${field.title}"
|
|
508
|
+
activityOutputData=${arrayToNestedJSONWithFirstValue(
|
|
509
|
+
JSONToActivityOutputData(this.props.variables || {}),
|
|
510
|
+
JSONToDynamicFieldData(this.props.variables || {}),
|
|
511
|
+
)}
|
|
512
|
+
activityOutputDataRaw=${JSONToActivityOutputData(
|
|
513
|
+
this.props.variables || {},
|
|
514
|
+
)}
|
|
515
|
+
description="${field.description}"
|
|
516
|
+
value=${this.state.dynamicFieldDataState[field.id]}
|
|
517
|
+
placeholder="${field.placeholder}"
|
|
518
|
+
regex=${field.regex}
|
|
519
|
+
regexErrorMessage=${field.regexErrorMessage}
|
|
520
|
+
isRequired="${field.is_required}"
|
|
521
|
+
onChange=${(val: any) => {
|
|
522
|
+
this.onFieldChange(
|
|
523
|
+
field.id,
|
|
524
|
+
val,
|
|
525
|
+
field.dataType,
|
|
526
|
+
field.is_required,
|
|
527
|
+
parentFieldId,
|
|
528
|
+
);
|
|
529
|
+
}}
|
|
530
|
+
type=${fieldType}
|
|
531
|
+
isMappable=${this.props.variables &&
|
|
532
|
+
Object.entries(this.props.variables).length > 0 &&
|
|
533
|
+
field.dataType !== 'array'}
|
|
534
|
+
isEditable=${true}
|
|
535
|
+
allowTagsInText=${this.props.variables}
|
|
536
|
+
fieldId=${field.id}
|
|
537
|
+
isArray=${field.dataType === 'array'}
|
|
538
|
+
><//>
|
|
539
|
+
<//>
|
|
540
|
+
</div>
|
|
541
|
+
`;
|
|
542
|
+
break;
|
|
543
|
+
case 'TEXTAREA':
|
|
544
|
+
fieldElement = html`
|
|
545
|
+
<div class="${styles.functionFieldWrap} integry-action-field-wrap">
|
|
546
|
+
<${ConfigureFieldWrapper} field=${field}>
|
|
547
|
+
<${MultipurposeField}
|
|
548
|
+
id="${field.id}"
|
|
549
|
+
title="${field.title}"
|
|
550
|
+
activityOutputData=${arrayToNestedJSONWithFirstValue(
|
|
551
|
+
JSONToActivityOutputData(this.props.variables || {}),
|
|
552
|
+
JSONToDynamicFieldData(this.props.variables || {}),
|
|
553
|
+
)}
|
|
554
|
+
activityOutputDataRaw=${JSONToActivityOutputData(
|
|
555
|
+
this.props.variables || {},
|
|
556
|
+
)}
|
|
557
|
+
description="${field.description}"
|
|
558
|
+
value=${this.state.dynamicFieldDataState[field.id]}
|
|
559
|
+
placeholder="${field.placeholder}"
|
|
560
|
+
isRequired=${field.is_required}
|
|
561
|
+
isEditable="${field.is_editable}"
|
|
562
|
+
fieldId=${field.id}
|
|
563
|
+
onChange=${(val: any) => {
|
|
564
|
+
this.onFieldChange(
|
|
565
|
+
field.id,
|
|
566
|
+
val,
|
|
567
|
+
field.dataType,
|
|
568
|
+
field.is_required,
|
|
569
|
+
parentFieldId,
|
|
570
|
+
);
|
|
571
|
+
}}
|
|
572
|
+
regex=${field.regex}
|
|
573
|
+
regexErrorMessage=${field.regexErrorMessage}
|
|
574
|
+
type=${fieldType}
|
|
575
|
+
isMappable=${this.props.variables &&
|
|
576
|
+
Object.entries(this.props.variables).length > 0}
|
|
577
|
+
allowTagsInText=${this.props.variables}
|
|
578
|
+
><//>
|
|
579
|
+
<//>
|
|
580
|
+
</div>
|
|
581
|
+
`;
|
|
582
|
+
break;
|
|
583
|
+
case 'DYNAMIC_DROPDOWN':
|
|
584
|
+
case 'STATIC_DROPDOWN':
|
|
585
|
+
isDynamic = field.type === 'DYNAMIC_DROPDOWN';
|
|
586
|
+
fieldElement = html`
|
|
587
|
+
<div class="${styles.functionFieldWrap} integry-action-field-wrap">
|
|
588
|
+
<${ConfigureFieldWrapper} field=${field}>
|
|
589
|
+
<${ListBox}
|
|
590
|
+
key=${field.id}
|
|
591
|
+
fieldId=${field.id}
|
|
592
|
+
apiHandler=${this.props.apiHandler}
|
|
593
|
+
title=${field.title}
|
|
594
|
+
description=${field.description}
|
|
595
|
+
placeholder=${field.placeholder}
|
|
596
|
+
isRequired=${field.is_required}
|
|
597
|
+
value=${this.state.dynamicFieldDataState[field.id]}
|
|
598
|
+
endpointUrl=${isDynamic
|
|
599
|
+
? field.endpointURL
|
|
600
|
+
: JSON.stringify(options)}
|
|
601
|
+
isDynamic=${isDynamic}
|
|
602
|
+
optionKeyPath=${field.valueKeyPath}
|
|
603
|
+
valueKeyPath=${field.optionKeyPath}
|
|
604
|
+
endpointData=${field.dependsOn.length > 0
|
|
605
|
+
? JSON.stringify({
|
|
606
|
+
authorization_id: `${connectedAccount}`,
|
|
607
|
+
...this.fetchDynamicData(field),
|
|
608
|
+
})
|
|
609
|
+
: null}
|
|
610
|
+
type=${`${fieldType}`}
|
|
611
|
+
isEditable=${field.type === 'DYNAMIC_DROPDOWN'}
|
|
612
|
+
isSearchable=${true}
|
|
613
|
+
appName=${`${appName}`}
|
|
614
|
+
isMultiSelect=${field.isMultiSelect}
|
|
615
|
+
onChange=${(val: any, stopChangePropagation = false) => {
|
|
616
|
+
this.onFieldChange(
|
|
617
|
+
field.id,
|
|
618
|
+
val,
|
|
619
|
+
field.dataType,
|
|
620
|
+
field.is_required,
|
|
621
|
+
parentFieldId,
|
|
622
|
+
-1,
|
|
623
|
+
stopChangePropagation,
|
|
624
|
+
);
|
|
625
|
+
}}
|
|
626
|
+
dataSourceBody=${this.replacePlaceholders(
|
|
627
|
+
field.dataSourceBody,
|
|
628
|
+
this.state.dynamicFieldDataState,
|
|
629
|
+
)}
|
|
630
|
+
selectedAuthId=${`${connectedAccount}`}
|
|
631
|
+
><//>
|
|
632
|
+
<//>
|
|
633
|
+
</div>
|
|
634
|
+
`;
|
|
635
|
+
break;
|
|
636
|
+
case 'CHECKBOX':
|
|
637
|
+
fieldElement = html`
|
|
638
|
+
<div class="${styles.functionFieldWrap} integry-action-field-wrap">
|
|
639
|
+
<${ConfigureFieldWrapper} field=${field}>
|
|
640
|
+
<${CheckboxGroup}
|
|
641
|
+
fieldId=${field.id}
|
|
642
|
+
title=${field.title}
|
|
643
|
+
description=${field.description}
|
|
644
|
+
placeholder=${field.placeholder}
|
|
645
|
+
value=${this.state.dynamicFieldDataState[field.id]}
|
|
646
|
+
isRequired=${field.is_required}
|
|
647
|
+
dataSrcEndpoint=${null}
|
|
648
|
+
isDynamic=${false}
|
|
649
|
+
initialOptions=${options.filter(
|
|
650
|
+
(option: Option) => option.id === '1',
|
|
651
|
+
)}
|
|
652
|
+
onChange=${(val: any) => {
|
|
653
|
+
this.onFieldChange(
|
|
654
|
+
field.id,
|
|
655
|
+
val,
|
|
656
|
+
field.dataType,
|
|
657
|
+
false,
|
|
658
|
+
parentFieldId,
|
|
659
|
+
);
|
|
660
|
+
}}
|
|
661
|
+
>
|
|
662
|
+
<//>
|
|
663
|
+
<//>
|
|
664
|
+
</div>
|
|
665
|
+
`;
|
|
666
|
+
|
|
667
|
+
break;
|
|
668
|
+
case 'CUSTOM_FIELDS':
|
|
669
|
+
if (!field.endpointURL) {
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
672
|
+
fieldElement = html`
|
|
673
|
+
<div
|
|
674
|
+
key=${field.id}
|
|
675
|
+
class=${`${styles.actionStepFieldWrap} integry-action-field-wrap`}
|
|
676
|
+
>
|
|
677
|
+
<${DynamicTypedField}
|
|
678
|
+
dynamicField=${field}
|
|
679
|
+
endpointData=${JSON.stringify({
|
|
680
|
+
authorization_id: `${connectedAccount}`,
|
|
681
|
+
})}
|
|
682
|
+
placeHolder=${field.placeholder}
|
|
683
|
+
appName=${`${appName}`}
|
|
684
|
+
selectedAuthId=${`${connectedAccount}`}
|
|
685
|
+
sourceFlowIntegrataionInvocationUrl=${field.endpointURL}
|
|
686
|
+
isMappable=${Object.entries(this.props.variables || {}).length >
|
|
687
|
+
0}
|
|
688
|
+
isEditable=${false}
|
|
689
|
+
allowTagsInText=${true}
|
|
690
|
+
apiHandler=${this.props.apiHandler}
|
|
691
|
+
idKeyPath=${field.idKeyPath}
|
|
692
|
+
typeKeyPath=${field.typeKeyPath}
|
|
693
|
+
titleKeyPath=${field.titleKeyPath}
|
|
694
|
+
onChange=${(val: any) => {
|
|
695
|
+
this.onFieldChange(field.id, val, field.dataType, false);
|
|
696
|
+
}}
|
|
697
|
+
dataSourceBody=${this.replacePlaceholders(
|
|
698
|
+
field.dataSourceBody,
|
|
699
|
+
this.state.dynamicFieldDataState,
|
|
700
|
+
)}
|
|
701
|
+
parentFieldsChanged=${this.state.parentFieldsChanged}
|
|
702
|
+
activityOutputData=${arrayToNestedJSONWithFirstValue(
|
|
703
|
+
JSONToActivityOutputData(this.props.variables || {}),
|
|
704
|
+
JSONToDynamicFieldData(this.props.variables || {}),
|
|
705
|
+
)}
|
|
706
|
+
activityOutputDataRaw=${JSONToActivityOutputData(
|
|
707
|
+
this.props.variables || {},
|
|
708
|
+
)}
|
|
709
|
+
value=${this.state.dynamicFieldDataState[field.id] || {}}
|
|
710
|
+
/>
|
|
711
|
+
</div>
|
|
712
|
+
`;
|
|
713
|
+
|
|
714
|
+
break;
|
|
715
|
+
case 'STANDARD_FIELDS':
|
|
716
|
+
// Recursively render fields for object type
|
|
717
|
+
if (field.properties) {
|
|
718
|
+
fieldElement = html`
|
|
719
|
+
<div
|
|
720
|
+
class="${styles.functionFieldWrap} integry-action-field-wrap"
|
|
721
|
+
>
|
|
722
|
+
<${ObjectField}
|
|
723
|
+
field=${field}
|
|
724
|
+
functionArguments=${functionArguments}
|
|
725
|
+
connectedAccount=${connectedAccount}
|
|
726
|
+
appName=${appName}
|
|
727
|
+
onChange=${this.onFieldChange}
|
|
728
|
+
apiHandler=${this.props.apiHandler}
|
|
729
|
+
isArray=${field.dataType === 'array'}
|
|
730
|
+
activityOutputData=${arrayToNestedJSONWithFirstValue(
|
|
731
|
+
JSONToActivityOutputData(this.props.variables || {}),
|
|
732
|
+
JSONToDynamicFieldData(this.props.variables || {}),
|
|
733
|
+
)}
|
|
734
|
+
activityOutputDataRaw=${JSONToActivityOutputData(
|
|
735
|
+
this.props.variables || {},
|
|
736
|
+
)}
|
|
737
|
+
/>
|
|
738
|
+
</div>
|
|
739
|
+
`;
|
|
740
|
+
}
|
|
741
|
+
break;
|
|
742
|
+
|
|
743
|
+
// You can add cases for other field types here
|
|
744
|
+
default:
|
|
745
|
+
fieldElement = html``;
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
return html`
|
|
749
|
+
<div class="${styles.functionFieldWrap} integry-action-field-wrap">
|
|
750
|
+
<${ConfigureFieldWrapper} field=${field}> ${fieldElement} <//>
|
|
751
|
+
</div>
|
|
752
|
+
`;
|
|
753
|
+
});
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
renderFunctionDetails = (
|
|
757
|
+
functionName: string,
|
|
758
|
+
functionDetails: any,
|
|
759
|
+
functionArguments: any,
|
|
760
|
+
) => {
|
|
761
|
+
const context = useContext(AppContext);
|
|
762
|
+
if (!functionDetails || !functionDetails.parameters) return null;
|
|
763
|
+
|
|
764
|
+
const connectedAccount =
|
|
765
|
+
this.props.connectedAccountId ||
|
|
766
|
+
functionDetails.meta.app.connected_accounts.length > 0
|
|
767
|
+
? functionDetails.meta.app.connected_accounts[0].id
|
|
768
|
+
: null;
|
|
769
|
+
return this.renderFields(
|
|
770
|
+
functionDetails.parameters.properties,
|
|
771
|
+
functionArguments,
|
|
772
|
+
connectedAccount,
|
|
773
|
+
functionDetails.meta.app.name,
|
|
774
|
+
);
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
render() {
|
|
778
|
+
const {
|
|
779
|
+
functionArguments,
|
|
780
|
+
functionName,
|
|
781
|
+
connectedAccountId,
|
|
782
|
+
onClose,
|
|
783
|
+
} = this.props;
|
|
784
|
+
const { functionDetails } = this.state;
|
|
785
|
+
|
|
786
|
+
return html`
|
|
787
|
+
${this.state.loading
|
|
788
|
+
? html`<div>
|
|
789
|
+
<${AppPageLoader} renderMode=${`MODAL`} />
|
|
790
|
+
</div>`
|
|
791
|
+
: functionDetails &&
|
|
792
|
+
functionDetails.meta &&
|
|
793
|
+
html`
|
|
794
|
+
<div class="${styles.functionFormWrap}">
|
|
795
|
+
<div class="${styles.functionHeader}">
|
|
796
|
+
<div class="${styles.name}">
|
|
797
|
+
<div class="${styles.functionIcon}">
|
|
798
|
+
<img
|
|
799
|
+
src=${functionDetails.meta.app.icon_url}
|
|
800
|
+
alt=${functionDetails.meta.app.name}
|
|
801
|
+
/>
|
|
802
|
+
</div>
|
|
803
|
+
<div class="${styles.text}">
|
|
804
|
+
${functionDetails.meta.ui.title}
|
|
805
|
+
</div>
|
|
806
|
+
</div>
|
|
807
|
+
</div>
|
|
808
|
+
<div class="${styles.functionFormContainer}">
|
|
809
|
+
${functionDetails.meta.app.connected_accounts.length > 0
|
|
810
|
+
? this.renderFunctionDetails(
|
|
811
|
+
functionName,
|
|
812
|
+
functionDetails,
|
|
813
|
+
functionArguments,
|
|
814
|
+
)
|
|
815
|
+
: html`<div class="${styles.errorMessage}">
|
|
816
|
+
Error: User authorization is missing.
|
|
817
|
+
</div>`}
|
|
818
|
+
</div>
|
|
819
|
+
|
|
820
|
+
<div class="${styles.btnSubmit}">
|
|
821
|
+
<${Button}
|
|
822
|
+
label="${functionDetails.meta.app.connected_accounts.length >
|
|
823
|
+
0
|
|
824
|
+
? 'Submit'
|
|
825
|
+
: 'Close'}"
|
|
826
|
+
position="top-right"
|
|
827
|
+
onClick=${this.onSubmit}
|
|
828
|
+
isLoading=${this.state.isSubmitting}
|
|
829
|
+
disabled=${this.state.invalidFields.length > 0}
|
|
830
|
+
tooltip=${this.state.invalidFields.length > 0
|
|
831
|
+
? 'Please complete all required fields with valid data.'
|
|
832
|
+
: ''}
|
|
833
|
+
/>
|
|
834
|
+
</div>
|
|
835
|
+
</div>
|
|
836
|
+
`}
|
|
837
|
+
`;
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
export default connect<
|
|
842
|
+
FunctionFormPropsType,
|
|
843
|
+
ActionFormStateType,
|
|
844
|
+
StoreType,
|
|
845
|
+
unknown
|
|
846
|
+
>(
|
|
847
|
+
[
|
|
848
|
+
'stepState',
|
|
849
|
+
'stepMapping',
|
|
850
|
+
'stepDataMapping',
|
|
851
|
+
'parentChildMapping',
|
|
852
|
+
'fieldListMapping',
|
|
853
|
+
'conditionalFieldMapping',
|
|
854
|
+
'embedConfig',
|
|
855
|
+
'activityOutputData',
|
|
856
|
+
'genericData',
|
|
857
|
+
'userConfig',
|
|
858
|
+
'authMapping',
|
|
859
|
+
'showSetupModal',
|
|
860
|
+
],
|
|
861
|
+
actionFunctions,
|
|
862
|
+
)(FunctionForm);
|