@amp-labs/react 1.0.1 → 1.0.2
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/DefaultApi.d.ts +48 -2
- package/build/generated-sources/api/src/apis/DefaultApi.js +51 -1
- package/build/generated-sources/api/src/models/BaseConfigContent.d.ts +8 -1
- package/build/generated-sources/api/src/models/BaseConfigContent.js +4 -1
- package/build/generated-sources/api/src/models/BaseReadConfig.d.ts +1 -1
- package/build/generated-sources/api/src/models/BaseReadConfig.js +1 -1
- package/build/generated-sources/api/src/models/BaseReadConfigStandardObject.d.ts +2 -2
- package/build/generated-sources/api/src/models/BaseReadConfigStandardObject.js +1 -1
- package/build/generated-sources/api/src/models/BaseWriteConfig.d.ts +34 -0
- package/build/generated-sources/api/src/models/BaseWriteConfig.js +51 -0
- package/build/generated-sources/api/src/models/BaseWriteConfigObject.d.ts +31 -0
- package/build/generated-sources/api/src/models/BaseWriteConfigObject.js +50 -0
- package/build/generated-sources/api/src/models/BatchUpsertIntegrationsRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/BatchUpsertIntegrationsRequest.js +1 -1
- package/build/generated-sources/api/src/models/Config.d.ts +1 -1
- package/build/generated-sources/api/src/models/Config.js +1 -1
- package/build/generated-sources/api/src/models/ConfigContent.d.ts +7 -1
- package/build/generated-sources/api/src/models/ConfigContent.js +3 -1
- package/build/generated-sources/api/src/models/ConfigContentAllOf.d.ts +7 -1
- package/build/generated-sources/api/src/models/ConfigContentAllOf.js +3 -1
- package/build/generated-sources/api/src/models/Connection.d.ts +1 -1
- package/build/generated-sources/api/src/models/Connection.js +1 -1
- package/build/generated-sources/api/src/models/Consumer.d.ts +1 -1
- package/build/generated-sources/api/src/models/Consumer.js +1 -1
- package/build/generated-sources/api/src/models/CreateConsumerRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateConsumerRequest.js +1 -1
- package/build/generated-sources/api/src/models/CreateDestinationRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateDestinationRequest.js +1 -1
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateDestinationRequestMetadata.js +1 -1
- package/build/generated-sources/api/src/models/CreateGroupRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateGroupRequest.js +1 -1
- package/build/generated-sources/api/src/models/CreateInstallationRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateInstallationRequest.js +1 -1
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateInstallationRequestConfig.js +1 -1
- package/build/generated-sources/api/src/models/CreateIntegrationRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateIntegrationRequest.js +1 -1
- package/build/generated-sources/api/src/models/CreateIntegrationRequestLatestRevision.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateIntegrationRequestLatestRevision.js +1 -1
- package/build/generated-sources/api/src/models/CreateProjectRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/CreateProjectRequest.js +1 -1
- package/build/generated-sources/api/src/models/CreateProviderAppRequest.d.ts +7 -1
- package/build/generated-sources/api/src/models/CreateProviderAppRequest.js +3 -1
- package/build/generated-sources/api/src/models/Group.d.ts +1 -1
- package/build/generated-sources/api/src/models/Group.js +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegration.d.ts +8 -1
- package/build/generated-sources/api/src/models/HydratedIntegration.js +4 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationField.d.ts +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationField.js +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationFieldExistent.d.ts +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationFieldExistent.js +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationObject.d.ts +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationObject.js +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationRead.d.ts +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationRead.js +1 -1
- package/build/generated-sources/api/src/models/HydratedIntegrationWrite.d.ts +32 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationWrite.js +51 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationWriteObject.d.ts +37 -0
- package/build/generated-sources/api/src/models/HydratedIntegrationWriteObject.js +53 -0
- package/build/generated-sources/api/src/models/HydratedRevision.d.ts +1 -1
- package/build/generated-sources/api/src/models/HydratedRevision.js +1 -1
- package/build/generated-sources/api/src/models/ImportConnectionRequest.d.ts +1 -7
- package/build/generated-sources/api/src/models/ImportConnectionRequest.js +1 -4
- package/build/generated-sources/api/src/models/ImportInstallationRequest.d.ts +7 -1
- package/build/generated-sources/api/src/models/ImportInstallationRequest.js +4 -1
- package/build/generated-sources/api/src/models/ImportInstallationRequestConfig.d.ts +1 -1
- package/build/generated-sources/api/src/models/ImportInstallationRequestConfig.js +1 -1
- package/build/generated-sources/api/src/models/Installation.d.ts +1 -1
- package/build/generated-sources/api/src/models/Installation.js +1 -1
- package/build/generated-sources/api/src/models/Integration.d.ts +1 -1
- package/build/generated-sources/api/src/models/Integration.js +1 -1
- package/build/generated-sources/api/src/models/Integration1.d.ts +8 -1
- package/build/generated-sources/api/src/models/Integration1.js +4 -1
- package/build/generated-sources/api/src/models/IntegrationField.d.ts +1 -1
- package/build/generated-sources/api/src/models/IntegrationField.js +1 -1
- package/build/generated-sources/api/src/models/IntegrationFieldExistent.d.ts +1 -1
- package/build/generated-sources/api/src/models/IntegrationFieldExistent.js +1 -1
- package/build/generated-sources/api/src/models/IntegrationFieldMapping.d.ts +1 -1
- package/build/generated-sources/api/src/models/IntegrationFieldMapping.js +1 -1
- package/build/generated-sources/api/src/models/IntegrationObject.d.ts +1 -1
- package/build/generated-sources/api/src/models/IntegrationObject.js +1 -1
- package/build/generated-sources/api/src/models/IntegrationRead.d.ts +1 -1
- package/build/generated-sources/api/src/models/IntegrationRead.js +1 -1
- package/build/generated-sources/api/src/models/IntegrationWrite.d.ts +32 -0
- package/build/generated-sources/api/src/models/IntegrationWrite.js +51 -0
- package/build/generated-sources/api/src/models/IntegrationWriteObject.d.ts +31 -0
- package/build/generated-sources/api/src/models/IntegrationWriteObject.js +50 -0
- package/build/generated-sources/api/src/models/OauthConnectRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/OauthConnectRequest.js +1 -1
- package/build/generated-sources/api/src/models/Operation.d.ts +1 -1
- package/build/generated-sources/api/src/models/Operation.js +1 -1
- package/build/generated-sources/api/src/models/OperationError.d.ts +1 -1
- package/build/generated-sources/api/src/models/OperationError.js +1 -1
- package/build/generated-sources/api/src/models/OptionalFieldsAutoOption.d.ts +1 -1
- package/build/generated-sources/api/src/models/OptionalFieldsAutoOption.js +1 -1
- package/build/generated-sources/api/src/models/Project.d.ts +1 -1
- package/build/generated-sources/api/src/models/Project.js +1 -1
- package/build/generated-sources/api/src/models/ProjectMembership.d.ts +1 -1
- package/build/generated-sources/api/src/models/ProjectMembership.js +1 -1
- package/build/generated-sources/api/src/models/ProviderApp.d.ts +1 -1
- package/build/generated-sources/api/src/models/ProviderApp.js +1 -1
- package/build/generated-sources/api/src/models/Revision.d.ts +1 -1
- package/build/generated-sources/api/src/models/Revision.js +1 -1
- package/build/generated-sources/api/src/models/SignedUrl.d.ts +43 -0
- package/build/generated-sources/api/src/models/SignedUrl.js +56 -0
- package/build/generated-sources/api/src/models/UpdateInstallationConfigContent.d.ts +8 -1
- package/build/generated-sources/api/src/models/UpdateInstallationConfigContent.js +4 -1
- package/build/generated-sources/api/src/models/UpdateInstallationRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpdateInstallationRequest.js +1 -1
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallation.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallation.js +1 -1
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallationConfig.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpdateInstallationRequestInstallationConfig.js +1 -1
- package/build/generated-sources/api/src/models/UpdateProjectRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpdateProjectRequest.js +1 -1
- package/build/generated-sources/api/src/models/UpdateProjectRequestProject.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpdateProjectRequestProject.js +1 -1
- package/build/generated-sources/api/src/models/UpdateProviderAppRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpdateProviderAppRequest.js +1 -1
- package/build/generated-sources/api/src/models/UpdateProviderAppRequestProviderApp.d.ts +7 -1
- package/build/generated-sources/api/src/models/UpdateProviderAppRequestProviderApp.js +3 -1
- package/build/generated-sources/api/src/models/UpsertProjectMembershipRequest.d.ts +1 -1
- package/build/generated-sources/api/src/models/UpsertProjectMembershipRequest.js +1 -1
- package/build/generated-sources/api/src/models/index.d.ts +7 -0
- package/build/generated-sources/api/src/models/index.js +7 -0
- package/build/generated-sources/api/src/runtime.d.ts +1 -1
- package/build/generated-sources/api/src/runtime.js +1 -1
- package/build/src/assets/NavIcon.d.ts +1 -0
- package/build/src/assets/NavIcon.js +3 -2
- package/build/src/assets/TrashIcon.d.ts +1 -0
- package/build/src/assets/TrashIcon.js +9 -0
- package/build/src/components/AmpersandProvider/AmpersandProvider.js +2 -2
- package/build/src/components/Configure/ConfigureInstallationBase.js +14 -2
- package/build/src/components/Configure/CreateInstallation.js +11 -14
- package/build/src/components/Configure/InstallIntegration.js +1 -2
- package/build/src/components/Configure/ObjectManagementNav/UninstallInstallation.d.ts +7 -0
- package/build/src/components/Configure/ObjectManagementNav/UninstallInstallation.js +15 -0
- package/build/src/components/Configure/ObjectManagementNav/index.js +13 -6
- package/build/src/components/Configure/ProtectedConnectionLayout.d.ts +7 -2
- package/build/src/components/Configure/ProtectedConnectionLayout.js +10 -5
- package/build/src/components/Configure/UninstallContent.d.ts +1 -0
- package/build/src/components/Configure/UninstallContent.js +37 -0
- package/build/src/components/Configure/UpdateInstallation.js +10 -21
- package/build/src/components/Configure/fields/{FieldMapping.d.ts → FieldMappings/FieldMapping.d.ts} +2 -3
- package/build/src/components/Configure/fields/{FieldMapping.js → FieldMappings/FieldMapping.js} +12 -11
- package/build/src/components/Configure/fields/{RequiredFieldMappings.js → FieldMappings/RequiredFieldMappings.js} +9 -9
- package/build/src/components/Configure/fields/FieldMappings/index.d.ts +3 -0
- package/build/src/components/Configure/fields/FieldMappings/index.js +7 -0
- package/build/src/components/Configure/fields/FieldMappings/setFieldMapping.d.ts +3 -0
- package/build/src/components/Configure/fields/FieldMappings/setFieldMapping.js +18 -0
- package/build/src/components/Configure/fields/{OptionalFields.js → OptionalFields/OptionalFields.js} +8 -19
- package/build/src/components/Configure/fields/OptionalFields/index.d.ts +2 -0
- package/build/src/components/Configure/fields/OptionalFields/index.js +5 -0
- package/build/src/components/Configure/fields/OptionalFields/setOptionalField.d.ts +3 -0
- package/build/src/components/Configure/fields/OptionalFields/setOptionalField.js +21 -0
- package/build/src/components/Configure/state/ConfigurationStateProvider.d.ts +47 -1
- package/build/src/components/Configure/state/ConfigurationStateProvider.js +28 -6
- package/build/src/components/Configure/state/HydratedRevisionContext.js +3 -6
- package/build/src/components/Configure/state/utils.d.ts +4 -16
- package/build/src/components/Configure/state/utils.js +28 -63
- package/build/src/components/Configure/types.d.ts +6 -9
- package/build/src/components/Configure/utils.d.ts +6 -4
- package/build/src/components/Configure/utils.js +17 -16
- package/build/src/components/Connect/ConnectProvider.d.ts +9 -0
- package/build/src/components/Connect/ConnectProvider.js +18 -0
- package/build/src/components/{OAuthPopup → Connect}/OAuthPopup.js +3 -3
- package/build/src/components/Salesforce/SalesforceOauthFlow.js +41 -30
- package/build/src/components/ThemeProvider/Button/buttonTheme.d.ts +13 -0
- package/build/src/components/ThemeProvider/Button/buttonTheme.js +17 -0
- package/build/src/components/ThemeProvider/Button/index.d.ts +2 -0
- package/build/src/components/ThemeProvider/Button/index.js +5 -0
- package/build/src/components/ThemeProvider/index.js +21 -0
- package/build/src/components/index.d.ts +1 -0
- package/build/src/components/index.js +1 -0
- package/build/src/context/{ApiKeyContext.d.ts → ApiKeyProvider.d.ts} +1 -0
- package/build/src/context/ApiKeyProvider.js +14 -0
- package/build/src/context/ConnectionsContext.d.ts +5 -4
- package/build/src/context/ConnectionsContext.js +13 -5
- package/build/src/context/InstallIntegrationContext.d.ts +1 -0
- package/build/src/context/InstallIntegrationContext.js +15 -10
- package/build/src/context/IntegrationListContext.js +3 -3
- package/build/src/context/ProjectContext.js +3 -3
- package/build/src/hooks/useIsIntegrationInstalled.js +2 -2
- package/package.json +4 -3
- package/build/src/context/ApiKeyContext.js +0 -6
- /package/build/src/components/Configure/fields/{RequiredFieldMappings.d.ts → FieldMappings/RequiredFieldMappings.d.ts} +0 -0
- /package/build/src/components/Configure/fields/{OptionalFields.d.ts → OptionalFields/OptionalFields.d.ts} +0 -0
- /package/build/src/components/{OAuthPopup → Connect}/OAuthPopup.d.ts +0 -0
|
@@ -3,45 +3,35 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getConfigureState = exports.
|
|
6
|
+
exports.getConfigureState = exports.generateSelectedFieldMappingsFromConfigureState = exports.generateSelectedFieldsFromConfigureState = exports.resetAllObjectsConfigurationState = exports.setHydrateConfigState = exports.generateConfigurationState = exports.isFieldObjectEqual = void 0;
|
|
7
7
|
const lodash_isequal_1 = __importDefault(require("lodash.isequal"));
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
|
-
function createSavedFields(fields) {
|
|
10
|
-
const savedFields = {};
|
|
11
|
-
fields === null || fields === void 0 ? void 0 : fields.forEach((field) => {
|
|
12
|
-
const { value } = field;
|
|
13
|
-
if (value) {
|
|
14
|
-
savedFields[field.mapToName] = value;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
return savedFields;
|
|
18
|
-
}
|
|
19
|
-
exports.createSavedFields = createSavedFields;
|
|
20
9
|
// uses lodash deep equality check to compare two saved fields objects
|
|
21
|
-
function
|
|
10
|
+
function isFieldObjectEqual(prevFields, currentFields) {
|
|
22
11
|
return (0, lodash_isequal_1.default)(prevFields, currentFields);
|
|
23
12
|
}
|
|
24
|
-
exports.
|
|
13
|
+
exports.isFieldObjectEqual = isFieldObjectEqual;
|
|
25
14
|
function generateConfigurationState(action, objectName, config) {
|
|
26
|
-
var _a, _b, _c, _d, _e;
|
|
15
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
16
|
+
// refactor this section to be immutable at hydrated revision level
|
|
27
17
|
const object = (0, utils_1.getStandardObjectFromAction)(action, objectName);
|
|
28
18
|
const requiredFields = object && (0, utils_1.getRequiredFieldsFromObject)(object);
|
|
29
19
|
const optionalFields = object && (0, utils_1.getOptionalFieldsFromObject)(object);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const requiredMapFields = object ? (_a = (0, utils_1.getRequiredMapFieldsFromObject)(object)) === null || _a === void 0 ? void 0 : _a.map((field) => (Object.assign(Object.assign({}, field), { value: config ? (0, utils_1.getValueFromConfigCustomMapping)(config, objectName,
|
|
33
|
-
// should only use mapToName for custom mapping fields
|
|
34
|
-
(0, utils_1.getFieldKeyValue)(field)) : '' }))) : null; // type hack - TODO fix
|
|
20
|
+
const requiredMapFields = object && (0, utils_1.getRequiredMapFieldsFromObject)(object);
|
|
21
|
+
/// //////////////////////////////////////////////////////////////////////
|
|
35
22
|
const allFields = (object === null || object === void 0 ? void 0 : object.allFields) || [];
|
|
36
|
-
const selectedFields = ((
|
|
23
|
+
const selectedFields = ((_d = (_c = (_b = (_a = config === null || config === void 0 ? void 0 : config.content) === null || _a === void 0 ? void 0 : _a.read) === null || _b === void 0 ? void 0 : _b.standardObjects) === null || _c === void 0 ? void 0 : _c[objectName]) === null || _d === void 0 ? void 0 : _d.selectedFields) || {};
|
|
24
|
+
const selectedFieldMappings = ((_h = (_g = (_f = (_e = config === null || config === void 0 ? void 0 : config.content) === null || _e === void 0 ? void 0 : _e.read) === null || _f === void 0 ? void 0 : _f.standardObjects) === null || _g === void 0 ? void 0 : _g[objectName]) === null || _h === void 0 ? void 0 : _h.selectedFieldMappings) || {};
|
|
37
25
|
const optionalFieldsSaved = Object.assign({}, selectedFields);
|
|
38
|
-
const requiredMapFieldsSaved =
|
|
26
|
+
const requiredMapFieldsSaved = Object.assign({}, selectedFieldMappings);
|
|
39
27
|
return {
|
|
40
28
|
allFields,
|
|
41
29
|
requiredFields,
|
|
42
30
|
optionalFields,
|
|
43
31
|
requiredMapFields,
|
|
32
|
+
// selected state
|
|
44
33
|
selectedOptionalFields: selectedFields,
|
|
34
|
+
selectedFieldMappings,
|
|
45
35
|
isOptionalFieldsModified: false,
|
|
46
36
|
isRequiredMapFieldsModified: false,
|
|
47
37
|
savedConfig: {
|
|
@@ -52,7 +42,7 @@ function generateConfigurationState(action, objectName, config) {
|
|
|
52
42
|
}
|
|
53
43
|
exports.generateConfigurationState = generateConfigurationState;
|
|
54
44
|
// resets configure state for single object to hydrated revision values
|
|
55
|
-
const
|
|
45
|
+
const setHydrateConfigState = (hydratedRevision, config, selectedObjectName, setConfigureState) => {
|
|
56
46
|
var _a;
|
|
57
47
|
const readAction = (_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.read;
|
|
58
48
|
if (!readAction) {
|
|
@@ -61,7 +51,7 @@ const resetConfigurationState = (hydratedRevision, config, selectedObjectName, s
|
|
|
61
51
|
const state = generateConfigurationState(readAction, selectedObjectName, config);
|
|
62
52
|
setConfigureState(selectedObjectName, state);
|
|
63
53
|
};
|
|
64
|
-
exports.
|
|
54
|
+
exports.setHydrateConfigState = setHydrateConfigState;
|
|
65
55
|
/**
|
|
66
56
|
* resets configure state for all objects in hydrated revision to hydrated revision values
|
|
67
57
|
*/
|
|
@@ -98,47 +88,22 @@ exports.generateSelectedFieldsFromConfigureState = generateSelectedFieldsFromCon
|
|
|
98
88
|
* @returns
|
|
99
89
|
*/
|
|
100
90
|
const generateSelectedFieldMappingsFromConfigureState = (configureState) => {
|
|
101
|
-
const {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
* @param configureState
|
|
114
|
-
* @returns
|
|
115
|
-
*/
|
|
116
|
-
const setRequiredCustomMapFieldValue = (fieldKey, value, configureState) => {
|
|
117
|
-
const { requiredMapFields } = configureState;
|
|
118
|
-
if (requiredMapFields === null) {
|
|
119
|
-
return { isUpdated: false, newState: configureState };
|
|
120
|
-
}
|
|
121
|
-
// flag to know if field was updated
|
|
122
|
-
let isUpdated = false;
|
|
123
|
-
const updatedRequiredMapFields = requiredMapFields.map((field) => {
|
|
124
|
-
// updated field
|
|
125
|
-
if (field.mapToName === fieldKey) {
|
|
126
|
-
isUpdated = true;
|
|
127
|
-
return Object.assign(Object.assign({}, field), { value });
|
|
128
|
-
}
|
|
129
|
-
// else return a copy of the field
|
|
130
|
-
return Object.assign({}, field);
|
|
131
|
-
});
|
|
132
|
-
if (isUpdated) {
|
|
133
|
-
const savedFields = configureState.savedConfig.requiredMapFields;
|
|
134
|
-
const updatedFields = createSavedFields(updatedRequiredMapFields);
|
|
135
|
-
const isModified = !checkFieldsEquality(savedFields, updatedFields);
|
|
136
|
-
const newState = Object.assign(Object.assign({}, configureState), { requiredMapFields: updatedRequiredMapFields, isRequiredMapFieldsModified: isModified });
|
|
137
|
-
return { isUpdated, newState };
|
|
91
|
+
const { selectedFieldMappings: selectedRequiredMapFields } = configureState;
|
|
92
|
+
// filter out undefined values of selectedRequiredMapFields
|
|
93
|
+
const selectedRequiredMapFieldsSubmit = {};
|
|
94
|
+
if (selectedRequiredMapFields) {
|
|
95
|
+
Object.keys(selectedRequiredMapFields).forEach((key) => {
|
|
96
|
+
if (selectedRequiredMapFields[key] !== undefined) {
|
|
97
|
+
selectedRequiredMapFieldsSubmit[key] = selectedRequiredMapFields[key] || '';
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
console.warn(`Error undefined when generating selectedRequiredMapFieldsSubmit for key: ${key}`);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
138
103
|
}
|
|
139
|
-
return
|
|
104
|
+
return selectedRequiredMapFieldsSubmit;
|
|
140
105
|
};
|
|
141
|
-
exports.
|
|
106
|
+
exports.generateSelectedFieldMappingsFromConfigureState = generateSelectedFieldMappingsFromConfigureState;
|
|
142
107
|
// get configure state of single object
|
|
143
108
|
function getConfigureState(objectName, objectConfigurationsState) {
|
|
144
109
|
return objectConfigurationsState[objectName] || undefined;
|
|
@@ -1,24 +1,21 @@
|
|
|
1
1
|
import { HydratedIntegrationField, HydratedIntegrationFieldExistent, IntegrationFieldMapping } from '../../services/api';
|
|
2
|
-
export type ConfigureStateIntegrationField = HydratedIntegrationFieldExistent & {
|
|
3
|
-
value: string | number | boolean | null;
|
|
4
|
-
};
|
|
5
|
-
export type ConfigureStateMappingIntegrationField = IntegrationFieldMapping & {
|
|
6
|
-
value: string | number | undefined;
|
|
7
|
-
};
|
|
8
2
|
export type SelectOptionalFields = {
|
|
9
3
|
[key: string]: boolean;
|
|
10
4
|
};
|
|
11
|
-
export type
|
|
5
|
+
export type SelectMappingFields = {
|
|
6
|
+
[key: string]: string | undefined;
|
|
7
|
+
};
|
|
12
8
|
type SavedConfigureState = {
|
|
13
9
|
optionalFields: SelectOptionalFields;
|
|
14
|
-
requiredMapFields:
|
|
10
|
+
requiredMapFields: SelectMappingFields;
|
|
15
11
|
};
|
|
16
12
|
export type ConfigureState = {
|
|
17
13
|
allFields: HydratedIntegrationFieldExistent[] | null;
|
|
18
14
|
requiredFields: HydratedIntegrationField[] | null;
|
|
19
15
|
optionalFields: HydratedIntegrationField[] | null;
|
|
20
|
-
requiredMapFields:
|
|
16
|
+
requiredMapFields: IntegrationFieldMapping[] | null;
|
|
21
17
|
selectedOptionalFields: SelectOptionalFields | null;
|
|
18
|
+
selectedFieldMappings: SelectMappingFields | null;
|
|
22
19
|
isOptionalFieldsModified: boolean;
|
|
23
20
|
isRequiredMapFieldsModified: boolean;
|
|
24
21
|
savedConfig: SavedConfigureState;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { ErrorBoundary } from '../../context/ErrorContextProvider';
|
|
1
2
|
import { Config, HydratedIntegrationField, HydratedIntegrationObject, HydratedIntegrationRead, HydratedRevision, IntegrationFieldMapping } from '../../services/api';
|
|
2
|
-
import { NavObject } from './types';
|
|
3
|
+
import { NavObject, SelectMappingFields } from './types';
|
|
3
4
|
/**
|
|
4
5
|
* type guard for IntegrationFieldMapping | IntegrationFieldExistent
|
|
5
6
|
*
|
|
@@ -15,10 +16,11 @@ export declare function isIntegrationFieldMapping(field: HydratedIntegrationFiel
|
|
|
15
16
|
*/
|
|
16
17
|
export declare function getStandardObjectFromAction(action: HydratedIntegrationRead, objectName: string): HydratedIntegrationObject | null;
|
|
17
18
|
export declare function getRequiredFieldsFromObject(object: HydratedIntegrationObject): HydratedIntegrationField[] | null;
|
|
18
|
-
export declare function getRequiredMapFieldsFromObject(object: HydratedIntegrationObject):
|
|
19
|
+
export declare function getRequiredMapFieldsFromObject(object: HydratedIntegrationObject): IntegrationFieldMapping[] | null;
|
|
19
20
|
export declare function getOptionalFieldsFromObject(object: HydratedIntegrationObject): HydratedIntegrationField[] | null;
|
|
20
21
|
export declare const getReadObject: (config: Config, objectName: string) => any;
|
|
21
|
-
export declare function getValueFromConfigExist(config: Config, objectName: string, key: string): boolean;
|
|
22
|
-
export declare function getValueFromConfigCustomMapping(config: Config, objectName: string, key: string): string;
|
|
23
22
|
export declare function getFieldKeyValue(field: HydratedIntegrationField): string;
|
|
24
23
|
export declare function generateNavObjects(config: Config | undefined, hydratedRevision: HydratedRevision): NavObject[];
|
|
24
|
+
export declare function validateFieldMappings(requiredMapFields: IntegrationFieldMapping[] | null, selectedRequiredMapFields: SelectMappingFields | null, setErrors: (boundary: ErrorBoundary, errors: string[]) => void): {
|
|
25
|
+
errorList: string[];
|
|
26
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.validateFieldMappings = exports.generateNavObjects = exports.getFieldKeyValue = exports.getReadObject = exports.getOptionalFieldsFromObject = exports.getRequiredMapFieldsFromObject = exports.getRequiredFieldsFromObject = exports.getStandardObjectFromAction = exports.isIntegrationFieldMapping = void 0;
|
|
4
|
+
const ErrorContextProvider_1 = require("../../context/ErrorContextProvider");
|
|
4
5
|
/**
|
|
5
6
|
* type guard for IntegrationFieldMapping | IntegrationFieldExistent
|
|
6
7
|
*
|
|
@@ -32,7 +33,8 @@ exports.getRequiredFieldsFromObject = getRequiredFieldsFromObject;
|
|
|
32
33
|
// 2b. get required custom mapping fields
|
|
33
34
|
function getRequiredMapFieldsFromObject(object) {
|
|
34
35
|
var _a;
|
|
35
|
-
|
|
36
|
+
const requiredMapFields = ((_a = object === null || object === void 0 ? void 0 : object.requiredFields) === null || _a === void 0 ? void 0 : _a.filter((rf) => isIntegrationFieldMapping(rf) && !!rf.mapToName)) || [];
|
|
37
|
+
return requiredMapFields; // type hack
|
|
36
38
|
}
|
|
37
39
|
exports.getRequiredMapFieldsFromObject = getRequiredMapFieldsFromObject;
|
|
38
40
|
// 3. get optional fields
|
|
@@ -43,20 +45,6 @@ function getOptionalFieldsFromObject(object) {
|
|
|
43
45
|
exports.getOptionalFieldsFromObject = getOptionalFieldsFromObject;
|
|
44
46
|
const getReadObject = (config, objectName) => { var _a, _b, _c; return (_c = (_b = (_a = config === null || config === void 0 ? void 0 : config.content) === null || _a === void 0 ? void 0 : _a.read) === null || _b === void 0 ? void 0 : _b.standardObjects) === null || _c === void 0 ? void 0 : _c[objectName]; };
|
|
45
47
|
exports.getReadObject = getReadObject;
|
|
46
|
-
// 4a. get value for field
|
|
47
|
-
function getValueFromConfigExist(config, objectName, key) {
|
|
48
|
-
var _a;
|
|
49
|
-
const object = (0, exports.getReadObject)(config, objectName);
|
|
50
|
-
return ((_a = object === null || object === void 0 ? void 0 : object.selectedFields) === null || _a === void 0 ? void 0 : _a[key]) || false;
|
|
51
|
-
}
|
|
52
|
-
exports.getValueFromConfigExist = getValueFromConfigExist;
|
|
53
|
-
// 4b. get value for custom mapping field
|
|
54
|
-
function getValueFromConfigCustomMapping(config, objectName, key) {
|
|
55
|
-
var _a;
|
|
56
|
-
const object = (0, exports.getReadObject)(config, objectName);
|
|
57
|
-
return ((_a = object === null || object === void 0 ? void 0 : object.selectedFieldMappings) === null || _a === void 0 ? void 0 : _a[key]) || '';
|
|
58
|
-
}
|
|
59
|
-
exports.getValueFromConfigCustomMapping = getValueFromConfigCustomMapping;
|
|
60
48
|
// aux. get field value based on type guard
|
|
61
49
|
function getFieldKeyValue(field) {
|
|
62
50
|
if (isIntegrationFieldMapping(field)) {
|
|
@@ -80,3 +68,16 @@ function generateNavObjects(config, hydratedRevision) {
|
|
|
80
68
|
return navObjects;
|
|
81
69
|
}
|
|
82
70
|
exports.generateNavObjects = generateNavObjects;
|
|
71
|
+
// validates whether required fields are filled out or throws error
|
|
72
|
+
function validateFieldMappings(requiredMapFields, selectedRequiredMapFields, setErrors) {
|
|
73
|
+
// check if fields with requirements are met
|
|
74
|
+
const fieldsWithRequirementsNotMet = (requiredMapFields === null || requiredMapFields === void 0 ? void 0 : requiredMapFields.filter((field) => !(selectedRequiredMapFields === null || selectedRequiredMapFields === void 0 ? void 0 : selectedRequiredMapFields[field === null || field === void 0 ? void 0 : field.mapToName]))) || [];
|
|
75
|
+
const errorList = fieldsWithRequirementsNotMet.map((field) => field.mapToName);
|
|
76
|
+
setErrors(ErrorContextProvider_1.ErrorBoundary.MAPPING, errorList);
|
|
77
|
+
// if requires fields are not met, set error fields and return
|
|
78
|
+
if (fieldsWithRequirementsNotMet === null || fieldsWithRequirementsNotMet === void 0 ? void 0 : fieldsWithRequirementsNotMet.length) {
|
|
79
|
+
console.error('required fields not met', fieldsWithRequirementsNotMet.map((field) => field.mapToDisplayName));
|
|
80
|
+
}
|
|
81
|
+
return { errorList };
|
|
82
|
+
}
|
|
83
|
+
exports.validateFieldMappings = validateFieldMappings;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
interface ConnectProviderProps {
|
|
2
|
+
provider: string;
|
|
3
|
+
consumerRef: string;
|
|
4
|
+
consumerName?: string;
|
|
5
|
+
groupRef: string;
|
|
6
|
+
groupName?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function ConnectProvider({ provider, consumerRef, consumerName, groupRef, groupName, }: ConnectProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConnectProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const NavIcon_1 = require("../../assets/NavIcon");
|
|
7
|
+
const ConnectionsContext_1 = require("../../context/ConnectionsContext");
|
|
8
|
+
const ProjectContext_1 = require("../../context/ProjectContext");
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
10
|
+
const ProtectedConnectionLayout_1 = require("../Configure/ProtectedConnectionLayout");
|
|
11
|
+
function ConnectedSuccessBox({ provider }) {
|
|
12
|
+
const { appName } = (0, ProjectContext_1.useProject)();
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsxs)(react_1.Box, { p: 8, maxWidth: "600px", minHeight: "290px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", margin: "auto", marginTop: "40px", bgColor: "white", paddingTop: "100px", children: [(0, jsx_runtime_1.jsx)(react_1.Box, { width: "100%", display: "flex", alignContent: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(react_1.Box, { margin: "auto", children: NavIcon_1.CheckMarkIcon }) }), (0, jsx_runtime_1.jsx)(react_1.Box, { textAlign: "center", paddingTop: "25px", children: `You've successfully connected ${(0, utils_1.capitalize)(provider)} to ${appName}.` })] }) }));
|
|
14
|
+
}
|
|
15
|
+
function ConnectProvider({ provider, consumerRef, consumerName, groupRef, groupName, }) {
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(ConnectionsContext_1.ConnectionsProvider, { provider: provider, groupRef: groupRef, children: (0, jsx_runtime_1.jsx)(ProtectedConnectionLayout_1.ProtectedConnectionLayout, { provider: provider, consumerRef: consumerRef, consumerName: consumerName, groupRef: groupRef, groupName: groupName, children: (0, jsx_runtime_1.jsx)(ConnectedSuccessBox, { provider: provider }) }) }));
|
|
17
|
+
}
|
|
18
|
+
exports.ConnectProvider = ConnectProvider;
|
|
@@ -7,7 +7,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
7
7
|
* Takes a URL and creates a popup showing that page.
|
|
8
8
|
*/
|
|
9
9
|
const react_1 = require("react");
|
|
10
|
-
const
|
|
10
|
+
const ApiKeyProvider_1 = require("../../context/ApiKeyProvider");
|
|
11
11
|
const ConnectionsContext_1 = require("../../context/ConnectionsContext");
|
|
12
12
|
const ProjectContext_1 = require("../../context/ProjectContext");
|
|
13
13
|
const api_1 = require("../../services/api");
|
|
@@ -23,12 +23,12 @@ const createPopup = ({ url, title, }) => {
|
|
|
23
23
|
return popup;
|
|
24
24
|
};
|
|
25
25
|
function OAuthPopup({ title = '', url, children, onClose, }) {
|
|
26
|
+
const { projectId } = (0, ProjectContext_1.useProject)();
|
|
27
|
+
const apiKey = (0, ApiKeyProvider_1.useApiKey)();
|
|
26
28
|
const [externalWindow, setExternalWindow] = (0, react_1.useState)();
|
|
27
29
|
const intervalRef = (0, react_1.useRef)();
|
|
28
30
|
const clearTimer = () => window.clearInterval(intervalRef.current);
|
|
29
31
|
const { setSelectedConnection } = (0, ConnectionsContext_1.useConnections)();
|
|
30
|
-
const { projectId } = (0, ProjectContext_1.useProject)();
|
|
31
|
-
const apiKey = (0, react_1.useContext)(ApiKeyContext_1.ApiKeyContext);
|
|
32
32
|
(0, react_1.useEffect)(() => {
|
|
33
33
|
if (url)
|
|
34
34
|
setExternalWindow(createPopup({ url, title }));
|
|
@@ -12,54 +12,63 @@ const react_1 = require("react");
|
|
|
12
12
|
const icons_1 = require("@chakra-ui/icons");
|
|
13
13
|
const react_2 = require("@chakra-ui/react");
|
|
14
14
|
const constants_1 = require("../../constants");
|
|
15
|
-
const
|
|
15
|
+
const ApiKeyProvider_1 = require("../../context/ApiKeyProvider");
|
|
16
16
|
const ProjectContext_1 = require("../../context/ProjectContext");
|
|
17
17
|
const api_1 = require("../../services/api");
|
|
18
|
-
const OAuthPopup_1 = __importDefault(require("../
|
|
18
|
+
const OAuthPopup_1 = __importDefault(require("../Connect/OAuthPopup"));
|
|
19
19
|
function OAuthErrorAlert({ error }) {
|
|
20
20
|
if (error) {
|
|
21
21
|
return ((0, jsx_runtime_1.jsxs)(react_2.Alert, { status: "error", marginTop: "2em", children: [(0, jsx_runtime_1.jsx)(react_2.AlertIcon, {}), (0, jsx_runtime_1.jsx)(react_2.AlertDescription, { children: error })] }));
|
|
22
22
|
}
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
+
const SALESFORCE_HELP_URL = 'https://help.salesforce.com/articleView?id=domain_name_not_found.htm&type=5';
|
|
26
|
+
function SubdomainEntry({ handleSubmit, setWorkspace, error, isButtonDisabled, }) {
|
|
27
|
+
return ((0, jsx_runtime_1.jsx)(react_2.Container, { children: (0, jsx_runtime_1.jsx)(react_2.Box, { p: 8, maxWidth: "600px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", textAlign: ['left'], margin: "auto", marginTop: "40px", bgColor: "white", children: (0, jsx_runtime_1.jsxs)(react_2.FormControl, { children: [(0, jsx_runtime_1.jsx)(react_2.FormLabel, { marginTop: "16", marginBottom: "0", children: (0, jsx_runtime_1.jsx)(react_2.Heading, { as: "h4", size: "md", children: "Enter your Salesforce subdomain" }) }), (0, jsx_runtime_1.jsxs)(react_2.Link, { href: SALESFORCE_HELP_URL, color: "blackAlpha.600", isExternal: true, children: ["What is my Salesforce subdomain?", (0, jsx_runtime_1.jsx)(icons_1.ExternalLinkIcon, { mx: "2px" })] }), (0, jsx_runtime_1.jsx)(OAuthErrorAlert, { error: error }), (0, jsx_runtime_1.jsxs)(react_2.Flex, { marginTop: "1em", children: [(0, jsx_runtime_1.jsx)(react_2.Input, { placeholder: "MyDomain", onChange: (event) => setWorkspace(event.currentTarget.value) }), (0, jsx_runtime_1.jsx)(react_2.Text, { lineHeight: "2.2em", marginLeft: "0.4em", children: ".my.salesforce.com" })] }), (0, jsx_runtime_1.jsx)("br", {}), (0, jsx_runtime_1.jsx)(react_2.Button, { isDisabled: isButtonDisabled, width: "100%", type: "submit", onClick: handleSubmit, children: "Next" })] }) }) }));
|
|
28
|
+
}
|
|
29
|
+
const fetchOAuthCallbackURL = async (projectId, workspace, consumerRef, groupRef, consumerName, groupName, apiKey, provider = constants_1.PROVIDER_SALESFORCE) => {
|
|
30
|
+
const providerApps = await (0, api_1.api)().listProviderApps({ projectId }, {
|
|
31
|
+
headers: { 'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '' },
|
|
32
|
+
});
|
|
33
|
+
const app = providerApps.find((a) => a.provider === provider);
|
|
34
|
+
if (!app) {
|
|
35
|
+
throw new Error(`You must first set up a ${provider} Connected App using the Ampersand Console.`);
|
|
36
|
+
}
|
|
37
|
+
const url = await (0, api_1.api)().oauthConnect({
|
|
38
|
+
connectOAuthParams: {
|
|
39
|
+
providerWorkspaceRef: workspace,
|
|
40
|
+
projectId,
|
|
41
|
+
groupRef,
|
|
42
|
+
groupName,
|
|
43
|
+
consumerRef,
|
|
44
|
+
consumerName,
|
|
45
|
+
providerAppId: app.id,
|
|
46
|
+
provider,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return url;
|
|
50
|
+
};
|
|
25
51
|
/**
|
|
26
52
|
* SalesforceOauthFlow first prompts user for their workspace ("subdomain" in Salesforce lingo),
|
|
27
53
|
* then launches a popup with the OAuth flow.
|
|
28
54
|
*/
|
|
29
55
|
function SalesforceOauthFlow({ consumerRef, consumerName, groupRef, groupName, }) {
|
|
56
|
+
const { projectId } = (0, ProjectContext_1.useProject)();
|
|
57
|
+
const apiKey = (0, ApiKeyProvider_1.useApiKey)();
|
|
30
58
|
const [workspace, setWorkspace] = (0, react_1.useState)('');
|
|
31
59
|
const [oAuthCallbackURL, setOAuthCallbackURL] = (0, react_1.useState)(null);
|
|
32
60
|
const [error, setError] = (0, react_1.useState)(null);
|
|
33
|
-
const
|
|
34
|
-
const
|
|
61
|
+
const isButtonDisabled = workspace.length === 0;
|
|
62
|
+
const provider = constants_1.PROVIDER_SALESFORCE;
|
|
63
|
+
// 1. fetch provider apps
|
|
64
|
+
// 2. find matching app to provider
|
|
65
|
+
// 3. fetch OAuth callback URL from connection so that oath popup can be launched
|
|
35
66
|
const handleSubmit = async () => {
|
|
36
67
|
var _a;
|
|
37
68
|
setError(null);
|
|
38
|
-
if (workspace) {
|
|
69
|
+
if (workspace && consumerName && groupName && apiKey) {
|
|
39
70
|
try {
|
|
40
|
-
const
|
|
41
|
-
projectId,
|
|
42
|
-
}, {
|
|
43
|
-
headers: {
|
|
44
|
-
'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '',
|
|
45
|
-
},
|
|
46
|
-
});
|
|
47
|
-
const app = providerApps.find((a) => a.provider === constants_1.PROVIDER_SALESFORCE);
|
|
48
|
-
if (!app) {
|
|
49
|
-
throw new Error('You must first set up a Salesforce Connected App using the Ampersand Console.');
|
|
50
|
-
}
|
|
51
|
-
const url = await (0, api_1.api)().oauthConnect({
|
|
52
|
-
connectOAuthParams: {
|
|
53
|
-
providerWorkspaceRef: workspace,
|
|
54
|
-
projectId,
|
|
55
|
-
groupRef,
|
|
56
|
-
groupName,
|
|
57
|
-
consumerRef,
|
|
58
|
-
consumerName,
|
|
59
|
-
providerAppId: app.id,
|
|
60
|
-
provider: constants_1.PROVIDER_SALESFORCE,
|
|
61
|
-
},
|
|
62
|
-
});
|
|
71
|
+
const url = await fetchOAuthCallbackURL(projectId, workspace, consumerRef, groupRef, consumerName, groupName, apiKey, provider);
|
|
63
72
|
setOAuthCallbackURL(url);
|
|
64
73
|
}
|
|
65
74
|
catch (err) {
|
|
@@ -67,12 +76,14 @@ function SalesforceOauthFlow({ consumerRef, consumerName, groupRef, groupName, }
|
|
|
67
76
|
setError((_a = err.message) !== null && _a !== void 0 ? _a : 'Unexpected error');
|
|
68
77
|
}
|
|
69
78
|
}
|
|
79
|
+
else {
|
|
80
|
+
setError('missing required fields');
|
|
81
|
+
}
|
|
70
82
|
};
|
|
71
83
|
const onClose = (0, react_1.useCallback)((err) => {
|
|
72
84
|
setError(err);
|
|
73
85
|
setOAuthCallbackURL(null);
|
|
74
86
|
}, []);
|
|
75
|
-
|
|
76
|
-
return ((0, jsx_runtime_1.jsx)(OAuthPopup_1.default, { title: "Connect to Salesforce", url: oAuthCallbackURL, onClose: onClose, children: SubdomainEntry }));
|
|
87
|
+
return ((0, jsx_runtime_1.jsx)(OAuthPopup_1.default, { title: "Connect to Salesforce", url: oAuthCallbackURL, onClose: onClose, children: (0, jsx_runtime_1.jsx)(SubdomainEntry, { handleSubmit: handleSubmit, setWorkspace: setWorkspace, error: error, isButtonDisabled: isButtonDisabled }) }));
|
|
77
88
|
}
|
|
78
89
|
exports.default = SalesforceOauthFlow;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buttonVariants = void 0;
|
|
4
|
+
// define custom button variants
|
|
5
|
+
exports.buttonVariants = {
|
|
6
|
+
warning: {
|
|
7
|
+
bg: 'red.50',
|
|
8
|
+
outlineColor: 'red.800',
|
|
9
|
+
outline: '2px solid',
|
|
10
|
+
outlineOffset: '0',
|
|
11
|
+
borderColor: 'red.800',
|
|
12
|
+
color: 'red.800',
|
|
13
|
+
_hover: {
|
|
14
|
+
bg: 'red.100', // Background color on hover
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buttonVariants = void 0;
|
|
4
|
+
const buttonTheme_1 = require("./buttonTheme");
|
|
5
|
+
Object.defineProperty(exports, "buttonVariants", { enumerable: true, get: function () { return buttonTheme_1.buttonVariants; } });
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ThemeProvider = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("@chakra-ui/react");
|
|
6
|
+
const Button_1 = require("./Button");
|
|
6
7
|
const customTheme = (0, react_1.extendTheme)({
|
|
7
8
|
components: {
|
|
8
9
|
Tabs: {
|
|
@@ -23,8 +24,28 @@ const customTheme = (0, react_1.extendTheme)({
|
|
|
23
24
|
},
|
|
24
25
|
},
|
|
25
26
|
},
|
|
27
|
+
// consider creating a warning variant tab
|
|
28
|
+
warningTab: {
|
|
29
|
+
width: '100%',
|
|
30
|
+
borderRadius: '4px',
|
|
31
|
+
_hover: {
|
|
32
|
+
bg: 'red.200',
|
|
33
|
+
},
|
|
34
|
+
_selected: {
|
|
35
|
+
color: 'red.800',
|
|
36
|
+
fontWeight: '500',
|
|
37
|
+
bg: 'red.100',
|
|
38
|
+
border: 'none',
|
|
39
|
+
_hover: {
|
|
40
|
+
bg: 'red.200',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
26
44
|
},
|
|
27
45
|
},
|
|
46
|
+
Button: {
|
|
47
|
+
variants: Button_1.buttonVariants,
|
|
48
|
+
},
|
|
28
49
|
},
|
|
29
50
|
});
|
|
30
51
|
const theme = (0, react_1.extendTheme)((0, react_1.withDefaultColorScheme)({
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./AmpersandProvider"), exports);
|
|
18
18
|
__exportStar(require("./Configure"), exports);
|
|
19
|
+
__exportStar(require("./Connect/ConnectProvider"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useApiKey = exports.ApiKeyProvider = exports.ApiKeyContext = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
exports.ApiKeyContext = (0, react_1.createContext)(null);
|
|
6
|
+
exports.ApiKeyProvider = exports.ApiKeyContext.Provider;
|
|
7
|
+
const useApiKey = () => {
|
|
8
|
+
const apiKey = (0, react_1.useContext)(exports.ApiKeyContext);
|
|
9
|
+
if (apiKey === null) {
|
|
10
|
+
throw new Error('useApiKey must be used within an ApiKeyProvider');
|
|
11
|
+
}
|
|
12
|
+
return apiKey;
|
|
13
|
+
};
|
|
14
|
+
exports.useApiKey = useApiKey;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { Connection } from '../services/api';
|
|
3
3
|
interface ConnectionsContextValue {
|
|
4
4
|
connections: Connection[] | null;
|
|
@@ -6,11 +6,12 @@ interface ConnectionsContextValue {
|
|
|
6
6
|
setConnections: React.Dispatch<React.SetStateAction<Connection[] | null>>;
|
|
7
7
|
setSelectedConnection: React.Dispatch<React.SetStateAction<Connection | null>>;
|
|
8
8
|
}
|
|
9
|
-
export declare const ConnectionsContext:
|
|
9
|
+
export declare const ConnectionsContext: import("react").Context<ConnectionsContextValue>;
|
|
10
10
|
export declare const useConnections: () => ConnectionsContextValue;
|
|
11
11
|
type ConnectionsProviderProps = {
|
|
12
|
-
|
|
12
|
+
provider?: string;
|
|
13
|
+
groupRef: string;
|
|
13
14
|
children?: React.ReactNode;
|
|
14
15
|
};
|
|
15
|
-
export declare function ConnectionsProvider({
|
|
16
|
+
export declare function ConnectionsProvider({ provider, groupRef, children, }: ConnectionsProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
16
17
|
export {};
|
|
@@ -6,9 +6,10 @@ const react_1 = require("react");
|
|
|
6
6
|
const LoadingIcon_1 = require("../assets/LoadingIcon");
|
|
7
7
|
const ErrorTextBox_1 = require("../components/Configure/ErrorTextBox");
|
|
8
8
|
const api_1 = require("../services/api");
|
|
9
|
-
const
|
|
9
|
+
const ApiKeyProvider_1 = require("./ApiKeyProvider");
|
|
10
10
|
const ErrorContextProvider_1 = require("./ErrorContextProvider");
|
|
11
11
|
const InstallIntegrationContext_1 = require("./InstallIntegrationContext");
|
|
12
|
+
const ProjectContext_1 = require("./ProjectContext");
|
|
12
13
|
exports.ConnectionsContext = (0, react_1.createContext)({
|
|
13
14
|
connections: null,
|
|
14
15
|
selectedConnection: null,
|
|
@@ -18,18 +19,25 @@ exports.ConnectionsContext = (0, react_1.createContext)({
|
|
|
18
19
|
const useConnections = () => {
|
|
19
20
|
const context = (0, react_1.useContext)(exports.ConnectionsContext);
|
|
20
21
|
if (!context) {
|
|
21
|
-
throw new Error('useConnections must be used within a
|
|
22
|
+
throw new Error('useConnections must be used within a ConnectionsProvider');
|
|
22
23
|
}
|
|
23
24
|
return context;
|
|
24
25
|
};
|
|
25
26
|
exports.useConnections = useConnections;
|
|
26
|
-
function ConnectionsProvider({
|
|
27
|
-
const
|
|
27
|
+
function ConnectionsProvider({ provider, groupRef, children, }) {
|
|
28
|
+
const apiKey = (0, ApiKeyProvider_1.useApiKey)();
|
|
29
|
+
const { projectId } = (0, ProjectContext_1.useProject)();
|
|
28
30
|
const [connections, setConnections] = (0, react_1.useState)(null);
|
|
29
31
|
const [selectedConnection, setSelectedConnection] = (0, react_1.useState)(null);
|
|
30
|
-
const apiKey = (0, react_1.useContext)(ApiKeyContext_1.ApiKeyContext);
|
|
31
32
|
const [isLoading, setLoadingState] = (0, react_1.useState)(true);
|
|
32
33
|
const { setError, isError } = (0, ErrorContextProvider_1.useErrorState)();
|
|
34
|
+
const { provider: providerFromProps } = (0, InstallIntegrationContext_1.useInstallIntegrationProps)();
|
|
35
|
+
if (!projectId) {
|
|
36
|
+
throw new Error('ConnectionsProvider must be used within AmpersandProvider');
|
|
37
|
+
}
|
|
38
|
+
if (!provider && !providerFromProps) {
|
|
39
|
+
throw new Error('ConnectionsProvider must be given a provider prop or be used within InstallIntegrationProvider');
|
|
40
|
+
}
|
|
33
41
|
(0, react_1.useEffect)(() => {
|
|
34
42
|
(0, api_1.api)().listConnections({ projectId, groupRef, provider }, {
|
|
35
43
|
headers: {
|
|
@@ -10,6 +10,7 @@ interface InstallIntegrationContextValue {
|
|
|
10
10
|
groupName?: string;
|
|
11
11
|
installation?: Installation;
|
|
12
12
|
setInstallation: (installationObj: Installation) => void;
|
|
13
|
+
resetInstallations: () => void;
|
|
13
14
|
}
|
|
14
15
|
export declare function useInstallIntegrationProps(): InstallIntegrationContextValue;
|
|
15
16
|
interface InstallIntegrationProviderProps {
|