@amp-labs/react 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/generated-sources/api/src/apis/AllowedDomainApi.d.ts +79 -0
- package/build/generated-sources/api/src/apis/AllowedDomainApi.js +101 -0
- package/build/generated-sources/api/src/apis/ConnectionApi.d.ts +82 -0
- package/build/generated-sources/api/src/apis/ConnectionApi.js +107 -0
- package/build/generated-sources/api/src/apis/ConsumerApi.d.ts +52 -0
- package/build/generated-sources/api/src/apis/ConsumerApi.js +75 -0
- package/build/generated-sources/api/src/apis/DestinationApi.d.ts +78 -0
- package/build/generated-sources/api/src/apis/DestinationApi.js +102 -0
- package/build/generated-sources/api/src/apis/GroupApi.d.ts +52 -0
- package/build/generated-sources/api/src/apis/GroupApi.js +75 -0
- package/build/generated-sources/api/src/apis/InstallationApi.d.ts +168 -0
- package/build/generated-sources/api/src/apis/InstallationApi.js +205 -0
- package/build/generated-sources/api/src/apis/IntegrationApi.d.ts +128 -0
- package/build/generated-sources/api/src/apis/IntegrationApi.js +154 -0
- package/build/generated-sources/api/src/apis/OAuthApi.d.ts +76 -0
- package/build/generated-sources/api/src/apis/OAuthApi.js +102 -0
- package/build/generated-sources/api/src/apis/OperationApi.d.ts +80 -0
- package/build/generated-sources/api/src/apis/OperationApi.js +104 -0
- package/build/generated-sources/api/src/apis/OperationLogApi.d.ts +55 -0
- package/build/generated-sources/api/src/apis/OperationLogApi.js +76 -0
- package/build/generated-sources/api/src/apis/ProjectApi.d.ts +124 -0
- package/build/generated-sources/api/src/apis/ProjectApi.js +148 -0
- package/build/generated-sources/api/src/apis/ProjectMembershipApi.d.ts +126 -0
- package/build/generated-sources/api/src/apis/ProjectMembershipApi.js +154 -0
- package/build/generated-sources/api/src/apis/ProviderAppApi.d.ts +130 -0
- package/build/generated-sources/api/src/apis/ProviderAppApi.js +158 -0
- package/build/generated-sources/api/src/apis/RevisionApi.d.ts +87 -0
- package/build/generated-sources/api/src/apis/RevisionApi.js +113 -0
- package/build/generated-sources/api/src/apis/UploadURLApi.d.ts +46 -0
- package/build/generated-sources/api/src/apis/UploadURLApi.js +68 -0
- package/build/generated-sources/api/src/apis/index.d.ts +15 -1
- package/build/generated-sources/api/src/apis/index.js +15 -1
- package/build/generated-sources/api/src/models/Destination.d.ts +44 -0
- package/build/generated-sources/api/src/models/Destination.js +57 -0
- package/build/generated-sources/api/src/models/DestinationMetadata.d.ts +39 -0
- package/build/generated-sources/api/src/models/{CreateDestinationRequestMetadata.js → DestinationMetadata.js} +11 -11
- package/build/generated-sources/api/src/models/OperationLog.d.ts +43 -0
- package/build/generated-sources/api/src/models/OperationLog.js +56 -0
- package/build/generated-sources/api/src/models/ProviderApp.d.ts +6 -0
- package/build/generated-sources/api/src/models/ProviderApp.js +2 -0
- package/build/generated-sources/api/src/models/index.d.ts +3 -2
- package/build/generated-sources/api/src/models/index.js +3 -2
- package/build/src/assets/TrashIcon.js +3 -1
- package/build/src/components/Configure/InstallIntegration.d.ts +4 -1
- package/build/src/components/Configure/InstallIntegration.js +10 -23
- package/build/src/components/Configure/actions/onSaveReadCreateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/{onSaveCreate.js → onSaveReadCreateInstallation.js} +7 -6
- package/build/src/components/Configure/actions/onSaveReadUpdateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/{onSaveUpdate.js → onSaveReadUpdateInstallation.js} +13 -8
- package/build/src/components/Configure/actions/write/generateConfigWriteObjects.d.ts +26 -0
- package/build/src/components/Configure/actions/write/generateConfigWriteObjects.js +41 -0
- package/build/src/components/Configure/actions/write/onSaveWriteCreateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/write/onSaveWriteCreateInstallation.js +85 -0
- package/build/src/components/Configure/actions/write/onSaveWriteUpdateInstallation.d.ts +3 -0
- package/build/src/components/Configure/actions/write/onSaveWriteUpdateInstallation.js +60 -0
- package/build/src/components/Configure/{ConfigureInstallationBase.d.ts → content/ConfigureInstallationBase.d.ts} +2 -1
- package/build/src/components/Configure/content/ConfigureInstallationBase.js +36 -0
- package/build/src/components/Configure/content/CreateInstallation.js +83 -0
- package/build/src/components/Configure/content/InstallationContent.d.ts +1 -0
- package/build/src/components/Configure/content/InstallationContent.js +20 -0
- package/build/src/components/Configure/{UninstallContent.js → content/UninstallContent.js} +10 -9
- package/build/src/components/Configure/{UpdateInstallation.d.ts → content/UpdateInstallation.d.ts} +1 -1
- package/build/src/components/Configure/{UpdateInstallation.js → content/UpdateInstallation.js} +42 -28
- package/build/src/components/Configure/{fields → content/fields}/FieldMappings/FieldMapping.d.ts +1 -1
- package/build/src/components/Configure/{fields → content/fields}/FieldMappings/FieldMapping.js +4 -7
- package/build/src/components/Configure/{fields → content/fields}/FieldMappings/RequiredFieldMappings.js +10 -11
- package/build/src/components/Configure/{fields → content/fields}/FieldMappings/setFieldMapping.d.ts +1 -1
- package/build/src/components/Configure/content/fields/FieldMappings/setFieldMapping.js +21 -0
- package/build/src/components/Configure/{fields → content/fields}/OptionalFields/OptionalFields.js +9 -14
- package/build/src/components/Configure/{fields → content/fields}/OptionalFields/setOptionalField.d.ts +1 -1
- package/build/src/components/Configure/content/fields/OptionalFields/setOptionalField.js +27 -0
- package/build/src/components/Configure/content/fields/ReadFields.d.ts +1 -0
- package/build/src/components/Configure/content/fields/ReadFields.js +11 -0
- package/build/src/components/Configure/content/fields/RequiredFields.js +23 -0
- package/build/src/components/Configure/content/fields/WriteFields/WriteFields.d.ts +1 -0
- package/build/src/components/Configure/content/fields/WriteFields/WriteFields.js +22 -0
- package/build/src/components/Configure/content/fields/WriteFields/index.d.ts +2 -0
- package/build/src/components/Configure/content/fields/WriteFields/index.js +5 -0
- package/build/src/components/Configure/content/fields/WriteFields/setNonConfigurableWriteField.d.ts +3 -0
- package/build/src/components/Configure/content/fields/WriteFields/setNonConfigurableWriteField.js +32 -0
- package/build/src/components/Configure/content/useMutateInstallation.d.ts +23 -0
- package/build/src/components/Configure/content/useMutateInstallation.js +47 -0
- package/build/src/components/Configure/content/useSelectedConfigureState.d.ts +72 -0
- package/build/src/components/Configure/content/useSelectedConfigureState.js +24 -0
- package/build/src/components/Configure/{ProtectedConnectionLayout.d.ts → layout/ProtectedConnectionLayout.d.ts} +2 -1
- package/build/src/components/Configure/{ProtectedConnectionLayout.js → layout/ProtectedConnectionLayout.js} +13 -13
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/NavObjectItem.d.ts +1 -0
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/NavObjectItem.js +3 -3
- package/build/src/components/Configure/nav/ObjectManagementNav/OtherTab.d.ts +7 -0
- package/build/src/components/Configure/nav/ObjectManagementNav/OtherTab.js +11 -0
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/UninstallInstallation.d.ts +1 -1
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/UninstallInstallation.js +2 -2
- package/build/src/components/Configure/nav/ObjectManagementNav/constant.d.ts +1 -0
- package/build/src/components/Configure/nav/ObjectManagementNav/constant.js +4 -0
- package/build/src/components/Configure/{ObjectManagementNav → nav/ObjectManagementNav}/index.d.ts +1 -0
- package/build/src/components/Configure/nav/ObjectManagementNav/index.js +61 -0
- package/build/src/components/Configure/state/ConfigurationStateProvider.d.ts +70 -42
- package/build/src/components/Configure/state/ConfigurationStateProvider.js +39 -17
- package/build/src/components/Configure/state/HydratedRevisionContext.js +11 -9
- package/build/src/components/Configure/state/utils.d.ts +2 -2
- package/build/src/components/Configure/state/utils.js +44 -19
- package/build/src/components/Configure/types.d.ts +22 -6
- package/build/src/components/Configure/utils.d.ts +3 -2
- package/build/src/components/Configure/utils.js +25 -5
- package/build/src/components/Connect/ConnectProvider.d.ts +3 -1
- package/build/src/components/Connect/ConnectProvider.js +6 -12
- package/build/src/components/Connect/ConnectedSuccessBox.d.ts +5 -0
- package/build/src/components/Connect/ConnectedSuccessBox.js +13 -0
- package/build/src/components/Connect/useConnectionHandler.d.ts +10 -0
- package/build/src/components/Connect/useConnectionHandler.js +24 -0
- package/build/src/components/ErrorTextBox.js +11 -0
- package/build/src/components/Oauth/NoSubdomainEntry/LandingContent.d.ts +8 -0
- package/build/src/components/Oauth/{Hubspot/HubspotLandingContent.js → NoSubdomainEntry/LandingContent.js} +5 -4
- package/build/src/components/Oauth/NoSubdomainEntry/NoSubdomainOauthFlow.d.ts +16 -0
- package/build/src/components/Oauth/{Hubspot/HubspotOauthFlow.js → NoSubdomainEntry/NoSubdomainOauthFlow.js} +14 -14
- package/build/src/components/{Connect → Oauth}/OAuthPopup.js +8 -10
- package/build/src/components/Oauth/Salesforce/SalesforceOauthFlow.js +5 -5
- package/build/src/components/Oauth/fetchOAuthCallbackURL.d.ts +1 -1
- package/build/src/components/Oauth/fetchOAuthCallbackURL.js +3 -4
- package/build/src/components/RedirectHandler/RedirectHandler.d.ts +15 -0
- package/build/src/components/RedirectHandler/RedirectHandler.js +31 -0
- package/build/src/components/RedirectHandler/index.d.ts +1 -0
- package/build/src/components/RedirectHandler/index.js +5 -0
- package/build/src/{components/AmpersandProvider/AmpersandProvider.js → context/AmpersandContextProvider/AmpersandContextProvider.js} +6 -6
- package/build/src/context/AmpersandContextProvider/index.d.ts +1 -0
- package/build/src/{components/AmpersandProvider → context/AmpersandContextProvider}/index.js +1 -1
- package/build/src/context/{ConnectionsContext.js → ConnectionsContextProvider.js} +11 -10
- package/build/src/context/{InstallIntegrationContext.d.ts → InstallIntegrationContextProvider.d.ts} +7 -2
- package/build/src/context/{InstallIntegrationContext.js → InstallIntegrationContextProvider.js} +29 -14
- package/build/src/context/{IntegrationListContext.js → IntegrationListContextProvider.js} +4 -4
- package/build/src/context/{ProjectContext.js → ProjectContextProvider.js} +4 -4
- package/build/src/hooks/useIsIntegrationInstalled.js +7 -7
- package/build/src/index.d.ts +1 -2
- package/build/src/index.js +1 -2
- package/build/src/public/index.d.ts +7 -0
- package/build/src/{components → public}/index.js +7 -3
- package/build/src/services/ApiService.d.ts +27 -0
- package/build/src/services/ApiService.js +34 -0
- package/build/src/services/api.d.ts +5 -4
- package/build/src/services/api.js +11 -6
- package/package.json +2 -2
- package/build/generated-sources/api/src/apis/DefaultApi.d.ts +0 -930
- package/build/generated-sources/api/src/apis/DefaultApi.js +0 -1019
- package/build/generated-sources/api/src/models/CreateDestinationRequest.d.ts +0 -44
- package/build/generated-sources/api/src/models/CreateDestinationRequest.js +0 -57
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.d.ts +0 -39
- package/build/src/components/AmpersandProvider/index.d.ts +0 -1
- package/build/src/components/CenteredTextBox/CenteredTextBox.d.ts +0 -5
- package/build/src/components/CenteredTextBox/CenteredTextBox.js +0 -8
- package/build/src/components/Configure/ConfigureInstallationBase.js +0 -29
- package/build/src/components/Configure/CreateInstallation.js +0 -70
- package/build/src/components/Configure/ErrorTextBox.js +0 -9
- package/build/src/components/Configure/ObjectManagementNav/index.js +0 -53
- package/build/src/components/Configure/actions/onSaveCreate.d.ts +0 -3
- package/build/src/components/Configure/actions/onSaveUpdate.d.ts +0 -3
- package/build/src/components/Configure/fields/FieldMappings/setFieldMapping.js +0 -18
- package/build/src/components/Configure/fields/OptionalFields/setOptionalField.js +0 -21
- package/build/src/components/Configure/fields/RequiredFields.js +0 -27
- package/build/src/components/Oauth/Hubspot/HubspotLandingContent.d.ts +0 -7
- package/build/src/components/Oauth/Hubspot/HubspotOauthFlow.d.ts +0 -15
- package/build/src/components/index.d.ts +0 -3
- /package/build/src/components/Configure/{CreateInstallation.d.ts → content/CreateInstallation.d.ts} +0 -0
- /package/build/src/components/Configure/{UninstallContent.d.ts → content/UninstallContent.d.ts} +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldHeader.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldHeader.js +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/RequiredFieldMappings.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/index.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/FieldMappings/index.js +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/OptionalFields.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/index.d.ts +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/OptionalFields/index.js +0 -0
- /package/build/src/components/Configure/{fields → content/fields}/RequiredFields.d.ts +0 -0
- /package/build/src/components/{Configure/ErrorTextBox.d.ts → ErrorTextBox.d.ts} +0 -0
- /package/build/src/components/{Connect → Oauth}/OAuthPopup.d.ts +0 -0
- /package/build/src/{components/AmpersandProvider/AmpersandProvider.d.ts → context/AmpersandContextProvider/AmpersandContextProvider.d.ts} +0 -0
- /package/build/src/context/{ApiKeyProvider.d.ts → ApiKeyContextProvider.d.ts} +0 -0
- /package/build/src/context/{ApiKeyProvider.js → ApiKeyContextProvider.js} +0 -0
- /package/build/src/context/{ConnectionsContext.d.ts → ConnectionsContextProvider.d.ts} +0 -0
- /package/build/src/context/{IntegrationListContext.d.ts → IntegrationListContextProvider.d.ts} +0 -0
- /package/build/src/context/{ProjectContext.d.ts → ProjectContextProvider.d.ts} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.onSaveWriteUpdateInstallation = void 0;
|
|
4
|
+
const api_1 = require("../../../../services/api");
|
|
5
|
+
const generateConfigWriteObjects_1 = require("./generateConfigWriteObjects");
|
|
6
|
+
/**
|
|
7
|
+
* given a configureState generate the config object that is need for
|
|
8
|
+
* update installation request.
|
|
9
|
+
*
|
|
10
|
+
* @param configureState
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
const generateUpdateWriteConfigFromConfigureState = (configureState) => {
|
|
14
|
+
const configWriteObjects = (0, generateConfigWriteObjects_1.generateConfigWriteObjects)(configureState);
|
|
15
|
+
// config request object type needs to be fixed
|
|
16
|
+
const updateConfigObject = {
|
|
17
|
+
content: {
|
|
18
|
+
write: {
|
|
19
|
+
objects: configWriteObjects,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
return updateConfigObject;
|
|
24
|
+
};
|
|
25
|
+
const onSaveWriteUpdateInstallation = (projectId, integrationId, installationId, apiKey, configureState, setInstallation, onUpdateSuccess) => {
|
|
26
|
+
// get configuration state
|
|
27
|
+
// transform configuration state to update shape
|
|
28
|
+
const updateConfig = generateUpdateWriteConfigFromConfigureState(configureState);
|
|
29
|
+
if (!updateConfig) {
|
|
30
|
+
console.error('Error when generating write updateConfig from configureState');
|
|
31
|
+
return Promise.resolve(null);
|
|
32
|
+
}
|
|
33
|
+
const updateInstallationRequest = {
|
|
34
|
+
projectId,
|
|
35
|
+
installationId,
|
|
36
|
+
integrationId,
|
|
37
|
+
installationUpdate: {
|
|
38
|
+
// update mask will recurse to the object path and replace the object at the object path
|
|
39
|
+
// this example will replace the object at the object (i.e. accounts)
|
|
40
|
+
updateMask: ['config.content.write.objects'],
|
|
41
|
+
installation: {
|
|
42
|
+
config: updateConfig,
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
// call api.updateInstallation
|
|
47
|
+
return (0, api_1.api)().installationApi.updateInstallation(updateInstallationRequest, {
|
|
48
|
+
headers: {
|
|
49
|
+
'X-Api-Key': apiKey,
|
|
50
|
+
'Content-Type': 'application/json',
|
|
51
|
+
},
|
|
52
|
+
}).then((installation) => {
|
|
53
|
+
// update local installation state
|
|
54
|
+
setInstallation(installation);
|
|
55
|
+
onUpdateSuccess === null || onUpdateSuccess === void 0 ? void 0 : onUpdateSuccess(installation.id, installation.config);
|
|
56
|
+
}).catch((err) => {
|
|
57
|
+
console.error('ERROR: ', err);
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
exports.onSaveWriteUpdateInstallation = onSaveWriteUpdateInstallation;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { FormEventHandler } from 'react';
|
|
2
2
|
interface ConfigureInstallationBaseProps {
|
|
3
|
+
isCreateMode?: boolean;
|
|
3
4
|
onSave: FormEventHandler;
|
|
4
5
|
onReset: () => void;
|
|
5
6
|
isLoading: boolean;
|
|
6
7
|
}
|
|
7
|
-
export declare function ConfigureInstallationBase({ onSave, onReset, isLoading }: ConfigureInstallationBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function ConfigureInstallationBase({ onSave, onReset, isLoading, isCreateMode, }: ConfigureInstallationBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConfigureInstallationBase = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const LoadingIcon_1 = require("../../../assets/LoadingIcon");
|
|
7
|
+
const constant_1 = require("../nav/ObjectManagementNav/constant");
|
|
8
|
+
const UninstallInstallation_1 = require("../nav/ObjectManagementNav/UninstallInstallation");
|
|
9
|
+
const HydratedRevisionContext_1 = require("../state/HydratedRevisionContext");
|
|
10
|
+
const ReadFields_1 = require("./fields/ReadFields");
|
|
11
|
+
const WriteFields_1 = require("./fields/WriteFields");
|
|
12
|
+
const UninstallContent_1 = require("./UninstallContent");
|
|
13
|
+
const useSelectedConfigureState_1 = require("./useSelectedConfigureState");
|
|
14
|
+
// Installation UI Base
|
|
15
|
+
function ConfigureInstallationBase({ onSave, onReset, isLoading, isCreateMode = false, }) {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
const { hydratedRevision, loading } = (0, HydratedRevisionContext_1.useHydratedRevision)();
|
|
18
|
+
const { configureState, selectedObjectName } = (0, useSelectedConfigureState_1.useSelectedConfigureState)();
|
|
19
|
+
// has the form been modified?
|
|
20
|
+
const isReadModified = ((_a = configureState === null || configureState === void 0 ? void 0 : configureState.read) === null || _a === void 0 ? void 0 : _a.isOptionalFieldsModified)
|
|
21
|
+
|| ((_b = configureState === null || configureState === void 0 ? void 0 : configureState.read) === null || _b === void 0 ? void 0 : _b.isRequiredMapFieldsModified);
|
|
22
|
+
const isWriteModified = (_c = configureState === null || configureState === void 0 ? void 0 : configureState.write) === null || _c === void 0 ? void 0 : _c.isWriteModified;
|
|
23
|
+
const isModified = isReadModified || isWriteModified;
|
|
24
|
+
// is this a new state (modified or creating a new state)
|
|
25
|
+
const isStateNew = isModified || isCreateMode;
|
|
26
|
+
// should the save button be disabled?
|
|
27
|
+
const isDisabled = loading || isLoading || !configureState || !selectedObjectName
|
|
28
|
+
|| !isStateNew;
|
|
29
|
+
// is other selected?
|
|
30
|
+
const isNonConfigurableWrite = selectedObjectName === constant_1.OTHER_CONST;
|
|
31
|
+
// is the form in the uninstall case?
|
|
32
|
+
const isUninstall = selectedObjectName === UninstallInstallation_1.UNINSTALL_INSTALLATION_CONST;
|
|
33
|
+
return (isLoading ? (0, jsx_runtime_1.jsx)(LoadingIcon_1.LoadingIcon, {})
|
|
34
|
+
: ((0, jsx_runtime_1.jsxs)("form", { style: { width: '100%', maxWidth: '50rem' }, onSubmit: onSave, children: [(0, jsx_runtime_1.jsxs)(react_1.Stack, { direction: "row", spacing: 4, marginBottom: "20px", flexDir: "row-reverse", children: [(0, jsx_runtime_1.jsx)(react_1.Button, { backgroundColor: "gray.800", _hover: { backgroundColor: 'gray.600' }, type: "submit", isDisabled: isDisabled, children: isCreateMode ? 'Install' : 'Save' }), (0, jsx_runtime_1.jsx)(react_1.Button, { backgroundColor: "gray.200", color: "blackAlpha.700", _hover: { backgroundColor: 'gray.300' }, isDisabled: isDisabled, onClick: onReset, children: "Reset" })] }), (0, jsx_runtime_1.jsxs)(react_1.Box, { p: 8, width: "100%", border: "1px solid #EFEFEF", borderRadius: 8, boxShadow: "md", textAlign: ['left'], margin: "auto", bgColor: "white", maxHeight: "100%", overflowY: "scroll", children: [loading && (0, jsx_runtime_1.jsx)(LoadingIcon_1.LoadingIcon, {}), hydratedRevision && !isUninstall && !isNonConfigurableWrite && (0, jsx_runtime_1.jsx)(ReadFields_1.ReadFields, {}), hydratedRevision && !isUninstall && isNonConfigurableWrite && (0, jsx_runtime_1.jsx)(WriteFields_1.WriteFields, {}), !loading && isUninstall && (0, jsx_runtime_1.jsx)(UninstallContent_1.UninstallContent, {})] })] })));
|
|
35
|
+
}
|
|
36
|
+
exports.ConfigureInstallationBase = ConfigureInstallationBase;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateInstallation = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
/**
|
|
6
|
+
* this page is wip: untested
|
|
7
|
+
*/
|
|
8
|
+
const react_1 = require("react");
|
|
9
|
+
const ErrorContextProvider_1 = require("../../../context/ErrorContextProvider");
|
|
10
|
+
const onSaveReadCreateInstallation_1 = require("../actions/onSaveReadCreateInstallation");
|
|
11
|
+
const onSaveWriteCreateInstallation_1 = require("../actions/write/onSaveWriteCreateInstallation");
|
|
12
|
+
const constant_1 = require("../nav/ObjectManagementNav/constant");
|
|
13
|
+
const utils_1 = require("../state/utils");
|
|
14
|
+
const utils_2 = require("../utils");
|
|
15
|
+
const ConfigureInstallationBase_1 = require("./ConfigureInstallationBase");
|
|
16
|
+
const useMutateInstallation_1 = require("./useMutateInstallation");
|
|
17
|
+
// the config should be undefined for create flow
|
|
18
|
+
const UNDEFINED_CONFIG = undefined;
|
|
19
|
+
// Create Installation Flow
|
|
20
|
+
function CreateInstallation() {
|
|
21
|
+
const { integrationId, groupRef, consumerRef, setInstallation, hydratedRevision, loading, selectedObjectName, selectedConnection, apiKey, projectId, resetBoundary, setErrors, resetConfigureState, objectConfigurationsState, resetPendingConfigurationState, configureState, onInstallSuccess, } = (0, useMutateInstallation_1.useMutateInstallation)();
|
|
22
|
+
const [isLoading, setLoadingState] = (0, react_1.useState)(false);
|
|
23
|
+
// is other selected?
|
|
24
|
+
const isOtherSelected = selectedObjectName === constant_1.OTHER_CONST;
|
|
25
|
+
const resetState = (0, react_1.useCallback)(() => {
|
|
26
|
+
resetBoundary(ErrorContextProvider_1.ErrorBoundary.MAPPING);
|
|
27
|
+
if ((hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) && !loading && selectedObjectName) {
|
|
28
|
+
(0, utils_1.setHydrateConfigState)(hydratedRevision, UNDEFINED_CONFIG, selectedObjectName, resetConfigureState);
|
|
29
|
+
}
|
|
30
|
+
}, [resetBoundary, hydratedRevision, loading, selectedObjectName, resetConfigureState]);
|
|
31
|
+
(0, react_1.useEffect)(() => {
|
|
32
|
+
// set configurationState when hydratedRevision is loaded
|
|
33
|
+
if (!configureState && (hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) && !loading) {
|
|
34
|
+
resetState();
|
|
35
|
+
}
|
|
36
|
+
}, [configureState, objectConfigurationsState, hydratedRevision, loading, resetState]);
|
|
37
|
+
const onSaveRead = () => {
|
|
38
|
+
// check if fields with requirements are met
|
|
39
|
+
const { requiredMapFields, selectedFieldMappings } = (configureState === null || configureState === void 0 ? void 0 : configureState.read) || {};
|
|
40
|
+
const { errorList } = (0, utils_2.validateFieldMappings)(requiredMapFields, selectedFieldMappings, setErrors);
|
|
41
|
+
if (errorList.length > 0) {
|
|
42
|
+
return;
|
|
43
|
+
} // skip if there are errors
|
|
44
|
+
if (selectedObjectName && (selectedConnection === null || selectedConnection === void 0 ? void 0 : selectedConnection.id) && apiKey && projectId
|
|
45
|
+
&& integrationId && groupRef && consumerRef && hydratedRevision) {
|
|
46
|
+
setLoadingState(true);
|
|
47
|
+
const res = (0, onSaveReadCreateInstallation_1.onSaveReadCreateInstallation)(projectId, integrationId, groupRef, consumerRef, selectedConnection.id, selectedObjectName, apiKey, hydratedRevision, configureState, setInstallation, onInstallSuccess);
|
|
48
|
+
res.finally(() => {
|
|
49
|
+
setLoadingState(false);
|
|
50
|
+
resetPendingConfigurationState(selectedObjectName);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
console.error('CreateInstallallation - onSaveReadCreate: missing required props');
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const onSaveWrite = () => {
|
|
58
|
+
// check if fields with requirements are met
|
|
59
|
+
if (selectedObjectName && (selectedConnection === null || selectedConnection === void 0 ? void 0 : selectedConnection.id) && apiKey && projectId
|
|
60
|
+
&& integrationId && groupRef && consumerRef && hydratedRevision) {
|
|
61
|
+
setLoadingState(true);
|
|
62
|
+
const res = (0, onSaveWriteCreateInstallation_1.onSaveWriteCreateInstallation)(projectId, integrationId, groupRef, consumerRef, selectedConnection.id, apiKey, hydratedRevision, configureState, setInstallation, onInstallSuccess);
|
|
63
|
+
res.finally(() => {
|
|
64
|
+
setLoadingState(false);
|
|
65
|
+
resetPendingConfigurationState(selectedObjectName); // reset write pending/isModified state
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
console.error('CreateInstallallation - onSaveWriteCreate: missing required props');
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
const onSave = (e) => {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
if (!isOtherSelected) {
|
|
75
|
+
onSaveRead();
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
onSaveWrite();
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return ((0, jsx_runtime_1.jsx)(ConfigureInstallationBase_1.ConfigureInstallationBase, { isCreateMode: true, isLoading: isLoading, onSave: onSave, onReset: resetState }));
|
|
82
|
+
}
|
|
83
|
+
exports.CreateInstallation = CreateInstallation;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function InstallationContent(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.InstallationContent = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const InstallIntegrationContextProvider_1 = require("../../../context/InstallIntegrationContextProvider");
|
|
6
|
+
const ErrorTextBox_1 = require("../../ErrorTextBox");
|
|
7
|
+
const CreateInstallation_1 = require("./CreateInstallation");
|
|
8
|
+
const UpdateInstallation_1 = require("./UpdateInstallation");
|
|
9
|
+
function InstallationContent() {
|
|
10
|
+
const { integrationObj, installation } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
|
|
11
|
+
if (!integrationObj) {
|
|
12
|
+
return (0, jsx_runtime_1.jsx)(ErrorTextBox_1.ErrorTextBox, { message: "We can't load the integration" });
|
|
13
|
+
}
|
|
14
|
+
return installation && integrationObj ? (
|
|
15
|
+
// If installation exists, render update installation flow
|
|
16
|
+
(0, jsx_runtime_1.jsx)(UpdateInstallation_1.UpdateInstallation, { installation: installation, integrationObj: integrationObj })) : (
|
|
17
|
+
// No installation, render create installation flow
|
|
18
|
+
(0, jsx_runtime_1.jsx)(CreateInstallation_1.CreateInstallation, {}));
|
|
19
|
+
}
|
|
20
|
+
exports.InstallationContent = InstallationContent;
|
|
@@ -4,14 +4,14 @@ exports.UninstallContent = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const react_2 = require("@chakra-ui/react");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const api_1 = require("
|
|
7
|
+
const ApiKeyContextProvider_1 = require("../../../context/ApiKeyContextProvider");
|
|
8
|
+
const InstallIntegrationContextProvider_1 = require("../../../context/InstallIntegrationContextProvider");
|
|
9
|
+
const ProjectContextProvider_1 = require("../../../context/ProjectContextProvider");
|
|
10
|
+
const api_1 = require("../../../services/api");
|
|
11
11
|
function UninstallContent() {
|
|
12
|
-
const apiKey = (0,
|
|
13
|
-
const { projectId, appName } = (0,
|
|
14
|
-
const { integrationId, installation, resetInstallations } = (0,
|
|
12
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
13
|
+
const { projectId, appName } = (0, ProjectContextProvider_1.useProject)();
|
|
14
|
+
const { integrationId, installation, resetInstallations } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
|
|
15
15
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
16
16
|
const isDisabled = !projectId || !integrationId || !(installation === null || installation === void 0 ? void 0 : installation.id) || loading;
|
|
17
17
|
const onDelete = async () => {
|
|
@@ -19,7 +19,7 @@ function UninstallContent() {
|
|
|
19
19
|
setLoading(true);
|
|
20
20
|
console.warn('uninstalling installation', { projectId, integrationId, installationId: installation.id });
|
|
21
21
|
try {
|
|
22
|
-
await (0, api_1.api)().deleteInstallation({ projectId, integrationId, installationId: installation.id }, {
|
|
22
|
+
await (0, api_1.api)().installationApi.deleteInstallation({ projectId, integrationId, installationId: installation.id }, {
|
|
23
23
|
headers: {
|
|
24
24
|
'X-Api-Key': apiKey,
|
|
25
25
|
'Content-Type': 'application/json',
|
|
@@ -37,7 +37,8 @@ function UninstallContent() {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
const buttonContent = loading ? 'Uninstalling...' : 'Yes, uninstall';
|
|
40
|
-
const content = (installation === null || installation === void 0 ? void 0 : installation.id)
|
|
40
|
+
const content = (installation === null || installation === void 0 ? void 0 : installation.id)
|
|
41
|
+
? `Once you uninstall this integration, all your configuration will be lost, and "${appName}" may stop working.`
|
|
41
42
|
: "You've successfully uninstalled the integration.";
|
|
42
43
|
return ((0, jsx_runtime_1.jsxs)(react_2.Stack, { children: [(0, jsx_runtime_1.jsx)(react_2.Text, { paddingBottom: 3, children: content }), (installation === null || installation === void 0 ? void 0 : installation.id) && ((0, jsx_runtime_1.jsx)(react_2.Button, { onClick: onDelete, variant: "warning", isDisabled: isDisabled, children: buttonContent }))] }));
|
|
43
44
|
}
|
package/build/src/components/Configure/{UpdateInstallation.js → content/UpdateInstallation.js}
RENAMED
|
@@ -3,33 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.UpdateInstallation = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const HydratedRevisionContext_1 = require("./state/HydratedRevisionContext");
|
|
13
|
-
const utils_1 = require("./state/utils");
|
|
6
|
+
const ErrorContextProvider_1 = require("../../../context/ErrorContextProvider");
|
|
7
|
+
const onSaveReadUpdateInstallation_1 = require("../actions/onSaveReadUpdateInstallation");
|
|
8
|
+
const onSaveWriteUpdateInstallation_1 = require("../actions/write/onSaveWriteUpdateInstallation");
|
|
9
|
+
const constant_1 = require("../nav/ObjectManagementNav/constant");
|
|
10
|
+
const utils_1 = require("../state/utils");
|
|
11
|
+
const utils_2 = require("../utils");
|
|
14
12
|
const ConfigureInstallationBase_1 = require("./ConfigureInstallationBase");
|
|
15
|
-
const
|
|
16
|
-
const utils_2 = require("./utils");
|
|
13
|
+
const useMutateInstallation_1 = require("./useMutateInstallation");
|
|
17
14
|
// Update Installation Flow
|
|
18
15
|
function UpdateInstallation({ installation, integrationObj }) {
|
|
19
|
-
const apiKey = (0,
|
|
20
|
-
const { setInstallation } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
|
|
21
|
-
const { hydratedRevision, loading } = (0, HydratedRevisionContext_1.useHydratedRevision)();
|
|
22
|
-
const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
|
|
23
|
-
const { projectId } = (0, ProjectContext_1.useProject)();
|
|
16
|
+
const { setInstallation, hydratedRevision, loading, selectedObjectName, apiKey, projectId, resetBoundary, setErrors, resetConfigureState, resetPendingConfigurationState, configureState, onUpdateSuccess, } = (0, useMutateInstallation_1.useMutateInstallation)();
|
|
24
17
|
const [isLoading, setLoadingState] = (0, react_1.useState)(false);
|
|
18
|
+
// is other selected?
|
|
19
|
+
const isOtherSelected = selectedObjectName === constant_1.OTHER_CONST;
|
|
25
20
|
// when no installation or config exists, render create flow
|
|
26
21
|
const { config } = installation;
|
|
27
22
|
// 1. get config from installations (contains form selection state)
|
|
28
23
|
// 2. get the hydrated revision (contains full form)
|
|
29
24
|
// 3. generate the configuration state from the hydrated revision and config
|
|
30
|
-
const { resetBoundary, setErrors } = (0, ErrorContextProvider_1.useErrorState)();
|
|
31
|
-
const { resetConfigureState, objectConfigurationsState, resetPendingConfigurationState, } = (0, ConfigurationStateProvider_1.useConfigureState)();
|
|
32
|
-
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
33
25
|
const resetState = (0, react_1.useCallback)(() => {
|
|
34
26
|
resetBoundary(ErrorContextProvider_1.ErrorBoundary.MAPPING);
|
|
35
27
|
// set configurationState when hydratedRevision is loaded
|
|
@@ -42,33 +34,55 @@ function UpdateInstallation({ installation, integrationObj }) {
|
|
|
42
34
|
resetState();
|
|
43
35
|
}
|
|
44
36
|
}, [configureState, resetState]);
|
|
37
|
+
// reset state when installation (i.e. config) is reloaded.
|
|
38
|
+
(0, react_1.useEffect)(() => {
|
|
39
|
+
if (installation)
|
|
40
|
+
resetState();
|
|
41
|
+
}, [installation, resetState]);
|
|
45
42
|
const hydratedObject = (0, react_1.useMemo)(() => {
|
|
46
43
|
var _a, _b, _c;
|
|
47
44
|
const hydrated = (_c = (_b = (_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.read) === null || _b === void 0 ? void 0 : _b.standardObjects) === null || _c === void 0 ? void 0 : _c.find((obj) => (obj === null || obj === void 0 ? void 0 : obj.objectName) === selectedObjectName);
|
|
48
45
|
return hydrated;
|
|
49
46
|
}, [hydratedRevision, selectedObjectName]);
|
|
50
|
-
const
|
|
51
|
-
e.preventDefault();
|
|
47
|
+
const onSaveRead = () => {
|
|
52
48
|
// check if fields with requirements are met
|
|
53
|
-
const { requiredMapFields, selectedFieldMappings } = configureState || {};
|
|
49
|
+
const { requiredMapFields, selectedFieldMappings } = (configureState === null || configureState === void 0 ? void 0 : configureState.read) || {};
|
|
54
50
|
const { errorList } = (0, utils_2.validateFieldMappings)(requiredMapFields, selectedFieldMappings, setErrors);
|
|
55
51
|
if (errorList.length > 0) {
|
|
56
52
|
return;
|
|
57
53
|
}
|
|
58
|
-
if (installation
|
|
59
|
-
&& selectedObjectName
|
|
60
|
-
&& apiKey
|
|
61
|
-
&& projectId
|
|
62
|
-
&& hydratedObject) {
|
|
54
|
+
if (installation && selectedObjectName && apiKey && projectId && hydratedObject) {
|
|
63
55
|
setLoadingState(true);
|
|
64
|
-
const res = (0,
|
|
56
|
+
const res = (0, onSaveReadUpdateInstallation_1.onSaveReadUpdateInstallation)(projectId, integrationObj.id, installation.id, selectedObjectName, apiKey, configureState, setInstallation, hydratedObject, onUpdateSuccess);
|
|
65
57
|
res.finally(() => {
|
|
66
58
|
setLoadingState(false);
|
|
67
59
|
resetPendingConfigurationState(selectedObjectName);
|
|
68
60
|
});
|
|
69
61
|
}
|
|
70
62
|
else {
|
|
71
|
-
console.error('
|
|
63
|
+
console.error('UpdateInstallation - onSaveUpdate missing required props');
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const onSaveWrite = () => {
|
|
67
|
+
if (installation && selectedObjectName && apiKey && projectId) {
|
|
68
|
+
setLoadingState(true);
|
|
69
|
+
const res = (0, onSaveWriteUpdateInstallation_1.onSaveWriteUpdateInstallation)(projectId, integrationObj.id, installation.id, apiKey, configureState, setInstallation, onUpdateSuccess);
|
|
70
|
+
res.finally(() => {
|
|
71
|
+
setLoadingState(false);
|
|
72
|
+
resetPendingConfigurationState(selectedObjectName);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
console.error('UpdateInstallation - onSaveUpdate missing required props');
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const onSave = (e) => {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
if (!isOtherSelected) {
|
|
82
|
+
onSaveRead();
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
onSaveWrite();
|
|
72
86
|
}
|
|
73
87
|
};
|
|
74
88
|
return ((0, jsx_runtime_1.jsx)(ConfigureInstallationBase_1.ConfigureInstallationBase, { onSave: onSave, onReset: resetState, isLoading: isLoading }));
|
package/build/src/components/Configure/{fields → content/fields}/FieldMappings/FieldMapping.d.ts
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { HydratedIntegrationFieldExistent, IntegrationFieldMapping } from '
|
|
2
|
+
import { HydratedIntegrationFieldExistent, IntegrationFieldMapping } from '../../../../../services/api';
|
|
3
3
|
interface FieldMappingProps {
|
|
4
4
|
field: IntegrationFieldMapping;
|
|
5
5
|
onSelectChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
|
package/build/src/components/Configure/{fields → content/fields}/FieldMappings/FieldMapping.js
RENAMED
|
@@ -4,16 +4,13 @@ exports.FieldMapping = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const react_2 = require("@chakra-ui/react");
|
|
7
|
-
const
|
|
8
|
-
const ConfigurationStateProvider_1 = require("../../state/ConfigurationStateProvider");
|
|
9
|
-
const utils_1 = require("../../state/utils");
|
|
7
|
+
const useSelectedConfigureState_1 = require("../../useSelectedConfigureState");
|
|
10
8
|
const setFieldMapping_1 = require("./setFieldMapping");
|
|
11
9
|
function FieldMapping({ field, onSelectChange, allFields }) {
|
|
12
|
-
|
|
13
|
-
const {
|
|
10
|
+
var _a;
|
|
11
|
+
const { configureState, selectedObjectName, setConfigureState } = (0, useSelectedConfigureState_1.useSelectedConfigureState)();
|
|
14
12
|
const [disabled, setDisabled] = (0, react_1.useState)(true);
|
|
15
|
-
const
|
|
16
|
-
const { selectedFieldMappings: selectedRequiredMapFields } = configureState || {};
|
|
13
|
+
const selectedRequiredMapFields = (_a = configureState === null || configureState === void 0 ? void 0 : configureState.read) === null || _a === void 0 ? void 0 : _a.selectedFieldMappings;
|
|
17
14
|
const fieldValue = selectedRequiredMapFields === null || selectedRequiredMapFields === void 0 ? void 0 : selectedRequiredMapFields[field.mapToName];
|
|
18
15
|
(0, react_1.useEffect)(() => {
|
|
19
16
|
/* eslint no-underscore-dangle: ["error", { "allow": ["_default"] }] */
|
|
@@ -4,18 +4,14 @@ exports.RequiredFieldMappings = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("react");
|
|
6
6
|
const react_2 = require("@chakra-ui/react");
|
|
7
|
-
const ErrorContextProvider_1 = require("
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const utils_1 = require("../../state/utils");
|
|
11
|
-
const utils_2 = require("../../utils");
|
|
7
|
+
const ErrorContextProvider_1 = require("../../../../../context/ErrorContextProvider");
|
|
8
|
+
const utils_1 = require("../../../utils");
|
|
9
|
+
const useSelectedConfigureState_1 = require("../../useSelectedConfigureState");
|
|
12
10
|
const FieldHeader_1 = require("../FieldHeader");
|
|
13
11
|
const FieldMapping_1 = require("./FieldMapping");
|
|
14
12
|
const setFieldMapping_1 = require("./setFieldMapping");
|
|
15
13
|
function RequiredFieldMappings() {
|
|
16
|
-
const { selectedObjectName } = (0,
|
|
17
|
-
const { objectConfigurationsState, setConfigureState } = (0, ConfigurationStateProvider_1.useConfigureState)();
|
|
18
|
-
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
14
|
+
const { selectedObjectName, configureState, setConfigureState } = (0, useSelectedConfigureState_1.useSelectedConfigureState)();
|
|
19
15
|
const { isError, removeError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
20
16
|
const onSelectChange = (e) => {
|
|
21
17
|
const { value, name } = e.target;
|
|
@@ -31,10 +27,13 @@ function RequiredFieldMappings() {
|
|
|
31
27
|
}
|
|
32
28
|
};
|
|
33
29
|
const integrationFieldMappings = (0, react_1.useMemo)(() => {
|
|
34
|
-
var _a;
|
|
35
|
-
return ((_a = configureState === null || configureState === void 0 ? void 0 : configureState.
|
|
30
|
+
var _a, _b;
|
|
31
|
+
return ((_b = (_a = configureState === null || configureState === void 0 ? void 0 : configureState.read) === null || _a === void 0 ? void 0 : _a.requiredMapFields) === null || _b === void 0 ? void 0 : _b.filter(utils_1.isIntegrationFieldMapping)) || [];
|
|
36
32
|
}, [configureState]);
|
|
37
|
-
return (integrationFieldMappings.length ? ((0, jsx_runtime_1.jsxs)(react_2.Box, { children: [(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { string: "Map the following fields (required)" }), (0, jsx_runtime_1.jsx)(react_2.Stack, { children: integrationFieldMappings.map((field) =>
|
|
33
|
+
return (integrationFieldMappings.length ? ((0, jsx_runtime_1.jsxs)(react_2.Box, { children: [(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { string: "Map the following fields (required)" }), (0, jsx_runtime_1.jsx)(react_2.Stack, { children: integrationFieldMappings.map((field) => {
|
|
34
|
+
var _a;
|
|
35
|
+
return ((0, jsx_runtime_1.jsxs)(react_2.FormControl, { isInvalid: isError(ErrorContextProvider_1.ErrorBoundary.MAPPING, field.mapToName), children: [(0, jsx_runtime_1.jsx)(FieldMapping_1.FieldMapping, { allFields: ((_a = configureState.read) === null || _a === void 0 ? void 0 : _a.allFields) || [], field: field, onSelectChange: onSelectChange }), (0, jsx_runtime_1.jsx)(react_2.FormErrorMessage, { children: " * required" })] }, field.mapToName));
|
|
36
|
+
}) })] }))
|
|
38
37
|
: null);
|
|
39
38
|
}
|
|
40
39
|
exports.RequiredFieldMappings = RequiredFieldMappings;
|
package/build/src/components/Configure/{fields → content/fields}/FieldMappings/setFieldMapping.d.ts
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
|
-
import { ConfigureState } from '
|
|
2
|
+
import { ConfigureState } from '../../../types';
|
|
3
3
|
export declare function setFieldMapping(selectedObjectName: string, setConfigureState: (objectName: string, producer: (draft: Draft<ConfigureState>) => void) => void, fieldKey: string, newValue: string): void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setFieldMapping = void 0;
|
|
4
|
+
const utils_1 = require("../../../state/utils");
|
|
5
|
+
function setFieldMappingProducer(draft, fieldKey, newValue) {
|
|
6
|
+
var _a;
|
|
7
|
+
const draftRequiredMapFields = ((_a = draft === null || draft === void 0 ? void 0 : draft.read) === null || _a === void 0 ? void 0 : _a.selectedFieldMappings) || {};
|
|
8
|
+
draftRequiredMapFields[fieldKey] = newValue;
|
|
9
|
+
if (draft === null || draft === void 0 ? void 0 : draft.read) {
|
|
10
|
+
const savedFields = draft.read.savedConfig.requiredMapFields;
|
|
11
|
+
const updatedFields = draftRequiredMapFields;
|
|
12
|
+
const isModified = !(0, utils_1.isFieldObjectEqual)(savedFields, updatedFields);
|
|
13
|
+
// immer exception if we try to set a value
|
|
14
|
+
// eslint-disable-next-line no-param-reassign
|
|
15
|
+
draft.read.isRequiredMapFieldsModified = isModified;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function setFieldMapping(selectedObjectName, setConfigureState, fieldKey, newValue) {
|
|
19
|
+
setConfigureState(selectedObjectName, (draft) => setFieldMappingProducer(draft, fieldKey, newValue));
|
|
20
|
+
}
|
|
21
|
+
exports.setFieldMapping = setFieldMapping;
|
package/build/src/components/Configure/{fields → content/fields}/OptionalFields/OptionalFields.js
RENAMED
|
@@ -3,29 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OptionalFields = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("@chakra-ui/react");
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const ConfigurationStateProvider_1 = require("../../state/ConfigurationStateProvider");
|
|
9
|
-
const utils_1 = require("../../state/utils");
|
|
10
|
-
const utils_2 = require("../../utils");
|
|
6
|
+
const utils_1 = require("../../../utils");
|
|
7
|
+
const useSelectedConfigureState_1 = require("../../useSelectedConfigureState");
|
|
11
8
|
const FieldHeader_1 = require("../FieldHeader");
|
|
12
9
|
const setOptionalField_1 = require("./setOptionalField");
|
|
13
10
|
function OptionalFields() {
|
|
14
|
-
var _a;
|
|
15
|
-
const { appName } = (0,
|
|
16
|
-
const
|
|
17
|
-
const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
|
|
18
|
-
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
19
|
-
const { selectedOptionalFields } = configureState || {};
|
|
11
|
+
var _a, _b, _c, _d, _e;
|
|
12
|
+
const { appName, configureState, setConfigureState, selectedObjectName, } = (0, useSelectedConfigureState_1.useSelectedConfigureState)();
|
|
13
|
+
const selectedOptionalFields = (_a = configureState === null || configureState === void 0 ? void 0 : configureState.read) === null || _a === void 0 ? void 0 : _a.selectedOptionalFields;
|
|
20
14
|
const onCheckboxChange = (e) => {
|
|
21
15
|
const { name, checked } = e.target;
|
|
22
16
|
if (selectedObjectName && configureState) {
|
|
23
17
|
(0, setOptionalField_1.setOptionalField)(selectedObjectName, setConfigureState, name, checked);
|
|
24
18
|
}
|
|
25
19
|
};
|
|
26
|
-
const shouldRender = !!((configureState === null || configureState === void 0 ? void 0 : configureState.
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
const shouldRender = !!(((_b = configureState === null || configureState === void 0 ? void 0 : configureState.read) === null || _b === void 0 ? void 0 : _b.optionalFields)
|
|
21
|
+
&& ((_c = configureState === null || configureState === void 0 ? void 0 : configureState.read) === null || _c === void 0 ? void 0 : _c.optionalFields));
|
|
22
|
+
return (shouldRender && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { string: `${appName} reads the following optional fields` }), (0, jsx_runtime_1.jsx)(react_1.Stack, { marginBottom: 10, height: 300, overflowY: "scroll", border: "2px solid #EFEFEF", borderRadius: 8, padding: 4, children: (_e = (_d = configureState === null || configureState === void 0 ? void 0 : configureState.read) === null || _d === void 0 ? void 0 : _d.optionalFields) === null || _e === void 0 ? void 0 : _e.map((field) => {
|
|
23
|
+
if (!(0, utils_1.isIntegrationFieldMapping)(field)) {
|
|
29
24
|
return ((0, jsx_runtime_1.jsx)(react_1.Box, { display: "flex", gap: "5px", borderBottom: "1px", borderColor: "gray.100", children: (0, jsx_runtime_1.jsx)(react_1.Checkbox, { name: field.fieldName, id: field.fieldName, isChecked: !!(selectedOptionalFields === null || selectedOptionalFields === void 0 ? void 0 : selectedOptionalFields[field === null || field === void 0 ? void 0 : field.fieldName]), onChange: onCheckboxChange, children: field.displayName }) }, field.fieldName));
|
|
30
25
|
}
|
|
31
26
|
return null; // fallback for customed mapped fields
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { Draft } from 'immer';
|
|
2
|
-
import { ConfigureState } from '
|
|
2
|
+
import { ConfigureState } from '../../../types';
|
|
3
3
|
export declare function setOptionalField(selectedObjectName: string, setConfigureState: (objectName: string, producer: (draft: Draft<ConfigureState>) => void) => void, fieldKey: string, checked: boolean): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setOptionalField = void 0;
|
|
4
|
+
const utils_1 = require("../../../state/utils");
|
|
5
|
+
function setOptionalFieldProducer(draft, fieldKey, checked) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const draftSelectedOptionalFields = ((_a = draft === null || draft === void 0 ? void 0 : draft.read) === null || _a === void 0 ? void 0 : _a.selectedOptionalFields) || {};
|
|
8
|
+
draftSelectedOptionalFields[fieldKey] = checked;
|
|
9
|
+
if (!checked) {
|
|
10
|
+
delete draftSelectedOptionalFields[fieldKey];
|
|
11
|
+
}
|
|
12
|
+
if ((_b = draft.read) === null || _b === void 0 ? void 0 : _b.savedConfig.optionalFields) {
|
|
13
|
+
const savedFields = draft.read.savedConfig.optionalFields;
|
|
14
|
+
const updatedFields = draftSelectedOptionalFields;
|
|
15
|
+
const isModified = !(0, utils_1.isFieldObjectEqual)(savedFields, updatedFields);
|
|
16
|
+
// immer exception if we try to set a value
|
|
17
|
+
// eslint-disable-next-line no-param-reassign
|
|
18
|
+
draft.read.isOptionalFieldsModified = isModified;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.warn('read.savedConfig.optionalFields is undefined');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function setOptionalField(selectedObjectName, setConfigureState, fieldKey, checked) {
|
|
25
|
+
setConfigureState(selectedObjectName, (draft) => setOptionalFieldProducer(draft, fieldKey, checked));
|
|
26
|
+
}
|
|
27
|
+
exports.setOptionalField = setOptionalField;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function ReadFields(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReadFields = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const FieldMappings_1 = require("./FieldMappings");
|
|
6
|
+
const OptionalFields_1 = require("./OptionalFields");
|
|
7
|
+
const RequiredFields_1 = require("./RequiredFields");
|
|
8
|
+
function ReadFields() {
|
|
9
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(RequiredFields_1.RequiredFields, {}), (0, jsx_runtime_1.jsx)(FieldMappings_1.RequiredFieldMappings, {}), (0, jsx_runtime_1.jsx)(OptionalFields_1.OptionalFields, {})] }));
|
|
10
|
+
}
|
|
11
|
+
exports.ReadFields = ReadFields;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RequiredFields = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const ProjectContextProvider_1 = require("../../../../context/ProjectContextProvider");
|
|
7
|
+
const utils_1 = require("../../utils");
|
|
8
|
+
const useSelectedConfigureState_1 = require("../useSelectedConfigureState");
|
|
9
|
+
const FieldHeader_1 = require("./FieldHeader");
|
|
10
|
+
function RequiredFields() {
|
|
11
|
+
var _a, _b, _c;
|
|
12
|
+
const { configureState, selectedObjectName } = (0, useSelectedConfigureState_1.useSelectedConfigureState)();
|
|
13
|
+
const { appName } = (0, ProjectContextProvider_1.useProject)();
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { string: `${appName} reads the following ${selectedObjectName} fields` }), (0, jsx_runtime_1.jsx)(react_1.Box, { marginBottom: "20px", children: ((_b = (_a = configureState === null || configureState === void 0 ? void 0 : configureState.read) === null || _a === void 0 ? void 0 : _a.requiredFields) === null || _b === void 0 ? void 0 : _b.length)
|
|
15
|
+
? ((_c = configureState.read) === null || _c === void 0 ? void 0 : _c.requiredFields.map((field) => {
|
|
16
|
+
if (!(0, utils_1.isIntegrationFieldMapping)(field)) {
|
|
17
|
+
return (0, jsx_runtime_1.jsx)(react_1.Tag, { children: field.displayName }, field.fieldName);
|
|
18
|
+
}
|
|
19
|
+
return null; // fallback for customed mapped fields
|
|
20
|
+
}))
|
|
21
|
+
: 'There are no required fields.' })] }));
|
|
22
|
+
}
|
|
23
|
+
exports.RequiredFields = RequiredFields;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function WriteFields(): false | import("react/jsx-runtime").JSX.Element;
|