@amp-labs/react 1.1.0 → 1.3.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 +102 -0
- package/build/generated-sources/api/src/apis/DestinationApi.js +126 -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 +196 -0
- package/build/generated-sources/api/src/apis/InstallationApi.js +235 -0
- package/build/generated-sources/api/src/apis/IntegrationApi.d.ts +128 -0
- package/build/generated-sources/api/src/apis/IntegrationApi.js +151 -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/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/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/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/OauthConnectRequest.d.ts +6 -6
- package/build/generated-sources/api/src/models/OauthConnectRequest.js +1 -2
- 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/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/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 +6 -3
- package/build/generated-sources/api/src/models/index.js +6 -3
- package/build/src/assets/SuccessIcon.d.ts +1 -0
- package/build/src/assets/SuccessIcon.js +8 -0
- 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 +11 -23
- package/build/src/components/Configure/actions/createInstallationReducer.d.ts +15 -0
- package/build/src/components/Configure/actions/createInstallationReducer.js +30 -0
- package/build/src/components/Configure/actions/onSaveReadCreateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/{onSaveCreate.js → onSaveReadCreateInstallation.js} +13 -25
- 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/proxy/createInstallationProxyOnly.d.ts +8 -0
- package/build/src/components/Configure/actions/proxy/createInstallationProxyOnly.js +44 -0
- 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 +72 -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/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/{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/Salesforce/SubdomainEntry.js +1 -1
- 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/SuccessTextBox.d.ts +5 -0
- package/build/src/components/SuccessTextBox.js +10 -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 +26 -19
- 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/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/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
|
@@ -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 ProjectContextProvider_1 = require("../../context/ProjectContextProvider");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
const SuccessTextBox_1 = require("../SuccessTextBox");
|
|
8
|
+
function ConnectedSuccessBox({ provider }) {
|
|
9
|
+
const { appName } = (0, ProjectContextProvider_1.useProject)();
|
|
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
|
+
}
|
|
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;
|
|
@@ -7,9 +7,9 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
7
7
|
* Takes a URL and creates a popup showing that page.
|
|
8
8
|
*/
|
|
9
9
|
const react_1 = require("react");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
10
|
+
const ApiKeyContextProvider_1 = require("../../context/ApiKeyContextProvider");
|
|
11
|
+
const ConnectionsContextProvider_1 = require("../../context/ConnectionsContextProvider");
|
|
12
|
+
const ProjectContextProvider_1 = require("../../context/ProjectContextProvider");
|
|
13
13
|
const api_1 = require("../../services/api");
|
|
14
14
|
const DEFAULT_WIDTH = 600; // px
|
|
15
15
|
const DEFAULT_HEIGHT = 600; // px
|
|
@@ -23,21 +23,19 @@ const createPopup = ({ url, title, }) => {
|
|
|
23
23
|
return popup;
|
|
24
24
|
};
|
|
25
25
|
function OAuthPopup({ title = '', url, children, onClose, }) {
|
|
26
|
-
const { projectId } = (0,
|
|
27
|
-
const apiKey = (0,
|
|
26
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
27
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
28
28
|
const [externalWindow, setExternalWindow] = (0, react_1.useState)();
|
|
29
29
|
const intervalRef = (0, react_1.useRef)();
|
|
30
30
|
const clearTimer = () => window.clearInterval(intervalRef.current);
|
|
31
|
-
const { setSelectedConnection } = (0,
|
|
31
|
+
const { setSelectedConnection } = (0, ConnectionsContextProvider_1.useConnections)();
|
|
32
32
|
(0, react_1.useEffect)(() => {
|
|
33
33
|
if (url)
|
|
34
34
|
setExternalWindow(createPopup({ url, title }));
|
|
35
35
|
}, [url, title]);
|
|
36
36
|
const refreshConnections = (0, react_1.useCallback)(async (connectionId) => {
|
|
37
|
-
const connection = await (0, api_1.api)().getConnection({ projectId, connectionId }, {
|
|
38
|
-
headers: {
|
|
39
|
-
'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '',
|
|
40
|
-
},
|
|
37
|
+
const connection = await (0, api_1.api)().connectionApi.getConnection({ projectId, connectionId }, {
|
|
38
|
+
headers: { 'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '' },
|
|
41
39
|
});
|
|
42
40
|
setSelectedConnection(connection);
|
|
43
41
|
}, [projectId, apiKey, setSelectedConnection]);
|
|
@@ -11,18 +11,18 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
11
11
|
*/
|
|
12
12
|
const react_1 = require("react");
|
|
13
13
|
const constants_1 = require("../../../constants");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const OAuthPopup_1 = __importDefault(require("../../Connect/OAuthPopup"));
|
|
14
|
+
const ApiKeyContextProvider_1 = require("../../../context/ApiKeyContextProvider");
|
|
15
|
+
const ProjectContextProvider_1 = require("../../../context/ProjectContextProvider");
|
|
17
16
|
const fetchOAuthCallbackURL_1 = require("../fetchOAuthCallbackURL");
|
|
17
|
+
const OAuthPopup_1 = __importDefault(require("../OAuthPopup"));
|
|
18
18
|
const SubdomainEntry_1 = require("./SubdomainEntry");
|
|
19
19
|
/**
|
|
20
20
|
* SalesforceOauthFlow first prompts user for their workspace ("subdomain" in Salesforce lingo),
|
|
21
21
|
* then launches a popup with the OAuth flow.
|
|
22
22
|
*/
|
|
23
23
|
function SalesforceOauthFlow({ consumerRef, consumerName, groupRef, groupName, }) {
|
|
24
|
-
const { projectId } = (0,
|
|
25
|
-
const apiKey = (0,
|
|
24
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
25
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
26
26
|
const [workspace, setWorkspace] = (0, react_1.useState)('');
|
|
27
27
|
const [oAuthCallbackURL, setOAuthCallbackURL] = (0, react_1.useState)(null);
|
|
28
28
|
const [error, setError] = (0, react_1.useState)(null);
|
|
@@ -5,7 +5,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const icons_1 = require("@chakra-ui/icons");
|
|
6
6
|
const react_1 = require("@chakra-ui/react");
|
|
7
7
|
const OAuthErrorAlert_1 = require("../OAuthErrorAlert");
|
|
8
|
-
const SALESFORCE_HELP_URL = 'https://help.salesforce.com/articleView?id=
|
|
8
|
+
const SALESFORCE_HELP_URL = 'https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5';
|
|
9
9
|
function SubdomainEntry({ handleSubmit, setWorkspace, error, isButtonDisabled, }) {
|
|
10
10
|
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: "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" })] }) }) }));
|
|
11
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const fetchOAuthCallbackURL: (projectId: string, consumerRef: string, groupRef: string, consumerName: string, groupName: string, apiKey: string, provider
|
|
1
|
+
export declare const fetchOAuthCallbackURL: (projectId: string, consumerRef: string, groupRef: string, consumerName: string, groupName: string, apiKey: string, provider: string, workspace?: string) => Promise<string>;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.fetchOAuthCallbackURL = void 0;
|
|
4
|
-
const constants_1 = require("../../constants");
|
|
5
4
|
const api_1 = require("../../services/api");
|
|
6
5
|
const utils_1 = require("../../utils");
|
|
7
|
-
const fetchOAuthCallbackURL = async (projectId, consumerRef, groupRef, consumerName, groupName, apiKey, provider
|
|
8
|
-
const providerApps = await (0, api_1.api)().listProviderApps({ projectId }, {
|
|
6
|
+
const fetchOAuthCallbackURL = async (projectId, consumerRef, groupRef, consumerName, groupName, apiKey, provider, workspace) => {
|
|
7
|
+
const providerApps = await (0, api_1.api)().providerAppApi.listProviderApps({ projectId }, {
|
|
9
8
|
headers: { 'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '' },
|
|
10
9
|
});
|
|
11
10
|
const app = providerApps.find((a) => a.provider === provider);
|
|
12
11
|
if (!app) {
|
|
13
12
|
throw new Error(`You must first set up a ${(0, utils_1.capitalize)(provider)} Connected App using the Ampersand Console.`);
|
|
14
13
|
}
|
|
15
|
-
const url = await (0, api_1.api)().oauthConnect({
|
|
14
|
+
const url = await (0, api_1.api)().oAuthApi.oauthConnect({
|
|
16
15
|
connectOAuthParams: {
|
|
17
16
|
providerWorkspaceRef: workspace,
|
|
18
17
|
projectId,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
type RedirectHandlerProps = {
|
|
3
|
+
redirectURL?: string;
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* RedirectHandler is a component that redirects to a specified URL when mounted or
|
|
8
|
+
* will render the children if no redirect URL is present.
|
|
9
|
+
*
|
|
10
|
+
* @param redirectURL
|
|
11
|
+
* @param children
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function RedirectHandler({ redirectURL, children }: RedirectHandlerProps): string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedirectHandler = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const react_2 = require("@chakra-ui/react");
|
|
7
|
+
const LoadingIcon_1 = require("../../assets/LoadingIcon");
|
|
8
|
+
/**
|
|
9
|
+
* RedirectHandler is a component that redirects to a specified URL when mounted or
|
|
10
|
+
* will render the children if no redirect URL is present.
|
|
11
|
+
*
|
|
12
|
+
* @param redirectURL
|
|
13
|
+
* @param children
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
function RedirectHandler({ redirectURL, children }) {
|
|
17
|
+
(0, react_1.useEffect)(() => {
|
|
18
|
+
// Check if a redirect URL is present
|
|
19
|
+
if (redirectURL) {
|
|
20
|
+
// Redirect to the specified URL
|
|
21
|
+
window.location.replace(redirectURL);
|
|
22
|
+
}
|
|
23
|
+
}, [redirectURL]);
|
|
24
|
+
// show a loading message if a redirect URL is present
|
|
25
|
+
if (redirectURL) {
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(react_2.Box, { display: "flex", alignItems: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(LoadingIcon_1.LoadingIcon, { message: "Redirecting..." }) }));
|
|
27
|
+
}
|
|
28
|
+
// render children if no redirect URL is present
|
|
29
|
+
return children;
|
|
30
|
+
}
|
|
31
|
+
exports.RedirectHandler = RedirectHandler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RedirectHandler } from './RedirectHandler';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedirectHandler = void 0;
|
|
4
|
+
var RedirectHandler_1 = require("./RedirectHandler");
|
|
5
|
+
Object.defineProperty(exports, "RedirectHandler", { enumerable: true, get: function () { return RedirectHandler_1.RedirectHandler; } });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SuccessTextBox = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const SuccessIcon_1 = require("../assets/SuccessIcon");
|
|
7
|
+
function SuccessTextBox({ text }) {
|
|
8
|
+
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: (0, jsx_runtime_1.jsx)(SuccessIcon_1.SuccessCheckmarkIcon, {}) }) }), (0, jsx_runtime_1.jsx)(react_1.Box, { textAlign: "center", paddingTop: "25px", children: text })] }) }));
|
|
9
|
+
}
|
|
10
|
+
exports.SuccessTextBox = SuccessTextBox;
|
|
@@ -9,14 +9,14 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
9
9
|
* Also optionally accepts theme styles object with CSS values.
|
|
10
10
|
*/
|
|
11
11
|
const react_1 = require("react");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
12
|
+
const ThemeProvider_1 = require("../../components/ThemeProvider");
|
|
13
|
+
const ApiKeyContextProvider_1 = require("../ApiKeyContextProvider");
|
|
14
|
+
const ErrorContextProvider_1 = require("../ErrorContextProvider");
|
|
15
|
+
const IntegrationListContextProvider_1 = require("../IntegrationListContextProvider");
|
|
16
|
+
const ProjectContextProvider_1 = require("../ProjectContextProvider");
|
|
17
17
|
function AmpersandProvider(props) {
|
|
18
18
|
const { options: { apiKey, projectId }, children } = props;
|
|
19
|
-
return ((0, jsx_runtime_1.jsx)(ThemeProvider_1.ThemeProvider, { children: (0, jsx_runtime_1.jsx)(ErrorContextProvider_1.ErrorStateProvider, { children: (0, jsx_runtime_1.jsx)(
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(ThemeProvider_1.ThemeProvider, { children: (0, jsx_runtime_1.jsx)(ErrorContextProvider_1.ErrorStateProvider, { children: (0, jsx_runtime_1.jsx)(ApiKeyContextProvider_1.ApiKeyProvider, { value: apiKey, children: (0, jsx_runtime_1.jsx)(ProjectContextProvider_1.ProjectProvider, { projectId: projectId, children: (0, jsx_runtime_1.jsx)(IntegrationListContextProvider_1.IntegrationListProvider, { projectId: projectId, children: children }) }) }) }) }));
|
|
20
20
|
}
|
|
21
21
|
exports.AmpersandProvider = AmpersandProvider;
|
|
22
22
|
exports.AmpersandContext = (0, react_1.createContext)(null);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AmpersandContextProvider';
|
package/build/src/{components/AmpersandProvider → context/AmpersandContextProvider}/index.js
RENAMED
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./AmpersandContextProvider"), exports);
|
|
@@ -4,12 +4,12 @@ exports.ConnectionsProvider = exports.useConnections = exports.ConnectionsContex
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const LoadingIcon_1 = require("../assets/LoadingIcon");
|
|
7
|
-
const ErrorTextBox_1 = require("../components/
|
|
7
|
+
const ErrorTextBox_1 = require("../components/ErrorTextBox");
|
|
8
8
|
const api_1 = require("../services/api");
|
|
9
|
-
const
|
|
9
|
+
const ApiKeyContextProvider_1 = require("./ApiKeyContextProvider");
|
|
10
10
|
const ErrorContextProvider_1 = require("./ErrorContextProvider");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const InstallIntegrationContextProvider_1 = require("./InstallIntegrationContextProvider");
|
|
12
|
+
const ProjectContextProvider_1 = require("./ProjectContextProvider");
|
|
13
13
|
exports.ConnectionsContext = (0, react_1.createContext)({
|
|
14
14
|
connections: null,
|
|
15
15
|
selectedConnection: null,
|
|
@@ -25,21 +25,22 @@ const useConnections = () => {
|
|
|
25
25
|
};
|
|
26
26
|
exports.useConnections = useConnections;
|
|
27
27
|
function ConnectionsProvider({ provider, groupRef, children, }) {
|
|
28
|
-
const apiKey = (0,
|
|
29
|
-
const { projectId } = (0,
|
|
28
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
29
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
30
30
|
const [connections, setConnections] = (0, react_1.useState)(null);
|
|
31
31
|
const [selectedConnection, setSelectedConnection] = (0, react_1.useState)(null);
|
|
32
32
|
const [isLoading, setLoadingState] = (0, react_1.useState)(true);
|
|
33
33
|
const { setError, isError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
34
|
-
const { provider: providerFromProps } = (0,
|
|
34
|
+
const { provider: providerFromProps } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
|
|
35
35
|
if (!projectId) {
|
|
36
36
|
throw new Error('ConnectionsProvider must be used within AmpersandProvider');
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
const selectedProvider = provider || providerFromProps;
|
|
39
|
+
if (!selectedProvider) {
|
|
39
40
|
throw new Error('ConnectionsProvider must be given a provider prop or be used within InstallIntegrationProvider');
|
|
40
41
|
}
|
|
41
42
|
(0, react_1.useEffect)(() => {
|
|
42
|
-
(0, api_1.api)().listConnections({ projectId, groupRef, provider }, {
|
|
43
|
+
(0, api_1.api)().connectionApi.listConnections({ projectId, groupRef, provider: selectedProvider }, {
|
|
43
44
|
headers: {
|
|
44
45
|
'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '',
|
|
45
46
|
},
|
|
@@ -51,7 +52,7 @@ function ConnectionsProvider({ provider, groupRef, children, }) {
|
|
|
51
52
|
setError(ErrorContextProvider_1.ErrorBoundary.CONNECTION_LIST, projectId);
|
|
52
53
|
console.error(`Error retrieving existing OAuth connections for group ID ${groupRef}:`, err);
|
|
53
54
|
});
|
|
54
|
-
}, [projectId, apiKey, groupRef,
|
|
55
|
+
}, [projectId, apiKey, groupRef, selectedProvider, setError]);
|
|
55
56
|
const contextValue = (0, react_1.useMemo)(() => ({
|
|
56
57
|
connections,
|
|
57
58
|
selectedConnection,
|
package/build/src/context/{InstallIntegrationContext.d.ts → InstallIntegrationContextProvider.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { Installation, Integration } from '../services/api';
|
|
2
|
+
import { Config, Installation, Integration } from '../services/api';
|
|
3
3
|
interface InstallIntegrationContextValue {
|
|
4
4
|
integrationId: string;
|
|
5
5
|
provider: string;
|
|
@@ -11,7 +11,10 @@ interface InstallIntegrationContextValue {
|
|
|
11
11
|
installation?: Installation;
|
|
12
12
|
setInstallation: (installationObj: Installation) => void;
|
|
13
13
|
resetInstallations: () => void;
|
|
14
|
+
onInstallSuccess?: (installationId: string, config: Config) => void;
|
|
15
|
+
onUpdateSuccess?: (installationId: string, config: Config) => void;
|
|
14
16
|
}
|
|
17
|
+
export declare const InstallIntegrationContext: import("react").Context<InstallIntegrationContextValue>;
|
|
15
18
|
export declare function useInstallIntegrationProps(): InstallIntegrationContextValue;
|
|
16
19
|
interface InstallIntegrationProviderProps {
|
|
17
20
|
integration: string;
|
|
@@ -20,6 +23,8 @@ interface InstallIntegrationProviderProps {
|
|
|
20
23
|
groupRef: string;
|
|
21
24
|
groupName?: string;
|
|
22
25
|
children: React.ReactNode;
|
|
26
|
+
onInstallSuccess?: (installationId: string, config: Config) => void;
|
|
27
|
+
onUpdateSuccess?: (installationId: string, config: Config) => void;
|
|
23
28
|
}
|
|
24
|
-
export declare function InstallIntegrationProvider({ children, integration, consumerRef, consumerName, groupRef, groupName, }: InstallIntegrationProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
export declare function InstallIntegrationProvider({ children, integration, consumerRef, consumerName, groupRef, groupName, onInstallSuccess, onUpdateSuccess, }: InstallIntegrationProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
25
30
|
export {};
|
package/build/src/context/{InstallIntegrationContext.js → InstallIntegrationContextProvider.js}
RENAMED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InstallIntegrationProvider = exports.useInstallIntegrationProps = void 0;
|
|
3
|
+
exports.InstallIntegrationProvider = exports.useInstallIntegrationProps = exports.InstallIntegrationContext = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const LoadingIcon_1 = require("../assets/LoadingIcon");
|
|
7
|
-
const ErrorTextBox_1 = require("../components/
|
|
7
|
+
const ErrorTextBox_1 = require("../components/ErrorTextBox");
|
|
8
8
|
const api_1 = require("../services/api");
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
|
-
const
|
|
10
|
+
const ApiKeyContextProvider_1 = require("./ApiKeyContextProvider");
|
|
11
11
|
const ErrorContextProvider_1 = require("./ErrorContextProvider");
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const IntegrationListContextProvider_1 = require("./IntegrationListContextProvider");
|
|
13
|
+
const ProjectContextProvider_1 = require("./ProjectContextProvider");
|
|
14
14
|
// Create a context to pass down the props
|
|
15
|
-
|
|
15
|
+
exports.InstallIntegrationContext = (0, react_1.createContext)({
|
|
16
16
|
integrationId: '',
|
|
17
17
|
provider: '',
|
|
18
18
|
integrationObj: undefined,
|
|
@@ -23,10 +23,12 @@ const InstallIntegrationContext = (0, react_1.createContext)({
|
|
|
23
23
|
installation: undefined,
|
|
24
24
|
setInstallation: () => { },
|
|
25
25
|
resetInstallations: () => { },
|
|
26
|
+
onInstallSuccess: undefined,
|
|
27
|
+
onUpdateSuccess: undefined,
|
|
26
28
|
});
|
|
27
29
|
// Create a custom hook to access the props
|
|
28
30
|
function useInstallIntegrationProps() {
|
|
29
|
-
const context = (0, react_1.useContext)(InstallIntegrationContext);
|
|
31
|
+
const context = (0, react_1.useContext)(exports.InstallIntegrationContext);
|
|
30
32
|
if (!context) {
|
|
31
33
|
throw new Error('useInstallIntegrationProps must be used within an InstallIntegrationProvider');
|
|
32
34
|
}
|
|
@@ -34,10 +36,10 @@ function useInstallIntegrationProps() {
|
|
|
34
36
|
}
|
|
35
37
|
exports.useInstallIntegrationProps = useInstallIntegrationProps;
|
|
36
38
|
// Wrap your parent component with the context provider
|
|
37
|
-
function InstallIntegrationProvider({ children, integration, consumerRef, consumerName, groupRef, groupName, }) {
|
|
38
|
-
const apiKey = (0,
|
|
39
|
-
const { projectId } = (0,
|
|
40
|
-
const { integrations } = (0,
|
|
39
|
+
function InstallIntegrationProvider({ children, integration, consumerRef, consumerName, groupRef, groupName, onInstallSuccess, onUpdateSuccess, }) {
|
|
40
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
41
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
42
|
+
const { integrations } = (0, IntegrationListContextProvider_1.useIntegrationList)();
|
|
41
43
|
const [installations, setInstallations] = (0, react_1.useState)([]);
|
|
42
44
|
const [isLoading, setLoadingState] = (0, react_1.useState)(true);
|
|
43
45
|
const { setError, isError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
@@ -56,7 +58,11 @@ function InstallIntegrationProvider({ children, integration, consumerRef, consum
|
|
|
56
58
|
const resetInstallations = (0, react_1.useCallback)(() => {
|
|
57
59
|
if (integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.id) {
|
|
58
60
|
// check if installation exists on selected integration
|
|
59
|
-
(0, api_1.api)().listInstallations({
|
|
61
|
+
(0, api_1.api)().installationApi.listInstallations({
|
|
62
|
+
projectId,
|
|
63
|
+
integrationId: integrationObj.id,
|
|
64
|
+
groupRef,
|
|
65
|
+
}, {
|
|
60
66
|
headers: {
|
|
61
67
|
'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '',
|
|
62
68
|
},
|
|
@@ -88,8 +94,17 @@ function InstallIntegrationProvider({ children, integration, consumerRef, consum
|
|
|
88
94
|
installation,
|
|
89
95
|
setInstallation,
|
|
90
96
|
resetInstallations,
|
|
97
|
+
onInstallSuccess,
|
|
98
|
+
onUpdateSuccess,
|
|
91
99
|
}), [integrationObj, consumerRef, consumerName, groupRef,
|
|
92
|
-
groupName, installation, setInstallation, resetInstallations]);
|
|
93
|
-
|
|
100
|
+
groupName, installation, setInstallation, resetInstallations, onInstallSuccess, onUpdateSuccess]);
|
|
101
|
+
if (integrationObj !== null) {
|
|
102
|
+
const errorMessage = 'Error retrieving installation information for integration '
|
|
103
|
+
+ `"${(integrationObj === null || integrationObj === void 0 ? void 0 : integrationObj.name) || 'unknown'}"`;
|
|
104
|
+
return (isError(ErrorContextProvider_1.ErrorBoundary.INSTALLATION_LIST, integrationErrorKey))
|
|
105
|
+
? (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: errorMessage }) : ((0, jsx_runtime_1.jsx)(exports.InstallIntegrationContext.Provider, { value: props, children: isLoading ? (0, jsx_runtime_1.jsx)(LoadingIcon_1.LoadingIcon, {}) : children }));
|
|
106
|
+
}
|
|
107
|
+
// if integration not found, return error message
|
|
108
|
+
return (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: `Integration "${integration}" not found` });
|
|
94
109
|
}
|
|
95
110
|
exports.InstallIntegrationProvider = InstallIntegrationProvider;
|
|
@@ -4,9 +4,9 @@ exports.IntegrationListProvider = exports.useIntegrationList = exports.Integrati
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const LoadingIcon_1 = require("../assets/LoadingIcon");
|
|
7
|
-
const ErrorTextBox_1 = require("../components/
|
|
7
|
+
const ErrorTextBox_1 = require("../components/ErrorTextBox");
|
|
8
8
|
const api_1 = require("../services/api");
|
|
9
|
-
const
|
|
9
|
+
const ApiKeyContextProvider_1 = require("./ApiKeyContextProvider");
|
|
10
10
|
const ErrorContextProvider_1 = require("./ErrorContextProvider");
|
|
11
11
|
exports.IntegrationListContext = (0, react_1.createContext)({
|
|
12
12
|
integrations: null,
|
|
@@ -20,12 +20,12 @@ const useIntegrationList = () => {
|
|
|
20
20
|
};
|
|
21
21
|
exports.useIntegrationList = useIntegrationList;
|
|
22
22
|
function IntegrationListProvider({ projectId, children }) {
|
|
23
|
-
const apiKey = (0,
|
|
23
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
24
24
|
const { setError, isError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
25
25
|
const [integrations, setIntegrations] = (0, react_1.useState)(null);
|
|
26
26
|
const [isLoading, setLoadingState] = (0, react_1.useState)(true);
|
|
27
27
|
(0, react_1.useEffect)(() => {
|
|
28
|
-
(0, api_1.api)().listIntegrations({ projectId }, {
|
|
28
|
+
(0, api_1.api)().integrationApi.listIntegrations({ projectId }, {
|
|
29
29
|
headers: {
|
|
30
30
|
'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '',
|
|
31
31
|
},
|
|
@@ -4,9 +4,9 @@ exports.ProjectProvider = exports.useProject = exports.ProjectContext = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const LoadingIcon_1 = require("../assets/LoadingIcon");
|
|
7
|
-
const ErrorTextBox_1 = require("../components/
|
|
7
|
+
const ErrorTextBox_1 = require("../components/ErrorTextBox");
|
|
8
8
|
const api_1 = require("../services/api");
|
|
9
|
-
const
|
|
9
|
+
const ApiKeyContextProvider_1 = require("./ApiKeyContextProvider");
|
|
10
10
|
const ErrorContextProvider_1 = require("./ErrorContextProvider");
|
|
11
11
|
exports.ProjectContext = (0, react_1.createContext)({
|
|
12
12
|
project: null,
|
|
@@ -22,12 +22,12 @@ const useProject = () => {
|
|
|
22
22
|
};
|
|
23
23
|
exports.useProject = useProject;
|
|
24
24
|
function ProjectProvider({ projectId, children }) {
|
|
25
|
-
const apiKey = (0,
|
|
25
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
26
26
|
const { isError, setError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
27
27
|
const [project, setProject] = (0, react_1.useState)(null);
|
|
28
28
|
const [isLoading, setLoadingState] = (0, react_1.useState)(true);
|
|
29
29
|
(0, react_1.useEffect)(() => {
|
|
30
|
-
(0, api_1.api)().getProject({ projectId }, {
|
|
30
|
+
(0, api_1.api)().projectApi.getProject({ projectId }, {
|
|
31
31
|
headers: {
|
|
32
32
|
'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '',
|
|
33
33
|
},
|