@amp-labs/react 1.0.0 → 1.0.2
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/README.md +6 -105
- package/build/generated-sources/api/src/apis/DefaultApi.d.ts +48 -2
- package/build/generated-sources/api/src/apis/DefaultApi.js +51 -1
- package/build/generated-sources/api/src/models/BaseConfigContent.d.ts +8 -1
- package/build/generated-sources/api/src/models/BaseConfigContent.js +4 -1
- package/build/generated-sources/api/src/models/BaseReadConfig.d.ts +1 -1
- package/build/generated-sources/api/src/models/BaseReadConfig.js +1 -1
- package/build/generated-sources/api/src/models/BaseReadConfigStandardObject.d.ts +2 -2
- package/build/generated-sources/api/src/models/BaseReadConfigStandardObject.js +1 -1
- package/build/generated-sources/api/src/models/BaseWriteConfig.d.ts +34 -0
- package/build/generated-sources/api/src/models/BaseWriteConfig.js +51 -0
- package/build/generated-sources/api/src/models/BaseWriteConfigObject.d.ts +31 -0
- package/build/generated-sources/api/src/models/BaseWriteConfigObject.js +50 -0
- package/build/generated-sources/api/src/models/BatchUpsertIntegrationsRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/BatchUpsertIntegrationsRequest.js +1 -1
- package/build/generated-sources/api/src/models/Config.d.ts +1 -1
- package/build/generated-sources/api/src/models/Config.js +1 -1
- package/build/generated-sources/api/src/models/ConfigContent.d.ts +7 -1
- package/build/generated-sources/api/src/models/ConfigContent.js +3 -1
- package/build/generated-sources/api/src/models/ConfigContentAllOf.d.ts +7 -1
- package/build/generated-sources/api/src/models/ConfigContentAllOf.js +3 -1
- package/build/generated-sources/api/src/models/Connection.d.ts +1 -1
- package/build/generated-sources/api/src/models/Connection.js +1 -1
- package/build/generated-sources/api/src/models/Consumer.d.ts +1 -1
- package/build/generated-sources/api/src/models/Consumer.js +1 -1
- package/build/generated-sources/api/src/models/CreateConsumerRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateConsumerRequest.js +1 -1
- package/build/generated-sources/api/src/models/CreateDestinationRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateDestinationRequest.js +1 -1
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.js +1 -1
- package/build/generated-sources/api/src/models/CreateGroupRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateGroupRequest.js +1 -1
- package/build/generated-sources/api/src/models/CreateInstallationRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateInstallationRequest.js +1 -1
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.js +1 -1
- package/build/generated-sources/api/src/models/CreateIntegrationRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateIntegrationRequest.js +1 -1
- package/build/generated-sources/api/src/models/CreateIntegrationRequestLatestRevision.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateIntegrationRequestLatestRevision.js +1 -1
- package/build/generated-sources/api/src/models/CreateProjectRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateProjectRequest.js +1 -1
- package/build/generated-sources/api/src/models/CreateProviderAppRequest.d.ts +7 -1
- package/build/generated-sources/api/src/models/CreateProviderAppRequest.js +3 -1
- package/build/generated-sources/api/src/models/Group.d.ts +1 -1
- package/build/generated-sources/api/src/models/Group.js +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegration.d.ts +8 -1
- package/build/generated-sources/api/src/models/HydratedIntegration.js +4 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationField.d.ts +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationField.js +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationFieldExistent.d.ts +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationFieldExistent.js +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationObject.d.ts +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationObject.js +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationRead.d.ts +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationRead.js +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationWrite.d.ts +32 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationWrite.js +51 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationWriteObject.d.ts +37 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationWriteObject.js +53 -0
- package/build/generated-sources/api/src/models/HydratedRevision.d.ts +1 -1
- package/build/generated-sources/api/src/models/HydratedRevision.js +1 -1
- package/build/generated-sources/api/src/models/ImportConnectionRequest.d.ts +1 -7
- package/build/generated-sources/api/src/models/ImportConnectionRequest.js +1 -4
- package/build/generated-sources/api/src/models/ImportInstallationRequest.d.ts +7 -1
- package/build/generated-sources/api/src/models/ImportInstallationRequest.js +4 -1
- package/build/generated-sources/api/src/models/ImportInstallationRequestConfig.d.ts +1 -1
- package/build/generated-sources/api/src/models/ImportInstallationRequestConfig.js +1 -1
- package/build/generated-sources/api/src/models/Installation.d.ts +1 -1
- package/build/generated-sources/api/src/models/Installation.js +1 -1
- package/build/generated-sources/api/src/models/Integration.d.ts +1 -1
- package/build/generated-sources/api/src/models/Integration.js +1 -1
- package/build/generated-sources/api/src/models/Integration1.d.ts +8 -1
- package/build/generated-sources/api/src/models/Integration1.js +4 -1
- package/build/generated-sources/api/src/models/IntegrationField.d.ts +1 -1
- package/build/generated-sources/api/src/models/IntegrationField.js +1 -1
- package/build/generated-sources/api/src/models/IntegrationFieldExistent.d.ts +1 -1
- package/build/generated-sources/api/src/models/IntegrationFieldExistent.js +1 -1
- package/build/generated-sources/api/src/models/IntegrationFieldMapping.d.ts +1 -1
- package/build/generated-sources/api/src/models/IntegrationFieldMapping.js +1 -1
- package/build/generated-sources/api/src/models/IntegrationObject.d.ts +1 -1
- package/build/generated-sources/api/src/models/IntegrationObject.js +1 -1
- package/build/generated-sources/api/src/models/IntegrationRead.d.ts +1 -1
- package/build/generated-sources/api/src/models/IntegrationRead.js +1 -1
- package/build/generated-sources/api/src/models/IntegrationWrite.d.ts +32 -0
- package/build/generated-sources/api/src/models/IntegrationWrite.js +51 -0
- package/build/generated-sources/api/src/models/IntegrationWriteObject.d.ts +31 -0
- package/build/generated-sources/api/src/models/IntegrationWriteObject.js +50 -0
- package/build/generated-sources/api/src/models/OauthConnectRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/OauthConnectRequest.js +1 -1
- package/build/generated-sources/api/src/models/Operation.d.ts +1 -1
- package/build/generated-sources/api/src/models/Operation.js +1 -1
- package/build/generated-sources/api/src/models/OperationError.d.ts +1 -1
- package/build/generated-sources/api/src/models/OperationError.js +1 -1
- package/build/generated-sources/api/src/models/OptionalFieldsAutoOption.d.ts +1 -1
- package/build/generated-sources/api/src/models/OptionalFieldsAutoOption.js +1 -1
- package/build/generated-sources/api/src/models/Project.d.ts +1 -1
- package/build/generated-sources/api/src/models/Project.js +1 -1
- package/build/generated-sources/api/src/models/ProjectMembership.d.ts +1 -1
- package/build/generated-sources/api/src/models/ProjectMembership.js +1 -1
- package/build/generated-sources/api/src/models/ProviderApp.d.ts +1 -1
- package/build/generated-sources/api/src/models/ProviderApp.js +1 -1
- package/build/generated-sources/api/src/models/Revision.d.ts +1 -1
- package/build/generated-sources/api/src/models/Revision.js +1 -1
- package/build/generated-sources/api/src/models/SignedUrl.d.ts +43 -0
- package/build/generated-sources/api/src/models/SignedUrl.js +56 -0
- package/build/generated-sources/api/src/models/UpdateInstallationConfigContent.d.ts +8 -1
- package/build/generated-sources/api/src/models/UpdateInstallationConfigContent.js +4 -1
- package/build/generated-sources/api/src/models/UpdateInstallationRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpdateInstallationRequest.js +1 -1
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallation.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallation.js +1 -1
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallationConfig.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallationConfig.js +1 -1
- package/build/generated-sources/api/src/models/UpdateProjectRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpdateProjectRequest.js +1 -1
- package/build/generated-sources/api/src/models/UpdateProjectRequestProject.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpdateProjectRequestProject.js +1 -1
- package/build/generated-sources/api/src/models/UpdateProviderAppRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpdateProviderAppRequest.js +1 -1
- package/build/generated-sources/api/src/models/UpdateProviderAppRequestProviderApp.d.ts +7 -1
- package/build/generated-sources/api/src/models/UpdateProviderAppRequestProviderApp.js +3 -1
- package/build/generated-sources/api/src/models/UpsertProjectMembershipRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpsertProjectMembershipRequest.js +1 -1
- package/build/generated-sources/api/src/models/index.d.ts +7 -0
- package/build/generated-sources/api/src/models/index.js +7 -0
- package/build/generated-sources/api/src/runtime.d.ts +1 -1
- package/build/generated-sources/api/src/runtime.js +1 -1
- package/build/src/assets/NavIcon.d.ts +1 -0
- package/build/src/assets/NavIcon.js +3 -2
- package/build/src/assets/TrashIcon.d.ts +1 -0
- package/build/src/assets/TrashIcon.js +9 -0
- package/build/src/components/AmpersandProvider/AmpersandProvider.js +2 -2
- package/build/src/components/Configure/ConfigureInstallationBase.js +14 -2
- package/build/src/components/Configure/CreateInstallation.js +11 -14
- package/build/src/components/Configure/InstallIntegration.js +1 -2
- package/build/src/components/Configure/ObjectManagementNav/UninstallInstallation.d.ts +7 -0
- package/build/src/components/Configure/ObjectManagementNav/UninstallInstallation.js +15 -0
- package/build/src/components/Configure/ObjectManagementNav/index.js +13 -6
- package/build/src/components/Configure/ProtectedConnectionLayout.d.ts +7 -2
- package/build/src/components/Configure/ProtectedConnectionLayout.js +10 -5
- package/build/src/components/Configure/UninstallContent.d.ts +1 -0
- package/build/src/components/Configure/UninstallContent.js +37 -0
- package/build/src/components/Configure/UpdateInstallation.js +10 -21
- package/build/src/components/Configure/fields/{FieldMapping.d.ts → FieldMappings/FieldMapping.d.ts} +2 -3
- package/build/src/components/Configure/fields/{FieldMapping.js → FieldMappings/FieldMapping.js} +12 -11
- package/build/src/components/Configure/fields/{RequiredFieldMappings.js → FieldMappings/RequiredFieldMappings.js} +9 -9
- package/build/src/components/Configure/fields/FieldMappings/index.d.ts +3 -0
- package/build/src/components/Configure/fields/FieldMappings/index.js +7 -0
- package/build/src/components/Configure/fields/FieldMappings/setFieldMapping.d.ts +3 -0
- package/build/src/components/Configure/fields/FieldMappings/setFieldMapping.js +18 -0
- package/build/src/components/Configure/fields/{OptionalFields.js → OptionalFields/OptionalFields.js} +8 -19
- package/build/src/components/Configure/fields/OptionalFields/index.d.ts +2 -0
- package/build/src/components/Configure/fields/OptionalFields/index.js +5 -0
- package/build/src/components/Configure/fields/OptionalFields/setOptionalField.d.ts +3 -0
- package/build/src/components/Configure/fields/OptionalFields/setOptionalField.js +21 -0
- package/build/src/components/Configure/state/ConfigurationStateProvider.d.ts +47 -1
- package/build/src/components/Configure/state/ConfigurationStateProvider.js +28 -6
- package/build/src/components/Configure/state/HydratedRevisionContext.js +3 -6
- package/build/src/components/Configure/state/utils.d.ts +4 -16
- package/build/src/components/Configure/state/utils.js +28 -63
- package/build/src/components/Configure/types.d.ts +6 -9
- package/build/src/components/Configure/utils.d.ts +6 -4
- package/build/src/components/Configure/utils.js +17 -16
- package/build/src/components/Connect/ConnectProvider.d.ts +9 -0
- package/build/src/components/Connect/ConnectProvider.js +18 -0
- package/build/src/components/{OAuthPopup → Connect}/OAuthPopup.js +3 -3
- package/build/src/components/Salesforce/SalesforceOauthFlow.js +41 -30
- package/build/src/components/ThemeProvider/Button/buttonTheme.d.ts +13 -0
- package/build/src/components/ThemeProvider/Button/buttonTheme.js +17 -0
- package/build/src/components/ThemeProvider/Button/index.d.ts +2 -0
- package/build/src/components/ThemeProvider/Button/index.js +5 -0
- package/build/src/components/ThemeProvider/index.js +21 -0
- package/build/src/components/index.d.ts +1 -0
- package/build/src/components/index.js +1 -0
- package/build/src/context/{ApiKeyContext.d.ts → ApiKeyProvider.d.ts} +1 -0
- package/build/src/context/ApiKeyProvider.js +14 -0
- package/build/src/context/ConnectionsContext.d.ts +5 -4
- package/build/src/context/ConnectionsContext.js +13 -5
- package/build/src/context/InstallIntegrationContext.d.ts +1 -0
- package/build/src/context/InstallIntegrationContext.js +15 -10
- package/build/src/context/IntegrationListContext.js +3 -3
- package/build/src/context/ProjectContext.js +3 -3
- package/build/src/hooks/useIsIntegrationInstalled.js +2 -2
- package/package.json +4 -3
- package/build/src/context/ApiKeyContext.js +0 -6
- /package/build/src/components/Configure/fields/{RequiredFieldMappings.d.ts → FieldMappings/RequiredFieldMappings.d.ts} +0 -0
- /package/build/src/components/Configure/fields/{OptionalFields.d.ts → OptionalFields/OptionalFields.d.ts} +0 -0
- /package/build/src/components/{OAuthPopup → Connect}/OAuthPopup.d.ts +0 -0
|
@@ -6,7 +6,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
* this page is wip: untested
|
|
7
7
|
*/
|
|
8
8
|
const react_1 = require("react");
|
|
9
|
-
const
|
|
9
|
+
const ApiKeyProvider_1 = require("../../context/ApiKeyProvider");
|
|
10
10
|
const ConnectionsContext_1 = require("../../context/ConnectionsContext");
|
|
11
11
|
const ErrorContextProvider_1 = require("../../context/ErrorContextProvider");
|
|
12
12
|
const InstallIntegrationContext_1 = require("../../context/InstallIntegrationContext");
|
|
@@ -17,6 +17,7 @@ const HydratedRevisionContext_1 = require("./state/HydratedRevisionContext");
|
|
|
17
17
|
const utils_1 = require("./state/utils");
|
|
18
18
|
const ConfigureInstallationBase_1 = require("./ConfigureInstallationBase");
|
|
19
19
|
const ObjectManagementNav_1 = require("./ObjectManagementNav");
|
|
20
|
+
const utils_2 = require("./utils");
|
|
20
21
|
// the config should be undefined for create flow
|
|
21
22
|
const UNDEFINED_CONFIG = undefined;
|
|
22
23
|
// Create Installation Flow
|
|
@@ -25,18 +26,18 @@ function CreateInstallation() {
|
|
|
25
26
|
const { hydratedRevision, loading } = (0, HydratedRevisionContext_1.useHydratedRevision)();
|
|
26
27
|
const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
|
|
27
28
|
const { selectedConnection } = (0, ConnectionsContext_1.useConnections)();
|
|
28
|
-
const apiKey = (0,
|
|
29
|
+
const apiKey = (0, ApiKeyProvider_1.useApiKey)();
|
|
29
30
|
const { projectId } = (0, ProjectContext_1.useProject)();
|
|
30
31
|
const { resetBoundary, setErrors } = (0, ErrorContextProvider_1.useErrorState)();
|
|
31
|
-
const {
|
|
32
|
+
const { resetConfigureState, objectConfigurationsState, resetPendingConfigurationState, } = (0, ConfigurationStateProvider_1.useConfigureState)();
|
|
32
33
|
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
33
34
|
const [isLoading, setLoadingState] = (0, react_1.useState)(false);
|
|
34
35
|
const resetState = (0, react_1.useCallback)(() => {
|
|
35
36
|
resetBoundary(ErrorContextProvider_1.ErrorBoundary.MAPPING);
|
|
36
37
|
if ((hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) && !loading && selectedObjectName) {
|
|
37
|
-
(0, utils_1.
|
|
38
|
+
(0, utils_1.setHydrateConfigState)(hydratedRevision, UNDEFINED_CONFIG, selectedObjectName, resetConfigureState);
|
|
38
39
|
}
|
|
39
|
-
}, [hydratedRevision, loading, selectedObjectName,
|
|
40
|
+
}, [resetBoundary, hydratedRevision, loading, selectedObjectName, resetConfigureState]);
|
|
40
41
|
(0, react_1.useEffect)(() => {
|
|
41
42
|
// set configurationState when hydratedRevision is loaded
|
|
42
43
|
if (!configureState && (hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) && !loading) {
|
|
@@ -45,16 +46,12 @@ function CreateInstallation() {
|
|
|
45
46
|
}, [configureState, objectConfigurationsState, hydratedRevision, loading, resetState]);
|
|
46
47
|
const onSave = (e) => {
|
|
47
48
|
e.preventDefault();
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
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));
|
|
49
|
+
// check if fields with requirements are met
|
|
50
|
+
const { requiredMapFields, selectedFieldMappings } = configureState || {};
|
|
51
|
+
const { errorList } = (0, utils_2.validateFieldMappings)(requiredMapFields, selectedFieldMappings, setErrors);
|
|
52
|
+
if (errorList.length > 0) {
|
|
56
53
|
return;
|
|
57
|
-
}
|
|
54
|
+
} // skip if there are errors
|
|
58
55
|
if (selectedObjectName && (selectedConnection === null || selectedConnection === void 0 ? void 0 : selectedConnection.id) && apiKey && projectId
|
|
59
56
|
&& integrationId && groupRef && consumerRef && hydratedRevision) {
|
|
60
57
|
setLoadingState(true);
|
|
@@ -25,7 +25,6 @@ function InstallationContent() {
|
|
|
25
25
|
// No installation, render create installation flow
|
|
26
26
|
(0, jsx_runtime_1.jsx)(CreateInstallation_1.CreateInstallation, {}));
|
|
27
27
|
}
|
|
28
|
-
// TODO consider creating an integration obj context
|
|
29
28
|
function InstallIntegration({ integration, consumerRef, consumerName, groupRef, groupName, }) {
|
|
30
29
|
var _a;
|
|
31
30
|
const { projectId } = (0, ProjectContext_1.useProject)();
|
|
@@ -35,6 +34,6 @@ function InstallIntegration({ integration, consumerRef, consumerName, groupRef,
|
|
|
35
34
|
}
|
|
36
35
|
return (
|
|
37
36
|
// 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, {
|
|
37
|
+
(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, { groupRef: groupRef, children: (0, jsx_runtime_1.jsx)(ProtectedConnectionLayout_1.ProtectedConnectionLayout, { consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName, 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
38
|
}
|
|
40
39
|
exports.InstallIntegration = InstallIntegration;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface NavObjectItemProps {
|
|
3
|
+
text?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare const UNINSTALL_INSTALLATION_CONST = "uninstall-intallation";
|
|
6
|
+
export declare const UninstallInstallation: import("react").ForwardRefExoticComponent<NavObjectItemProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UninstallInstallation = exports.UNINSTALL_INSTALLATION_CONST = 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 TrashIcon_1 = require("../../../assets/TrashIcon");
|
|
8
|
+
exports.UNINSTALL_INSTALLATION_CONST = 'uninstall-intallation';
|
|
9
|
+
exports.UninstallInstallation = (0, react_1.forwardRef)(({ text = 'Uninstall' }, ref) => {
|
|
10
|
+
// 1. Reuse the `useTab` hook
|
|
11
|
+
const tabProps = (0, react_2.useTab)({ ref });
|
|
12
|
+
// 2. Hook into the Tabs `size`, `variant`, props
|
|
13
|
+
const styles = (0, react_2.useMultiStyleConfig)('Tabs', tabProps);
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.Button, Object.assign({ __css: styles.warningTab }, tabProps, { minHeight: 15, children: [(0, jsx_runtime_1.jsxs)(react_2.Box, { as: "span", display: "flex", alignItems: "center", gap: 2, my: 2, mx: 4, children: [(0, TrashIcon_1.TrashIcon)(), (0, jsx_runtime_1.jsx)(react_2.Box, { textAlign: "left", children: (0, jsx_runtime_1.jsx)(react_2.Text, { color: "red.800", children: text }) })] }), tabProps.children] })));
|
|
15
|
+
});
|
|
@@ -10,6 +10,7 @@ const ConfigurationStateProvider_1 = require("../state/ConfigurationStateProvide
|
|
|
10
10
|
const HydratedRevisionContext_1 = require("../state/HydratedRevisionContext");
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
12
|
const NavObjectItem_1 = require("./NavObjectItem");
|
|
13
|
+
const UninstallInstallation_1 = require("./UninstallInstallation");
|
|
13
14
|
// Create a context for the selected navObject's name
|
|
14
15
|
const SelectedObjectNameContext = (0, react_1.createContext)(null);
|
|
15
16
|
// Custom hook to access the selected navObject's name
|
|
@@ -22,7 +23,13 @@ function useSelectedObjectName() {
|
|
|
22
23
|
}
|
|
23
24
|
exports.useSelectedObjectName = useSelectedObjectName;
|
|
24
25
|
function getSelectedObject(navObjects, tabIndex) {
|
|
25
|
-
|
|
26
|
+
if (navObjects === null || navObjects === void 0 ? void 0 : navObjects[tabIndex]) {
|
|
27
|
+
return navObjects[tabIndex];
|
|
28
|
+
}
|
|
29
|
+
if (tabIndex > navObjects.length - 1) {
|
|
30
|
+
return { name: UninstallInstallation_1.UNINSTALL_INSTALLATION_CONST, completed: false };
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
26
33
|
}
|
|
27
34
|
// note: when the object key exists in the config; the user has already completed the object before
|
|
28
35
|
function ObjectManagementNav({ children, }) {
|
|
@@ -36,10 +43,10 @@ function ObjectManagementNav({ children, }) {
|
|
|
36
43
|
const selectedObject = getSelectedObject(navObjects || [], tabIndex);
|
|
37
44
|
const { project } = (0, ProjectContext_1.useProject)();
|
|
38
45
|
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.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
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.jsxs)(react_2.Tabs, { index: tabIndex, onChange: handleTabsChange, orientation: "horizontal", children: [navObjects.map((object) => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
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)
|
|
49
|
+
|| ((_b = objectConfigurationsState[object.name]) === null || _b === void 0 ? void 0 : _b.isRequiredMapFieldsModified) }, object.name));
|
|
50
|
+
}), installation && ((0, jsx_runtime_1.jsx)(UninstallInstallation_1.UninstallInstallation, { text: "Uninstall" }, "uninstall-intallation"))] }))] }), children] }) }));
|
|
44
51
|
}
|
|
45
52
|
exports.ObjectManagementNav = ObjectManagementNav;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
interface
|
|
2
|
+
interface ProtectedConnectionLayoutProps {
|
|
3
|
+
provider?: string;
|
|
4
|
+
consumerRef: string;
|
|
5
|
+
consumerName?: string;
|
|
6
|
+
groupRef: string;
|
|
7
|
+
groupName?: string;
|
|
3
8
|
children: JSX.Element;
|
|
4
9
|
}
|
|
5
|
-
export declare function ProtectedConnectionLayout({ children }:
|
|
10
|
+
export declare function ProtectedConnectionLayout({ provider, consumerRef, consumerName, groupRef, groupName, children, }: ProtectedConnectionLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
6
11
|
export {};
|
|
@@ -6,12 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ProtectedConnectionLayout = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
|
+
const constants_1 = require("../../constants");
|
|
9
10
|
const ConnectionsContext_1 = require("../../context/ConnectionsContext");
|
|
10
11
|
const InstallIntegrationContext_1 = require("../../context/InstallIntegrationContext");
|
|
11
12
|
const SalesforceOauthFlow_1 = __importDefault(require("../Salesforce/SalesforceOauthFlow"));
|
|
12
|
-
|
|
13
|
-
function ProtectedConnectionLayout({ children }) {
|
|
14
|
-
const { consumerRef, consumerName, groupRef, groupName, } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
|
|
13
|
+
function ProtectedConnectionLayout({ provider, consumerRef, consumerName, groupRef, groupName, children, }) {
|
|
15
14
|
const { selectedConnection, setSelectedConnection, connections } = (0, ConnectionsContext_1.useConnections)();
|
|
16
15
|
(0, react_1.useEffect)(() => {
|
|
17
16
|
if (!selectedConnection && connections && connections.length > 0) {
|
|
@@ -19,10 +18,16 @@ function ProtectedConnectionLayout({ children }) {
|
|
|
19
18
|
setSelectedConnection(connection);
|
|
20
19
|
}
|
|
21
20
|
}, [connections, selectedConnection, setSelectedConnection]);
|
|
21
|
+
const { provider: providerFromProps } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
|
|
22
|
+
if (!provider && !providerFromProps) {
|
|
23
|
+
throw new Error('ProtectedConnectionLayout must be given a provider prop or be used within InstallIntegrationProvider');
|
|
24
|
+
}
|
|
22
25
|
// a selected connection exists, render children
|
|
23
26
|
if (selectedConnection)
|
|
24
27
|
return children;
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
if (provider === constants_1.PROVIDER_SALESFORCE || providerFromProps === constants_1.PROVIDER_SALESFORCE) {
|
|
29
|
+
return ((0, jsx_runtime_1.jsx)(SalesforceOauthFlow_1.default, { consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName }));
|
|
30
|
+
}
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)("div", { children: "Unsupported provider" }));
|
|
27
32
|
}
|
|
28
33
|
exports.ProtectedConnectionLayout = ProtectedConnectionLayout;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function UninstallContent(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UninstallContent = 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 api_1 = require("../../services/api");
|
|
10
|
+
function UninstallContent() {
|
|
11
|
+
const { projectId, appName } = (0, ProjectContext_1.useProject)();
|
|
12
|
+
const { integrationId, installation, resetInstallations } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
|
|
13
|
+
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
14
|
+
const isDisabled = !projectId || !integrationId || !(installation === null || installation === void 0 ? void 0 : installation.id) || loading;
|
|
15
|
+
const onDelete = async () => {
|
|
16
|
+
if (!isDisabled) {
|
|
17
|
+
setLoading(true);
|
|
18
|
+
console.warn('uninstalling installation', { projectId, integrationId, installationId: installation.id });
|
|
19
|
+
try {
|
|
20
|
+
await (0, api_1.api)().deleteInstallation({ projectId, integrationId, installationId: installation.id });
|
|
21
|
+
resetInstallations();
|
|
22
|
+
console.warn('successfully uninstalled installation: ', installation.id);
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
console.error('error uninstalling installation', e);
|
|
26
|
+
}
|
|
27
|
+
finally {
|
|
28
|
+
setLoading(false);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const buttonContent = loading ? 'Uninstalling...' : 'Yes, uninstall';
|
|
33
|
+
const content = (installation === null || installation === void 0 ? void 0 : installation.id) ? `Once you uninstall this integration, all your configuration will be lost, and "${appName}" may stop working.`
|
|
34
|
+
: "You've successfully uninstalled the integration.";
|
|
35
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.Stack, { children: [(0, jsx_runtime_1.jsx)(react_2.Text, { paddingBottom: 3, children: content }), (installation === null || installation === void 0 ? void 0 : installation.id) && ((0, jsx_runtime_1.jsx)(react_2.Button, { onClick: onDelete, variant: "warning", isDisabled: isDisabled, children: buttonContent }))] }));
|
|
36
|
+
}
|
|
37
|
+
exports.UninstallContent = UninstallContent;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.UpdateInstallation = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
6
|
+
const ApiKeyProvider_1 = require("../../context/ApiKeyProvider");
|
|
7
7
|
const ErrorContextProvider_1 = require("../../context/ErrorContextProvider");
|
|
8
8
|
const InstallIntegrationContext_1 = require("../../context/InstallIntegrationContext");
|
|
9
9
|
const ProjectContext_1 = require("../../context/ProjectContext");
|
|
@@ -13,36 +13,30 @@ const HydratedRevisionContext_1 = require("./state/HydratedRevisionContext");
|
|
|
13
13
|
const utils_1 = require("./state/utils");
|
|
14
14
|
const ConfigureInstallationBase_1 = require("./ConfigureInstallationBase");
|
|
15
15
|
const ObjectManagementNav_1 = require("./ObjectManagementNav");
|
|
16
|
+
const utils_2 = require("./utils");
|
|
16
17
|
// Update Installation Flow
|
|
17
18
|
function UpdateInstallation({ installation, integrationObj }) {
|
|
19
|
+
const apiKey = (0, ApiKeyProvider_1.useApiKey)();
|
|
18
20
|
const { setInstallation } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
|
|
19
21
|
const { hydratedRevision, loading } = (0, HydratedRevisionContext_1.useHydratedRevision)();
|
|
20
22
|
const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
|
|
21
|
-
const apiKey = (0, react_1.useContext)(ApiKeyContext_1.ApiKeyContext);
|
|
22
23
|
const { projectId } = (0, ProjectContext_1.useProject)();
|
|
24
|
+
const [isLoading, setLoadingState] = (0, react_1.useState)(false);
|
|
23
25
|
// when no installation or config exists, render create flow
|
|
24
26
|
const { config } = installation;
|
|
25
|
-
const [isLoading, setLoadingState] = (0, react_1.useState)(false);
|
|
26
27
|
// 1. get config from installations (contains form selection state)
|
|
27
28
|
// 2. get the hydrated revision (contains full form)
|
|
28
29
|
// 3. generate the configuration state from the hydrated revision and config
|
|
29
30
|
const { resetBoundary, setErrors } = (0, ErrorContextProvider_1.useErrorState)();
|
|
30
|
-
const {
|
|
31
|
+
const { resetConfigureState, objectConfigurationsState, resetPendingConfigurationState, } = (0, ConfigurationStateProvider_1.useConfigureState)();
|
|
31
32
|
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
32
33
|
const resetState = (0, react_1.useCallback)(() => {
|
|
33
34
|
resetBoundary(ErrorContextProvider_1.ErrorBoundary.MAPPING);
|
|
34
35
|
// set configurationState when hydratedRevision is loaded
|
|
35
36
|
if ((hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) && !loading && selectedObjectName) {
|
|
36
|
-
(0, utils_1.
|
|
37
|
+
(0, utils_1.setHydrateConfigState)(hydratedRevision, config, selectedObjectName, resetConfigureState);
|
|
37
38
|
}
|
|
38
|
-
}, [
|
|
39
|
-
hydratedRevision,
|
|
40
|
-
loading,
|
|
41
|
-
config,
|
|
42
|
-
selectedObjectName,
|
|
43
|
-
setConfigureState,
|
|
44
|
-
resetBoundary,
|
|
45
|
-
]);
|
|
39
|
+
}, [resetBoundary, hydratedRevision, loading, selectedObjectName, config, resetConfigureState]);
|
|
46
40
|
(0, react_1.useEffect)(() => {
|
|
47
41
|
if (!configureState) {
|
|
48
42
|
resetState();
|
|
@@ -56,14 +50,9 @@ function UpdateInstallation({ installation, integrationObj }) {
|
|
|
56
50
|
const onSave = (e) => {
|
|
57
51
|
e.preventDefault();
|
|
58
52
|
// check if fields with requirements are met
|
|
59
|
-
const { requiredMapFields } = configureState;
|
|
60
|
-
const
|
|
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));
|
|
53
|
+
const { requiredMapFields, selectedFieldMappings } = configureState || {};
|
|
54
|
+
const { errorList } = (0, utils_2.validateFieldMappings)(requiredMapFields, selectedFieldMappings, setErrors);
|
|
55
|
+
if (errorList.length > 0) {
|
|
67
56
|
return;
|
|
68
57
|
}
|
|
69
58
|
if (installation
|
package/build/src/components/Configure/fields/{FieldMapping.d.ts → FieldMappings/FieldMapping.d.ts}
RENAMED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { HydratedIntegrationFieldExistent } from '
|
|
3
|
-
import { ConfigureStateMappingIntegrationField } from '../types';
|
|
2
|
+
import { HydratedIntegrationFieldExistent, IntegrationFieldMapping } from '../../../../services/api';
|
|
4
3
|
interface FieldMappingProps {
|
|
5
|
-
field:
|
|
4
|
+
field: IntegrationFieldMapping;
|
|
6
5
|
onSelectChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
7
6
|
allFields: HydratedIntegrationFieldExistent[];
|
|
8
7
|
}
|
package/build/src/components/Configure/fields/{FieldMapping.js → FieldMappings/FieldMapping.js}
RENAMED
|
@@ -4,25 +4,26 @@ exports.FieldMapping = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const react_2 = require("@chakra-ui/react");
|
|
7
|
-
const ObjectManagementNav_1 = require("
|
|
8
|
-
const ConfigurationStateProvider_1 = require("
|
|
9
|
-
const utils_1 = require("
|
|
7
|
+
const ObjectManagementNav_1 = require("../../ObjectManagementNav");
|
|
8
|
+
const ConfigurationStateProvider_1 = require("../../state/ConfigurationStateProvider");
|
|
9
|
+
const utils_1 = require("../../state/utils");
|
|
10
|
+
const setFieldMapping_1 = require("./setFieldMapping");
|
|
10
11
|
function FieldMapping({ field, onSelectChange, allFields }) {
|
|
11
12
|
const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
|
|
12
13
|
const { objectConfigurationsState, setConfigureState } = (0, ConfigurationStateProvider_1.useConfigureState)();
|
|
13
|
-
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
14
14
|
const [disabled, setDisabled] = (0, react_1.useState)(true);
|
|
15
|
+
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
16
|
+
const { selectedFieldMappings: selectedRequiredMapFields } = configureState || {};
|
|
17
|
+
const fieldValue = selectedRequiredMapFields === null || selectedRequiredMapFields === void 0 ? void 0 : selectedRequiredMapFields[field.mapToName];
|
|
15
18
|
(0, react_1.useEffect)(() => {
|
|
16
19
|
/* eslint no-underscore-dangle: ["error", { "allow": ["_default"] }] */
|
|
17
|
-
if (!!field._default && !
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
setConfigureState(selectedObjectName, newState);
|
|
21
|
-
}
|
|
20
|
+
if (!!field._default && !fieldValue && selectedObjectName && !!configureState) {
|
|
21
|
+
// set field mapping default value if no value exists
|
|
22
|
+
(0, setFieldMapping_1.setFieldMapping)(selectedObjectName, setConfigureState, field.mapToName, field._default);
|
|
22
23
|
}
|
|
23
24
|
setDisabled(false);
|
|
24
|
-
}, [field,
|
|
25
|
+
}, [field, setConfigureState, selectedObjectName, fieldValue, configureState]);
|
|
25
26
|
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:
|
|
27
|
+
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: fieldValue || undefined, onChange: onSelectChange, placeholder: !fieldValue ? 'Please select one' : undefined, disabled: disabled, children: options })] }, field.mapToName));
|
|
27
28
|
}
|
|
28
29
|
exports.FieldMapping = FieldMapping;
|
|
@@ -4,13 +4,14 @@ exports.RequiredFieldMappings = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const react_2 = require("@chakra-ui/react");
|
|
7
|
-
const ErrorContextProvider_1 = require("
|
|
8
|
-
const ObjectManagementNav_1 = require("
|
|
9
|
-
const ConfigurationStateProvider_1 = require("
|
|
10
|
-
const utils_1 = require("
|
|
11
|
-
const utils_2 = require("
|
|
12
|
-
const FieldHeader_1 = require("
|
|
7
|
+
const ErrorContextProvider_1 = require("../../../../context/ErrorContextProvider");
|
|
8
|
+
const ObjectManagementNav_1 = require("../../ObjectManagementNav");
|
|
9
|
+
const ConfigurationStateProvider_1 = require("../../state/ConfigurationStateProvider");
|
|
10
|
+
const utils_1 = require("../../state/utils");
|
|
11
|
+
const utils_2 = require("../../utils");
|
|
12
|
+
const FieldHeader_1 = require("../FieldHeader");
|
|
13
13
|
const FieldMapping_1 = require("./FieldMapping");
|
|
14
|
+
const setFieldMapping_1 = require("./setFieldMapping");
|
|
14
15
|
function RequiredFieldMappings() {
|
|
15
16
|
const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
|
|
16
17
|
const { objectConfigurationsState, setConfigureState } = (0, ConfigurationStateProvider_1.useConfigureState)();
|
|
@@ -22,9 +23,8 @@ function RequiredFieldMappings() {
|
|
|
22
23
|
// if place holder value is chosen, we don't change state
|
|
23
24
|
return;
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
setConfigureState(selectedObjectName, newState);
|
|
26
|
+
if (selectedObjectName) {
|
|
27
|
+
(0, setFieldMapping_1.setFieldMapping)(selectedObjectName, setConfigureState, name, value);
|
|
28
28
|
}
|
|
29
29
|
if (isError(ErrorContextProvider_1.ErrorBoundary.MAPPING, name)) {
|
|
30
30
|
removeError(ErrorContextProvider_1.ErrorBoundary.MAPPING, name);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequiredFieldMappings = exports.FieldMapping = void 0;
|
|
4
|
+
const FieldMapping_1 = require("./FieldMapping");
|
|
5
|
+
Object.defineProperty(exports, "FieldMapping", { enumerable: true, get: function () { return FieldMapping_1.FieldMapping; } });
|
|
6
|
+
const RequiredFieldMappings_1 = require("./RequiredFieldMappings");
|
|
7
|
+
Object.defineProperty(exports, "RequiredFieldMappings", { enumerable: true, get: function () { return RequiredFieldMappings_1.RequiredFieldMappings; } });
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Draft } from 'immer';
|
|
2
|
+
import { ConfigureState } from '../../types';
|
|
3
|
+
export declare function setFieldMapping(selectedObjectName: string, setConfigureState: (objectName: string, producer: (draft: Draft<ConfigureState>) => void) => void, fieldKey: string, newValue: string): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setFieldMapping = void 0;
|
|
4
|
+
const utils_1 = require("../../state/utils");
|
|
5
|
+
function setFieldMappingProducer(draft, fieldKey, newValue) {
|
|
6
|
+
const draftRequiredMapFields = (draft === null || draft === void 0 ? void 0 : draft.selectedFieldMappings) || {};
|
|
7
|
+
draftRequiredMapFields[fieldKey] = newValue;
|
|
8
|
+
const savedFields = draft.savedConfig.requiredMapFields;
|
|
9
|
+
const updatedFields = draftRequiredMapFields;
|
|
10
|
+
const isModified = !(0, utils_1.isFieldObjectEqual)(savedFields, updatedFields);
|
|
11
|
+
// immer exception if we try to set a value
|
|
12
|
+
// eslint-disable-next-line no-param-reassign
|
|
13
|
+
draft.isRequiredMapFieldsModified = isModified;
|
|
14
|
+
}
|
|
15
|
+
function setFieldMapping(selectedObjectName, setConfigureState, fieldKey, newValue) {
|
|
16
|
+
setConfigureState(selectedObjectName, (draft) => setFieldMappingProducer(draft, fieldKey, newValue));
|
|
17
|
+
}
|
|
18
|
+
exports.setFieldMapping = setFieldMapping;
|
package/build/src/components/Configure/fields/{OptionalFields.js → OptionalFields/OptionalFields.js}
RENAMED
|
@@ -3,12 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OptionalFields = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("@chakra-ui/react");
|
|
6
|
-
const ProjectContext_1 = require("
|
|
7
|
-
const ObjectManagementNav_1 = require("
|
|
8
|
-
const ConfigurationStateProvider_1 = require("
|
|
9
|
-
const utils_1 = require("
|
|
10
|
-
const utils_2 = require("
|
|
11
|
-
const FieldHeader_1 = require("
|
|
6
|
+
const ProjectContext_1 = require("../../../../context/ProjectContext");
|
|
7
|
+
const ObjectManagementNav_1 = require("../../ObjectManagementNav");
|
|
8
|
+
const ConfigurationStateProvider_1 = require("../../state/ConfigurationStateProvider");
|
|
9
|
+
const utils_1 = require("../../state/utils");
|
|
10
|
+
const utils_2 = require("../../utils");
|
|
11
|
+
const FieldHeader_1 = require("../FieldHeader");
|
|
12
|
+
const setOptionalField_1 = require("./setOptionalField");
|
|
12
13
|
function OptionalFields() {
|
|
13
14
|
var _a;
|
|
14
15
|
const { appName } = (0, ProjectContext_1.useProject)();
|
|
@@ -17,21 +18,9 @@ function OptionalFields() {
|
|
|
17
18
|
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
18
19
|
const { selectedOptionalFields } = configureState || {};
|
|
19
20
|
const onCheckboxChange = (e) => {
|
|
20
|
-
var _a;
|
|
21
21
|
const { name, checked } = e.target;
|
|
22
22
|
if (selectedObjectName && configureState) {
|
|
23
|
-
|
|
24
|
-
const updatedSelectOptionalFields = Object.assign(Object.assign({}, selectedOptionalFields), { [name]: checked });
|
|
25
|
-
// removed from check fields if not checked
|
|
26
|
-
if (!checked) {
|
|
27
|
-
delete updatedSelectOptionalFields[name];
|
|
28
|
-
}
|
|
29
|
-
// Compare saved fields from updated fields
|
|
30
|
-
const savedOptionalFields = (_a = configureState.savedConfig) === null || _a === void 0 ? void 0 : _a.optionalFields;
|
|
31
|
-
// Check if the optionalFields are modified
|
|
32
|
-
const isModified = !(0, utils_1.checkFieldsEquality)(savedOptionalFields, updatedSelectOptionalFields);
|
|
33
|
-
// update state
|
|
34
|
-
setConfigureState(selectedObjectName, Object.assign(Object.assign({}, configureState), { selectedOptionalFields: updatedSelectOptionalFields, isOptionalFieldsModified: isModified }));
|
|
23
|
+
(0, setOptionalField_1.setOptionalField)(selectedObjectName, setConfigureState, name, checked);
|
|
35
24
|
}
|
|
36
25
|
};
|
|
37
26
|
const shouldRender = !!((configureState === null || configureState === void 0 ? void 0 : configureState.optionalFields) && (configureState === null || configureState === void 0 ? void 0 : configureState.optionalFields));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OptionalFields = void 0;
|
|
4
|
+
const OptionalFields_1 = require("./OptionalFields");
|
|
5
|
+
Object.defineProperty(exports, "OptionalFields", { enumerable: true, get: function () { return OptionalFields_1.OptionalFields; } });
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Draft } from 'immer';
|
|
2
|
+
import { ConfigureState } from '../../types';
|
|
3
|
+
export declare function setOptionalField(selectedObjectName: string, setConfigureState: (objectName: string, producer: (draft: Draft<ConfigureState>) => void) => void, fieldKey: string, checked: boolean): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setOptionalField = void 0;
|
|
4
|
+
const utils_1 = require("../../state/utils");
|
|
5
|
+
function setOptionalFieldProducer(draft, fieldKey, checked) {
|
|
6
|
+
const draftSelectedOptionalFields = (draft === null || draft === void 0 ? void 0 : draft.selectedOptionalFields) || {};
|
|
7
|
+
draftSelectedOptionalFields[fieldKey] = checked;
|
|
8
|
+
if (!checked) {
|
|
9
|
+
delete draftSelectedOptionalFields[fieldKey];
|
|
10
|
+
}
|
|
11
|
+
const savedFields = draft.savedConfig.optionalFields;
|
|
12
|
+
const updatedFields = draftSelectedOptionalFields;
|
|
13
|
+
const isModified = !(0, utils_1.isFieldObjectEqual)(savedFields, updatedFields);
|
|
14
|
+
// immer exception if we try to set a value
|
|
15
|
+
// eslint-disable-next-line no-param-reassign
|
|
16
|
+
draft.isOptionalFieldsModified = isModified;
|
|
17
|
+
}
|
|
18
|
+
function setOptionalField(selectedObjectName, setConfigureState, fieldKey, checked) {
|
|
19
|
+
setConfigureState(selectedObjectName, (draft) => setOptionalFieldProducer(draft, fieldKey, checked));
|
|
20
|
+
}
|
|
21
|
+
exports.setOptionalField = setOptionalField;
|
|
@@ -3,7 +3,53 @@ import { ConfigureState, ObjectConfigurationsState } from '../types';
|
|
|
3
3
|
export declare function useConfigureState(): {
|
|
4
4
|
objectConfigurationsState: ObjectConfigurationsState;
|
|
5
5
|
setObjectConfigurationsState: React.Dispatch<React.SetStateAction<ObjectConfigurationsState>>;
|
|
6
|
-
setConfigureState: (objectName: string,
|
|
6
|
+
setConfigureState: (objectName: string, producer: (draft: {
|
|
7
|
+
allFields: {
|
|
8
|
+
fieldName: string;
|
|
9
|
+
displayName: string;
|
|
10
|
+
}[] | null;
|
|
11
|
+
requiredFields: ({
|
|
12
|
+
fieldName: string;
|
|
13
|
+
displayName: string;
|
|
14
|
+
} | {
|
|
15
|
+
mapToName: string;
|
|
16
|
+
mapToDisplayName?: string | undefined;
|
|
17
|
+
_default?: string | undefined;
|
|
18
|
+
prompt?: string | undefined;
|
|
19
|
+
})[] | null;
|
|
20
|
+
optionalFields: ({
|
|
21
|
+
fieldName: string;
|
|
22
|
+
displayName: string;
|
|
23
|
+
} | {
|
|
24
|
+
mapToName: string;
|
|
25
|
+
mapToDisplayName?: string | undefined;
|
|
26
|
+
_default?: string | undefined;
|
|
27
|
+
prompt?: string | undefined;
|
|
28
|
+
})[] | null;
|
|
29
|
+
requiredMapFields: {
|
|
30
|
+
mapToName: string;
|
|
31
|
+
mapToDisplayName?: string | undefined;
|
|
32
|
+
_default?: string | undefined;
|
|
33
|
+
prompt?: string | undefined;
|
|
34
|
+
}[] | null;
|
|
35
|
+
selectedOptionalFields: {
|
|
36
|
+
[x: string]: boolean;
|
|
37
|
+
} | null;
|
|
38
|
+
selectedFieldMappings: {
|
|
39
|
+
[x: string]: string | undefined;
|
|
40
|
+
} | null;
|
|
41
|
+
isOptionalFieldsModified: boolean;
|
|
42
|
+
isRequiredMapFieldsModified: boolean;
|
|
43
|
+
savedConfig: {
|
|
44
|
+
optionalFields: {
|
|
45
|
+
[x: string]: boolean;
|
|
46
|
+
};
|
|
47
|
+
requiredMapFields: {
|
|
48
|
+
[x: string]: string | undefined;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}) => void) => void;
|
|
52
|
+
resetConfigureState: (objectName: string, configureState: ConfigureState) => void;
|
|
7
53
|
resetPendingConfigurationState: (objectName: string) => void;
|
|
8
54
|
};
|
|
9
55
|
type ConfigurationProviderProps = {
|