@integry/sdk 4.5.4 → 4.5.6
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 +1 -1
- package/dist/esm/index.csm.d.ts +7 -4
- package/dist/esm/index.csm.js +38 -18
- package/dist/umd/index.umd.d.ts +1 -0
- package/dist/umd/index.umd.js +38 -18
- package/package.json +2 -1
- package/src/features/common/ActionForm/index.ts +74 -23
- package/src/features/common/ActionForm/styles.module.scss +5 -0
- package/src/index.ts +44 -0
- package/src/renderFlowStep.test.ts +0 -0
- package/src/store/actionFunctions.ts +9 -4
- package/vitest.config.ts +6 -0
|
@@ -29,6 +29,7 @@ import NewMappingUI from '@/features/common/NewMappingUI';
|
|
|
29
29
|
import { ObjectField } from '@/components/form';
|
|
30
30
|
import { areParentValuesValid, getFieldLabelTags } from '@/utils/stepUtils';
|
|
31
31
|
import ConfigureFieldWrapper from '@/components/ConfigureFieldWrapper';
|
|
32
|
+
import { notEmpty } from '@/types/utils';
|
|
32
33
|
import {
|
|
33
34
|
JSONToActivityOutputData,
|
|
34
35
|
JSONToDynamicFieldData,
|
|
@@ -44,11 +45,14 @@ interface ActionFormPropsType extends StoreType {
|
|
|
44
45
|
eventEmitter: EventEmitter<IntegrySDKEvents>;
|
|
45
46
|
isReadOnly?: boolean;
|
|
46
47
|
accountConnected: boolean;
|
|
48
|
+
selectedAuthId: string;
|
|
49
|
+
tagsTree: any;
|
|
47
50
|
}
|
|
48
51
|
|
|
49
52
|
interface ActionFormStateType {
|
|
50
53
|
loading: boolean;
|
|
51
54
|
dynamicFieldDataState: any;
|
|
55
|
+
tagsTree: any;
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
interface StepDataMapping {
|
|
@@ -61,6 +65,10 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
61
65
|
this.state = {
|
|
62
66
|
loading: false,
|
|
63
67
|
dynamicFieldDataState: {},
|
|
68
|
+
tagsTree:
|
|
69
|
+
this.props.tagsTree && Object.keys(this.props.tagsTree).length > 0
|
|
70
|
+
? JSONToActivityOutputData(this.props.tagsTree)
|
|
71
|
+
: {},
|
|
64
72
|
};
|
|
65
73
|
}
|
|
66
74
|
|
|
@@ -711,6 +719,9 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
711
719
|
};
|
|
712
720
|
|
|
713
721
|
private shouldShowStep = (field: TemplateField) => {
|
|
722
|
+
if (!this.props.showStepValidation) {
|
|
723
|
+
return true;
|
|
724
|
+
}
|
|
714
725
|
const stepId = this.props.step.id;
|
|
715
726
|
const stepObject = this.props.stepMapping && this.props.stepMapping[stepId];
|
|
716
727
|
|
|
@@ -756,13 +767,15 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
756
767
|
|
|
757
768
|
private stepIsOfType = (fields: string[]) => {
|
|
758
769
|
const stepId = this.props.step.id;
|
|
759
|
-
const stepObject = this.props.stepMapping &&
|
|
760
|
-
|
|
770
|
+
const stepObject = (this.props.stepMapping &&
|
|
771
|
+
this.props.stepMapping[stepId]) || { step: this.props.step };
|
|
772
|
+
return fields.indexOf(stepObject.step.activity?.type) > -1;
|
|
761
773
|
};
|
|
762
774
|
|
|
763
775
|
private textFieldParentHasValues = (currentField: any) => {
|
|
764
776
|
const stepId = this.props.step.id;
|
|
765
|
-
const stepObject = this.props.stepMapping &&
|
|
777
|
+
const stepObject = (this.props.stepMapping &&
|
|
778
|
+
this.props.stepMapping[stepId]) || { step: this.props.step };
|
|
766
779
|
|
|
767
780
|
const anyVisibleFields = stepObject.step.template_fields.filter(
|
|
768
781
|
(el) => el.is_visible,
|
|
@@ -1123,8 +1136,10 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
1123
1136
|
isReadOnly,
|
|
1124
1137
|
accountConnected,
|
|
1125
1138
|
} = this.props;
|
|
1126
|
-
const selectedStep =
|
|
1127
|
-
|
|
1139
|
+
const selectedStep =
|
|
1140
|
+
(stepMapping[step.id] && stepMapping[step.id].step) || step;
|
|
1141
|
+
const selectedStepData =
|
|
1142
|
+
(stepDataMapping && stepDataMapping[step.id]) || {};
|
|
1128
1143
|
const actionConfigPayload = {};
|
|
1129
1144
|
// userConfig?.objects && genericData.directActionPayloadName
|
|
1130
1145
|
// ? embedConfig?.objects[genericData.directActionPayloadName]
|
|
@@ -1134,9 +1149,9 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
1134
1149
|
const activityOutputData =
|
|
1135
1150
|
actionConfigPayload || this.props.activityOutputData || {};
|
|
1136
1151
|
const noStepFields =
|
|
1137
|
-
selectedStep.template_fields
|
|
1152
|
+
selectedStep.template_fields?.length === 0 ||
|
|
1138
1153
|
(!(this.props.userConfig && this.props.userConfig.viewAsIU) &&
|
|
1139
|
-
selectedStep.template_fields
|
|
1154
|
+
selectedStep.template_fields?.filter((field) => field.is_visible)
|
|
1140
1155
|
.length === 0);
|
|
1141
1156
|
return html`
|
|
1142
1157
|
${this.state.loading
|
|
@@ -1144,12 +1159,18 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
1144
1159
|
: html`
|
|
1145
1160
|
${selectedStep
|
|
1146
1161
|
? html`
|
|
1147
|
-
<div
|
|
1162
|
+
<div
|
|
1163
|
+
class=${`${styles.actionFormWrap} ${
|
|
1164
|
+
this.props.selectedAuthId && this.props.accountConnected
|
|
1165
|
+
? `${styles.actionFormWrapAutoWidth}`
|
|
1166
|
+
: ``
|
|
1167
|
+
}`}
|
|
1168
|
+
>
|
|
1148
1169
|
${noStepFields
|
|
1149
1170
|
? html`<span class=${styles.noStepFields}
|
|
1150
1171
|
>There’s nothing to configure, please proceed.</span
|
|
1151
1172
|
>`
|
|
1152
|
-
: selectedStep.template_fields
|
|
1173
|
+
: selectedStep.template_fields?.map((el) => {
|
|
1153
1174
|
if (
|
|
1154
1175
|
this.shouldShowStep(el) &&
|
|
1155
1176
|
(el.activity_field || el.type === 'SECTION')
|
|
@@ -1239,11 +1260,15 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
1239
1260
|
type=${el.activity_field?.type}
|
|
1240
1261
|
selectedAuthId=${`${
|
|
1241
1262
|
this.props.stepMapping[this.props.step.id]
|
|
1242
|
-
?.selectedAuthId ||
|
|
1263
|
+
?.selectedAuthId ||
|
|
1264
|
+
this.props.selectedAuthId ||
|
|
1265
|
+
''
|
|
1243
1266
|
}`}
|
|
1244
|
-
disabled=${
|
|
1245
|
-
this.props.step.id
|
|
1246
|
-
|
|
1267
|
+
disabled=${
|
|
1268
|
+
!this.props.stepMapping[this.props.step.id]
|
|
1269
|
+
?.isAuthVerified &&
|
|
1270
|
+
!this.props.accountConnected
|
|
1271
|
+
}
|
|
1247
1272
|
sourceFlowData=${this.sourceFlowData(el)}
|
|
1248
1273
|
sourceFlowIntegrataionInvocationUrl=${
|
|
1249
1274
|
el.source_flow_integration_invocation_url
|
|
@@ -1316,13 +1341,15 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
1316
1341
|
el.title || el.activity_field?.title
|
|
1317
1342
|
}
|
|
1318
1343
|
activityOutputData=${this.arrayToNestedJSONWithFirstValue(
|
|
1319
|
-
this.props.activityOutputData
|
|
1344
|
+
this.props.activityOutputData ||
|
|
1345
|
+
this.state.tagsTree,
|
|
1320
1346
|
this.props.dynamicFieldData ||
|
|
1321
1347
|
this.state.dynamicFieldDataState ||
|
|
1322
1348
|
{},
|
|
1323
1349
|
)}
|
|
1324
1350
|
activityOutputDataRaw=${
|
|
1325
|
-
this.props.activityOutputData
|
|
1351
|
+
this.props.activityOutputData ||
|
|
1352
|
+
this.state.tagsTree
|
|
1326
1353
|
}
|
|
1327
1354
|
description=${elDescription}
|
|
1328
1355
|
value=${
|
|
@@ -1337,9 +1364,16 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
1337
1364
|
}
|
|
1338
1365
|
placeholder=${this.getPlaceholder(el)}
|
|
1339
1366
|
showStepValidation=${showStepValidation}
|
|
1340
|
-
regex=${
|
|
1367
|
+
regex=${
|
|
1368
|
+
selectedStepData[el.id]
|
|
1369
|
+
? selectedStepData[el.id].regex
|
|
1370
|
+
: ''
|
|
1371
|
+
}
|
|
1341
1372
|
regexErrorMessage=${
|
|
1342
|
-
selectedStepData[el.id]
|
|
1373
|
+
selectedStepData[el.id]
|
|
1374
|
+
? selectedStepData[el.id]
|
|
1375
|
+
.regexErrorMessage
|
|
1376
|
+
: ''
|
|
1343
1377
|
}
|
|
1344
1378
|
isRequired=${el.is_required}
|
|
1345
1379
|
isHidden=${el.is_hidden}
|
|
@@ -1449,10 +1483,15 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
1449
1483
|
placeholder=${el.placeholder ||
|
|
1450
1484
|
'Please enter a URL'}
|
|
1451
1485
|
showStepValidation=${showStepValidation}
|
|
1452
|
-
regex=${selectedStepData[el.id]
|
|
1486
|
+
regex=${selectedStepData[el.id]
|
|
1487
|
+
? selectedStepData[el.id].regex
|
|
1488
|
+
: ''}
|
|
1453
1489
|
regexErrorMessage=${selectedStepData[
|
|
1454
1490
|
el.id
|
|
1455
|
-
]
|
|
1491
|
+
]
|
|
1492
|
+
? selectedStepData[el.id]
|
|
1493
|
+
.regexErrorMessage
|
|
1494
|
+
: ''}
|
|
1456
1495
|
isRequired=${el.is_required}
|
|
1457
1496
|
onChange=${(
|
|
1458
1497
|
val: string,
|
|
@@ -1586,10 +1625,15 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
1586
1625
|
placeholder=${el.placeholder ||
|
|
1587
1626
|
el.activity_field?.placeholder ||
|
|
1588
1627
|
'Please enter a value'}
|
|
1589
|
-
regex=${selectedStepData[el.id]
|
|
1628
|
+
regex=${selectedStepData[el.id]
|
|
1629
|
+
? selectedStepData[el.id].regex
|
|
1630
|
+
: ''}
|
|
1590
1631
|
regexErrorMessage=${selectedStepData[
|
|
1591
1632
|
el.id
|
|
1592
|
-
]
|
|
1633
|
+
]
|
|
1634
|
+
? selectedStepData[el.id]
|
|
1635
|
+
.regexErrorMessage
|
|
1636
|
+
: ''}
|
|
1593
1637
|
showStepValidation=${showStepValidation}
|
|
1594
1638
|
isRequired=${el.is_required}
|
|
1595
1639
|
onChange=${(val: string) => {
|
|
@@ -1631,9 +1675,16 @@ class ActionForm extends Component<ActionFormPropsType, ActionFormStateType> {
|
|
|
1631
1675
|
''
|
|
1632
1676
|
}
|
|
1633
1677
|
placeholder=${this.getPlaceholder(el)}
|
|
1634
|
-
regex=${
|
|
1678
|
+
regex=${
|
|
1679
|
+
selectedStepData[el.id].regex
|
|
1680
|
+
? selectedStepData[el.id].regex
|
|
1681
|
+
: ''
|
|
1682
|
+
}
|
|
1635
1683
|
regexErrorMessage=${
|
|
1636
|
-
selectedStepData[el.id]
|
|
1684
|
+
selectedStepData[el.id]
|
|
1685
|
+
? selectedStepData[el.id]
|
|
1686
|
+
.regexErrorMessage
|
|
1687
|
+
: ''
|
|
1637
1688
|
}
|
|
1638
1689
|
showStepValidation=${showStepValidation}
|
|
1639
1690
|
isRequired=${el.is_required}
|
package/src/index.ts
CHANGED
|
@@ -41,6 +41,7 @@ import FlowSetupContainer from '@/features/containers/FlowSetupContainer';
|
|
|
41
41
|
import MarketplaceContainer from '@/features/containers/MarketplaceContainer';
|
|
42
42
|
import AppFlowContainer from '@/features/containers/AppFlowContainer';
|
|
43
43
|
import MarketplaceAppsContainer from '@/features/containers/MarketplaceAppsContainer';
|
|
44
|
+
import ActionForm from '@/features/common/ActionForm';
|
|
44
45
|
|
|
45
46
|
import FunctionForm from '@/features/common/FunctionForm';
|
|
46
47
|
import { openPopupWindow } from '@/utils/popup';
|
|
@@ -1980,6 +1981,49 @@ export class IntegryJS {
|
|
|
1980
1981
|
}
|
|
1981
1982
|
};
|
|
1982
1983
|
|
|
1984
|
+
public renderFlowStep = (
|
|
1985
|
+
containerId: string,
|
|
1986
|
+
step: any,
|
|
1987
|
+
connectedAccountId: string,
|
|
1988
|
+
tagsTree = {},
|
|
1989
|
+
) => {
|
|
1990
|
+
const target = document.getElementById(containerId);
|
|
1991
|
+
|
|
1992
|
+
if (target) {
|
|
1993
|
+
const store = createSDKStore();
|
|
1994
|
+
render(
|
|
1995
|
+
html`<div>
|
|
1996
|
+
<${AppContext.Provider}
|
|
1997
|
+
value=${{
|
|
1998
|
+
apiHandler: this.apiHandler,
|
|
1999
|
+
eventEmitter: this.eventEmitter,
|
|
2000
|
+
isPreviewMode: false,
|
|
2001
|
+
}}
|
|
2002
|
+
>
|
|
2003
|
+
<${Provider} store=${store} key=${this.getRandomFlowId(10)}>
|
|
2004
|
+
<${ActionForm}
|
|
2005
|
+
step=${step}
|
|
2006
|
+
stepType=${'CONFIGURE'}
|
|
2007
|
+
showStepValidation=${false}
|
|
2008
|
+
apiHandler=${this.apiHandler}
|
|
2009
|
+
eventEmitter=${this.eventEmitter}
|
|
2010
|
+
isReadOnly="${false}"
|
|
2011
|
+
selectedAuthId="${connectedAccountId}"
|
|
2012
|
+
accountConnected=${true}
|
|
2013
|
+
tagsTree=${tagsTree}
|
|
2014
|
+
/>
|
|
2015
|
+
<//>
|
|
2016
|
+
<//>
|
|
2017
|
+
</div>`,
|
|
2018
|
+
target,
|
|
2019
|
+
);
|
|
2020
|
+
} else {
|
|
2021
|
+
console.warn(
|
|
2022
|
+
`Integry SDK render target with id ${containerId} was not found`,
|
|
2023
|
+
);
|
|
2024
|
+
}
|
|
2025
|
+
};
|
|
2026
|
+
|
|
1983
2027
|
public verifyAuthConfig = () =>
|
|
1984
2028
|
this.apiHandler.verifyAuthConfig({
|
|
1985
2029
|
deploymentId: this.config.deploymentId,
|
|
File without changes
|
|
@@ -517,10 +517,15 @@ export const actionFunctions = (storeSnapshot: Store<State>) => ({
|
|
|
517
517
|
const { stepDataMapping, conditionalFieldMapping } = state;
|
|
518
518
|
const element = stepDataMapping[stepId];
|
|
519
519
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
520
|
+
let fieldsData: any[] = [];
|
|
521
|
+
if (element) {
|
|
522
|
+
fieldsData = Object.keys(element).map((fieldId) => {
|
|
523
|
+
const ele = element[Number(fieldId)];
|
|
524
|
+
return ele;
|
|
525
|
+
});
|
|
526
|
+
} else {
|
|
527
|
+
fieldsData = [];
|
|
528
|
+
}
|
|
524
529
|
|
|
525
530
|
const visibleFields = fieldsData.filter((el) => {
|
|
526
531
|
// filter out hidden conditional fields
|
package/vitest.config.ts
CHANGED