@amp-labs/react 1.3.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 +62 -8
- package/build/generated-sources/api/src/apis/DestinationApi.js +62 -3
- 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/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/{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/OauthOpts.d.ts +56 -0
- package/build/generated-sources/api/src/models/OauthOpts.js +63 -0
- 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/index.d.ts +15 -2
- package/build/generated-sources/api/src/models/index.js +15 -2
- package/build/src/components/Configure/actions/{createInstallationReducer.d.ts → mutateAndSetState/createInstallationAndSetState.d.ts} +3 -3
- package/build/src/components/Configure/actions/{createInstallationReducer.js → mutateAndSetState/createInstallationAndSetState.js} +4 -4
- 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/{createInstallationProxyOnly.js → onCreateInstallationProxyOnly.js} +5 -5
- 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} +9 -3
- 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 +10 -3
- 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.js +2 -2
- package/build/src/components/Configure/layout/ProtectedConnectionLayout.js +2 -7
- package/build/src/components/Configure/state/utils.js +5 -5
- 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/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 +5 -0
- 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/src/components/Configure/actions/onSaveReadUpdateInstallation.d.ts +0 -3
- package/build/src/components/Configure/actions/proxy/createInstallationProxyOnly.d.ts +0 -8
- 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
|
@@ -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;
|
|
@@ -4,12 +4,12 @@ exports.buttonVariants = void 0;
|
|
|
4
4
|
// define custom button variants
|
|
5
5
|
exports.buttonVariants = {
|
|
6
6
|
warning: {
|
|
7
|
-
bg: 'red.50',
|
|
7
|
+
bg: 'red.50', // Background color
|
|
8
8
|
outlineColor: 'red.800',
|
|
9
9
|
outline: '2px solid',
|
|
10
10
|
outlineOffset: '0',
|
|
11
|
-
borderColor: 'red.800',
|
|
12
|
-
color: 'red.800',
|
|
11
|
+
borderColor: 'red.800', // Border color
|
|
12
|
+
color: 'red.800', // Text color
|
|
13
13
|
_hover: {
|
|
14
14
|
bg: 'red.100', // Background color on hover
|
|
15
15
|
},
|
|
@@ -15,9 +15,9 @@ const customTheme = (0, react_1.extendTheme)({
|
|
|
15
15
|
bg: 'gray.300',
|
|
16
16
|
},
|
|
17
17
|
_selected: {
|
|
18
|
-
color: 'black',
|
|
19
|
-
fontWeight: '500',
|
|
20
|
-
bg: 'gray.200',
|
|
18
|
+
color: 'black', // Set the color of the selected tab to 'black
|
|
19
|
+
fontWeight: '500', // Set the font weight of the selected tab
|
|
20
|
+
bg: 'gray.200', // Set the background color of the selected tab
|
|
21
21
|
border: 'none',
|
|
22
22
|
_hover: {
|
|
23
23
|
bg: 'gray.300',
|
|
@@ -32,9 +32,9 @@ const customTheme = (0, react_1.extendTheme)({
|
|
|
32
32
|
bg: 'red.200',
|
|
33
33
|
},
|
|
34
34
|
_selected: {
|
|
35
|
-
color: 'red.800',
|
|
36
|
-
fontWeight: '500',
|
|
37
|
-
bg: 'red.100',
|
|
35
|
+
color: 'red.800', // Set the color of the selected tab
|
|
36
|
+
fontWeight: '500', // Set the font weight of the selected tab
|
|
37
|
+
bg: 'red.100', // Set the background color of the selected tab
|
|
38
38
|
border: 'none',
|
|
39
39
|
_hover: {
|
|
40
40
|
bg: 'red.200',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AllowedDomainApi, Configuration, ConnectionApi, ConsumerApi, DestinationApi, GroupApi, InstallationApi, IntegrationApi, OAuthApi, OperationApi,
|
|
1
|
+
import { AllowedDomainApi, Configuration, ConnectionApi, ConsumerApi, DestinationApi, GroupApi, InstallationApi, IntegrationApi, OAuthApi, OperationApi, ProjectApi, ProjectMembershipApi, ProviderApi, ProviderAppApi, RevisionApi, UploadURLApi } from '../../generated-sources/api/src';
|
|
2
2
|
/**
|
|
3
3
|
* ApiService is a wrapper around the generated API client, which exposes
|
|
4
4
|
* all generated api services as properties.
|
|
@@ -17,9 +17,9 @@ export declare class ApiService {
|
|
|
17
17
|
integrationApi: IntegrationApi;
|
|
18
18
|
oAuthApi: OAuthApi;
|
|
19
19
|
operationApi: OperationApi;
|
|
20
|
-
operationLogApi: OperationLogApi;
|
|
21
20
|
projectApi: ProjectApi;
|
|
22
21
|
projectMembershipApi: ProjectMembershipApi;
|
|
22
|
+
providerApi: ProviderApi;
|
|
23
23
|
providerAppApi: ProviderAppApi;
|
|
24
24
|
revisionApi: RevisionApi;
|
|
25
25
|
uploadURLApi: UploadURLApi;
|
|
@@ -23,9 +23,9 @@ class ApiService {
|
|
|
23
23
|
this.integrationApi = new src_1.IntegrationApi(config);
|
|
24
24
|
this.oAuthApi = new src_1.OAuthApi(config);
|
|
25
25
|
this.operationApi = new src_1.OperationApi(config);
|
|
26
|
-
this.operationLogApi = new src_1.OperationLogApi(config);
|
|
27
26
|
this.projectApi = new src_1.ProjectApi(config);
|
|
28
27
|
this.projectMembershipApi = new src_1.ProjectMembershipApi(config);
|
|
28
|
+
this.providerApi = new src_1.ProviderApi(config);
|
|
29
29
|
this.providerAppApi = new src_1.ProviderAppApi(config);
|
|
30
30
|
this.revisionApi = new src_1.RevisionApi(config);
|
|
31
31
|
this.uploadURLApi = new src_1.UploadURLApi(config);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Config, Connection, CreateInstallationOperationRequest, CreateInstallationRequestConfig, HydratedIntegrationField, HydratedIntegrationFieldExistent, HydratedIntegrationObject, HydratedIntegrationRead, HydratedIntegrationWrite, HydratedIntegrationWriteObject, HydratedRevision, Installation, Integration, IntegrationFieldMapping, Project, ProviderApp, UpdateInstallationOperationRequest, UpdateInstallationRequestInstallationConfig } from '../../generated-sources/api/src';
|
|
1
|
+
import { Config, Connection, CreateInstallationOperationRequest, CreateInstallationRequestConfig, HydratedIntegrationField, HydratedIntegrationFieldExistent, HydratedIntegrationObject, HydratedIntegrationRead, HydratedIntegrationWrite, HydratedIntegrationWriteObject, HydratedRevision, Installation, Integration, IntegrationFieldMapping, Project, ProviderApp, ProviderInfo, UpdateInstallationOperationRequest, UpdateInstallationRequestInstallationConfig } from '../../generated-sources/api/src';
|
|
2
2
|
import { ApiService } from './ApiService';
|
|
3
3
|
export declare const AMP_SERVER: string;
|
|
4
4
|
export declare const AMP_API_ROOT: string;
|
|
@@ -7,4 +7,4 @@ export declare const api: () => ApiService;
|
|
|
7
7
|
/**
|
|
8
8
|
* Types exported from generated api
|
|
9
9
|
*/
|
|
10
|
-
export type { Config, Connection, CreateInstallationOperationRequest, CreateInstallationRequestConfig, HydratedIntegrationRead, HydratedIntegrationWrite, HydratedIntegrationWriteObject, HydratedIntegrationObject, HydratedIntegrationField, HydratedRevision, Installation, Integration, HydratedIntegrationFieldExistent, IntegrationFieldMapping, Project, ProviderApp, UpdateInstallationOperationRequest, UpdateInstallationRequestInstallationConfig, };
|
|
10
|
+
export type { Config, Connection, CreateInstallationOperationRequest, CreateInstallationRequestConfig, HydratedIntegrationRead, HydratedIntegrationWrite, HydratedIntegrationWriteObject, HydratedIntegrationObject, HydratedIntegrationField, HydratedRevision, Installation, Integration, HydratedIntegrationFieldExistent, IntegrationFieldMapping, Project, ProviderApp, ProviderInfo, UpdateInstallationOperationRequest, UpdateInstallationRequestInstallationConfig, };
|
|
@@ -5,6 +5,7 @@ exports.api = exports.setApi = exports.AMP_API_ROOT = exports.AMP_SERVER = void
|
|
|
5
5
|
// currently not using a bundler to support alias imports
|
|
6
6
|
const src_1 = require("../../generated-sources/api/src");
|
|
7
7
|
const ApiService_1 = require("./ApiService");
|
|
8
|
+
const version_1 = require("./version");
|
|
8
9
|
/**
|
|
9
10
|
* To update the api you need to
|
|
10
11
|
* 1. git clone `https://github.com/amp-labs/server` into a sibling directory
|
|
@@ -60,6 +61,10 @@ exports.AMP_API_ROOT = assignRoot();
|
|
|
60
61
|
* */
|
|
61
62
|
const config = new src_1.Configuration({
|
|
62
63
|
basePath: exports.AMP_API_ROOT,
|
|
64
|
+
headers: {
|
|
65
|
+
'X-Amp-Client': 'react',
|
|
66
|
+
'X-Amp-Client-Version': version_1.LIB_VERSION,
|
|
67
|
+
},
|
|
63
68
|
});
|
|
64
69
|
let apiValue = new ApiService_1.ApiService(config);
|
|
65
70
|
// For testing, etc. we may want to use a different API configuration than the default
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LIB_VERSION = "1.4.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amp-labs/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Ampersand React library.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ampersand Labs",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"test": "jest",
|
|
25
25
|
"watch": "npm run prepbuild && tsc -p tsconfig.json --watch",
|
|
26
26
|
"build": "npm run prepbuild && tsc -p tsconfig.json",
|
|
27
|
-
"prepbuild": "npm run clean",
|
|
27
|
+
"prepbuild": "npm run clean && node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" | sed \"s|\\\"|'|g\" > src/services/version.ts",
|
|
28
28
|
"clean": "rm -rf ./build/",
|
|
29
29
|
"assets": "mkdir ./build/ && cp -R ./src/public/ ./build/public/",
|
|
30
30
|
"lint": "eslint --ext .ts,.tsx -c .eslintrc.cjs src/ --fix",
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ampersand public API
|
|
3
|
-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
|
-
*
|
|
5
|
-
* The version of the OpenAPI document: 1.0.0
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
-
* https://openapi-generator.tech
|
|
10
|
-
* Do not edit the class manually.
|
|
11
|
-
*/
|
|
12
|
-
import * as runtime from '../runtime';
|
|
13
|
-
import type { OperationLog } from '../models';
|
|
14
|
-
export interface ListOperationLogsRequest {
|
|
15
|
-
projectId: string;
|
|
16
|
-
operationId: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* OperationLogApi - interface
|
|
20
|
-
*
|
|
21
|
-
* @export
|
|
22
|
-
* @interface OperationLogApiInterface
|
|
23
|
-
*/
|
|
24
|
-
export interface OperationLogApiInterface {
|
|
25
|
-
/**
|
|
26
|
-
* List logs for an operation, earliest first.
|
|
27
|
-
* @summary List logs for an operation
|
|
28
|
-
* @param {string} projectId
|
|
29
|
-
* @param {string} operationId
|
|
30
|
-
* @param {*} [options] Override http request option.
|
|
31
|
-
* @throws {RequiredError}
|
|
32
|
-
* @memberof OperationLogApiInterface
|
|
33
|
-
*/
|
|
34
|
-
listOperationLogsRaw(requestParameters: ListOperationLogsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<OperationLog>>>;
|
|
35
|
-
/**
|
|
36
|
-
* List logs for an operation, earliest first.
|
|
37
|
-
* List logs for an operation
|
|
38
|
-
*/
|
|
39
|
-
listOperationLogs(requestParameters: ListOperationLogsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<OperationLog>>;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
44
|
-
export declare class OperationLogApi extends runtime.BaseAPI implements OperationLogApiInterface {
|
|
45
|
-
/**
|
|
46
|
-
* List logs for an operation, earliest first.
|
|
47
|
-
* List logs for an operation
|
|
48
|
-
*/
|
|
49
|
-
listOperationLogsRaw(requestParameters: ListOperationLogsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<OperationLog>>>;
|
|
50
|
-
/**
|
|
51
|
-
* List logs for an operation, earliest first.
|
|
52
|
-
* List logs for an operation
|
|
53
|
-
*/
|
|
54
|
-
listOperationLogs(requestParameters: ListOperationLogsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<OperationLog>>;
|
|
55
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Ampersand public API
|
|
3
|
-
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
4
|
-
*
|
|
5
|
-
* The version of the OpenAPI document: 1.0.0
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
9
|
-
* https://openapi-generator.tech
|
|
10
|
-
* Do not edit the class manually.
|
|
11
|
-
*/
|
|
12
|
-
/**
|
|
13
|
-
*
|
|
14
|
-
* @export
|
|
15
|
-
* @interface DestinationMetadata
|
|
16
|
-
*/
|
|
17
|
-
export interface DestinationMetadata {
|
|
18
|
-
/**
|
|
19
|
-
* Webhook URL
|
|
20
|
-
* @type {string}
|
|
21
|
-
* @memberof DestinationMetadata
|
|
22
|
-
*/
|
|
23
|
-
url?: string;
|
|
24
|
-
/**
|
|
25
|
-
* Webhook headers to add
|
|
26
|
-
* @type {{ [key: string]: string; }}
|
|
27
|
-
* @memberof DestinationMetadata
|
|
28
|
-
*/
|
|
29
|
-
headers?: {
|
|
30
|
-
[key: string]: string;
|
|
31
|
-
} | null;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Check if a given object implements the DestinationMetadata interface.
|
|
35
|
-
*/
|
|
36
|
-
export declare function instanceOfDestinationMetadata(value: object): boolean;
|
|
37
|
-
export declare function DestinationMetadataFromJSON(json: any): DestinationMetadata;
|
|
38
|
-
export declare function DestinationMetadataFromJSONTyped(json: any, ignoreDiscriminator: boolean): DestinationMetadata;
|
|
39
|
-
export declare function DestinationMetadataToJSON(value?: DestinationMetadata | null): any;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { Config, HydratedIntegrationObject, Installation } from '../../../services/api';
|
|
2
|
-
import { ConfigureState } from '../types';
|
|
3
|
-
export declare const onSaveReadUpdateInstallation: (projectId: string, integrationId: string, installationId: string, selectedObjectName: string, apiKey: string, configureState: ConfigureState, setInstallation: (installationObj: Installation) => void, hydratedObject: HydratedIntegrationObject, onUpdateSuccess?: ((installationId: string, config: Config) => void) | undefined) => Promise<void | null>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { HydratedRevision } from '../../../../services/api';
|
|
2
|
-
import { CreateInstallationSharedProps } from '../createInstallationReducer';
|
|
3
|
-
type CreateInstallationProxyOnlyProps = CreateInstallationSharedProps & {
|
|
4
|
-
hydratedRevision: HydratedRevision;
|
|
5
|
-
consumerRef: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function createInstallationProxyOnly({ projectId, integrationId, groupRef, consumerRef, connectionId, apiKey, hydratedRevision, setInstallation, onInstallSuccess, }: CreateInstallationProxyOnlyProps): Promise<void> | Promise<null>;
|
|
8
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
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 OAuthErrorAlert_1 = require("../OAuthErrorAlert");
|
|
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" })] }) }) }));
|
|
10
|
-
}
|
|
11
|
-
exports.LandingContent = LandingContent;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Prompts customer to input their Salesforce subdomain, then creates an OAuth connection to
|
|
3
|
-
* that Salesforce instance.
|
|
4
|
-
*/
|
|
5
|
-
interface SalesforceOauthFlowProps {
|
|
6
|
-
consumerRef: string;
|
|
7
|
-
consumerName?: string;
|
|
8
|
-
groupRef: string;
|
|
9
|
-
groupName?: string;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* SalesforceOauthFlow first prompts user for their workspace ("subdomain" in Salesforce lingo),
|
|
13
|
-
* then launches a popup with the OAuth flow.
|
|
14
|
-
*/
|
|
15
|
-
export declare function SalesforceOauthFlow({ consumerRef, consumerName, groupRef, groupName, }: SalesforceOauthFlowProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
-
export {};
|
|
@@ -1,57 +0,0 @@
|
|
|
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.SalesforceOauthFlow = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
/**
|
|
9
|
-
* Prompts customer to input their Salesforce subdomain, then creates an OAuth connection to
|
|
10
|
-
* that Salesforce instance.
|
|
11
|
-
*/
|
|
12
|
-
const react_1 = require("react");
|
|
13
|
-
const constants_1 = require("../../../constants");
|
|
14
|
-
const ApiKeyContextProvider_1 = require("../../../context/ApiKeyContextProvider");
|
|
15
|
-
const ProjectContextProvider_1 = require("../../../context/ProjectContextProvider");
|
|
16
|
-
const fetchOAuthCallbackURL_1 = require("../fetchOAuthCallbackURL");
|
|
17
|
-
const OAuthPopup_1 = __importDefault(require("../OAuthPopup"));
|
|
18
|
-
const SubdomainEntry_1 = require("./SubdomainEntry");
|
|
19
|
-
/**
|
|
20
|
-
* SalesforceOauthFlow first prompts user for their workspace ("subdomain" in Salesforce lingo),
|
|
21
|
-
* then launches a popup with the OAuth flow.
|
|
22
|
-
*/
|
|
23
|
-
function SalesforceOauthFlow({ consumerRef, consumerName, groupRef, groupName, }) {
|
|
24
|
-
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
25
|
-
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
26
|
-
const [workspace, setWorkspace] = (0, react_1.useState)('');
|
|
27
|
-
const [oAuthCallbackURL, setOAuthCallbackURL] = (0, react_1.useState)(null);
|
|
28
|
-
const [error, setError] = (0, react_1.useState)(null);
|
|
29
|
-
const isButtonDisabled = workspace.length === 0;
|
|
30
|
-
const provider = constants_1.PROVIDER_SALESFORCE;
|
|
31
|
-
// 1. fetch provider apps
|
|
32
|
-
// 2. find matching app to provider
|
|
33
|
-
// 3. fetch OAuth callback URL from connection so that oath popup can be launched
|
|
34
|
-
const handleSubmit = async () => {
|
|
35
|
-
var _a;
|
|
36
|
-
setError(null);
|
|
37
|
-
if (workspace && consumerName && groupName && apiKey) {
|
|
38
|
-
try {
|
|
39
|
-
const url = await (0, fetchOAuthCallbackURL_1.fetchOAuthCallbackURL)(projectId, consumerRef, groupRef, consumerName, groupName, apiKey, provider, workspace);
|
|
40
|
-
setOAuthCallbackURL(url);
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
console.error(err);
|
|
44
|
-
setError((_a = err.message) !== null && _a !== void 0 ? _a : 'Unexpected error');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
setError('missing required fields');
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
const onClose = (0, react_1.useCallback)((err) => {
|
|
52
|
-
setError(err);
|
|
53
|
-
setOAuthCallbackURL(null);
|
|
54
|
-
}, []);
|
|
55
|
-
return ((0, jsx_runtime_1.jsx)(OAuthPopup_1.default, { title: "Connect to Salesforce", url: oAuthCallbackURL, onClose: onClose, children: (0, jsx_runtime_1.jsx)(SubdomainEntry_1.SubdomainEntry, { handleSubmit: handleSubmit, setWorkspace: setWorkspace, error: error, isButtonDisabled: isButtonDisabled }) }));
|
|
56
|
-
}
|
|
57
|
-
exports.SalesforceOauthFlow = SalesforceOauthFlow;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
type SubdomainEntryProps = {
|
|
2
|
-
handleSubmit: () => void;
|
|
3
|
-
setWorkspace: (workspace: string) => void;
|
|
4
|
-
error: string | null;
|
|
5
|
-
isButtonDisabled?: boolean;
|
|
6
|
-
};
|
|
7
|
-
export declare function SubdomainEntry({ handleSubmit, setWorkspace, error, isButtonDisabled, }: SubdomainEntryProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SubdomainEntry = 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 OAuthErrorAlert_1 = require("../OAuthErrorAlert");
|
|
8
|
-
const SALESFORCE_HELP_URL = 'https://help.salesforce.com/s/articleView?id=sf.faq_domain_name_what.htm&type=5';
|
|
9
|
-
function SubdomainEntry({ handleSubmit, setWorkspace, error, isButtonDisabled, }) {
|
|
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
|
-
}
|
|
12
|
-
exports.SubdomainEntry = SubdomainEntry;
|
package/build/src/constants.d.ts
DELETED
package/build/src/constants.js
DELETED
/package/build/src/components/Oauth/{NoSubdomainEntry → NoWorkspaceEntry}/LandingContent.d.ts
RENAMED
|
File without changes
|