@amp-labs/react 1.0.2 → 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/README.md +1 -1
- 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/CreateInstallationRequest.d.ts +2 -2
- package/build/generated-sources/api/src/models/CreateInstallationRequest.js +2 -2
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.d.ts +3 -3
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.js +3 -4
- 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/OauthConnectRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/OauthConnectRequest.js +1 -2
- package/build/generated-sources/api/src/models/Operation.d.ts +6 -12
- package/build/generated-sources/api/src/models/Operation.js +3 -6
- 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} +15 -7
- 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/layout/ProtectedConnectionLayout.js +34 -0
- 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/NoSubdomainEntry/LandingContent.js +11 -0
- package/build/src/components/Oauth/NoSubdomainEntry/NoSubdomainOauthFlow.d.ts +16 -0
- package/build/src/components/Oauth/NoSubdomainEntry/NoSubdomainOauthFlow.js +50 -0
- package/build/src/components/Oauth/OAuthErrorAlert.d.ts +5 -0
- package/build/src/components/Oauth/OAuthErrorAlert.js +12 -0
- package/build/src/components/{Connect → Oauth}/OAuthPopup.js +8 -10
- package/build/src/components/{Salesforce → Oauth/Salesforce}/SalesforceOauthFlow.d.ts +2 -2
- package/build/src/components/Oauth/Salesforce/SalesforceOauthFlow.js +57 -0
- package/build/src/components/Oauth/Salesforce/SubdomainEntry.d.ts +8 -0
- package/build/src/components/Oauth/Salesforce/SubdomainEntry.js +12 -0
- package/build/src/components/Oauth/fetchOAuthCallbackURL.d.ts +1 -0
- package/build/src/components/Oauth/fetchOAuthCallbackURL.js +28 -0
- 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/constants.d.ts +1 -0
- package/build/src/constants.js +2 -1
- 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 +3 -3
- package/build/generated-sources/api/src/apis/DefaultApi.d.ts +0 -904
- package/build/generated-sources/api/src/apis/DefaultApi.js +0 -992
- 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 -52
- package/build/src/components/Configure/ProtectedConnectionLayout.js +0 -33
- 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/Salesforce/SalesforceOauthFlow.js +0 -89
- 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
|
@@ -4,12 +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
|
|
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");
|
|
10
11
|
function UninstallContent() {
|
|
11
|
-
const
|
|
12
|
-
const {
|
|
12
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
13
|
+
const { projectId, appName } = (0, ProjectContextProvider_1.useProject)();
|
|
14
|
+
const { integrationId, installation, resetInstallations } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
|
|
13
15
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
14
16
|
const isDisabled = !projectId || !integrationId || !(installation === null || installation === void 0 ? void 0 : installation.id) || loading;
|
|
15
17
|
const onDelete = async () => {
|
|
@@ -17,7 +19,12 @@ function UninstallContent() {
|
|
|
17
19
|
setLoading(true);
|
|
18
20
|
console.warn('uninstalling installation', { projectId, integrationId, installationId: installation.id });
|
|
19
21
|
try {
|
|
20
|
-
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
|
+
headers: {
|
|
24
|
+
'X-Api-Key': apiKey,
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
21
28
|
resetInstallations();
|
|
22
29
|
console.warn('successfully uninstalled installation: ', installation.id);
|
|
23
30
|
}
|
|
@@ -30,7 +37,8 @@ function UninstallContent() {
|
|
|
30
37
|
}
|
|
31
38
|
};
|
|
32
39
|
const buttonContent = loading ? 'Uninstalling...' : 'Yes, uninstall';
|
|
33
|
-
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.`
|
|
34
42
|
: "You've successfully uninstalled the integration.";
|
|
35
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 }))] }));
|
|
36
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;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteFields = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const useSelectedConfigureState_1 = require("../../useSelectedConfigureState");
|
|
7
|
+
const FieldHeader_1 = require("../FieldHeader");
|
|
8
|
+
const setNonConfigurableWriteField_1 = require("./setNonConfigurableWriteField");
|
|
9
|
+
function WriteFields() {
|
|
10
|
+
var _a, _b, _c, _d;
|
|
11
|
+
const { appName, selectedObjectName, configureState, setConfigureState, } = (0, useSelectedConfigureState_1.useSelectedConfigureState)();
|
|
12
|
+
const selectedWriteFields = (_a = configureState === null || configureState === void 0 ? void 0 : configureState.write) === null || _a === void 0 ? void 0 : _a.selectedNonConfigurableWriteFields;
|
|
13
|
+
const onCheckboxChange = (e) => {
|
|
14
|
+
const { name, checked } = e.target;
|
|
15
|
+
if (selectedObjectName && configureState) {
|
|
16
|
+
(0, setNonConfigurableWriteField_1.setNonConfigurableWriteField)(selectedObjectName, setConfigureState, name, checked);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const shouldRender = !!((_b = configureState === null || configureState === void 0 ? void 0 : configureState.write) === null || _b === void 0 ? void 0 : _b.writeObjects);
|
|
20
|
+
return (shouldRender && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(FieldHeader_1.FieldHeader, { string: `Allow ${appName} to write to these object` }), (0, jsx_runtime_1.jsx)(react_1.Stack, { marginBottom: 10, height: 300, overflowY: "scroll", border: "2px solid #EFEFEF", borderRadius: 8, padding: 4, children: (_d = (_c = configureState === null || configureState === void 0 ? void 0 : configureState.write) === null || _c === void 0 ? void 0 : _c.writeObjects) === null || _d === void 0 ? void 0 : _d.map((field) => ((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.objectName, id: field.objectName, onChange: onCheckboxChange, isChecked: !!(selectedWriteFields === null || selectedWriteFields === void 0 ? void 0 : selectedWriteFields[field.objectName]), children: field.displayName }) }, field.objectName))) })] })));
|
|
21
|
+
}
|
|
22
|
+
exports.WriteFields = WriteFields;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WriteFields = void 0;
|
|
4
|
+
const WriteFields_1 = require("./WriteFields");
|
|
5
|
+
Object.defineProperty(exports, "WriteFields", { enumerable: true, get: function () { return WriteFields_1.WriteFields; } });
|
package/build/src/components/Configure/content/fields/WriteFields/setNonConfigurableWriteField.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Draft } from 'immer';
|
|
2
|
+
import { ConfigureState } from '../../../types';
|
|
3
|
+
export declare function setNonConfigurableWriteField(selectedObjectName: string, setConfigureState: (objectName: string, producer: (draft: Draft<ConfigureState>) => void) => void, fieldKey: string, checked: boolean): void;
|
package/build/src/components/Configure/content/fields/WriteFields/setNonConfigurableWriteField.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setNonConfigurableWriteField = void 0;
|
|
4
|
+
const utils_1 = require("../../../state/utils");
|
|
5
|
+
function setNonConfigurableWriteFieldProducer(draft, fieldKey, checked) {
|
|
6
|
+
var _a, _b, _c;
|
|
7
|
+
if (((_a = draft === null || draft === void 0 ? void 0 : draft.write) === null || _a === void 0 ? void 0 : _a.selectedNonConfigurableWriteFields) === null) {
|
|
8
|
+
// immer syntax to set a value
|
|
9
|
+
// eslint-disable-next-line no-param-reassign
|
|
10
|
+
draft.write.selectedNonConfigurableWriteFields = {};
|
|
11
|
+
}
|
|
12
|
+
if (draft === null || draft === void 0 ? void 0 : draft.write) {
|
|
13
|
+
const draftSelectedWriteFields = draft.write.selectedNonConfigurableWriteFields;
|
|
14
|
+
draftSelectedWriteFields[fieldKey] = checked;
|
|
15
|
+
if (!checked) {
|
|
16
|
+
delete draftSelectedWriteFields[fieldKey];
|
|
17
|
+
}
|
|
18
|
+
// check is modified
|
|
19
|
+
if ((_c = (_b = draft === null || draft === void 0 ? void 0 : draft.write) === null || _b === void 0 ? void 0 : _b.savedConfig) === null || _c === void 0 ? void 0 : _c.selectedNonConfigurableWriteFields) {
|
|
20
|
+
const savedFields = draft.write.savedConfig.selectedNonConfigurableWriteFields;
|
|
21
|
+
const updatedFields = draftSelectedWriteFields;
|
|
22
|
+
const isModified = !(0, utils_1.isFieldObjectEqual)(savedFields, updatedFields);
|
|
23
|
+
// immer syntax to set a value
|
|
24
|
+
// eslint-disable-next-line no-param-reassign
|
|
25
|
+
draft.write.isWriteModified = isModified;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function setNonConfigurableWriteField(selectedObjectName, setConfigureState, fieldKey, checked) {
|
|
30
|
+
setConfigureState(selectedObjectName, (draft) => { setNonConfigurableWriteFieldProducer(draft, fieldKey, checked); });
|
|
31
|
+
}
|
|
32
|
+
exports.setNonConfigurableWriteField = setNonConfigurableWriteField;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* state hook for installation flows (Create/Update)
|
|
3
|
+
* */
|
|
4
|
+
export declare const useMutateInstallation: () => {
|
|
5
|
+
integrationId: string;
|
|
6
|
+
groupRef: string;
|
|
7
|
+
consumerRef: string;
|
|
8
|
+
setInstallation: (installationObj: import("../../../services/api").Installation) => void;
|
|
9
|
+
hydratedRevision: import("../../../services/api").HydratedRevision | null;
|
|
10
|
+
loading: boolean;
|
|
11
|
+
selectedObjectName: string | undefined;
|
|
12
|
+
selectedConnection: import("../../../services/api").Connection | null;
|
|
13
|
+
apiKey: string;
|
|
14
|
+
projectId: string;
|
|
15
|
+
resetBoundary: (boundary: import("../../../context/ErrorContextProvider").ErrorBoundary) => void;
|
|
16
|
+
setErrors: (boundary: import("../../../context/ErrorContextProvider").ErrorBoundary, keys: string[]) => void;
|
|
17
|
+
resetConfigureState: (objectName: string, configureState: import("../types").ConfigureState) => void;
|
|
18
|
+
objectConfigurationsState: import("../types").ObjectConfigurationsState;
|
|
19
|
+
resetPendingConfigurationState: (objectName: string) => void;
|
|
20
|
+
configureState: import("../types").ConfigureState;
|
|
21
|
+
onInstallSuccess: ((installationId: string, config: import("../../../services/api").Config) => void) | undefined;
|
|
22
|
+
onUpdateSuccess: ((installationId: string, config: import("../../../services/api").Config) => void) | undefined;
|
|
23
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useMutateInstallation = void 0;
|
|
4
|
+
const ApiKeyContextProvider_1 = require("../../../context/ApiKeyContextProvider");
|
|
5
|
+
const ConnectionsContextProvider_1 = require("../../../context/ConnectionsContextProvider");
|
|
6
|
+
const ErrorContextProvider_1 = require("../../../context/ErrorContextProvider");
|
|
7
|
+
const InstallIntegrationContextProvider_1 = require("../../../context/InstallIntegrationContextProvider");
|
|
8
|
+
const ProjectContextProvider_1 = require("../../../context/ProjectContextProvider");
|
|
9
|
+
const ObjectManagementNav_1 = require("../nav/ObjectManagementNav");
|
|
10
|
+
const ConfigurationStateProvider_1 = require("../state/ConfigurationStateProvider");
|
|
11
|
+
const HydratedRevisionContext_1 = require("../state/HydratedRevisionContext");
|
|
12
|
+
const utils_1 = require("../state/utils");
|
|
13
|
+
/**
|
|
14
|
+
* state hook for installation flows (Create/Update)
|
|
15
|
+
* */
|
|
16
|
+
const useMutateInstallation = () => {
|
|
17
|
+
const { integrationId, groupRef, consumerRef, setInstallation, onInstallSuccess, onUpdateSuccess, } = (0, InstallIntegrationContextProvider_1.useInstallIntegrationProps)();
|
|
18
|
+
const { hydratedRevision, loading } = (0, HydratedRevisionContext_1.useHydratedRevision)();
|
|
19
|
+
const { selectedObjectName } = (0, ObjectManagementNav_1.useSelectedObjectName)();
|
|
20
|
+
const { selectedConnection } = (0, ConnectionsContextProvider_1.useConnections)();
|
|
21
|
+
const apiKey = (0, ApiKeyContextProvider_1.useApiKey)();
|
|
22
|
+
const { projectId } = (0, ProjectContextProvider_1.useProject)();
|
|
23
|
+
const { resetBoundary, setErrors } = (0, ErrorContextProvider_1.useErrorState)();
|
|
24
|
+
const { resetConfigureState, objectConfigurationsState, resetPendingConfigurationState, } = (0, ConfigurationStateProvider_1.useObjectsConfigureState)();
|
|
25
|
+
const configureState = (0, utils_1.getConfigureState)(selectedObjectName || '', objectConfigurationsState);
|
|
26
|
+
return {
|
|
27
|
+
integrationId,
|
|
28
|
+
groupRef,
|
|
29
|
+
consumerRef,
|
|
30
|
+
setInstallation,
|
|
31
|
+
hydratedRevision,
|
|
32
|
+
loading,
|
|
33
|
+
selectedObjectName,
|
|
34
|
+
selectedConnection,
|
|
35
|
+
apiKey,
|
|
36
|
+
projectId,
|
|
37
|
+
resetBoundary,
|
|
38
|
+
setErrors,
|
|
39
|
+
resetConfigureState,
|
|
40
|
+
objectConfigurationsState,
|
|
41
|
+
resetPendingConfigurationState,
|
|
42
|
+
configureState,
|
|
43
|
+
onInstallSuccess,
|
|
44
|
+
onUpdateSuccess,
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
exports.useMutateInstallation = useMutateInstallation;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @returns {object} configureState for the selected object in nav
|
|
4
|
+
*/
|
|
5
|
+
export declare const useSelectedConfigureState: () => {
|
|
6
|
+
appName: string;
|
|
7
|
+
configureState: import("../types").ConfigureState;
|
|
8
|
+
setConfigureState: (objectName: string, producer: (draft: {
|
|
9
|
+
read: {
|
|
10
|
+
allFields: {
|
|
11
|
+
fieldName: string;
|
|
12
|
+
displayName: string;
|
|
13
|
+
}[] | null;
|
|
14
|
+
requiredFields: ({
|
|
15
|
+
fieldName: string;
|
|
16
|
+
displayName: string;
|
|
17
|
+
} | {
|
|
18
|
+
mapToName: string;
|
|
19
|
+
mapToDisplayName?: string | undefined;
|
|
20
|
+
_default?: string | undefined;
|
|
21
|
+
prompt?: string | undefined;
|
|
22
|
+
})[] | null;
|
|
23
|
+
optionalFields: ({
|
|
24
|
+
fieldName: string;
|
|
25
|
+
displayName: string;
|
|
26
|
+
} | {
|
|
27
|
+
mapToName: string;
|
|
28
|
+
mapToDisplayName?: string | undefined;
|
|
29
|
+
_default?: string | undefined;
|
|
30
|
+
prompt?: string | undefined;
|
|
31
|
+
})[] | null;
|
|
32
|
+
requiredMapFields: {
|
|
33
|
+
mapToName: string;
|
|
34
|
+
mapToDisplayName?: string | undefined;
|
|
35
|
+
_default?: string | undefined;
|
|
36
|
+
prompt?: string | undefined;
|
|
37
|
+
}[] | null;
|
|
38
|
+
selectedOptionalFields: {
|
|
39
|
+
[x: string]: boolean;
|
|
40
|
+
} | null;
|
|
41
|
+
selectedFieldMappings: {
|
|
42
|
+
[x: string]: string | undefined;
|
|
43
|
+
} | null;
|
|
44
|
+
isOptionalFieldsModified: boolean;
|
|
45
|
+
isRequiredMapFieldsModified: boolean;
|
|
46
|
+
savedConfig: {
|
|
47
|
+
optionalFields: {
|
|
48
|
+
[x: string]: boolean;
|
|
49
|
+
};
|
|
50
|
+
requiredMapFields: {
|
|
51
|
+
[x: string]: string | undefined;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
} | null;
|
|
55
|
+
write: {
|
|
56
|
+
writeObjects: {
|
|
57
|
+
objectName: string;
|
|
58
|
+
displayName: string;
|
|
59
|
+
}[] | null;
|
|
60
|
+
selectedNonConfigurableWriteFields: {
|
|
61
|
+
[x: string]: boolean;
|
|
62
|
+
} | null;
|
|
63
|
+
isWriteModified: boolean;
|
|
64
|
+
savedConfig: {
|
|
65
|
+
selectedNonConfigurableWriteFields: {
|
|
66
|
+
[x: string]: boolean;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
} | null;
|
|
70
|
+
}) => void) => void;
|
|
71
|
+
selectedObjectName: string | undefined;
|
|
72
|
+
};
|