@amp-labs/react 1.1.0 → 1.2.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/build/generated-sources/api/src/apis/AllowedDomainApi.d.ts +79 -0
- package/build/generated-sources/api/src/apis/AllowedDomainApi.js +101 -0
- package/build/generated-sources/api/src/apis/ConnectionApi.d.ts +82 -0
- package/build/generated-sources/api/src/apis/ConnectionApi.js +107 -0
- package/build/generated-sources/api/src/apis/ConsumerApi.d.ts +52 -0
- package/build/generated-sources/api/src/apis/ConsumerApi.js +75 -0
- package/build/generated-sources/api/src/apis/DestinationApi.d.ts +78 -0
- package/build/generated-sources/api/src/apis/DestinationApi.js +102 -0
- package/build/generated-sources/api/src/apis/GroupApi.d.ts +52 -0
- package/build/generated-sources/api/src/apis/GroupApi.js +75 -0
- package/build/generated-sources/api/src/apis/InstallationApi.d.ts +168 -0
- package/build/generated-sources/api/src/apis/InstallationApi.js +205 -0
- package/build/generated-sources/api/src/apis/IntegrationApi.d.ts +128 -0
- package/build/generated-sources/api/src/apis/IntegrationApi.js +154 -0
- package/build/generated-sources/api/src/apis/OAuthApi.d.ts +76 -0
- package/build/generated-sources/api/src/apis/OAuthApi.js +102 -0
- package/build/generated-sources/api/src/apis/OperationApi.d.ts +80 -0
- package/build/generated-sources/api/src/apis/OperationApi.js +104 -0
- package/build/generated-sources/api/src/apis/OperationLogApi.d.ts +55 -0
- package/build/generated-sources/api/src/apis/OperationLogApi.js +76 -0
- package/build/generated-sources/api/src/apis/ProjectApi.d.ts +124 -0
- package/build/generated-sources/api/src/apis/ProjectApi.js +148 -0
- package/build/generated-sources/api/src/apis/ProjectMembershipApi.d.ts +126 -0
- package/build/generated-sources/api/src/apis/ProjectMembershipApi.js +154 -0
- package/build/generated-sources/api/src/apis/ProviderAppApi.d.ts +130 -0
- package/build/generated-sources/api/src/apis/ProviderAppApi.js +158 -0
- package/build/generated-sources/api/src/apis/RevisionApi.d.ts +87 -0
- package/build/generated-sources/api/src/apis/RevisionApi.js +113 -0
- package/build/generated-sources/api/src/apis/UploadURLApi.d.ts +46 -0
- package/build/generated-sources/api/src/apis/UploadURLApi.js +68 -0
- package/build/generated-sources/api/src/apis/index.d.ts +15 -1
- package/build/generated-sources/api/src/apis/index.js +15 -1
- package/build/generated-sources/api/src/models/Destination.d.ts +44 -0
- package/build/generated-sources/api/src/models/Destination.js +57 -0
- package/build/generated-sources/api/src/models/DestinationMetadata.d.ts +39 -0
- package/build/generated-sources/api/src/models/{CreateDestinationRequestMetadata.js → DestinationMetadata.js} +11 -11
- package/build/generated-sources/api/src/models/OperationLog.d.ts +43 -0
- package/build/generated-sources/api/src/models/OperationLog.js +56 -0
- package/build/generated-sources/api/src/models/ProviderApp.d.ts +6 -0
- package/build/generated-sources/api/src/models/ProviderApp.js +2 -0
- package/build/generated-sources/api/src/models/index.d.ts +3 -2
- package/build/generated-sources/api/src/models/index.js +3 -2
- package/build/src/assets/TrashIcon.js +3 -1
- package/build/src/components/Configure/InstallIntegration.d.ts +4 -1
- package/build/src/components/Configure/InstallIntegration.js +10 -23
- package/build/src/components/Configure/actions/onSaveReadCreateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/{onSaveCreate.js → onSaveReadCreateInstallation.js} +7 -6
- package/build/src/components/Configure/actions/onSaveReadUpdateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/{onSaveUpdate.js → onSaveReadUpdateInstallation.js} +13 -8
- package/build/src/components/Configure/actions/write/generateConfigWriteObjects.d.ts +26 -0
- package/build/src/components/Configure/actions/write/generateConfigWriteObjects.js +41 -0
- package/build/src/components/Configure/actions/write/onSaveWriteCreateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/write/onSaveWriteCreateInstallation.js +85 -0
- package/build/src/components/Configure/actions/write/onSaveWriteUpdateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/write/onSaveWriteUpdateInstallation.js +60 -0
- package/build/src/components/Configure/{ConfigureInstallationBase.d.ts → content/ConfigureInstallationBase.d.ts} +2 -1
- package/build/src/components/Configure/content/ConfigureInstallationBase.js +36 -0
- package/build/src/components/Configure/content/CreateInstallation.js +83 -0
- package/build/src/components/Configure/content/InstallationContent.d.ts +1 -0
- package/build/src/components/Configure/content/InstallationContent.js +20 -0
- package/build/src/components/Configure/{UninstallContent.js → content/UninstallContent.js} +10 -9
- package/build/src/components/Configure/{UpdateInstallation.d.ts → content/UpdateInstallation.d.ts} +1 -1
- package/build/src/components/Configure/{UpdateInstallation.js → content/UpdateInstallation.js} +42 -28
- package/build/src/components/Configure/{fields → content/fields}/FieldMappings/FieldMapping.d.ts +1 -1
- package/build/src/components/Configure/{fields → content/fields}/FieldMappings/FieldMapping.js +4 -7
- package/build/src/components/Configure/{fields → content/fields}/FieldMappings/RequiredFieldMappings.js +10 -11
- package/build/src/components/Configure/{fields → content/fields}/FieldMappings/setFieldMapping.d.ts +1 -1
- package/build/src/components/Configure/content/fields/FieldMappings/setFieldMapping.js +21 -0
- package/build/src/components/Configure/{fields → content/fields}/OptionalFields/OptionalFields.js +9 -14
- package/build/src/components/Configure/{fields → content/fields}/OptionalFields/setOptionalField.d.ts +1 -1
- package/build/src/components/Configure/content/fields/OptionalFields/setOptionalField.js +27 -0
- package/build/src/components/Configure/content/fields/ReadFields.d.ts +1 -0
- package/build/src/components/Configure/content/fields/ReadFields.js +11 -0
- package/build/src/components/Configure/content/fields/RequiredFields.js +23 -0
- package/build/src/components/Configure/content/fields/WriteFields/WriteFields.d.ts +1 -0
- package/build/src/components/Configure/content/fields/WriteFields/WriteFields.js +22 -0
- package/build/src/components/Configure/content/fields/WriteFields/index.d.ts +2 -0
- package/build/src/components/Configure/content/fields/WriteFields/index.js +5 -0
- package/build/src/components/Configure/content/fields/WriteFields/setNonConfigurableWriteField.d.ts +3 -0
- package/build/src/components/Configure/content/fields/WriteFields/setNonConfigurableWriteField.js +32 -0
- package/build/src/components/Configure/content/useMutateInstallation.d.ts +23 -0
- package/build/src/components/Configure/content/useMutateInstallation.js +47 -0
- package/build/src/components/Configure/content/useSelectedConfigureState.d.ts +72 -0
- package/build/src/components/Configure/content/useSelectedConfigureState.js +24 -0
- package/build/src/components/Configure/{ProtectedConnectionLayout.d.ts → layout/ProtectedConnectionLayout.d.ts} +2 -1
- package/build/src/components/Configure/{ProtectedConnectionLayout.js → layout/ProtectedConnectionLayout.js} +13 -13
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/NavObjectItem.d.ts +1 -0
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/NavObjectItem.js +3 -3
- package/build/src/components/Configure/nav/ObjectManagementNav/OtherTab.d.ts +7 -0
- package/build/src/components/Configure/nav/ObjectManagementNav/OtherTab.js +11 -0
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/UninstallInstallation.d.ts +1 -1
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/UninstallInstallation.js +2 -2
- package/build/src/components/Configure/nav/ObjectManagementNav/constant.d.ts +1 -0
- package/build/src/components/Configure/nav/ObjectManagementNav/constant.js +4 -0
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/index.d.ts +1 -0
- package/build/src/components/Configure/nav/ObjectManagementNav/index.js +61 -0
- package/build/src/components/Configure/state/ConfigurationStateProvider.d.ts +70 -42
- package/build/src/components/Configure/state/ConfigurationStateProvider.js +39 -17
- package/build/src/components/Configure/state/HydratedRevisionContext.js +11 -9
- package/build/src/components/Configure/state/utils.d.ts +2 -2
- package/build/src/components/Configure/state/utils.js +44 -19
- package/build/src/components/Configure/types.d.ts +22 -6
- package/build/src/components/Configure/utils.d.ts +3 -2
- package/build/src/components/Configure/utils.js +25 -5
- package/build/src/components/Connect/ConnectProvider.d.ts +3 -1
- package/build/src/components/Connect/ConnectProvider.js +6 -12
- package/build/src/components/Connect/ConnectedSuccessBox.d.ts +5 -0
- package/build/src/components/Connect/ConnectedSuccessBox.js +13 -0
- package/build/src/components/Connect/useConnectionHandler.d.ts +10 -0
- package/build/src/components/Connect/useConnectionHandler.js +24 -0
- package/build/src/components/ErrorTextBox.js +11 -0
- package/build/src/components/Oauth/NoSubdomainEntry/LandingContent.d.ts +8 -0
- package/build/src/components/Oauth/{Hubspot/HubspotLandingContent.js → NoSubdomainEntry/LandingContent.js} +5 -4
- package/build/src/components/Oauth/NoSubdomainEntry/NoSubdomainOauthFlow.d.ts +16 -0
- package/build/src/components/Oauth/{Hubspot/HubspotOauthFlow.js → NoSubdomainEntry/NoSubdomainOauthFlow.js} +14 -14
- package/build/src/components/{Connect → Oauth}/OAuthPopup.js +8 -10
- package/build/src/components/Oauth/Salesforce/SalesforceOauthFlow.js +5 -5
- package/build/src/components/Oauth/fetchOAuthCallbackURL.d.ts +1 -1
- package/build/src/components/Oauth/fetchOAuthCallbackURL.js +3 -4
- package/build/src/components/RedirectHandler/RedirectHandler.d.ts +15 -0
- package/build/src/components/RedirectHandler/RedirectHandler.js +31 -0
- package/build/src/components/RedirectHandler/index.d.ts +1 -0
- package/build/src/components/RedirectHandler/index.js +5 -0
- package/build/src/{components/AmpersandProvider/AmpersandProvider.js → context/AmpersandContextProvider/AmpersandContextProvider.js} +6 -6
- package/build/src/context/AmpersandContextProvider/index.d.ts +1 -0
- package/build/src/{components/AmpersandProvider → context/AmpersandContextProvider}/index.js +1 -1
- package/build/src/context/{ConnectionsContext.js → ConnectionsContextProvider.js} +11 -10
- package/build/src/context/{InstallIntegrationContext.d.ts → InstallIntegrationContextProvider.d.ts} +7 -2
- package/build/src/context/{InstallIntegrationContext.js → InstallIntegrationContextProvider.js} +29 -14
- package/build/src/context/{IntegrationListContext.js → IntegrationListContextProvider.js} +4 -4
- package/build/src/context/{ProjectContext.js → ProjectContextProvider.js} +4 -4
- package/build/src/hooks/useIsIntegrationInstalled.js +7 -7
- package/build/src/index.d.ts +1 -2
- package/build/src/index.js +1 -2
- package/build/src/public/index.d.ts +7 -0
- package/build/src/{components → public}/index.js +7 -3
- package/build/src/services/ApiService.d.ts +27 -0
- package/build/src/services/ApiService.js +34 -0
- package/build/src/services/api.d.ts +5 -4
- package/build/src/services/api.js +11 -6
- package/package.json +2 -2
- package/build/generated-sources/api/src/apis/DefaultApi.d.ts +0 -930
- package/build/generated-sources/api/src/apis/DefaultApi.js +0 -1019
- package/build/generated-sources/api/src/models/CreateDestinationRequest.d.ts +0 -44
- package/build/generated-sources/api/src/models/CreateDestinationRequest.js +0 -57
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.d.ts +0 -39
- package/build/src/components/AmpersandProvider/index.d.ts +0 -1
- package/build/src/components/CenteredTextBox/CenteredTextBox.d.ts +0 -5
- package/build/src/components/CenteredTextBox/CenteredTextBox.js +0 -8
- package/build/src/components/Configure/ConfigureInstallationBase.js +0 -29
- package/build/src/components/Configure/CreateInstallation.js +0 -70
- package/build/src/components/Configure/ErrorTextBox.js +0 -9
- package/build/src/components/Configure/ObjectManagementNav/index.js +0 -53
- package/build/src/components/Configure/actions/onSaveCreate.d.ts +0 -3
- package/build/src/components/Configure/actions/onSaveUpdate.d.ts +0 -3
- package/build/src/components/Configure/fields/FieldMappings/setFieldMapping.js +0 -18
- package/build/src/components/Configure/fields/OptionalFields/setOptionalField.js +0 -21
- package/build/src/components/Configure/fields/RequiredFields.js +0 -27
- package/build/src/components/Oauth/Hubspot/HubspotLandingContent.d.ts +0 -7
- package/build/src/components/Oauth/Hubspot/HubspotOauthFlow.d.ts +0 -15
- package/build/src/components/index.d.ts +0 -3
- /package/build/src/components/Configure/{CreateInstallation.d.ts → content/CreateInstallation.d.ts} +0 -0
- /package/build/src/components/Configure/{UninstallContent.d.ts → content/UninstallContent.d.ts} +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldHeader.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldHeader.js +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/RequiredFieldMappings.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/index.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/index.js +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/OptionalFields.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/index.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/index.js +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/RequiredFields.d.ts +0 -0
- /package/build/src/components/{Configure/ErrorTextBox.d.ts → ErrorTextBox.d.ts} +0 -0
- /package/build/src/components/{Connect → Oauth}/OAuthPopup.d.ts +0 -0
- /package/build/src/{components/AmpersandProvider/AmpersandProvider.d.ts → context/AmpersandContextProvider/AmpersandContextProvider.d.ts} +0 -0
- /package/build/src/context/{ApiKeyProvider.d.ts → ApiKeyContextProvider.d.ts} +0 -0
- /package/build/src/context/{ApiKeyProvider.js → ApiKeyContextProvider.js} +0 -0
- /package/build/src/context/{ConnectionsContext.d.ts → ConnectionsContextProvider.d.ts} +0 -0
- /package/build/src/context/{IntegrationListContext.d.ts → IntegrationListContextProvider.d.ts} +0 -0
- /package/build/src/context/{ProjectContext.d.ts → ProjectContextProvider.d.ts} +0 -0
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConfigurationProvider = exports.
|
|
3
|
+
exports.ConfigurationProvider = exports.useObjectsConfigureState = exports.ConfigurationContext = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const immer_1 = require("immer");
|
|
7
|
-
const
|
|
7
|
+
const InstallIntegrationContextProvider_1 = require("../../../context/InstallIntegrationContextProvider");
|
|
8
|
+
const constant_1 = require("../nav/ObjectManagementNav/constant");
|
|
8
9
|
const HydratedRevisionContext_1 = require("./HydratedRevisionContext");
|
|
9
10
|
const utils_1 = require("./utils");
|
|
10
11
|
// Create a context for the configuration state
|
|
11
|
-
|
|
12
|
+
exports.ConfigurationContext = (0, react_1.createContext)(undefined);
|
|
12
13
|
const initialObjectConfigurationsState = {};
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Custom hook to access and update the configuration state for all objects
|
|
16
|
+
*/
|
|
17
|
+
function useObjectsConfigureState() {
|
|
18
|
+
const context = (0, react_1.useContext)(exports.ConfigurationContext);
|
|
16
19
|
if (!context) {
|
|
17
|
-
throw new Error('
|
|
20
|
+
throw new Error('useObjectsConfigureState must be used within a ConfigurationProvider');
|
|
18
21
|
}
|
|
19
22
|
return context;
|
|
20
23
|
}
|
|
21
|
-
exports.
|
|
24
|
+
exports.useObjectsConfigureState = useObjectsConfigureState;
|
|
22
25
|
// Create a provider component for the configuration context
|
|
23
26
|
function ConfigurationProvider({ children }) {
|
|
24
|
-
const { installation } = (0,
|
|
27
|
+
const { installation } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
|
|
25
28
|
const { hydratedRevision, loading } = (0, HydratedRevisionContext_1.useHydratedRevision)();
|
|
26
29
|
// 1. get config from installations (contains form selection state)
|
|
27
30
|
// 2. get the hydrated revision from installation revisionId (contains full form)
|
|
@@ -53,16 +56,35 @@ function ConfigurationProvider({ children }) {
|
|
|
53
56
|
draft[objectName] = configureState;
|
|
54
57
|
}));
|
|
55
58
|
}, [setObjectConfigurationsState]);
|
|
56
|
-
|
|
57
|
-
const resetPendingConfigurationState = (0, react_1.useCallback)((objectName) => {
|
|
59
|
+
const resetWritePendingConfigurationState = (0, react_1.useCallback)(() => {
|
|
58
60
|
setObjectConfigurationsState((0, immer_1.produce)((draft) => {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
const writeDraft = draft.other.write;
|
|
62
|
+
if (writeDraft) {
|
|
63
|
+
writeDraft.isWriteModified = false;
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
}, [setObjectConfigurationsState]);
|
|
67
|
+
const resetReadPendingConfigurationState = (0, react_1.useCallback)((objectName) => {
|
|
68
|
+
setObjectConfigurationsState((0, immer_1.produce)((draft) => {
|
|
69
|
+
var _a;
|
|
70
|
+
const readDraft = (_a = draft[objectName]) === null || _a === void 0 ? void 0 : _a.read;
|
|
71
|
+
if (readDraft) {
|
|
72
|
+
readDraft.isOptionalFieldsModified = false;
|
|
73
|
+
readDraft.isRequiredMapFieldsModified = false;
|
|
74
|
+
}
|
|
64
75
|
}));
|
|
65
76
|
}, [setObjectConfigurationsState]);
|
|
77
|
+
// set configure state of single object
|
|
78
|
+
const resetPendingConfigurationState = (0, react_1.useCallback)((objectName) => {
|
|
79
|
+
// write case
|
|
80
|
+
if (objectName === constant_1.OTHER_CONST) {
|
|
81
|
+
resetWritePendingConfigurationState();
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
// read case
|
|
85
|
+
resetReadPendingConfigurationState(objectName);
|
|
86
|
+
}
|
|
87
|
+
}, [resetReadPendingConfigurationState, resetWritePendingConfigurationState]);
|
|
66
88
|
const contextValue = (0, react_1.useMemo)(() => ({
|
|
67
89
|
objectConfigurationsState,
|
|
68
90
|
setObjectConfigurationsState,
|
|
@@ -71,6 +93,6 @@ function ConfigurationProvider({ children }) {
|
|
|
71
93
|
resetPendingConfigurationState,
|
|
72
94
|
}), [objectConfigurationsState,
|
|
73
95
|
resetConfigureState, resetPendingConfigurationState, setConfigureState]);
|
|
74
|
-
return ((0, jsx_runtime_1.jsx)(ConfigurationContext.Provider, { value: contextValue, children: children }));
|
|
96
|
+
return ((0, jsx_runtime_1.jsx)(exports.ConfigurationContext.Provider, { value: contextValue, children: children }));
|
|
75
97
|
}
|
|
76
98
|
exports.ConfigurationProvider = ConfigurationProvider;
|
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.HydratedRevisionProvider = exports.useHydratedRevision = exports.HydratedRevisionContext = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const ApiKeyContextProvider_1 = require("../../../context/ApiKeyContextProvider");
|
|
7
|
+
const ConnectionsContextProvider_1 = require("../../../context/ConnectionsContextProvider");
|
|
8
8
|
const ErrorContextProvider_1 = require("../../../context/ErrorContextProvider");
|
|
9
|
-
const
|
|
9
|
+
const InstallIntegrationContextProvider_1 = require("../../../context/InstallIntegrationContextProvider");
|
|
10
10
|
const api_1 = require("../../../services/api");
|
|
11
|
-
const ErrorTextBox_1 = require("
|
|
11
|
+
const ErrorTextBox_1 = require("../../ErrorTextBox");
|
|
12
12
|
exports.HydratedRevisionContext = (0, react_1.createContext)({
|
|
13
13
|
hydratedRevision: null,
|
|
14
14
|
loading: false,
|
|
@@ -23,12 +23,12 @@ const useHydratedRevision = () => {
|
|
|
23
23
|
exports.useHydratedRevision = useHydratedRevision;
|
|
24
24
|
function HydratedRevisionProvider({ projectId, children, }) {
|
|
25
25
|
var _a;
|
|
26
|
-
const { selectedConnection } = (0,
|
|
27
|
-
const { integrationId, integrationObj } = (0,
|
|
26
|
+
const { selectedConnection } = (0, ConnectionsContextProvider_1.useConnections)();
|
|
27
|
+
const { integrationId, integrationObj } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
|
|
28
28
|
const [hydratedRevision, setHydratedRevision] = (0, react_1.useState)(null);
|
|
29
29
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
30
30
|
const { isError, removeError, setError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
31
|
-
const apiKey = (0,
|
|
31
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
32
32
|
const connectionId = selectedConnection === null || selectedConnection === void 0 ? void 0 : selectedConnection.id;
|
|
33
33
|
const revisionId = (_a = integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.latestRevision) === null || _a === void 0 ? void 0 : _a.id;
|
|
34
34
|
const errorIntegrationIdentifier = (integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.name) || integrationId;
|
|
@@ -39,7 +39,7 @@ function HydratedRevisionProvider({ projectId, children, }) {
|
|
|
39
39
|
&& revisionId
|
|
40
40
|
&& connectionId
|
|
41
41
|
&& apiKey) {
|
|
42
|
-
(0, api_1.api)().getHydratedRevision({
|
|
42
|
+
(0, api_1.api)().revisionApi.getHydratedRevision({
|
|
43
43
|
projectId,
|
|
44
44
|
integrationId,
|
|
45
45
|
revisionId,
|
|
@@ -74,6 +74,8 @@ function HydratedRevisionProvider({ projectId, children, }) {
|
|
|
74
74
|
hydratedRevision,
|
|
75
75
|
loading,
|
|
76
76
|
}), [hydratedRevision, loading]);
|
|
77
|
-
|
|
77
|
+
const errorMsg = `Error retrieving integration details for '${(integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.name) || integrationId || 'unknown integration'}. This is sometimes caused by insufficient permissions with your credentials'`;
|
|
78
|
+
return ((0, jsx_runtime_1.jsx)(exports.HydratedRevisionContext.Provider, { value: contextValue, children: isError(ErrorContextProvider_1.ErrorBoundary.HYDRATED_REVISION, errorIntegrationIdentifier)
|
|
79
|
+
? (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: errorMsg }) : children }));
|
|
78
80
|
}
|
|
79
81
|
exports.HydratedRevisionProvider = HydratedRevisionProvider;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Config,
|
|
1
|
+
import { Config, HydratedRevision } from '../../../services/api';
|
|
2
2
|
import { ConfigureState, ObjectConfigurationsState, SelectMappingFields, SelectOptionalFields } from '../types';
|
|
3
3
|
export declare function isFieldObjectEqual(prevFields: SelectMappingFields | SelectOptionalFields, currentFields: SelectMappingFields | SelectOptionalFields): boolean;
|
|
4
|
-
export declare function generateConfigurationState(
|
|
4
|
+
export declare function generateConfigurationState(hydratedRevision: HydratedRevision, objectName: string, config?: Config): ConfigureState;
|
|
5
5
|
export declare const setHydrateConfigState: (hydratedRevision: HydratedRevision, config: Config | undefined, selectedObjectName: string, setConfigureState: (objectName: string, configureState: ConfigureState) => void) => void;
|
|
6
6
|
/**
|
|
7
7
|
* resets configure state for all objects in hydrated revision to hydrated revision values
|
|
@@ -11,18 +11,22 @@ function isFieldObjectEqual(prevFields, currentFields) {
|
|
|
11
11
|
return (0, lodash_isequal_1.default)(prevFields, currentFields);
|
|
12
12
|
}
|
|
13
13
|
exports.isFieldObjectEqual = isFieldObjectEqual;
|
|
14
|
-
|
|
15
|
-
var _a, _b, _c, _d, _e, _f
|
|
14
|
+
const generateConfigurationStateRead = (readAction, objectName, config) => {
|
|
15
|
+
var _a, _b, _c, _d, _e, _f;
|
|
16
|
+
if (!readAction) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
16
19
|
// refactor this section to be immutable at hydrated revision level
|
|
17
|
-
const object = (0, utils_1.getStandardObjectFromAction)(
|
|
20
|
+
const object = (0, utils_1.getStandardObjectFromAction)(readAction, objectName);
|
|
18
21
|
const requiredFields = object && (0, utils_1.getRequiredFieldsFromObject)(object);
|
|
19
22
|
const optionalFields = object && (0, utils_1.getOptionalFieldsFromObject)(object);
|
|
20
23
|
const requiredMapFields = object && (0, utils_1.getRequiredMapFieldsFromObject)(object);
|
|
21
24
|
/// //////////////////////////////////////////////////////////////////////
|
|
22
25
|
const allFields = (object === null || object === void 0 ? void 0 : object.allFields) || [];
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
+
const content = config === null || config === void 0 ? void 0 : config.content;
|
|
27
|
+
const readSelectedFields = ((_c = (_b = (_a = content === null || content === void 0 ? void 0 : content.read) === null || _a === void 0 ? void 0 : _a.standardObjects) === null || _b === void 0 ? void 0 : _b[objectName]) === null || _c === void 0 ? void 0 : _c.selectedFields) || {};
|
|
28
|
+
const selectedFieldMappings = ((_f = (_e = (_d = content === null || content === void 0 ? void 0 : content.read) === null || _d === void 0 ? void 0 : _d.standardObjects) === null || _e === void 0 ? void 0 : _e[objectName]) === null || _f === void 0 ? void 0 : _f.selectedFieldMappings) || {};
|
|
29
|
+
const optionalFieldsSaved = Object.assign({}, readSelectedFields);
|
|
26
30
|
const requiredMapFieldsSaved = Object.assign({}, selectedFieldMappings);
|
|
27
31
|
return {
|
|
28
32
|
allFields,
|
|
@@ -30,7 +34,7 @@ function generateConfigurationState(action, objectName, config) {
|
|
|
30
34
|
optionalFields,
|
|
31
35
|
requiredMapFields,
|
|
32
36
|
// selected state
|
|
33
|
-
selectedOptionalFields:
|
|
37
|
+
selectedOptionalFields: readSelectedFields,
|
|
34
38
|
selectedFieldMappings,
|
|
35
39
|
isOptionalFieldsModified: false,
|
|
36
40
|
isRequiredMapFieldsModified: false,
|
|
@@ -39,16 +43,39 @@ function generateConfigurationState(action, objectName, config) {
|
|
|
39
43
|
requiredMapFields: requiredMapFieldsSaved, // from config
|
|
40
44
|
},
|
|
41
45
|
};
|
|
46
|
+
};
|
|
47
|
+
const generateConfigurationStateWrite = (writeAction, config) => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
if (!writeAction) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const writeObjects = (_b = (_a = config === null || config === void 0 ? void 0 : config.content) === null || _a === void 0 ? void 0 : _a.write) === null || _b === void 0 ? void 0 : _b.objects;
|
|
53
|
+
const fields = Object.keys(writeObjects || {});
|
|
54
|
+
const selectedWriteFields = {};
|
|
55
|
+
fields.forEach((field) => { selectedWriteFields[field] = true; });
|
|
56
|
+
const savedFields = Object.assign({}, selectedWriteFields);
|
|
57
|
+
return {
|
|
58
|
+
writeObjects: (writeAction === null || writeAction === void 0 ? void 0 : writeAction.objects) || [],
|
|
59
|
+
selectedNonConfigurableWriteFields: selectedWriteFields,
|
|
60
|
+
isWriteModified: false,
|
|
61
|
+
savedConfig: {
|
|
62
|
+
selectedNonConfigurableWriteFields: savedFields,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
function generateConfigurationState(hydratedRevision, objectName, config) {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
const readAction = (_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.read;
|
|
69
|
+
const writeAction = (_b = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _b === void 0 ? void 0 : _b.write;
|
|
70
|
+
return {
|
|
71
|
+
read: generateConfigurationStateRead(readAction, objectName, config),
|
|
72
|
+
write: generateConfigurationStateWrite(writeAction, config),
|
|
73
|
+
};
|
|
42
74
|
}
|
|
43
75
|
exports.generateConfigurationState = generateConfigurationState;
|
|
44
76
|
// resets configure state for single object to hydrated revision values
|
|
45
77
|
const setHydrateConfigState = (hydratedRevision, config, selectedObjectName, setConfigureState) => {
|
|
46
|
-
|
|
47
|
-
const readAction = (_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.read;
|
|
48
|
-
if (!readAction) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
const state = generateConfigurationState(readAction, selectedObjectName, config);
|
|
78
|
+
const state = generateConfigurationState(hydratedRevision, selectedObjectName, config);
|
|
52
79
|
setConfigureState(selectedObjectName, state);
|
|
53
80
|
};
|
|
54
81
|
exports.setHydrateConfigState = setHydrateConfigState;
|
|
@@ -59,10 +86,8 @@ const resetAllObjectsConfigurationState = (hydratedRevision, config, setObjectCo
|
|
|
59
86
|
const navObjects = (0, utils_1.generateNavObjects)(config, hydratedRevision);
|
|
60
87
|
const objectConfigurationsState = {};
|
|
61
88
|
navObjects.forEach(({ name, completed }) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (completed && readAction) {
|
|
65
|
-
objectConfigurationsState[name] = generateConfigurationState(readAction, name, config);
|
|
89
|
+
if (completed) {
|
|
90
|
+
objectConfigurationsState[name] = generateConfigurationState(hydratedRevision, name, config);
|
|
66
91
|
}
|
|
67
92
|
});
|
|
68
93
|
setObjectConfiguresState(objectConfigurationsState);
|
|
@@ -74,7 +99,7 @@ exports.resetAllObjectsConfigurationState = resetAllObjectsConfigurationState;
|
|
|
74
99
|
* @returns
|
|
75
100
|
*/
|
|
76
101
|
const generateSelectedFieldsFromConfigureState = (configureState) => {
|
|
77
|
-
const { requiredFields, selectedOptionalFields } = configureState;
|
|
102
|
+
const { requiredFields, selectedOptionalFields } = (configureState === null || configureState === void 0 ? void 0 : configureState.read) || {};
|
|
78
103
|
const fields = new Set();
|
|
79
104
|
requiredFields === null || requiredFields === void 0 ? void 0 : requiredFields.forEach((field) => fields.add((0, utils_1.getFieldKeyValue)(field)));
|
|
80
105
|
// convert set to object for config
|
|
@@ -88,7 +113,7 @@ exports.generateSelectedFieldsFromConfigureState = generateSelectedFieldsFromCon
|
|
|
88
113
|
* @returns
|
|
89
114
|
*/
|
|
90
115
|
const generateSelectedFieldMappingsFromConfigureState = (configureState) => {
|
|
91
|
-
const { selectedFieldMappings: selectedRequiredMapFields } = configureState;
|
|
116
|
+
const { selectedFieldMappings: selectedRequiredMapFields } = (configureState === null || configureState === void 0 ? void 0 : configureState.read) || {};
|
|
92
117
|
// filter out undefined values of selectedRequiredMapFields
|
|
93
118
|
const selectedRequiredMapFieldsSubmit = {};
|
|
94
119
|
if (selectedRequiredMapFields) {
|
|
@@ -1,15 +1,23 @@
|
|
|
1
|
-
import { HydratedIntegrationField, HydratedIntegrationFieldExistent, IntegrationFieldMapping } from '../../services/api';
|
|
1
|
+
import { HydratedIntegrationField, HydratedIntegrationFieldExistent, HydratedIntegrationWriteObject, IntegrationFieldMapping } from '../../services/api';
|
|
2
|
+
export type SelectedNonConfigurableWriteFields = {
|
|
3
|
+
[key: string]: boolean;
|
|
4
|
+
};
|
|
5
|
+
type SavedWriteConfigureState = {
|
|
6
|
+
selectedNonConfigurableWriteFields: SelectedNonConfigurableWriteFields;
|
|
7
|
+
};
|
|
8
|
+
export type ConfigureStateWrite = {
|
|
9
|
+
writeObjects: HydratedIntegrationWriteObject[] | null;
|
|
10
|
+
selectedNonConfigurableWriteFields: SelectedNonConfigurableWriteFields | null;
|
|
11
|
+
isWriteModified: boolean;
|
|
12
|
+
savedConfig: SavedWriteConfigureState;
|
|
13
|
+
};
|
|
2
14
|
export type SelectOptionalFields = {
|
|
3
15
|
[key: string]: boolean;
|
|
4
16
|
};
|
|
5
17
|
export type SelectMappingFields = {
|
|
6
18
|
[key: string]: string | undefined;
|
|
7
19
|
};
|
|
8
|
-
type
|
|
9
|
-
optionalFields: SelectOptionalFields;
|
|
10
|
-
requiredMapFields: SelectMappingFields;
|
|
11
|
-
};
|
|
12
|
-
export type ConfigureState = {
|
|
20
|
+
export type ConfigureStateRead = {
|
|
13
21
|
allFields: HydratedIntegrationFieldExistent[] | null;
|
|
14
22
|
requiredFields: HydratedIntegrationField[] | null;
|
|
15
23
|
optionalFields: HydratedIntegrationField[] | null;
|
|
@@ -20,6 +28,14 @@ export type ConfigureState = {
|
|
|
20
28
|
isRequiredMapFieldsModified: boolean;
|
|
21
29
|
savedConfig: SavedConfigureState;
|
|
22
30
|
};
|
|
31
|
+
type SavedConfigureState = {
|
|
32
|
+
optionalFields: SelectOptionalFields;
|
|
33
|
+
requiredMapFields: SelectMappingFields;
|
|
34
|
+
};
|
|
35
|
+
export type ConfigureState = {
|
|
36
|
+
read: ConfigureStateRead | null;
|
|
37
|
+
write: ConfigureStateWrite | null;
|
|
38
|
+
};
|
|
23
39
|
export type ObjectConfigurationsState = Record<string, ConfigureState>;
|
|
24
40
|
export type NavObject = {
|
|
25
41
|
name: string;
|
|
@@ -11,7 +11,7 @@ export declare function isIntegrationFieldMapping(field: HydratedIntegrationFiel
|
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
13
13
|
* @param action HydratedIntegrationAction
|
|
14
|
-
* @param objectName string (account,
|
|
14
|
+
* @param objectName string (account, contact, etc...)
|
|
15
15
|
* @returns HydratedIntegrationObject | null
|
|
16
16
|
*/
|
|
17
17
|
export declare function getStandardObjectFromAction(action: HydratedIntegrationRead, objectName: string): HydratedIntegrationObject | null;
|
|
@@ -20,7 +20,8 @@ export declare function getRequiredMapFieldsFromObject(object: HydratedIntegrati
|
|
|
20
20
|
export declare function getOptionalFieldsFromObject(object: HydratedIntegrationObject): HydratedIntegrationField[] | null;
|
|
21
21
|
export declare const getReadObject: (config: Config, objectName: string) => any;
|
|
22
22
|
export declare function getFieldKeyValue(field: HydratedIntegrationField): string;
|
|
23
|
+
export declare const generateOtherNavObject: (config: Config | undefined) => NavObject;
|
|
23
24
|
export declare function generateNavObjects(config: Config | undefined, hydratedRevision: HydratedRevision): NavObject[];
|
|
24
|
-
export declare function validateFieldMappings(requiredMapFields: IntegrationFieldMapping[] | null, selectedRequiredMapFields: SelectMappingFields | null, setErrors: (boundary: ErrorBoundary, errors: string[]) => void): {
|
|
25
|
+
export declare function validateFieldMappings(requiredMapFields: IntegrationFieldMapping[] | null | undefined, selectedRequiredMapFields: SelectMappingFields | null | undefined, setErrors: (boundary: ErrorBoundary, errors: string[]) => void): {
|
|
25
26
|
errorList: string[];
|
|
26
27
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateFieldMappings = exports.generateNavObjects = exports.getFieldKeyValue = exports.getReadObject = exports.getOptionalFieldsFromObject = exports.getRequiredMapFieldsFromObject = exports.getRequiredFieldsFromObject = exports.getStandardObjectFromAction = exports.isIntegrationFieldMapping = void 0;
|
|
3
|
+
exports.validateFieldMappings = exports.generateNavObjects = exports.generateOtherNavObject = exports.getFieldKeyValue = exports.getReadObject = exports.getOptionalFieldsFromObject = exports.getRequiredMapFieldsFromObject = exports.getRequiredFieldsFromObject = exports.getStandardObjectFromAction = exports.isIntegrationFieldMapping = void 0;
|
|
4
4
|
const ErrorContextProvider_1 = require("../../context/ErrorContextProvider");
|
|
5
|
+
const constant_1 = require("./nav/ObjectManagementNav/constant");
|
|
5
6
|
/**
|
|
6
7
|
* type guard for IntegrationFieldMapping | IntegrationFieldExistent
|
|
7
8
|
*
|
|
@@ -16,7 +17,7 @@ exports.isIntegrationFieldMapping = isIntegrationFieldMapping;
|
|
|
16
17
|
/**
|
|
17
18
|
*
|
|
18
19
|
* @param action HydratedIntegrationAction
|
|
19
|
-
* @param objectName string (account,
|
|
20
|
+
* @param objectName string (account, contact, etc...)
|
|
20
21
|
* @returns HydratedIntegrationObject | null
|
|
21
22
|
*/
|
|
22
23
|
function getStandardObjectFromAction(action, objectName) {
|
|
@@ -50,11 +51,16 @@ function getFieldKeyValue(field) {
|
|
|
50
51
|
if (isIntegrationFieldMapping(field)) {
|
|
51
52
|
return field.mapToName; // custom mapping
|
|
52
53
|
}
|
|
53
|
-
return field.fieldName; //
|
|
54
|
+
return field.fieldName; // existent field
|
|
54
55
|
}
|
|
55
56
|
exports.getFieldKeyValue = getFieldKeyValue;
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
/**
|
|
58
|
+
* generates Nav Objects for read action
|
|
59
|
+
* @param config
|
|
60
|
+
* @param hydratedRevision
|
|
61
|
+
* @returns NavObject[]
|
|
62
|
+
*/
|
|
63
|
+
const generateReadNavObjects = (config, hydratedRevision) => {
|
|
58
64
|
var _a, _b, _c;
|
|
59
65
|
const navObjects = [];
|
|
60
66
|
(_c = (_b = (_a = 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.forEach((object) => {
|
|
@@ -66,6 +72,20 @@ function generateNavObjects(config, hydratedRevision) {
|
|
|
66
72
|
});
|
|
67
73
|
});
|
|
68
74
|
return navObjects;
|
|
75
|
+
};
|
|
76
|
+
const generateOtherNavObject = (config) => {
|
|
77
|
+
var _a;
|
|
78
|
+
const navObject = {
|
|
79
|
+
name: constant_1.OTHER_CONST,
|
|
80
|
+
completed: config ? !!((_a = config === null || config === void 0 ? void 0 : config.content) === null || _a === void 0 ? void 0 : _a.write) : false,
|
|
81
|
+
};
|
|
82
|
+
return navObject;
|
|
83
|
+
};
|
|
84
|
+
exports.generateOtherNavObject = generateOtherNavObject;
|
|
85
|
+
// generates standard objects and whether they are complete based on config and hydrated revision
|
|
86
|
+
function generateNavObjects(config, hydratedRevision) {
|
|
87
|
+
const navObjects = generateReadNavObjects(config, hydratedRevision);
|
|
88
|
+
return navObjects;
|
|
69
89
|
}
|
|
70
90
|
exports.generateNavObjects = generateNavObjects;
|
|
71
91
|
// validates whether required fields are filled out or throws error
|
|
@@ -4,6 +4,8 @@ interface ConnectProviderProps {
|
|
|
4
4
|
consumerName?: string;
|
|
5
5
|
groupRef: string;
|
|
6
6
|
groupName?: string;
|
|
7
|
+
redirectUrl?: string;
|
|
8
|
+
onSuccess?: (connectionID: string) => void;
|
|
7
9
|
}
|
|
8
|
-
export declare function ConnectProvider({ provider, consumerRef, consumerName, groupRef, groupName, }: ConnectProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function ConnectProvider({ provider, consumerRef, consumerName, groupRef, groupName, redirectUrl, onSuccess, }: ConnectProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
9
11
|
export {};
|
|
@@ -2,17 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConnectProvider = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
function ConnectedSuccessBox({ provider }) {
|
|
12
|
-
const { appName } = (0, ProjectContext_1.useProject)();
|
|
13
|
-
return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsxs)(react_1.Box, { p: 8, maxWidth: "600px", minHeight: "290px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", margin: "auto", marginTop: "40px", bgColor: "white", paddingTop: "100px", children: [(0, jsx_runtime_1.jsx)(react_1.Box, { width: "100%", display: "flex", alignContent: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(react_1.Box, { margin: "auto", children: NavIcon_1.CheckMarkIcon }) }), (0, jsx_runtime_1.jsx)(react_1.Box, { textAlign: "center", paddingTop: "25px", children: `You've successfully connected ${(0, utils_1.capitalize)(provider)} to ${appName}.` })] }) }));
|
|
14
|
-
}
|
|
15
|
-
function ConnectProvider({ provider, consumerRef, consumerName, groupRef, groupName, }) {
|
|
16
|
-
return ((0, jsx_runtime_1.jsx)(ConnectionsContext_1.ConnectionsProvider, { provider: provider, groupRef: groupRef, children: (0, jsx_runtime_1.jsx)(ProtectedConnectionLayout_1.ProtectedConnectionLayout, { provider: provider, consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName, children: (0, jsx_runtime_1.jsx)(ConnectedSuccessBox, { provider: provider }) }) }));
|
|
5
|
+
const ConnectionsContextProvider_1 = require("../../context/ConnectionsContextProvider");
|
|
6
|
+
const ProtectedConnectionLayout_1 = require("../Configure/layout/ProtectedConnectionLayout");
|
|
7
|
+
const RedirectHandler_1 = require("../RedirectHandler");
|
|
8
|
+
const ConnectedSuccessBox_1 = require("./ConnectedSuccessBox");
|
|
9
|
+
function ConnectProvider({ provider, consumerRef, consumerName, groupRef, groupName, redirectUrl, onSuccess, }) {
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(ConnectionsContextProvider_1.ConnectionsProvider, { provider: provider, groupRef: groupRef, children: (0, jsx_runtime_1.jsx)(ProtectedConnectionLayout_1.ProtectedConnectionLayout, { provider: provider, consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName, onSuccess: onSuccess, children: (0, jsx_runtime_1.jsx)(RedirectHandler_1.RedirectHandler, { redirectURL: redirectUrl, children: (0, jsx_runtime_1.jsx)(ConnectedSuccessBox_1.ConnectedSuccessBox, { provider: provider }) }) }) }));
|
|
17
11
|
}
|
|
18
12
|
exports.ConnectProvider = ConnectProvider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectedSuccessBox = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const NavIcon_1 = require("../../assets/NavIcon");
|
|
7
|
+
const ProjectContextProvider_1 = require("../../context/ProjectContextProvider");
|
|
8
|
+
const utils_1 = require("../../utils");
|
|
9
|
+
function ConnectedSuccessBox({ provider }) {
|
|
10
|
+
const { appName } = (0, ProjectContextProvider_1.useProject)();
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsxs)(react_1.Box, { p: 8, maxWidth: "600px", minHeight: "290px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", margin: "auto", marginTop: "40px", bgColor: "white", paddingTop: "100px", children: [(0, jsx_runtime_1.jsx)(react_1.Box, { width: "100%", display: "flex", alignContent: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(react_1.Box, { margin: "auto", children: NavIcon_1.CheckMarkIcon }) }), (0, jsx_runtime_1.jsx)(react_1.Box, { textAlign: "center", paddingTop: "25px", children: `You've successfully connected ${(0, utils_1.capitalize)(provider)} to ${appName}.` })] }) }));
|
|
12
|
+
}
|
|
13
|
+
exports.ConnectedSuccessBox = ConnectedSuccessBox;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type ConnectionHandlerPropsProps = {
|
|
2
|
+
onSuccess?: (connectionID: string) => void;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* ConnectionHandler is a component that handles onSuccess and onError callbacks
|
|
6
|
+
* @param onSuccess - callback function to be called when a connection is successful
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
export declare function useConnectionHandler({ onSuccess }: ConnectionHandlerPropsProps): void;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useConnectionHandler = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const ConnectionsContextProvider_1 = require("../../context/ConnectionsContextProvider");
|
|
6
|
+
function useOnSuccessHandler(onSuccess) {
|
|
7
|
+
const { selectedConnection } = (0, ConnectionsContextProvider_1.useConnections)();
|
|
8
|
+
(0, react_1.useEffect)(() => {
|
|
9
|
+
// Check if a onSuccess callback is present
|
|
10
|
+
if (onSuccess && selectedConnection) {
|
|
11
|
+
// call callback when connection is selected
|
|
12
|
+
onSuccess(selectedConnection.id);
|
|
13
|
+
}
|
|
14
|
+
}, [onSuccess, selectedConnection]);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* ConnectionHandler is a component that handles onSuccess and onError callbacks
|
|
18
|
+
* @param onSuccess - callback function to be called when a connection is successful
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
function useConnectionHandler({ onSuccess }) {
|
|
22
|
+
useOnSuccessHandler(onSuccess);
|
|
23
|
+
}
|
|
24
|
+
exports.useConnectionHandler = useConnectionHandler;
|
|
@@ -0,0 +1,11 @@
|
|
|
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", {
|
|
8
|
+
// eslint-disable-next-line max-len
|
|
9
|
+
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 }) })] }));
|
|
10
|
+
}
|
|
11
|
+
exports.ErrorTextBox = ErrorTextBox;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type LandingContentProps = {
|
|
2
|
+
provider: string;
|
|
3
|
+
handleSubmit: () => void;
|
|
4
|
+
error: string | null;
|
|
5
|
+
isButtonDisabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function LandingContent({ provider, handleSubmit, error, isButtonDisabled, }: LandingContentProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LandingContent = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
6
7
|
const OAuthErrorAlert_1 = require("../OAuthErrorAlert");
|
|
7
|
-
function
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsx)(react_1.Box, { p: 8, maxWidth: "600px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", textAlign: ['left'], margin: "auto", marginTop: "40px", bgColor: "white", children: (0, jsx_runtime_1.jsxs)(react_1.FormControl, { children: [(0, jsx_runtime_1.jsx)(react_1.FormLabel, { marginTop: "16", marginBottom: "0", children: (0, jsx_runtime_1.jsx)(react_1.Heading, { as: "h4", size: "md", children:
|
|
8
|
+
function LandingContent({ provider, handleSubmit, error, isButtonDisabled, }) {
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsx)(react_1.Box, { p: 8, maxWidth: "600px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", textAlign: ['left'], margin: "auto", marginTop: "40px", bgColor: "white", children: (0, jsx_runtime_1.jsxs)(react_1.FormControl, { children: [(0, jsx_runtime_1.jsx)(react_1.FormLabel, { marginTop: "16", marginBottom: "0", children: (0, jsx_runtime_1.jsx)(react_1.Heading, { as: "h4", size: "md", children: `Set up ${(0, utils_1.capitalize)(provider)} integration` }) }), (0, jsx_runtime_1.jsx)(OAuthErrorAlert_1.OAuthErrorAlert, { error: error }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(react_1.Button, { isDisabled: isButtonDisabled, width: "100%", type: "submit", onClick: handleSubmit, children: "Next" })] }) }) }));
|
|
9
10
|
}
|
|
10
|
-
exports.
|
|
11
|
+
exports.LandingContent = LandingContent;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth flow for any providers that do not require the consumer to enter a subdomain first.
|
|
3
|
+
*/
|
|
4
|
+
interface NoSubdomainOauthFlowProps {
|
|
5
|
+
provider: string;
|
|
6
|
+
consumerRef: string;
|
|
7
|
+
consumerName?: string;
|
|
8
|
+
groupRef: string;
|
|
9
|
+
groupName?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* NoSubdomainOauthFlow first prompts user with a next button,
|
|
13
|
+
* then launches a popup with the OAuth flow.
|
|
14
|
+
*/
|
|
15
|
+
export declare function NoSubdomainOauthFlow({ provider, consumerRef, consumerName, groupRef, groupName, }: NoSubdomainOauthFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -3,25 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.NoSubdomainOauthFlow = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* OAuth flow for any providers that do not require the consumer to enter a subdomain first.
|
|
10
10
|
*/
|
|
11
11
|
const react_1 = require("react");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const OAuthPopup_1 = __importDefault(require("../../Connect/OAuthPopup"));
|
|
12
|
+
const ApiKeyContextProvider_1 = require("../../../context/ApiKeyContextProvider");
|
|
13
|
+
const ProjectContextProvider_1 = require("../../../context/ProjectContextProvider");
|
|
14
|
+
const utils_1 = require("../../../utils");
|
|
16
15
|
const fetchOAuthCallbackURL_1 = require("../fetchOAuthCallbackURL");
|
|
17
|
-
const
|
|
16
|
+
const OAuthPopup_1 = __importDefault(require("../OAuthPopup"));
|
|
17
|
+
const LandingContent_1 = require("./LandingContent");
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* NoSubdomainOauthFlow first prompts user with a next button,
|
|
20
20
|
* then launches a popup with the OAuth flow.
|
|
21
21
|
*/
|
|
22
|
-
function
|
|
23
|
-
const { projectId } = (0,
|
|
24
|
-
const apiKey = (0,
|
|
22
|
+
function NoSubdomainOauthFlow({ provider, consumerRef, consumerName, groupRef, groupName, }) {
|
|
23
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
24
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
25
25
|
const [oAuthCallbackURL, setOAuthCallbackURL] = (0, react_1.useState)(null);
|
|
26
26
|
const [error, setError] = (0, react_1.useState)(null);
|
|
27
27
|
// 1. fetch provider apps
|
|
@@ -32,7 +32,7 @@ function HubspotOauthFlow({ consumerRef, consumerName, groupRef, groupName, }) {
|
|
|
32
32
|
setError(null);
|
|
33
33
|
if (consumerName && groupName && apiKey) {
|
|
34
34
|
try {
|
|
35
|
-
const url = await (0, fetchOAuthCallbackURL_1.fetchOAuthCallbackURL)(projectId, consumerRef, groupRef, consumerName, groupName, apiKey,
|
|
35
|
+
const url = await (0, fetchOAuthCallbackURL_1.fetchOAuthCallbackURL)(projectId, consumerRef, groupRef, consumerName, groupName, apiKey, provider);
|
|
36
36
|
setOAuthCallbackURL(url);
|
|
37
37
|
}
|
|
38
38
|
catch (err) {
|
|
@@ -45,6 +45,6 @@ function HubspotOauthFlow({ consumerRef, consumerName, groupRef, groupName, }) {
|
|
|
45
45
|
setError(err);
|
|
46
46
|
setOAuthCallbackURL(null);
|
|
47
47
|
}, []);
|
|
48
|
-
return ((0, jsx_runtime_1.jsx)(OAuthPopup_1.default, { title:
|
|
48
|
+
return ((0, jsx_runtime_1.jsx)(OAuthPopup_1.default, { title: `Connect to ${(0, utils_1.capitalize)(provider)}`, url: oAuthCallbackURL, onClose: onClose, children: (0, jsx_runtime_1.jsx)(LandingContent_1.LandingContent, { provider: provider, handleSubmit: handleSubmit, error: error }) }));
|
|
49
49
|
}
|
|
50
|
-
exports.
|
|
50
|
+
exports.NoSubdomainOauthFlow = NoSubdomainOauthFlow;
|