@amp-labs/react 1.0.0
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/LICENSE.md +21 -0
- package/README.md +138 -0
- package/build/generated-sources/api/src/apis/DefaultApi.d.ts +858 -0
- package/build/generated-sources/api/src/apis/DefaultApi.js +942 -0
- package/build/generated-sources/api/src/apis/index.d.ts +1 -0
- package/build/generated-sources/api/src/apis/index.js +19 -0
- package/build/generated-sources/api/src/index.d.ts +3 -0
- package/build/generated-sources/api/src/index.js +21 -0
- package/build/generated-sources/api/src/models/BaseConfigContent.d.ts +38 -0
- package/build/generated-sources/api/src/models/BaseConfigContent.js +53 -0
- package/build/generated-sources/api/src/models/BaseReadConfig.d.ts +34 -0
- package/build/generated-sources/api/src/models/BaseReadConfig.js +51 -0
- package/build/generated-sources/api/src/models/BaseReadConfigStandardObject.d.ts +59 -0
- package/build/generated-sources/api/src/models/BaseReadConfigStandardObject.js +58 -0
- package/build/generated-sources/api/src/models/BatchUpsertIntegrationsRequest.d.ts +31 -0
- package/build/generated-sources/api/src/models/BatchUpsertIntegrationsRequest.js +50 -0
- package/build/generated-sources/api/src/models/Config.d.ts +56 -0
- package/build/generated-sources/api/src/models/Config.js +63 -0
- package/build/generated-sources/api/src/models/ConfigContent.d.ts +37 -0
- package/build/generated-sources/api/src/models/ConfigContent.js +53 -0
- package/build/generated-sources/api/src/models/ConfigContentAllOf.d.ts +31 -0
- package/build/generated-sources/api/src/models/ConfigContentAllOf.js +50 -0
- package/build/generated-sources/api/src/models/Connection.d.ts +82 -0
- package/build/generated-sources/api/src/models/Connection.js +76 -0
- package/build/generated-sources/api/src/models/Consumer.d.ts +55 -0
- package/build/generated-sources/api/src/models/Consumer.js +62 -0
- package/build/generated-sources/api/src/models/CreateConsumerRequest.d.ts +37 -0
- package/build/generated-sources/api/src/models/CreateConsumerRequest.js +53 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequest.d.ts +44 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequest.js +57 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.d.ts +39 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.js +52 -0
- package/build/generated-sources/api/src/models/CreateGroupRequest.d.ts +37 -0
- package/build/generated-sources/api/src/models/CreateGroupRequest.js +53 -0
- package/build/generated-sources/api/src/models/CreateInstallationRequest.d.ts +44 -0
- package/build/generated-sources/api/src/models/CreateInstallationRequest.js +57 -0
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.d.ts +44 -0
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.js +57 -0
- package/build/generated-sources/api/src/models/CreateIntegrationRequest.d.ts +44 -0
- package/build/generated-sources/api/src/models/CreateIntegrationRequest.js +57 -0
- package/build/generated-sources/api/src/models/CreateIntegrationRequestLatestRevision.d.ts +31 -0
- package/build/generated-sources/api/src/models/CreateIntegrationRequestLatestRevision.js +50 -0
- package/build/generated-sources/api/src/models/CreateProjectRequest.d.ts +37 -0
- package/build/generated-sources/api/src/models/CreateProjectRequest.js +53 -0
- package/build/generated-sources/api/src/models/CreateProviderAppRequest.d.ts +49 -0
- package/build/generated-sources/api/src/models/CreateProviderAppRequest.js +59 -0
- package/build/generated-sources/api/src/models/Group.d.ts +55 -0
- package/build/generated-sources/api/src/models/Group.js +62 -0
- package/build/generated-sources/api/src/models/HydratedIntegration.d.ts +50 -0
- package/build/generated-sources/api/src/models/HydratedIntegration.js +59 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationField.d.ts +22 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationField.js +45 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationFieldExistent.d.ts +37 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationFieldExistent.js +53 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationObject.d.ts +75 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationObject.js +70 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationRead.d.ts +32 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationRead.js +51 -0
- package/build/generated-sources/api/src/models/HydratedRevision.d.ts +50 -0
- package/build/generated-sources/api/src/models/HydratedRevision.js +60 -0
- package/build/generated-sources/api/src/models/ImportConnectionRequest.d.ts +85 -0
- package/build/generated-sources/api/src/models/ImportConnectionRequest.js +75 -0
- package/build/generated-sources/api/src/models/ImportInstallationRequest.d.ts +39 -0
- package/build/generated-sources/api/src/models/ImportInstallationRequest.js +55 -0
- package/build/generated-sources/api/src/models/ImportInstallationRequestConfig.d.ts +38 -0
- package/build/generated-sources/api/src/models/ImportInstallationRequestConfig.js +54 -0
- package/build/generated-sources/api/src/models/Installation.d.ts +88 -0
- package/build/generated-sources/api/src/models/Installation.js +79 -0
- package/build/generated-sources/api/src/models/Integration.d.ts +68 -0
- package/build/generated-sources/api/src/models/Integration.js +69 -0
- package/build/generated-sources/api/src/models/Integration1.d.ts +50 -0
- package/build/generated-sources/api/src/models/Integration1.js +59 -0
- package/build/generated-sources/api/src/models/IntegrationField.d.ts +22 -0
- package/build/generated-sources/api/src/models/IntegrationField.js +45 -0
- package/build/generated-sources/api/src/models/IntegrationFieldExistent.d.ts +31 -0
- package/build/generated-sources/api/src/models/IntegrationFieldExistent.js +50 -0
- package/build/generated-sources/api/src/models/IntegrationFieldMapping.d.ts +49 -0
- package/build/generated-sources/api/src/models/IntegrationFieldMapping.js +57 -0
- package/build/generated-sources/api/src/models/IntegrationObject.d.ts +63 -0
- package/build/generated-sources/api/src/models/IntegrationObject.js +65 -0
- package/build/generated-sources/api/src/models/IntegrationRead.d.ts +32 -0
- package/build/generated-sources/api/src/models/IntegrationRead.js +51 -0
- package/build/generated-sources/api/src/models/OauthConnectRequest.d.ts +73 -0
- package/build/generated-sources/api/src/models/OauthConnectRequest.js +70 -0
- package/build/generated-sources/api/src/models/Operation.d.ts +80 -0
- package/build/generated-sources/api/src/models/Operation.js +73 -0
- package/build/generated-sources/api/src/models/OperationError.d.ts +49 -0
- package/build/generated-sources/api/src/models/OperationError.js +56 -0
- package/build/generated-sources/api/src/models/OptionalFieldsAutoOption.d.ts +22 -0
- package/build/generated-sources/api/src/models/OptionalFieldsAutoOption.js +35 -0
- package/build/generated-sources/api/src/models/Project.d.ts +55 -0
- package/build/generated-sources/api/src/models/Project.js +62 -0
- package/build/generated-sources/api/src/models/ProjectMembership.d.ts +56 -0
- package/build/generated-sources/api/src/models/ProjectMembership.js +63 -0
- package/build/generated-sources/api/src/models/ProviderApp.d.ts +67 -0
- package/build/generated-sources/api/src/models/ProviderApp.js +67 -0
- package/build/generated-sources/api/src/models/Revision.d.ts +50 -0
- package/build/generated-sources/api/src/models/Revision.js +60 -0
- package/build/generated-sources/api/src/models/UpdateInstallationConfigContent.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateInstallationConfigContent.js +53 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequest.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequest.js +54 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallation.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallation.js +53 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallationConfig.d.ts +44 -0
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallationConfig.js +55 -0
- package/build/generated-sources/api/src/models/UpdateProjectRequest.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateProjectRequest.js +54 -0
- package/build/generated-sources/api/src/models/UpdateProjectRequestProject.d.ts +37 -0
- package/build/generated-sources/api/src/models/UpdateProjectRequestProject.js +52 -0
- package/build/generated-sources/api/src/models/UpdateProviderAppRequest.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateProviderAppRequest.js +54 -0
- package/build/generated-sources/api/src/models/UpdateProviderAppRequestProviderApp.d.ts +49 -0
- package/build/generated-sources/api/src/models/UpdateProviderAppRequestProviderApp.js +56 -0
- package/build/generated-sources/api/src/models/UpsertProjectMembershipRequest.d.ts +37 -0
- package/build/generated-sources/api/src/models/UpsertProjectMembershipRequest.js +53 -0
- package/build/generated-sources/api/src/models/index.d.ts +54 -0
- package/build/generated-sources/api/src/models/index.js +72 -0
- package/build/generated-sources/api/src/runtime.d.ts +182 -0
- package/build/generated-sources/api/src/runtime.js +317 -0
- package/build/src/assets/LoadingIcon.d.ts +5 -0
- package/build/src/assets/LoadingIcon.js +9 -0
- package/build/src/assets/NavIcon.d.ts +1 -0
- package/build/src/assets/NavIcon.js +23 -0
- package/build/src/components/AmpersandProvider/AmpersandProvider.d.ts +19 -0
- package/build/src/components/AmpersandProvider/AmpersandProvider.js +31 -0
- package/build/src/components/AmpersandProvider/index.d.ts +1 -0
- package/build/src/components/AmpersandProvider/index.js +17 -0
- package/build/src/components/CenteredTextBox/CenteredTextBox.d.ts +5 -0
- package/build/src/components/CenteredTextBox/CenteredTextBox.js +8 -0
- package/build/src/components/Configure/ConfigureInstallationBase.d.ts +8 -0
- package/build/src/components/Configure/ConfigureInstallationBase.js +17 -0
- package/build/src/components/Configure/CreateInstallation.d.ts +1 -0
- package/build/src/components/Configure/CreateInstallation.js +73 -0
- package/build/src/components/Configure/ErrorTextBox.d.ts +5 -0
- package/build/src/components/Configure/ErrorTextBox.js +9 -0
- package/build/src/components/Configure/InstallIntegration.d.ts +9 -0
- package/build/src/components/Configure/InstallIntegration.js +40 -0
- package/build/src/components/Configure/ObjectManagementNav/NavObjectItem.d.ts +8 -0
- package/build/src/components/Configure/ObjectManagementNav/NavObjectItem.js +14 -0
- package/build/src/components/Configure/ObjectManagementNav/index.d.ts +9 -0
- package/build/src/components/Configure/ObjectManagementNav/index.js +45 -0
- package/build/src/components/Configure/ProtectedConnectionLayout.d.ts +6 -0
- package/build/src/components/Configure/ProtectedConnectionLayout.js +28 -0
- package/build/src/components/Configure/UpdateInstallation.d.ts +7 -0
- package/build/src/components/Configure/UpdateInstallation.js +87 -0
- package/build/src/components/Configure/actions/onSaveCreate.d.ts +3 -0
- package/build/src/components/Configure/actions/onSaveCreate.js +90 -0
- package/build/src/components/Configure/actions/onSaveUpdate.d.ts +3 -0
- package/build/src/components/Configure/actions/onSaveUpdate.js +74 -0
- package/build/src/components/Configure/fields/FieldHeader.d.ts +5 -0
- package/build/src/components/Configure/fields/FieldHeader.js +9 -0
- package/build/src/components/Configure/fields/FieldMapping.d.ts +10 -0
- package/build/src/components/Configure/fields/FieldMapping.js +28 -0
- package/build/src/components/Configure/fields/OptionalFields.d.ts +1 -0
- package/build/src/components/Configure/fields/OptionalFields.js +45 -0
- package/build/src/components/Configure/fields/RequiredFieldMappings.d.ts +1 -0
- package/build/src/components/Configure/fields/RequiredFieldMappings.js +40 -0
- package/build/src/components/Configure/fields/RequiredFields.d.ts +1 -0
- package/build/src/components/Configure/fields/RequiredFields.js +27 -0
- package/build/src/components/Configure/index.d.ts +1 -0
- package/build/src/components/Configure/index.js +5 -0
- package/build/src/components/Configure/state/ConfigurationStateProvider.d.ts +13 -0
- package/build/src/components/Configure/state/ConfigurationStateProvider.js +54 -0
- package/build/src/components/Configure/state/HydratedRevisionContext.d.ts +14 -0
- package/build/src/components/Configure/state/HydratedRevisionContext.js +82 -0
- package/build/src/components/Configure/state/utils.d.ts +34 -0
- package/build/src/components/Configure/state/utils.js +146 -0
- package/build/src/components/Configure/types.d.ts +31 -0
- package/build/src/components/Configure/types.js +2 -0
- package/build/src/components/Configure/utils.d.ts +24 -0
- package/build/src/components/Configure/utils.js +82 -0
- package/build/src/components/OAuthPopup/OAuthPopup.d.ts +14 -0
- package/build/src/components/OAuthPopup/OAuthPopup.js +85 -0
- package/build/src/components/Salesforce/SalesforceOauthFlow.d.ts +16 -0
- package/build/src/components/Salesforce/SalesforceOauthFlow.js +78 -0
- package/build/src/components/ThemeProvider/index.d.ts +6 -0
- package/build/src/components/ThemeProvider/index.js +37 -0
- package/build/src/components/index.d.ts +2 -0
- package/build/src/components/index.js +18 -0
- package/build/src/constants.d.ts +1 -0
- package/build/src/constants.js +4 -0
- package/build/src/context/ApiKeyContext.d.ts +3 -0
- package/build/src/context/ApiKeyContext.js +6 -0
- package/build/src/context/ConnectionsContext.d.ts +16 -0
- package/build/src/context/ConnectionsContext.js +57 -0
- package/build/src/context/ErrorContextProvider.d.ts +37 -0
- package/build/src/context/ErrorContextProvider.js +72 -0
- package/build/src/context/InstallIntegrationContext.d.ts +24 -0
- package/build/src/context/InstallIntegrationContext.js +90 -0
- package/build/src/context/IntegrationListContext.d.ts +13 -0
- package/build/src/context/IntegrationListContext.js +48 -0
- package/build/src/context/ProjectContext.d.ts +15 -0
- package/build/src/context/ProjectContext.js +50 -0
- package/build/src/hooks/index.d.ts +1 -0
- package/build/src/hooks/index.js +17 -0
- package/build/src/hooks/useIsIntegrationInstalled.d.ts +6 -0
- package/build/src/hooks/useIsIntegrationInstalled.js +48 -0
- package/build/src/index.d.ts +2 -0
- package/build/src/index.js +18 -0
- package/build/src/services/api.d.ts +9 -0
- package/build/src/services/api.js +64 -0
- package/build/src/utils/index.d.ts +10 -0
- package/build/src/utils/index.js +21 -0
- package/package.json +80 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateInstallation = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
/**
|
|
6
|
+
* this page is wip: untested
|
|
7
|
+
*/
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const ApiKeyContext_1 = require("../../context/ApiKeyContext");
|
|
10
|
+
const ConnectionsContext_1 = require("../../context/ConnectionsContext");
|
|
11
|
+
const ErrorContextProvider_1 = require("../../context/ErrorContextProvider");
|
|
12
|
+
const InstallIntegrationContext_1 = require("../../context/InstallIntegrationContext");
|
|
13
|
+
const ProjectContext_1 = require("../../context/ProjectContext");
|
|
14
|
+
const onSaveCreate_1 = require("./actions/onSaveCreate");
|
|
15
|
+
const ConfigurationStateProvider_1 = require("./state/ConfigurationStateProvider");
|
|
16
|
+
const HydratedRevisionContext_1 = require("./state/HydratedRevisionContext");
|
|
17
|
+
const utils_1 = require("./state/utils");
|
|
18
|
+
const ConfigureInstallationBase_1 = require("./ConfigureInstallationBase");
|
|
19
|
+
const ObjectManagementNav_1 = require("./ObjectManagementNav");
|
|
20
|
+
// the config should be undefined for create flow
|
|
21
|
+
const UNDEFINED_CONFIG = undefined;
|
|
22
|
+
// Create Installation Flow
|
|
23
|
+
function CreateInstallation() {
|
|
24
|
+
const { integrationId, groupRef, consumerRef, setInstallation, } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
|
|
25
|
+
const { hydratedRevision, loading } = (0, HydratedRevisionContext_1.useHydratedRevision)();
|
|
26
|
+
const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
|
|
27
|
+
const { selectedConnection } = (0, ConnectionsContext_1.useConnections)();
|
|
28
|
+
const apiKey = (0, react_1.useContext)(ApiKeyContext_1.ApiKeyContext);
|
|
29
|
+
const { projectId } = (0, ProjectContext_1.useProject)();
|
|
30
|
+
const { resetBoundary, setErrors } = (0, ErrorContextProvider_1.useErrorState)();
|
|
31
|
+
const { setConfigureState, objectConfigurationsState, resetPendingConfigurationState, } = (0, ConfigurationStateProvider_1.useConfigureState)();
|
|
32
|
+
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
33
|
+
const [isLoading, setLoadingState] = (0, react_1.useState)(false);
|
|
34
|
+
const resetState = (0, react_1.useCallback)(() => {
|
|
35
|
+
resetBoundary(ErrorContextProvider_1.ErrorBoundary.MAPPING);
|
|
36
|
+
if ((hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) && !loading && selectedObjectName) {
|
|
37
|
+
(0, utils_1.resetConfigurationState)(hydratedRevision, UNDEFINED_CONFIG, selectedObjectName, setConfigureState);
|
|
38
|
+
}
|
|
39
|
+
}, [hydratedRevision, loading, selectedObjectName, setConfigureState, resetBoundary]);
|
|
40
|
+
(0, react_1.useEffect)(() => {
|
|
41
|
+
// set configurationState when hydratedRevision is loaded
|
|
42
|
+
if (!configureState && (hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) && !loading) {
|
|
43
|
+
resetState();
|
|
44
|
+
}
|
|
45
|
+
}, [configureState, objectConfigurationsState, hydratedRevision, loading, resetState]);
|
|
46
|
+
const onSave = (e) => {
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
const { requiredMapFields } = configureState;
|
|
49
|
+
const fieldsWithRequirementsNotMet = (requiredMapFields === null || requiredMapFields === void 0 ? void 0 : requiredMapFields.filter((field) => !field.value))
|
|
50
|
+
|| [];
|
|
51
|
+
const errList = fieldsWithRequirementsNotMet.map((field) => field.mapToName);
|
|
52
|
+
setErrors(ErrorContextProvider_1.ErrorBoundary.MAPPING, errList);
|
|
53
|
+
// if requires fields are not met, set error fields and return
|
|
54
|
+
if (fieldsWithRequirementsNotMet === null || fieldsWithRequirementsNotMet === void 0 ? void 0 : fieldsWithRequirementsNotMet.length) {
|
|
55
|
+
console.error('required fields not met', fieldsWithRequirementsNotMet.map((field) => field.mapToDisplayName));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (selectedObjectName && (selectedConnection === null || selectedConnection === void 0 ? void 0 : selectedConnection.id) && apiKey && projectId
|
|
59
|
+
&& integrationId && groupRef && consumerRef && hydratedRevision) {
|
|
60
|
+
setLoadingState(true);
|
|
61
|
+
const res = (0, onSaveCreate_1.onSaveCreate)(projectId, integrationId, groupRef, consumerRef, selectedConnection.id, selectedObjectName, apiKey, hydratedRevision, configureState, setInstallation);
|
|
62
|
+
res.finally(() => {
|
|
63
|
+
setLoadingState(false);
|
|
64
|
+
resetPendingConfigurationState(selectedObjectName);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
console.error('OnSaveCreate: missing required props');
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
return ((0, jsx_runtime_1.jsx)(ConfigureInstallationBase_1.ConfigureInstallationBase, { isLoading: isLoading, onSave: onSave, onReset: resetState }));
|
|
72
|
+
}
|
|
73
|
+
exports.CreateInstallation = CreateInstallation;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ErrorTextBox = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
function ErrorTextBox({ message }) {
|
|
7
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Box, { minHeight: "300px", padding: "30px", display: "flex", flexDirection: "column", justifyContent: "space-evenly", alignItems: "center", children: [(0, jsx_runtime_1.jsxs)("svg", { width: "48", height: "48", viewBox: "0 0 48 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", { d: "M20.5796 7.72236L3.63955 36.0024C3.29029 36.6072 3.10549 37.293 3.10353 37.9914C3.10158 38.6898 3.28254 39.3766 3.62841 39.9834C3.97428 40.5902 4.473 41.0959 5.07497 41.4501C5.67693 41.8043 6.36115 41.9947 7.05955 42.0024H40.9396C41.638 41.9947 42.3222 41.8043 42.9241 41.4501C43.5261 41.0959 44.0248 40.5902 44.3707 39.9834C44.7166 39.3766 44.8975 38.6898 44.8956 37.9914C44.8936 37.293 44.7088 36.6072 44.3596 36.0024L27.4196 7.72236C27.063 7.13458 26.561 6.6486 25.9619 6.31133C25.3629 5.97406 24.687 5.79688 23.9996 5.79688C23.3121 5.79688 22.6362 5.97406 22.0372 6.31133C21.4381 6.6486 20.9361 7.13458 20.5796 7.72236Z", stroke: "#7F1D1D", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" }), (0, jsx_runtime_1.jsx)("path", { d: "M24 18V26", stroke: "#7F1D1D", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" }), (0, jsx_runtime_1.jsx)("path", { d: "M24 34H24.02", stroke: "#7F1D1D", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" })] }), (0, jsx_runtime_1.jsx)(react_1.Box, { boxSizing: "border-box", display: "flex", justifyContent: "center", alignItems: "center", "align-self": "stretch", padding: "12px 50px 12px 50px", borderRadius: "8px", border: "2px solid #FECACA", background: "#FEF2F2", children: (0, jsx_runtime_1.jsx)(react_1.Text, { color: "#991B1B", children: message }) })] }));
|
|
8
|
+
}
|
|
9
|
+
exports.ErrorTextBox = ErrorTextBox;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface InstallIntegrationProps {
|
|
2
|
+
integration: string;
|
|
3
|
+
consumerRef: string;
|
|
4
|
+
consumerName?: string;
|
|
5
|
+
groupRef: string;
|
|
6
|
+
groupName?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function InstallIntegration({ integration, consumerRef, consumerName, groupRef, groupName, }: InstallIntegrationProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InstallIntegration = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const ConnectionsContext_1 = require("../../context/ConnectionsContext");
|
|
6
|
+
const ErrorContextProvider_1 = require("../../context/ErrorContextProvider");
|
|
7
|
+
const InstallIntegrationContext_1 = require("../../context/InstallIntegrationContext");
|
|
8
|
+
const ProjectContext_1 = require("../../context/ProjectContext");
|
|
9
|
+
const ConfigurationStateProvider_1 = require("./state/ConfigurationStateProvider");
|
|
10
|
+
const HydratedRevisionContext_1 = require("./state/HydratedRevisionContext");
|
|
11
|
+
const CreateInstallation_1 = require("./CreateInstallation");
|
|
12
|
+
const ErrorTextBox_1 = require("./ErrorTextBox");
|
|
13
|
+
const ObjectManagementNav_1 = require("./ObjectManagementNav");
|
|
14
|
+
const ProtectedConnectionLayout_1 = require("./ProtectedConnectionLayout");
|
|
15
|
+
const UpdateInstallation_1 = require("./UpdateInstallation");
|
|
16
|
+
// todo : add the install integration provider to supply these properties
|
|
17
|
+
function InstallationContent() {
|
|
18
|
+
const { integrationObj, installation } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
|
|
19
|
+
if (!integrationObj) {
|
|
20
|
+
return (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: "We can't load the integration" });
|
|
21
|
+
}
|
|
22
|
+
return installation && integrationObj ? (
|
|
23
|
+
// If installation exists, render update installation flow
|
|
24
|
+
(0, jsx_runtime_1.jsx)(UpdateInstallation_1.UpdateInstallation, { installation: installation, integrationObj: integrationObj })) : (
|
|
25
|
+
// No installation, render create installation flow
|
|
26
|
+
(0, jsx_runtime_1.jsx)(CreateInstallation_1.CreateInstallation, {}));
|
|
27
|
+
}
|
|
28
|
+
// TODO consider creating an integration obj context
|
|
29
|
+
function InstallIntegration({ integration, consumerRef, consumerName, groupRef, groupName, }) {
|
|
30
|
+
var _a;
|
|
31
|
+
const { projectId } = (0, ProjectContext_1.useProject)();
|
|
32
|
+
const { errorState } = (0, ErrorContextProvider_1.useErrorState)();
|
|
33
|
+
if ((_a = errorState[ErrorContextProvider_1.ErrorBoundary.INTEGRATION_LIST]) === null || _a === void 0 ? void 0 : _a.apiError) {
|
|
34
|
+
return (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: "Something went wrong, couldn't find integration information" });
|
|
35
|
+
}
|
|
36
|
+
return (
|
|
37
|
+
// install integration provider provides all props, integrationObj and installation
|
|
38
|
+
(0, jsx_runtime_1.jsx)(InstallIntegrationContext_1.InstallIntegrationProvider, { integration: integration, consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName, children: (0, jsx_runtime_1.jsx)(ConnectionsContext_1.ConnectionsProvider, { projectId: projectId, children: (0, jsx_runtime_1.jsx)(ProtectedConnectionLayout_1.ProtectedConnectionLayout, { children: (0, jsx_runtime_1.jsx)(HydratedRevisionContext_1.HydratedRevisionProvider, { projectId: projectId, children: (0, jsx_runtime_1.jsx)(ConfigurationStateProvider_1.ConfigurationProvider, { children: (0, jsx_runtime_1.jsx)(ObjectManagementNav_1.ObjectManagementNav, { children: (0, jsx_runtime_1.jsx)(InstallationContent, {}) }) }) }) }) }) }));
|
|
39
|
+
}
|
|
40
|
+
exports.InstallIntegration = InstallIntegration;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface NavObjectItemProps {
|
|
3
|
+
objectName: string;
|
|
4
|
+
completed: boolean;
|
|
5
|
+
pending?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const NavObjectItem: import("react").ForwardRefExoticComponent<NavObjectItemProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NavObjectItem = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_2 = require("@chakra-ui/react");
|
|
7
|
+
const NavIcon_1 = require("../../../assets/NavIcon");
|
|
8
|
+
exports.NavObjectItem = (0, react_1.forwardRef)(({ objectName, completed, pending }, ref) => {
|
|
9
|
+
// 1. Reuse the `useTab` hook
|
|
10
|
+
const tabProps = (0, react_2.useTab)({ ref });
|
|
11
|
+
// 2. Hook into the Tabs `size`, `variant`, props
|
|
12
|
+
const styles = (0, react_2.useMultiStyleConfig)('Tabs', tabProps);
|
|
13
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.Button, Object.assign({ __css: styles.tab }, tabProps, { variant: "outline", minHeight: 15, children: [(0, jsx_runtime_1.jsxs)(react_2.Box, { as: "span", display: "flex", alignItems: "center", gap: 2, mr: "3", children: [(0, NavIcon_1.NavIcon)(completed, pending), (0, jsx_runtime_1.jsxs)(react_2.Box, { textAlign: "left", children: [(0, jsx_runtime_1.jsx)(react_2.Text, { children: objectName }), pending && (0, jsx_runtime_1.jsx)(react_2.Text, { fontSize: 10, fontStyle: "italic", children: "pending" })] })] }), tabProps.children] })));
|
|
14
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare function useSelectedObjectName(): {
|
|
3
|
+
selectedObjectName: string | undefined;
|
|
4
|
+
};
|
|
5
|
+
type ObjectManagementNavProps = {
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export declare function ObjectManagementNav({ children, }: ObjectManagementNavProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObjectManagementNav = exports.useSelectedObjectName = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_2 = require("@chakra-ui/react");
|
|
7
|
+
const InstallIntegrationContext_1 = require("../../../context/InstallIntegrationContext");
|
|
8
|
+
const ProjectContext_1 = require("../../../context/ProjectContext");
|
|
9
|
+
const ConfigurationStateProvider_1 = require("../state/ConfigurationStateProvider");
|
|
10
|
+
const HydratedRevisionContext_1 = require("../state/HydratedRevisionContext");
|
|
11
|
+
const utils_1 = require("../utils");
|
|
12
|
+
const NavObjectItem_1 = require("./NavObjectItem");
|
|
13
|
+
// Create a context for the selected navObject's name
|
|
14
|
+
const SelectedObjectNameContext = (0, react_1.createContext)(null);
|
|
15
|
+
// Custom hook to access the selected navObject's name
|
|
16
|
+
function useSelectedObjectName() {
|
|
17
|
+
const selectedNavObjectName = (0, react_1.useContext)(SelectedObjectNameContext);
|
|
18
|
+
if (selectedNavObjectName === null) {
|
|
19
|
+
throw new Error('useSelectedNavObjectName must be used within a SelectedNavObjectNameProvider');
|
|
20
|
+
}
|
|
21
|
+
return { selectedObjectName: selectedNavObjectName }; // Return as an object
|
|
22
|
+
}
|
|
23
|
+
exports.useSelectedObjectName = useSelectedObjectName;
|
|
24
|
+
function getSelectedObject(navObjects, tabIndex) {
|
|
25
|
+
return navObjects === null || navObjects === void 0 ? void 0 : navObjects[tabIndex];
|
|
26
|
+
}
|
|
27
|
+
// note: when the object key exists in the config; the user has already completed the object before
|
|
28
|
+
function ObjectManagementNav({ children, }) {
|
|
29
|
+
const { installation } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
|
|
30
|
+
const { hydratedRevision } = (0, HydratedRevisionContext_1.useHydratedRevision)();
|
|
31
|
+
const { objectConfigurationsState } = (0, ConfigurationStateProvider_1.useConfigureState)();
|
|
32
|
+
const config = installation === null || installation === void 0 ? void 0 : installation.config;
|
|
33
|
+
const navObjects = hydratedRevision && (0, utils_1.generateNavObjects)(config, hydratedRevision);
|
|
34
|
+
const [tabIndex, setTabIndex] = (0, react_1.useState)(0);
|
|
35
|
+
const handleTabsChange = (index) => { setTabIndex(index); };
|
|
36
|
+
const selectedObject = getSelectedObject(navObjects || [], tabIndex);
|
|
37
|
+
const { project } = (0, ProjectContext_1.useProject)();
|
|
38
|
+
const appName = (project === null || project === void 0 ? void 0 : project.appName) || '';
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)(SelectedObjectNameContext.Provider, { value: selectedObject === null || selectedObject === void 0 ? void 0 : selectedObject.name, children: (0, jsx_runtime_1.jsxs)(react_2.Box, { p: 8, maxWidth: "55rem", border: "1px solid #EFEFEF", borderRadius: 6, boxShadow: "md", margin: "auto", bgColor: "whitesmoke", display: "flex", gap: "6", minHeight: "100%", children: [(0, jsx_runtime_1.jsxs)(react_2.Box, { width: "20rem", children: [(0, jsx_runtime_1.jsx)(react_2.Text, { children: "Salesforce integration" }), (0, jsx_runtime_1.jsx)(react_2.Text, { marginBottom: "20px", fontSize: "1.125rem", fontWeight: "500", children: appName }), navObjects && ((0, jsx_runtime_1.jsx)(react_2.Tabs, { index: tabIndex, onChange: handleTabsChange, orientation: "horizontal", children: navObjects.map((object) => {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)(NavObjectItem_1.NavObjectItem, { objectName: object.name, completed: object.completed, pending: ((_a = objectConfigurationsState[object.name]) === null || _a === void 0 ? void 0 : _a.isOptionalFieldsModified)
|
|
42
|
+
|| ((_b = objectConfigurationsState[object.name]) === null || _b === void 0 ? void 0 : _b.isRequiredMapFieldsModified) }, object.name));
|
|
43
|
+
}) }))] }), children] }) }));
|
|
44
|
+
}
|
|
45
|
+
exports.ObjectManagementNav = ObjectManagementNav;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ProtectedConnectionLayout = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const ConnectionsContext_1 = require("../../context/ConnectionsContext");
|
|
10
|
+
const InstallIntegrationContext_1 = require("../../context/InstallIntegrationContext");
|
|
11
|
+
const SalesforceOauthFlow_1 = __importDefault(require("../Salesforce/SalesforceOauthFlow"));
|
|
12
|
+
// if connection does not exist, render SalesforceOauthFlow
|
|
13
|
+
function ProtectedConnectionLayout({ children }) {
|
|
14
|
+
const { consumerRef, consumerName, groupRef, groupName, } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
|
|
15
|
+
const { selectedConnection, setSelectedConnection, connections } = (0, ConnectionsContext_1.useConnections)();
|
|
16
|
+
(0, react_1.useEffect)(() => {
|
|
17
|
+
if (!selectedConnection && connections && connections.length > 0) {
|
|
18
|
+
const [connection] = connections;
|
|
19
|
+
setSelectedConnection(connection);
|
|
20
|
+
}
|
|
21
|
+
}, [connections, selectedConnection, setSelectedConnection]);
|
|
22
|
+
// a selected connection exists, render children
|
|
23
|
+
if (selectedConnection)
|
|
24
|
+
return children;
|
|
25
|
+
// Require user to login to Saleforce if there are no connections yet.
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(SalesforceOauthFlow_1.default, { consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName }));
|
|
27
|
+
}
|
|
28
|
+
exports.ProtectedConnectionLayout = ProtectedConnectionLayout;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Installation, Integration } from '../../services/api';
|
|
2
|
+
interface UpdateInstallationProps {
|
|
3
|
+
installation: Installation;
|
|
4
|
+
integrationObj: Integration;
|
|
5
|
+
}
|
|
6
|
+
export declare function UpdateInstallation({ installation, integrationObj }: UpdateInstallationProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdateInstallation = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ApiKeyContext_1 = require("../../context/ApiKeyContext");
|
|
7
|
+
const ErrorContextProvider_1 = require("../../context/ErrorContextProvider");
|
|
8
|
+
const InstallIntegrationContext_1 = require("../../context/InstallIntegrationContext");
|
|
9
|
+
const ProjectContext_1 = require("../../context/ProjectContext");
|
|
10
|
+
const onSaveUpdate_1 = require("./actions/onSaveUpdate");
|
|
11
|
+
const ConfigurationStateProvider_1 = require("./state/ConfigurationStateProvider");
|
|
12
|
+
const HydratedRevisionContext_1 = require("./state/HydratedRevisionContext");
|
|
13
|
+
const utils_1 = require("./state/utils");
|
|
14
|
+
const ConfigureInstallationBase_1 = require("./ConfigureInstallationBase");
|
|
15
|
+
const ObjectManagementNav_1 = require("./ObjectManagementNav");
|
|
16
|
+
// Update Installation Flow
|
|
17
|
+
function UpdateInstallation({ installation, integrationObj }) {
|
|
18
|
+
const { setInstallation } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
|
|
19
|
+
const { hydratedRevision, loading } = (0, HydratedRevisionContext_1.useHydratedRevision)();
|
|
20
|
+
const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
|
|
21
|
+
const apiKey = (0, react_1.useContext)(ApiKeyContext_1.ApiKeyContext);
|
|
22
|
+
const { projectId } = (0, ProjectContext_1.useProject)();
|
|
23
|
+
// when no installation or config exists, render create flow
|
|
24
|
+
const { config } = installation;
|
|
25
|
+
const [isLoading, setLoadingState] = (0, react_1.useState)(false);
|
|
26
|
+
// 1. get config from installations (contains form selection state)
|
|
27
|
+
// 2. get the hydrated revision (contains full form)
|
|
28
|
+
// 3. generate the configuration state from the hydrated revision and config
|
|
29
|
+
const { resetBoundary, setErrors } = (0, ErrorContextProvider_1.useErrorState)();
|
|
30
|
+
const { setConfigureState, objectConfigurationsState, resetPendingConfigurationState, } = (0, ConfigurationStateProvider_1.useConfigureState)();
|
|
31
|
+
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
32
|
+
const resetState = (0, react_1.useCallback)(() => {
|
|
33
|
+
resetBoundary(ErrorContextProvider_1.ErrorBoundary.MAPPING);
|
|
34
|
+
// set configurationState when hydratedRevision is loaded
|
|
35
|
+
if ((hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) && !loading && selectedObjectName) {
|
|
36
|
+
(0, utils_1.resetConfigurationState)(hydratedRevision, config, selectedObjectName, setConfigureState);
|
|
37
|
+
}
|
|
38
|
+
}, [
|
|
39
|
+
hydratedRevision,
|
|
40
|
+
loading,
|
|
41
|
+
config,
|
|
42
|
+
selectedObjectName,
|
|
43
|
+
setConfigureState,
|
|
44
|
+
resetBoundary,
|
|
45
|
+
]);
|
|
46
|
+
(0, react_1.useEffect)(() => {
|
|
47
|
+
if (!configureState) {
|
|
48
|
+
resetState();
|
|
49
|
+
}
|
|
50
|
+
}, [configureState, resetState]);
|
|
51
|
+
const hydratedObject = (0, react_1.useMemo)(() => {
|
|
52
|
+
var _a, _b, _c;
|
|
53
|
+
const hydrated = (_c = (_b = (_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.read) === null || _b === void 0 ? void 0 : _b.standardObjects) === null || _c === void 0 ? void 0 : _c.find((obj) => (obj === null || obj === void 0 ? void 0 : obj.objectName) === selectedObjectName);
|
|
54
|
+
return hydrated;
|
|
55
|
+
}, [hydratedRevision, selectedObjectName]);
|
|
56
|
+
const onSave = (e) => {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
// check if fields with requirements are met
|
|
59
|
+
const { requiredMapFields } = configureState;
|
|
60
|
+
const fieldsWithRequirementsNotMet = (requiredMapFields === null || requiredMapFields === void 0 ? void 0 : requiredMapFields.filter((field) => !field.value))
|
|
61
|
+
|| [];
|
|
62
|
+
const errList = fieldsWithRequirementsNotMet.map((field) => field.mapToName);
|
|
63
|
+
setErrors(ErrorContextProvider_1.ErrorBoundary.MAPPING, errList);
|
|
64
|
+
// if requires fields are not met, set error fields and return
|
|
65
|
+
if (fieldsWithRequirementsNotMet === null || fieldsWithRequirementsNotMet === void 0 ? void 0 : fieldsWithRequirementsNotMet.length) {
|
|
66
|
+
console.error('required fields not met', fieldsWithRequirementsNotMet.map((field) => field.mapToDisplayName));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
if (installation
|
|
70
|
+
&& selectedObjectName
|
|
71
|
+
&& apiKey
|
|
72
|
+
&& projectId
|
|
73
|
+
&& hydratedObject) {
|
|
74
|
+
setLoadingState(true);
|
|
75
|
+
const res = (0, onSaveUpdate_1.onSaveUpdate)(projectId, integrationObj.id, installation.id, selectedObjectName, apiKey, configureState, setInstallation, hydratedObject);
|
|
76
|
+
res.finally(() => {
|
|
77
|
+
setLoadingState(false);
|
|
78
|
+
resetPendingConfigurationState(selectedObjectName);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
console.error('update installation props missing');
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
return ((0, jsx_runtime_1.jsx)(ConfigureInstallationBase_1.ConfigureInstallationBase, { onSave: onSave, onReset: resetState, isLoading: isLoading }));
|
|
86
|
+
}
|
|
87
|
+
exports.UpdateInstallation = UpdateInstallation;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { HydratedRevision, Installation } from '../../../services/api';
|
|
2
|
+
import { ConfigureState } from '../types';
|
|
3
|
+
export declare const onSaveCreate: (projectId: string, integrationId: string, groupRef: string, consumerRef: string, connectionId: string, objectName: string, apiKey: string, hydratedRevision: HydratedRevision, configureState: ConfigureState, setInstallation: (installationObj: Installation) => void) => Promise<any>;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.onSaveCreate = void 0;
|
|
4
|
+
const api_1 = require("../../../services/api");
|
|
5
|
+
const utils_1 = require("../state/utils");
|
|
6
|
+
/**
|
|
7
|
+
* gets matching object from hydratedRevision
|
|
8
|
+
* @param hydratedRevision
|
|
9
|
+
* @param objectName
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
const getObjectFromHydratedRevision = (hydratedRevision, objectName) => {
|
|
13
|
+
const readAction = hydratedRevision.content.read;
|
|
14
|
+
const standardObjects = readAction === null || readAction === void 0 ? void 0 : readAction.standardObjects;
|
|
15
|
+
return standardObjects === null || standardObjects === void 0 ? void 0 : standardObjects.find((obj) => obj.objectName === objectName);
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* given a configureState, objectName, hyrdatedRevision, and consumerRef
|
|
19
|
+
* generate the config object that is need for update installation request.
|
|
20
|
+
*
|
|
21
|
+
* 1. get required fields from configureState
|
|
22
|
+
* 2. get optional fields from configureState
|
|
23
|
+
* 3. merge required fields and optional fields into selectedFields
|
|
24
|
+
* 4. get required custom map fields from configureState
|
|
25
|
+
* 5. generate create config object
|
|
26
|
+
* @param configureState
|
|
27
|
+
* @param objectName
|
|
28
|
+
* @param hydratedRevision
|
|
29
|
+
* @param consumerRef
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
const generateCreateConfigFromConfigureState = (configureState, objectName, hydratedRevision, consumerRef) => {
|
|
33
|
+
const selectedFields = (0, utils_1.generateSelectedFieldsFromConfigureState)(configureState);
|
|
34
|
+
const selectedFieldMappings = (0, utils_1.generateSelectedFieldMappingsFromConfigureState)(configureState);
|
|
35
|
+
const obj = getObjectFromHydratedRevision(hydratedRevision, objectName);
|
|
36
|
+
if (!obj) {
|
|
37
|
+
console.error(`Error when getting object from hydratedRevision for objectName: ${objectName}`);
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
// create config request object
|
|
41
|
+
const createConfigObj = {
|
|
42
|
+
revisionId: hydratedRevision.id,
|
|
43
|
+
createdBy: `consumer:${consumerRef}`,
|
|
44
|
+
content: {
|
|
45
|
+
provider: hydratedRevision.content.provider,
|
|
46
|
+
read: {
|
|
47
|
+
standardObjects: {
|
|
48
|
+
[objectName]: {
|
|
49
|
+
objectName,
|
|
50
|
+
schedule: obj.schedule,
|
|
51
|
+
destination: obj.destination,
|
|
52
|
+
selectedFields,
|
|
53
|
+
selectedFieldMappings,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
return createConfigObj;
|
|
60
|
+
};
|
|
61
|
+
const onSaveCreate = (projectId, integrationId, groupRef, consumerRef, connectionId, objectName, apiKey, hydratedRevision, configureState, setInstallation) => {
|
|
62
|
+
const createConfig = generateCreateConfigFromConfigureState(configureState, objectName, hydratedRevision, consumerRef);
|
|
63
|
+
if (!createConfig) {
|
|
64
|
+
console.error('Error when generating createConfig from configureState');
|
|
65
|
+
return Promise.resolve(null);
|
|
66
|
+
}
|
|
67
|
+
const createInstallationRequest = {
|
|
68
|
+
projectId,
|
|
69
|
+
integrationId,
|
|
70
|
+
installation: {
|
|
71
|
+
groupRef,
|
|
72
|
+
connectionId,
|
|
73
|
+
config: createConfig,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
return (0, api_1.api)().createInstallation(createInstallationRequest, {
|
|
77
|
+
headers: {
|
|
78
|
+
'X-Api-Key': apiKey,
|
|
79
|
+
'Content-Type': 'application/json',
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
|
+
.then((installation) => {
|
|
83
|
+
// update local installation state
|
|
84
|
+
setInstallation(installation);
|
|
85
|
+
})
|
|
86
|
+
.catch((err) => {
|
|
87
|
+
console.error('ERROR: ', err);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
exports.onSaveCreate = onSaveCreate;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { HydratedIntegrationObject, Installation } from '../../../services/api';
|
|
2
|
+
import { ConfigureState } from '../types';
|
|
3
|
+
export declare const onSaveUpdate: (projectId: string, integrationId: string, installationId: string, selectedObjectName: string, apiKey: string, configureState: ConfigureState, setInstallation: (installationObj: Installation) => void, hydratedObject: HydratedIntegrationObject) => Promise<any>;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.onSaveUpdate = void 0;
|
|
4
|
+
const api_1 = require("../../../services/api");
|
|
5
|
+
const utils_1 = require("../state/utils");
|
|
6
|
+
/**
|
|
7
|
+
* given a configureState, config, and objectName, generate the config object that is need for
|
|
8
|
+
* update installation request.
|
|
9
|
+
*
|
|
10
|
+
* 1. get required fields from configureState
|
|
11
|
+
* 2. get optional fields from configureState
|
|
12
|
+
* 3. merge required fields and optional fields into selectedFields
|
|
13
|
+
* 4. get required custom map fields from configureState
|
|
14
|
+
* 5. generate modified config object based on update mask
|
|
15
|
+
* @param configureState
|
|
16
|
+
* @param config
|
|
17
|
+
* @param objectName
|
|
18
|
+
* @param hydratedObject
|
|
19
|
+
* @param schedule
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
const generateUpdateConfigFromConfigureState = (configureState, objectName, hydratedObject, schedule) => {
|
|
23
|
+
const selectedFields = (0, utils_1.generateSelectedFieldsFromConfigureState)(configureState);
|
|
24
|
+
const selectedFieldMappings = (0, utils_1.generateSelectedFieldMappingsFromConfigureState)(configureState);
|
|
25
|
+
// config request object type needs to be fixed
|
|
26
|
+
const updateConfigObject = {
|
|
27
|
+
content: {
|
|
28
|
+
read: {
|
|
29
|
+
standardObjects: {
|
|
30
|
+
[objectName]: {
|
|
31
|
+
objectName,
|
|
32
|
+
// these two fields are copied from previous config, otherwise they will override null
|
|
33
|
+
schedule,
|
|
34
|
+
destination: (hydratedObject === null || hydratedObject === void 0 ? void 0 : hydratedObject.destination) || '',
|
|
35
|
+
selectedFields,
|
|
36
|
+
selectedFieldMappings,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
return updateConfigObject;
|
|
43
|
+
};
|
|
44
|
+
const onSaveUpdate = (projectId, integrationId, installationId, selectedObjectName, apiKey, configureState, setInstallation, hydratedObject) => {
|
|
45
|
+
// get configuration state
|
|
46
|
+
// transform configuration state to update shape
|
|
47
|
+
const updateConfig = generateUpdateConfigFromConfigureState(configureState, selectedObjectName || '', hydratedObject, hydratedObject.schedule);
|
|
48
|
+
const updateInstallationRequest = {
|
|
49
|
+
projectId,
|
|
50
|
+
installationId,
|
|
51
|
+
integrationId,
|
|
52
|
+
installationUpdate: {
|
|
53
|
+
// update mask will recurse to the object path and replace the object at the object path
|
|
54
|
+
// this example will replace the object at the object (i.e. accounts)
|
|
55
|
+
updateMask: [`config.content.read.standardObjects.${selectedObjectName}`],
|
|
56
|
+
installation: {
|
|
57
|
+
config: updateConfig,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
// call api.updateInstallation
|
|
62
|
+
return (0, api_1.api)().updateInstallation(updateInstallationRequest, {
|
|
63
|
+
headers: {
|
|
64
|
+
'X-Api-Key': apiKey,
|
|
65
|
+
'Content-Type': 'application/json',
|
|
66
|
+
},
|
|
67
|
+
}).then((data) => {
|
|
68
|
+
// update local installation state
|
|
69
|
+
setInstallation(data);
|
|
70
|
+
}).catch((err) => {
|
|
71
|
+
console.error('ERROR: ', err);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
exports.onSaveUpdate = onSaveUpdate;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FieldHeader = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
function FieldHeader({ string }) {
|
|
7
|
+
return ((0, jsx_runtime_1.jsxs)(react_1.Flex, { position: "relative", paddingTop: 8, paddingBottom: 4, children: [(0, jsx_runtime_1.jsx)(react_1.Heading, { color: "gray.500", as: "h3", fontSize: 16, fontWeight: "500", children: string }), (0, jsx_runtime_1.jsx)(react_1.Flex, { flex: "1", justifyContent: "flex-end", alignItems: "center", children: (0, jsx_runtime_1.jsx)(react_1.Divider, { marginLeft: 2 }) })] }));
|
|
8
|
+
}
|
|
9
|
+
exports.FieldHeader = FieldHeader;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { HydratedIntegrationFieldExistent } from '../../../services/api';
|
|
3
|
+
import { ConfigureStateMappingIntegrationField } from '../types';
|
|
4
|
+
interface FieldMappingProps {
|
|
5
|
+
field: ConfigureStateMappingIntegrationField;
|
|
6
|
+
onSelectChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
7
|
+
allFields: HydratedIntegrationFieldExistent[];
|
|
8
|
+
}
|
|
9
|
+
export declare function FieldMapping({ field, onSelectChange, allFields }: FieldMappingProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FieldMapping = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_2 = require("@chakra-ui/react");
|
|
7
|
+
const ObjectManagementNav_1 = require("../ObjectManagementNav");
|
|
8
|
+
const ConfigurationStateProvider_1 = require("../state/ConfigurationStateProvider");
|
|
9
|
+
const utils_1 = require("../state/utils");
|
|
10
|
+
function FieldMapping({ field, onSelectChange, allFields }) {
|
|
11
|
+
const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
|
|
12
|
+
const { objectConfigurationsState, setConfigureState } = (0, ConfigurationStateProvider_1.useConfigureState)();
|
|
13
|
+
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
14
|
+
const [disabled, setDisabled] = (0, react_1.useState)(true);
|
|
15
|
+
(0, react_1.useEffect)(() => {
|
|
16
|
+
/* eslint no-underscore-dangle: ["error", { "allow": ["_default"] }] */
|
|
17
|
+
if (!!field._default && !field.value) {
|
|
18
|
+
const { isUpdated, newState } = (0, utils_1.setRequiredCustomMapFieldValue)(field.mapToName, field._default, /* eslint no-underscore-dangle: ["error", { "allow": ["_default"] }] */ configureState);
|
|
19
|
+
if (isUpdated && selectedObjectName) {
|
|
20
|
+
setConfigureState(selectedObjectName, newState);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
setDisabled(false);
|
|
24
|
+
}, [field, allFields, configureState, setConfigureState, selectedObjectName]);
|
|
25
|
+
const options = (0, react_1.useMemo)(() => allFields === null || allFields === void 0 ? void 0 : allFields.map((f) => (0, jsx_runtime_1.jsx)("option", { value: f.fieldName, children: f.displayName }, f.fieldName)), [allFields]);
|
|
26
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.Stack, { children: [(0, jsx_runtime_1.jsx)(react_2.Text, { fontWeight: "500", children: field.mapToDisplayName }), (0, jsx_runtime_1.jsx)(react_2.Text, { marginBottom: "5px", fontSize: 14, children: field === null || field === void 0 ? void 0 : field.prompt }), (0, jsx_runtime_1.jsx)(react_2.Select, { name: field.mapToName, variant: "flushed", value: field.value, onChange: onSelectChange, placeholder: !field.value ? 'Please select one' : undefined, disabled: disabled, children: options })] }, field.mapToName));
|
|
27
|
+
}
|
|
28
|
+
exports.FieldMapping = FieldMapping;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function OptionalFields(): false | import("react/jsx-runtime").JSX.Element;
|