@amp-labs/react 1.2.0 → 1.4.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/APIKeyApi.d.ts +158 -0
- package/build/generated-sources/api/src/apis/APIKeyApi.js +188 -0
- package/build/generated-sources/api/src/apis/DestinationApi.d.ts +86 -8
- package/build/generated-sources/api/src/apis/DestinationApi.js +86 -3
- package/build/generated-sources/api/src/apis/InstallationApi.d.ts +28 -0
- package/build/generated-sources/api/src/apis/InstallationApi.js +30 -0
- package/build/generated-sources/api/src/apis/IntegrationApi.js +1 -4
- package/build/generated-sources/api/src/apis/OperationApi.d.ts +27 -1
- package/build/generated-sources/api/src/apis/OperationApi.js +27 -0
- package/build/generated-sources/api/src/apis/OperationEventApi.d.ts +84 -0
- package/build/generated-sources/api/src/apis/OperationEventApi.js +110 -0
- package/build/generated-sources/api/src/apis/ProviderApi.d.ts +78 -0
- package/build/generated-sources/api/src/apis/{OperationLogApi.js → ProviderApi.js} +33 -17
- package/build/generated-sources/api/src/apis/index.d.ts +3 -1
- package/build/generated-sources/api/src/apis/index.js +3 -1
- package/build/generated-sources/api/src/models/ApiKey.d.ts +49 -0
- package/build/generated-sources/api/src/models/ApiKey.js +59 -0
- package/build/generated-sources/api/src/models/ApiKeyRequest.d.ts +31 -0
- package/build/generated-sources/api/src/models/ApiKeyRequest.js +50 -0
- package/build/generated-sources/api/src/models/AuthType.d.ts +22 -0
- package/build/generated-sources/api/src/models/AuthType.js +35 -0
- package/build/generated-sources/api/src/models/BaseConfigContent.d.ts +7 -0
- package/build/generated-sources/api/src/models/BaseConfigContent.js +3 -0
- package/build/generated-sources/api/src/models/BaseProxyConfig.d.ts +31 -0
- package/build/generated-sources/api/src/models/BaseProxyConfig.js +50 -0
- package/build/generated-sources/api/src/models/ConfigContent.d.ts +7 -0
- package/build/generated-sources/api/src/models/ConfigContent.js +3 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequest.d.ts +44 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequest.js +57 -0
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.d.ts +39 -0
- package/build/generated-sources/api/src/models/{DestinationMetadata.js → CreateDestinationRequestMetadata.js} +11 -11
- package/build/generated-sources/api/src/models/Destination.d.ts +22 -4
- package/build/generated-sources/api/src/models/Destination.js +12 -3
- package/build/generated-sources/api/src/models/HydratedIntegration.d.ts +7 -0
- package/build/generated-sources/api/src/models/HydratedIntegration.js +3 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationProxy.d.ts +31 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationProxy.js +50 -0
- package/build/generated-sources/api/src/models/ImportConnectionRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/Integration1.d.ts +7 -0
- package/build/generated-sources/api/src/models/Integration1.js +3 -0
- package/build/generated-sources/api/src/models/IntegrationProxy.d.ts +31 -0
- package/build/generated-sources/api/src/models/IntegrationProxy.js +50 -0
- package/build/generated-sources/api/src/models/{OperationLog.d.ts → Log.d.ts} +12 -12
- package/build/generated-sources/api/src/models/{OperationLog.js → Log.js} +11 -11
- package/build/generated-sources/api/src/models/OauthConnectRequest.d.ts +6 -6
- package/build/generated-sources/api/src/models/OauthConnectRequest.js +1 -2
- package/build/generated-sources/api/src/models/OauthOpts.d.ts +56 -0
- package/build/generated-sources/api/src/models/OauthOpts.js +63 -0
- package/build/generated-sources/api/src/models/Operation.d.ts +26 -9
- package/build/generated-sources/api/src/models/Operation.js +14 -7
- package/build/generated-sources/api/src/models/OperationEvent.d.ts +61 -0
- package/build/generated-sources/api/src/models/OperationEvent.js +64 -0
- package/build/generated-sources/api/src/models/PatchApiKeyRequest.d.ts +38 -0
- package/build/generated-sources/api/src/models/PatchApiKeyRequest.js +54 -0
- package/build/generated-sources/api/src/models/PatchApiKeyRequestApiKey.d.ts +37 -0
- package/build/generated-sources/api/src/models/PatchApiKeyRequestApiKey.js +52 -0
- package/build/generated-sources/api/src/models/ProviderInfo.d.ts +60 -0
- package/build/generated-sources/api/src/models/ProviderInfo.js +65 -0
- package/build/generated-sources/api/src/models/Support.d.ts +55 -0
- package/build/generated-sources/api/src/models/Support.js +62 -0
- package/build/generated-sources/api/src/models/TokenMetadataFields.d.ts +43 -0
- package/build/generated-sources/api/src/models/TokenMetadataFields.js +54 -0
- package/build/generated-sources/api/src/models/UpdateDestinationRequest.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateDestinationRequest.js +54 -0
- package/build/generated-sources/api/src/models/UpdateDestinationRequestDestination.d.ts +38 -0
- package/build/generated-sources/api/src/models/UpdateDestinationRequestDestination.js +53 -0
- package/build/generated-sources/api/src/models/UpdateInstallationConfigContent.d.ts +7 -0
- package/build/generated-sources/api/src/models/UpdateInstallationConfigContent.js +3 -0
- package/build/generated-sources/api/src/models/index.d.ts +18 -3
- package/build/generated-sources/api/src/models/index.js +18 -3
- package/build/src/assets/SuccessIcon.d.ts +1 -0
- package/build/src/assets/SuccessIcon.js +8 -0
- package/build/src/components/Configure/InstallIntegration.js +2 -1
- package/build/src/components/Configure/actions/mutateAndSetState/createInstallationAndSetState.d.ts +15 -0
- package/build/src/components/Configure/actions/mutateAndSetState/createInstallationAndSetState.js +30 -0
- package/build/src/components/Configure/actions/mutateAndSetState/updateInstallationAndSetState.d.ts +15 -0
- package/build/src/components/Configure/actions/mutateAndSetState/updateInstallationAndSetState.js +33 -0
- package/build/src/components/Configure/actions/proxy/isProxyEnabled.d.ts +2 -0
- package/build/src/components/Configure/actions/proxy/isProxyEnabled.js +8 -0
- package/build/src/components/Configure/actions/proxy/onCreateInstallationProxyOnly.d.ts +8 -0
- package/build/src/components/Configure/actions/proxy/onCreateInstallationProxyOnly.js +44 -0
- package/build/src/components/Configure/actions/{onSaveReadCreateInstallation.d.ts → read/onSaveReadCreateInstallation.d.ts} +2 -2
- package/build/src/components/Configure/actions/{onSaveReadCreateInstallation.js → read/onSaveReadCreateInstallation.js} +15 -22
- package/build/src/components/Configure/actions/read/onSaveReadUpdateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/{onSaveReadUpdateInstallation.js → read/onSaveReadUpdateInstallation.js} +20 -28
- package/build/src/components/Configure/actions/write/onSaveWriteCreateInstallation.js +16 -22
- package/build/src/components/Configure/actions/write/onSaveWriteUpdateInstallation.d.ts +2 -2
- package/build/src/components/Configure/actions/write/onSaveWriteUpdateInstallation.js +11 -3
- package/build/src/components/Configure/content/CreateInstallation.js +1 -1
- package/build/src/components/Configure/content/UpdateInstallation.js +5 -5
- package/build/src/components/Configure/layout/ConditionalProxyLayout/ConditionalProxyLayout.d.ts +11 -0
- package/build/src/components/Configure/layout/ConditionalProxyLayout/ConditionalProxyLayout.js +67 -0
- package/build/src/components/Configure/layout/ConditionalProxyLayout/InstalledSuccessBox.d.ts +5 -0
- package/build/src/components/Configure/layout/ConditionalProxyLayout/InstalledSuccessBox.js +11 -0
- package/build/src/components/Configure/layout/ProtectedConnectionLayout.js +2 -7
- package/build/src/components/Configure/state/utils.js +5 -5
- package/build/src/components/Connect/ConnectedSuccessBox.js +3 -3
- package/build/src/components/Oauth/NoWorkspaceEntry/LandingContent.js +12 -0
- package/build/src/components/Oauth/{NoSubdomainEntry/NoSubdomainOauthFlow.d.ts → NoWorkspaceEntry/NoWorkspaceOauthFlow.d.ts} +4 -4
- package/build/src/components/Oauth/{NoSubdomainEntry/NoSubdomainOauthFlow.js → NoWorkspaceEntry/NoWorkspaceOauthFlow.js} +6 -8
- package/build/src/components/Oauth/OAuthPopup.js +1 -5
- package/build/src/components/Oauth/OauthCardLayout.d.ts +6 -0
- package/build/src/components/Oauth/OauthCardLayout.js +9 -0
- package/build/src/components/Oauth/OauthFlow/OauthFlow.d.ts +9 -0
- package/build/src/components/Oauth/OauthFlow/OauthFlow.js +33 -0
- package/build/src/components/Oauth/Salesforce/SalesforceSubdomainEntry.d.ts +13 -0
- package/build/src/components/Oauth/Salesforce/SalesforceSubdomainEntry.js +18 -0
- package/build/src/components/Oauth/WorkspaceEntry/WorkspaceEntry.d.ts +9 -0
- package/build/src/components/Oauth/WorkspaceEntry/WorkspaceEntry.js +12 -0
- package/build/src/components/Oauth/WorkspaceEntry/WorkspaceOauthFlow.d.ts +14 -0
- package/build/src/components/Oauth/WorkspaceEntry/WorkspaceOauthFlow.js +58 -0
- package/build/src/components/SuccessTextBox.d.ts +5 -0
- package/build/src/components/SuccessTextBox.js +10 -0
- package/build/src/components/ThemeProvider/Button/buttonTheme.js +3 -3
- package/build/src/components/ThemeProvider/index.js +6 -6
- package/build/src/services/ApiService.d.ts +2 -2
- package/build/src/services/ApiService.js +1 -1
- package/build/src/services/api.d.ts +2 -2
- package/build/src/services/api.js +28 -21
- package/build/src/services/version.d.ts +1 -0
- package/build/src/services/version.js +4 -0
- package/package.json +2 -2
- package/build/generated-sources/api/src/apis/OperationLogApi.d.ts +0 -55
- package/build/generated-sources/api/src/models/DestinationMetadata.d.ts +0 -39
- package/build/generated-sources/api/src/models/OperationError.d.ts +0 -49
- package/build/generated-sources/api/src/models/OperationError.js +0 -56
- package/build/src/components/Configure/actions/onSaveReadUpdateInstallation.d.ts +0 -3
- package/build/src/components/Oauth/NoSubdomainEntry/LandingContent.js +0 -11
- package/build/src/components/Oauth/Salesforce/SalesforceOauthFlow.d.ts +0 -16
- package/build/src/components/Oauth/Salesforce/SalesforceOauthFlow.js +0 -57
- package/build/src/components/Oauth/Salesforce/SubdomainEntry.d.ts +0 -8
- package/build/src/components/Oauth/Salesforce/SubdomainEntry.js +0 -12
- package/build/src/constants.d.ts +0 -2
- package/build/src/constants.js +0 -5
- /package/build/src/components/Oauth/{NoSubdomainEntry → NoWorkspaceEntry}/LandingContent.d.ts +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.onSaveWriteCreateInstallation = void 0;
|
|
4
|
-
const
|
|
4
|
+
const createInstallationAndSetState_1 = require("../mutateAndSetState/createInstallationAndSetState");
|
|
5
|
+
const isProxyEnabled_1 = require("../proxy/isProxyEnabled");
|
|
5
6
|
const generateConfigWriteObjects_1 = require("./generateConfigWriteObjects");
|
|
6
7
|
/**
|
|
7
8
|
* gets write objects from hydratedRevision
|
|
@@ -41,7 +42,8 @@ const generateCreateWriteConfigFromConfigureState = (configureState, hydratedRev
|
|
|
41
42
|
createdBy: `consumer:${consumerRef}`,
|
|
42
43
|
content: {
|
|
43
44
|
provider: hydratedRevision.content.provider,
|
|
44
|
-
// need empty read.standardObjects for update read
|
|
45
|
+
// hack: need empty read.standardObjects to be initialized for update read
|
|
46
|
+
// https://linear.app/ampersand/issue/ENG-780/bug-write-createupdate-installation-without-read
|
|
45
47
|
read: {
|
|
46
48
|
standardObjects: {},
|
|
47
49
|
},
|
|
@@ -50,6 +52,11 @@ const generateCreateWriteConfigFromConfigureState = (configureState, hydratedRev
|
|
|
50
52
|
},
|
|
51
53
|
},
|
|
52
54
|
};
|
|
55
|
+
// insert proxy into config if it is enabled
|
|
56
|
+
const isProxyEnabled = (0, isProxyEnabled_1.getIsProxyEnabled)(hydratedRevision);
|
|
57
|
+
if (isProxyEnabled) {
|
|
58
|
+
createConfigObj.content.proxy = { enabled: true };
|
|
59
|
+
}
|
|
53
60
|
return createConfigObj;
|
|
54
61
|
};
|
|
55
62
|
const onSaveWriteCreateInstallation = (projectId, integrationId, groupRef, consumerRef, connectionId, apiKey, hydratedRevision, configureState, setInstallation, onInstallSuccess) => {
|
|
@@ -58,28 +65,15 @@ const onSaveWriteCreateInstallation = (projectId, integrationId, groupRef, consu
|
|
|
58
65
|
console.error('Error when generating createConfig from configureState');
|
|
59
66
|
return Promise.resolve(null);
|
|
60
67
|
}
|
|
61
|
-
|
|
68
|
+
return (0, createInstallationAndSetState_1.createInstallationAndSetState)({
|
|
69
|
+
createConfig,
|
|
62
70
|
projectId,
|
|
63
71
|
integrationId,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
70
|
-
return (0, api_1.api)().installationApi.createInstallation(createInstallationRequest, {
|
|
71
|
-
headers: {
|
|
72
|
-
'X-Api-Key': apiKey,
|
|
73
|
-
'Content-Type': 'application/json',
|
|
74
|
-
},
|
|
75
|
-
})
|
|
76
|
-
.then((installation) => {
|
|
77
|
-
// update local installation state
|
|
78
|
-
setInstallation(installation);
|
|
79
|
-
onInstallSuccess === null || onInstallSuccess === void 0 ? void 0 : onInstallSuccess(installation.id, installation.config);
|
|
80
|
-
})
|
|
81
|
-
.catch((err) => {
|
|
82
|
-
console.error('ERROR: ', err);
|
|
72
|
+
groupRef,
|
|
73
|
+
connectionId,
|
|
74
|
+
apiKey,
|
|
75
|
+
setInstallation,
|
|
76
|
+
onInstallSuccess,
|
|
83
77
|
});
|
|
84
78
|
};
|
|
85
79
|
exports.onSaveWriteCreateInstallation = onSaveWriteCreateInstallation;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Config, Installation } from '../../../../services/api';
|
|
1
|
+
import { Config, HydratedRevision, Installation } from '../../../../services/api';
|
|
2
2
|
import { ConfigureState } from '../../types';
|
|
3
|
-
export declare const onSaveWriteUpdateInstallation: (projectId: string, integrationId: string, installationId: string, apiKey: string, configureState: ConfigureState, setInstallation: (installationObj: Installation) => void, onUpdateSuccess?: ((installationId: string, config: Config) => void) | undefined) => Promise<void | null>;
|
|
3
|
+
export declare const onSaveWriteUpdateInstallation: (projectId: string, integrationId: string, installationId: string, apiKey: string, configureState: ConfigureState, hydratedRevision: HydratedRevision, setInstallation: (installationObj: Installation) => void, onUpdateSuccess?: ((installationId: string, config: Config) => void) | undefined) => Promise<void | null>;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.onSaveWriteUpdateInstallation = void 0;
|
|
4
4
|
const api_1 = require("../../../../services/api");
|
|
5
|
+
const isProxyEnabled_1 = require("../proxy/isProxyEnabled");
|
|
5
6
|
const generateConfigWriteObjects_1 = require("./generateConfigWriteObjects");
|
|
6
7
|
/**
|
|
7
8
|
* given a configureState generate the config object that is need for
|
|
@@ -10,7 +11,7 @@ const generateConfigWriteObjects_1 = require("./generateConfigWriteObjects");
|
|
|
10
11
|
* @param configureState
|
|
11
12
|
* @returns
|
|
12
13
|
*/
|
|
13
|
-
const generateUpdateWriteConfigFromConfigureState = (configureState) => {
|
|
14
|
+
const generateUpdateWriteConfigFromConfigureState = (configureState, hydratedRevision) => {
|
|
14
15
|
const configWriteObjects = (0, generateConfigWriteObjects_1.generateConfigWriteObjects)(configureState);
|
|
15
16
|
// config request object type needs to be fixed
|
|
16
17
|
const updateConfigObject = {
|
|
@@ -20,12 +21,19 @@ const generateUpdateWriteConfigFromConfigureState = (configureState) => {
|
|
|
20
21
|
},
|
|
21
22
|
},
|
|
22
23
|
};
|
|
24
|
+
// insert proxy into config if it is enabled
|
|
25
|
+
const isProxyEnabled = (0, isProxyEnabled_1.getIsProxyEnabled)(hydratedRevision);
|
|
26
|
+
if (isProxyEnabled) {
|
|
27
|
+
if (!updateConfigObject.content)
|
|
28
|
+
updateConfigObject.content = {};
|
|
29
|
+
updateConfigObject.content.proxy = { enabled: true };
|
|
30
|
+
}
|
|
23
31
|
return updateConfigObject;
|
|
24
32
|
};
|
|
25
|
-
const onSaveWriteUpdateInstallation = (projectId, integrationId, installationId, apiKey, configureState, setInstallation, onUpdateSuccess) => {
|
|
33
|
+
const onSaveWriteUpdateInstallation = (projectId, integrationId, installationId, apiKey, configureState, hydratedRevision, setInstallation, onUpdateSuccess) => {
|
|
26
34
|
// get configuration state
|
|
27
35
|
// transform configuration state to update shape
|
|
28
|
-
const updateConfig = generateUpdateWriteConfigFromConfigureState(configureState);
|
|
36
|
+
const updateConfig = generateUpdateWriteConfigFromConfigureState(configureState, hydratedRevision);
|
|
29
37
|
if (!updateConfig) {
|
|
30
38
|
console.error('Error when generating write updateConfig from configureState');
|
|
31
39
|
return Promise.resolve(null);
|
|
@@ -7,7 +7,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
7
7
|
*/
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const ErrorContextProvider_1 = require("../../../context/ErrorContextProvider");
|
|
10
|
-
const onSaveReadCreateInstallation_1 = require("../actions/onSaveReadCreateInstallation");
|
|
10
|
+
const onSaveReadCreateInstallation_1 = require("../actions/read/onSaveReadCreateInstallation");
|
|
11
11
|
const onSaveWriteCreateInstallation_1 = require("../actions/write/onSaveWriteCreateInstallation");
|
|
12
12
|
const constant_1 = require("../nav/ObjectManagementNav/constant");
|
|
13
13
|
const utils_1 = require("../state/utils");
|
|
@@ -4,7 +4,7 @@ exports.UpdateInstallation = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const ErrorContextProvider_1 = require("../../../context/ErrorContextProvider");
|
|
7
|
-
const onSaveReadUpdateInstallation_1 = require("../actions/onSaveReadUpdateInstallation");
|
|
7
|
+
const onSaveReadUpdateInstallation_1 = require("../actions/read/onSaveReadUpdateInstallation");
|
|
8
8
|
const onSaveWriteUpdateInstallation_1 = require("../actions/write/onSaveWriteUpdateInstallation");
|
|
9
9
|
const constant_1 = require("../nav/ObjectManagementNav/constant");
|
|
10
10
|
const utils_1 = require("../state/utils");
|
|
@@ -51,9 +51,9 @@ function UpdateInstallation({ installation, integrationObj }) {
|
|
|
51
51
|
if (errorList.length > 0) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
if (installation && selectedObjectName && apiKey && projectId && hydratedObject) {
|
|
54
|
+
if (hydratedRevision && installation && selectedObjectName && apiKey && projectId && hydratedObject) {
|
|
55
55
|
setLoadingState(true);
|
|
56
|
-
const res = (0, onSaveReadUpdateInstallation_1.onSaveReadUpdateInstallation)(projectId, integrationObj.id, installation.id, selectedObjectName, apiKey, configureState, setInstallation, hydratedObject, onUpdateSuccess);
|
|
56
|
+
const res = (0, onSaveReadUpdateInstallation_1.onSaveReadUpdateInstallation)(projectId, integrationObj.id, installation.id, selectedObjectName, apiKey, configureState, setInstallation, hydratedObject, hydratedRevision, onUpdateSuccess);
|
|
57
57
|
res.finally(() => {
|
|
58
58
|
setLoadingState(false);
|
|
59
59
|
resetPendingConfigurationState(selectedObjectName);
|
|
@@ -64,9 +64,9 @@ function UpdateInstallation({ installation, integrationObj }) {
|
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
66
|
const onSaveWrite = () => {
|
|
67
|
-
if (installation && selectedObjectName && apiKey && projectId) {
|
|
67
|
+
if (installation && selectedObjectName && apiKey && projectId && hydratedRevision) {
|
|
68
68
|
setLoadingState(true);
|
|
69
|
-
const res = (0, onSaveWriteUpdateInstallation_1.onSaveWriteUpdateInstallation)(projectId, integrationObj.id, installation.id, apiKey, configureState, setInstallation, onUpdateSuccess);
|
|
69
|
+
const res = (0, onSaveWriteUpdateInstallation_1.onSaveWriteUpdateInstallation)(projectId, integrationObj.id, installation.id, apiKey, configureState, hydratedRevision, setInstallation, onUpdateSuccess);
|
|
70
70
|
res.finally(() => {
|
|
71
71
|
setLoadingState(false);
|
|
72
72
|
resetPendingConfigurationState(selectedObjectName);
|
package/build/src/components/Configure/layout/ConditionalProxyLayout/ConditionalProxyLayout.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
interface ConditionalProxyLayoutProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* if the hydratedRevision only has proxy actions,
|
|
7
|
+
* then it will not render the ConfigureInstallation
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export declare function ConditionalProxyLayout({ children }: ConditionalProxyLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
package/build/src/components/Configure/layout/ConditionalProxyLayout/ConditionalProxyLayout.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConditionalProxyLayout = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const LoadingIcon_1 = require("../../../../assets/LoadingIcon");
|
|
7
|
+
const ApiKeyContextProvider_1 = require("../../../../context/ApiKeyContextProvider");
|
|
8
|
+
const ConnectionsContextProvider_1 = require("../../../../context/ConnectionsContextProvider");
|
|
9
|
+
const InstallIntegrationContextProvider_1 = require("../../../../context/InstallIntegrationContextProvider");
|
|
10
|
+
const ProjectContextProvider_1 = require("../../../../context/ProjectContextProvider");
|
|
11
|
+
const ErrorTextBox_1 = require("../../../ErrorTextBox");
|
|
12
|
+
const onCreateInstallationProxyOnly_1 = require("../../actions/proxy/onCreateInstallationProxyOnly");
|
|
13
|
+
const HydratedRevisionContext_1 = require("../../state/HydratedRevisionContext");
|
|
14
|
+
const InstalledSuccessBox_1 = require("./InstalledSuccessBox");
|
|
15
|
+
// explicity check other actions (i.e. read, write) to determine if it's proxy only
|
|
16
|
+
// returns false if it's not proxy only or no hydratedRevision
|
|
17
|
+
const getIsProxyOnly = (hydratedRevision) => {
|
|
18
|
+
var _a;
|
|
19
|
+
const { read, write, proxy } = (_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) !== null && _a !== void 0 ? _a : {};
|
|
20
|
+
return (!read && !write && (proxy === null || proxy === void 0 ? void 0 : proxy.enabled)) || false;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* if the hydratedRevision only has proxy actions,
|
|
24
|
+
* then it will not render the ConfigureInstallation
|
|
25
|
+
* @returns
|
|
26
|
+
*/
|
|
27
|
+
function ConditionalProxyLayout({ children }) {
|
|
28
|
+
var _a;
|
|
29
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
30
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
31
|
+
const { hydratedRevision, loading: hydratedRevisionLoading } = (0, HydratedRevisionContext_1.useHydratedRevision)();
|
|
32
|
+
const { integrationObj, installation, groupRef, consumerRef, setInstallation, } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
|
|
33
|
+
const { selectedConnection } = (0, ConnectionsContextProvider_1.useConnections)();
|
|
34
|
+
const [createInstallLoading, setCreateInstallLoading] = (0, react_1.useState)(false);
|
|
35
|
+
const isLoading = hydratedRevisionLoading || createInstallLoading;
|
|
36
|
+
const provider = (_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.provider;
|
|
37
|
+
const isProxyOnly = getIsProxyOnly(hydratedRevision);
|
|
38
|
+
(0, react_1.useEffect)(() => {
|
|
39
|
+
if (hydratedRevision && isProxyOnly && !installation && selectedConnection && apiKey && (integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.id)) {
|
|
40
|
+
setCreateInstallLoading(true);
|
|
41
|
+
(0, onCreateInstallationProxyOnly_1.onCreateInstallationProxyOnly)({
|
|
42
|
+
apiKey,
|
|
43
|
+
projectId,
|
|
44
|
+
integrationId: integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.id,
|
|
45
|
+
groupRef,
|
|
46
|
+
consumerRef,
|
|
47
|
+
connectionId: selectedConnection === null || selectedConnection === void 0 ? void 0 : selectedConnection.id,
|
|
48
|
+
hydratedRevision,
|
|
49
|
+
setInstallation,
|
|
50
|
+
}).then(() => {
|
|
51
|
+
setCreateInstallLoading(false);
|
|
52
|
+
}).catch((e) => {
|
|
53
|
+
setCreateInstallLoading(false);
|
|
54
|
+
console.error('Error when creating proxy installation:', e);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}, [hydratedRevision, isProxyOnly, installation,
|
|
58
|
+
selectedConnection, apiKey, projectId, integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.id, groupRef, consumerRef, setInstallation]);
|
|
59
|
+
if (!integrationObj)
|
|
60
|
+
return (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: "We can't load the integration" });
|
|
61
|
+
if (isLoading)
|
|
62
|
+
return (0, jsx_runtime_1.jsx)(LoadingIcon_1.LoadingIcon, {});
|
|
63
|
+
if (isProxyOnly && provider && installation)
|
|
64
|
+
return (0, jsx_runtime_1.jsx)(InstalledSuccessBox_1.InstalledSuccessBox, { provider: provider });
|
|
65
|
+
return ((0, jsx_runtime_1.jsx)("div", { children: children }));
|
|
66
|
+
}
|
|
67
|
+
exports.ConditionalProxyLayout = ConditionalProxyLayout;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InstalledSuccessBox = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const utils_1 = require("../../../../utils");
|
|
6
|
+
const SuccessTextBox_1 = require("../../../SuccessTextBox");
|
|
7
|
+
function InstalledSuccessBox({ provider }) {
|
|
8
|
+
const text = `You have successfully installed your ${(0, utils_1.capitalize)(provider)} integration.`;
|
|
9
|
+
return ((0, jsx_runtime_1.jsx)(SuccessTextBox_1.SuccessTextBox, { text: text }));
|
|
10
|
+
}
|
|
11
|
+
exports.InstalledSuccessBox = InstalledSuccessBox;
|
|
@@ -3,12 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ProtectedConnectionLayout = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const constants_1 = require("../../../constants");
|
|
7
6
|
const ConnectionsContextProvider_1 = require("../../../context/ConnectionsContextProvider");
|
|
8
7
|
const InstallIntegrationContextProvider_1 = require("../../../context/InstallIntegrationContextProvider");
|
|
9
8
|
const useConnectionHandler_1 = require("../../Connect/useConnectionHandler");
|
|
10
|
-
const
|
|
11
|
-
const SalesforceOauthFlow_1 = require("../../Oauth/Salesforce/SalesforceOauthFlow");
|
|
9
|
+
const OauthFlow_1 = require("../../Oauth/OauthFlow/OauthFlow");
|
|
12
10
|
function ProtectedConnectionLayout({ provider, consumerRef, consumerName, groupRef, groupName, children, onSuccess, }) {
|
|
13
11
|
const { provider: providerFromProps } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
|
|
14
12
|
const { selectedConnection, setSelectedConnection, connections } = (0, ConnectionsContextProvider_1.useConnections)();
|
|
@@ -26,9 +24,6 @@ function ProtectedConnectionLayout({ provider, consumerRef, consumerName, groupR
|
|
|
26
24
|
if (selectedConnection)
|
|
27
25
|
return children;
|
|
28
26
|
const selectedProvider = provider || providerFromProps;
|
|
29
|
-
|
|
30
|
-
return ((0, jsx_runtime_1.jsx)(SalesforceOauthFlow_1.SalesforceOauthFlow, { consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName }));
|
|
31
|
-
}
|
|
32
|
-
return ((0, jsx_runtime_1.jsx)(NoSubdomainOauthFlow_1.NoSubdomainOauthFlow, { provider: selectedProvider, consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName }));
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(OauthFlow_1.OauthFlow, { provider: selectedProvider, consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName }));
|
|
33
28
|
}
|
|
34
29
|
exports.ProtectedConnectionLayout = ProtectedConnectionLayout;
|
|
@@ -29,17 +29,17 @@ const generateConfigurationStateRead = (readAction, objectName, config) => {
|
|
|
29
29
|
const optionalFieldsSaved = Object.assign({}, readSelectedFields);
|
|
30
30
|
const requiredMapFieldsSaved = Object.assign({}, selectedFieldMappings);
|
|
31
31
|
return {
|
|
32
|
-
allFields,
|
|
33
|
-
requiredFields,
|
|
34
|
-
optionalFields,
|
|
35
|
-
requiredMapFields,
|
|
32
|
+
allFields, // from hydrated revision
|
|
33
|
+
requiredFields, // from hydrated revision
|
|
34
|
+
optionalFields, // from hydrated revision
|
|
35
|
+
requiredMapFields, // from hydrated revision
|
|
36
36
|
// selected state
|
|
37
37
|
selectedOptionalFields: readSelectedFields,
|
|
38
38
|
selectedFieldMappings,
|
|
39
39
|
isOptionalFieldsModified: false,
|
|
40
40
|
isRequiredMapFieldsModified: false,
|
|
41
41
|
savedConfig: {
|
|
42
|
-
optionalFields: optionalFieldsSaved,
|
|
42
|
+
optionalFields: optionalFieldsSaved, // from config
|
|
43
43
|
requiredMapFields: requiredMapFieldsSaved, // from config
|
|
44
44
|
},
|
|
45
45
|
};
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConnectedSuccessBox = void 0;
|
|
4
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
5
|
const ProjectContextProvider_1 = require("../../context/ProjectContextProvider");
|
|
8
6
|
const utils_1 = require("../../utils");
|
|
7
|
+
const SuccessTextBox_1 = require("../SuccessTextBox");
|
|
9
8
|
function ConnectedSuccessBox({ provider }) {
|
|
10
9
|
const { appName } = (0, ProjectContextProvider_1.useProject)();
|
|
11
|
-
|
|
10
|
+
const text = `You have successfully connected your ${(0, utils_1.capitalize)(provider)} account to ${appName}.`;
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(SuccessTextBox_1.SuccessTextBox, { text: text }));
|
|
12
12
|
}
|
|
13
13
|
exports.ConnectedSuccessBox = ConnectedSuccessBox;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LandingContent = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const OauthCardLayout_1 = require("../OauthCardLayout");
|
|
8
|
+
const OAuthErrorAlert_1 = require("../OAuthErrorAlert");
|
|
9
|
+
function LandingContent({ provider, handleSubmit, error, isButtonDisabled, }) {
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(OauthCardLayout_1.OauthCardLayout, { 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" })] }) }));
|
|
11
|
+
}
|
|
12
|
+
exports.LandingContent = LandingContent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* OAuth flow for any providers that do not require the consumer to enter a
|
|
2
|
+
* OAuth flow for any providers that do not require the consumer to enter a workspace first.
|
|
3
3
|
*/
|
|
4
|
-
interface
|
|
4
|
+
interface NoWorkspaceOauthFlowProps {
|
|
5
5
|
provider: string;
|
|
6
6
|
consumerRef: string;
|
|
7
7
|
consumerName?: string;
|
|
@@ -9,8 +9,8 @@ interface NoSubdomainOauthFlowProps {
|
|
|
9
9
|
groupName?: string;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* NoWorkspaceOauthFlow first prompts user with a next button,
|
|
13
13
|
* then launches a popup with the OAuth flow.
|
|
14
14
|
*/
|
|
15
|
-
export declare function
|
|
15
|
+
export declare function NoWorkspaceOauthFlow({ provider, consumerRef, consumerName, groupRef, groupName, }: NoWorkspaceOauthFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
export {};
|
|
@@ -3,10 +3,10 @@ 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.NoWorkspaceOauthFlow = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
/**
|
|
9
|
-
* OAuth flow for any providers that do not require the consumer to enter a
|
|
9
|
+
* OAuth flow for any providers that do not require the consumer to enter a workspace first.
|
|
10
10
|
*/
|
|
11
11
|
const react_1 = require("react");
|
|
12
12
|
const ApiKeyContextProvider_1 = require("../../../context/ApiKeyContextProvider");
|
|
@@ -16,17 +16,15 @@ const fetchOAuthCallbackURL_1 = require("../fetchOAuthCallbackURL");
|
|
|
16
16
|
const OAuthPopup_1 = __importDefault(require("../OAuthPopup"));
|
|
17
17
|
const LandingContent_1 = require("./LandingContent");
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* NoWorkspaceOauthFlow first prompts user with a next button,
|
|
20
20
|
* then launches a popup with the OAuth flow.
|
|
21
21
|
*/
|
|
22
|
-
function
|
|
22
|
+
function NoWorkspaceOauthFlow({ provider, consumerRef, consumerName, groupRef, groupName, }) {
|
|
23
23
|
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
24
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
|
-
//
|
|
28
|
-
// 2. find matching app to provider
|
|
29
|
-
// 3. fetch OAuth callback URL from connection so that oath popup can be launched
|
|
27
|
+
// fetch OAuth callback URL from connection so that oath popup can be launched
|
|
30
28
|
const handleSubmit = async () => {
|
|
31
29
|
var _a;
|
|
32
30
|
setError(null);
|
|
@@ -47,4 +45,4 @@ function NoSubdomainOauthFlow({ provider, consumerRef, consumerName, groupRef, g
|
|
|
47
45
|
}, []);
|
|
48
46
|
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
47
|
}
|
|
50
|
-
exports.
|
|
48
|
+
exports.NoWorkspaceOauthFlow = NoWorkspaceOauthFlow;
|
|
@@ -55,14 +55,10 @@ function OAuthPopup({ title = '', url, children, onClose, }) {
|
|
|
55
55
|
refreshConnections(connectionId);
|
|
56
56
|
onClose(null);
|
|
57
57
|
}
|
|
58
|
-
if (externalWindow)
|
|
59
|
-
externalWindow.close();
|
|
60
58
|
}
|
|
61
59
|
else if (((_c = event.data) === null || _c === void 0 ? void 0 : _c.eventType) === FAILURE_EVENT) {
|
|
62
60
|
clearTimer();
|
|
63
|
-
onClose((_e = (_d = event.data.data) === null || _d === void 0 ? void 0 : _d.message) !== null && _e !== void 0 ? _e : 'There was an error logging
|
|
64
|
-
if (externalWindow)
|
|
65
|
-
externalWindow.close();
|
|
61
|
+
onClose((_e = (_d = event.data.data) === null || _d === void 0 ? void 0 : _d.message) !== null && _e !== void 0 ? _e : 'There was an error logging you in. Please try again.');
|
|
66
62
|
}
|
|
67
63
|
}
|
|
68
64
|
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OauthCardLayout = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
function OauthCardLayout({ children }) {
|
|
7
|
+
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: children }) }));
|
|
8
|
+
}
|
|
9
|
+
exports.OauthCardLayout = OauthCardLayout;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type OauthFlowProps = {
|
|
2
|
+
provider: string;
|
|
3
|
+
consumerRef: string;
|
|
4
|
+
consumerName?: string;
|
|
5
|
+
groupRef: string;
|
|
6
|
+
groupName?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function OauthFlow({ provider, consumerRef, consumerName, groupRef, groupName, }: OauthFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OauthFlow = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ApiKeyContextProvider_1 = require("../../../context/ApiKeyContextProvider");
|
|
7
|
+
const api_1 = require("../../../services/api");
|
|
8
|
+
const NoWorkspaceOauthFlow_1 = require("../NoWorkspaceEntry/NoWorkspaceOauthFlow");
|
|
9
|
+
const WorkspaceOauthFlow_1 = require("../WorkspaceEntry/WorkspaceOauthFlow");
|
|
10
|
+
function OauthFlow({ provider, consumerRef, consumerName, groupRef, groupName, }) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
13
|
+
const [providerInfo, setProviderInfo] = (0, react_1.useState)(null);
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
if (provider && api_1.api) {
|
|
16
|
+
(0, api_1.api)().providerApi.getProvider({ provider }, {
|
|
17
|
+
headers: { 'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '' },
|
|
18
|
+
}).then((_providerInfo) => {
|
|
19
|
+
setProviderInfo(_providerInfo);
|
|
20
|
+
}).catch((err) => {
|
|
21
|
+
console.error('Error loading provider info: ', err);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}, [apiKey, provider]);
|
|
25
|
+
const workspaceRequired = (_b = (_a = providerInfo === null || providerInfo === void 0 ? void 0 : providerInfo.oauthOpts) === null || _a === void 0 ? void 0 : _a.explicitWorkspaceRequired) !== null && _b !== void 0 ? _b : false;
|
|
26
|
+
// required workspace
|
|
27
|
+
if (workspaceRequired) {
|
|
28
|
+
return ((0, jsx_runtime_1.jsx)(WorkspaceOauthFlow_1.WorkspaceOauthFlow, { provider: provider, consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName }));
|
|
29
|
+
}
|
|
30
|
+
// no workspace required
|
|
31
|
+
return ((0, jsx_runtime_1.jsx)(NoWorkspaceOauthFlow_1.NoWorkspaceOauthFlow, { provider: provider, consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName }));
|
|
32
|
+
}
|
|
33
|
+
exports.OauthFlow = OauthFlow;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type SubdomainEntryProps = {
|
|
2
|
+
handleSubmit: () => void;
|
|
3
|
+
setWorkspace: (workspace: string) => void;
|
|
4
|
+
error: string | null;
|
|
5
|
+
isButtonDisabled?: boolean;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Salesforce specific subdomain entry component, use workspace entry for other providers.
|
|
9
|
+
* @param param0
|
|
10
|
+
* @returns
|
|
11
|
+
*/
|
|
12
|
+
export declare function SalesforceSubdomainEntry({ handleSubmit, setWorkspace, error, isButtonDisabled, }: SubdomainEntryProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SalesforceSubdomainEntry = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const icons_1 = require("@chakra-ui/icons");
|
|
6
|
+
const react_1 = require("@chakra-ui/react");
|
|
7
|
+
const OauthCardLayout_1 = require("../OauthCardLayout");
|
|
8
|
+
const OAuthErrorAlert_1 = require("../OAuthErrorAlert");
|
|
9
|
+
const SALESFORCE_HELP_URL = 'https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5';
|
|
10
|
+
/**
|
|
11
|
+
* Salesforce specific subdomain entry component, use workspace entry for other providers.
|
|
12
|
+
* @param param0
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
function SalesforceSubdomainEntry({ handleSubmit, setWorkspace, error, isButtonDisabled, }) {
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(OauthCardLayout_1.OauthCardLayout, { 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: "Enter your Salesforce subdomain" }) }), (0, jsx_runtime_1.jsxs)(react_1.Link, { href: SALESFORCE_HELP_URL, color: "blackAlpha.600", isExternal: true, children: ["What is my Salesforce subdomain?", (0, jsx_runtime_1.jsx)(icons_1.ExternalLinkIcon, { mx: "2px" })] }), (0, jsx_runtime_1.jsx)(OAuthErrorAlert_1.OAuthErrorAlert, { error: error }), (0, jsx_runtime_1.jsxs)(react_1.Flex, { marginTop: "1em", children: [(0, jsx_runtime_1.jsx)(react_1.Input, { placeholder: "MyDomain", onChange: (event) => setWorkspace(event.currentTarget.value) }), (0, jsx_runtime_1.jsx)(react_1.Text, { lineHeight: "2.2em", marginLeft: "0.4em", children: ".my.salesforce.com" })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(react_1.Button, { isDisabled: isButtonDisabled, width: "100%", type: "submit", onClick: handleSubmit, children: "Next" })] }) }));
|
|
17
|
+
}
|
|
18
|
+
exports.SalesforceSubdomainEntry = SalesforceSubdomainEntry;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type WorkspaceEntryProps = {
|
|
2
|
+
provider: string;
|
|
3
|
+
handleSubmit: () => void;
|
|
4
|
+
setWorkspace: (workspace: string) => void;
|
|
5
|
+
error: string | null;
|
|
6
|
+
isButtonDisabled?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function WorkspaceEntry({ provider, handleSubmit, setWorkspace, error, isButtonDisabled, }: WorkspaceEntryProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WorkspaceEntry = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const OauthCardLayout_1 = require("../OauthCardLayout");
|
|
8
|
+
const OAuthErrorAlert_1 = require("../OAuthErrorAlert");
|
|
9
|
+
function WorkspaceEntry({ provider, handleSubmit, setWorkspace, error, isButtonDisabled, }) {
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)(OauthCardLayout_1.OauthCardLayout, { 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.jsxs)(react_1.Heading, { as: "h4", size: "md", children: ["Enter your ", (0, utils_1.capitalize)(provider), " workspace"] }) }), (0, jsx_runtime_1.jsx)(OAuthErrorAlert_1.OAuthErrorAlert, { error: error }), (0, jsx_runtime_1.jsx)(react_1.Flex, { marginTop: "1em", children: (0, jsx_runtime_1.jsx)(react_1.Input, { placeholder: "MyWorkspace", onChange: (event) => setWorkspace(event.currentTarget.value) }) }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(react_1.Button, { isDisabled: isButtonDisabled, width: "100%", type: "submit", onClick: handleSubmit, children: "Next" })] }) }));
|
|
11
|
+
}
|
|
12
|
+
exports.WorkspaceEntry = WorkspaceEntry;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface WorkspaceOauthFlowProps {
|
|
2
|
+
provider: string;
|
|
3
|
+
consumerRef: string;
|
|
4
|
+
consumerName?: string;
|
|
5
|
+
groupRef: string;
|
|
6
|
+
groupName?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Chooses workspace/subdomain entry component based on provider.
|
|
10
|
+
* WorkspaceEntry is generic for any provider that requires a workspace to be entered first,
|
|
11
|
+
* then launches a popup with the OAuth flow.
|
|
12
|
+
*/
|
|
13
|
+
export declare function WorkspaceOauthFlow({ provider, consumerRef, consumerName, groupRef, groupName, }: WorkspaceOauthFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.WorkspaceOauthFlow = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const ApiKeyContextProvider_1 = require("../../../context/ApiKeyContextProvider");
|
|
10
|
+
const ProjectContextProvider_1 = require("../../../context/ProjectContextProvider");
|
|
11
|
+
const utils_1 = require("../../../utils");
|
|
12
|
+
const fetchOAuthCallbackURL_1 = require("../fetchOAuthCallbackURL");
|
|
13
|
+
const OAuthPopup_1 = __importDefault(require("../OAuthPopup"));
|
|
14
|
+
const SalesforceSubdomainEntry_1 = require("../Salesforce/SalesforceSubdomainEntry");
|
|
15
|
+
const WorkspaceEntry_1 = require("./WorkspaceEntry");
|
|
16
|
+
const PROVIDER_SALESFORCE = 'salesforce';
|
|
17
|
+
/**
|
|
18
|
+
* Chooses workspace/subdomain entry component based on provider.
|
|
19
|
+
* WorkspaceEntry is generic for any provider that requires a workspace to be entered first,
|
|
20
|
+
* then launches a popup with the OAuth flow.
|
|
21
|
+
*/
|
|
22
|
+
function WorkspaceOauthFlow({ provider, consumerRef, consumerName, groupRef, groupName, }) {
|
|
23
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
24
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
25
|
+
const [workspace, setWorkspace] = (0, react_1.useState)('');
|
|
26
|
+
const [oAuthCallbackURL, setOAuthCallbackURL] = (0, react_1.useState)(null);
|
|
27
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
28
|
+
// fetch OAuth callback URL from connection so that oath popup can be launched
|
|
29
|
+
const handleSubmit = async () => {
|
|
30
|
+
var _a;
|
|
31
|
+
setError(null);
|
|
32
|
+
if (!workspace) {
|
|
33
|
+
setError('Workspace is required');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (consumerName && groupName && apiKey && workspace) {
|
|
37
|
+
try {
|
|
38
|
+
const url = await (0, fetchOAuthCallbackURL_1.fetchOAuthCallbackURL)(projectId, consumerRef, groupRef, consumerName, groupName, apiKey, provider, workspace);
|
|
39
|
+
setOAuthCallbackURL(url);
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
console.error(err);
|
|
43
|
+
setError((_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unexpected error');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const onClose = (0, react_1.useCallback)((err) => {
|
|
48
|
+
setError(err);
|
|
49
|
+
setOAuthCallbackURL(null);
|
|
50
|
+
}, []);
|
|
51
|
+
// custom entry component for Salesforce provider
|
|
52
|
+
const workspaceEntryComponent = (provider === PROVIDER_SALESFORCE)
|
|
53
|
+
? ((0, jsx_runtime_1.jsx)(SalesforceSubdomainEntry_1.SalesforceSubdomainEntry, { handleSubmit: handleSubmit, setWorkspace: setWorkspace, error: error, isButtonDisabled: workspace.length === 0 })) : (
|
|
54
|
+
// general workspace entry component
|
|
55
|
+
(0, jsx_runtime_1.jsx)(WorkspaceEntry_1.WorkspaceEntry, { provider: provider, handleSubmit: handleSubmit, setWorkspace: setWorkspace, error: error, isButtonDisabled: workspace.length === 0 }));
|
|
56
|
+
return ((0, jsx_runtime_1.jsx)(OAuthPopup_1.default, { title: `Connect to ${(0, utils_1.capitalize)(provider)}`, url: oAuthCallbackURL, onClose: onClose, children: workspaceEntryComponent }));
|
|
57
|
+
}
|
|
58
|
+
exports.WorkspaceOauthFlow = WorkspaceOauthFlow;
|