@amp-labs/react 1.4.0 → 1.4.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/build/src/components/Configure/nav/ObjectManagementNav/index.js +2 -2
- package/build/src/components/Configure/state/utils.js +2 -1
- package/build/src/components/Configure/utils.d.ts +8 -1
- package/build/src/components/Configure/utils.js +11 -4
- package/build/src/components/ErrorTextBox.js +1 -1
- package/build/src/components/Oauth/NoWorkspaceEntry/NoWorkspaceOauthFlow.js +7 -9
- package/build/src/components/Oauth/OauthCardLayout.js +1 -1
- package/build/src/components/Oauth/WorkspaceEntry/WorkspaceOauthFlow.js +7 -9
- package/build/src/components/Oauth/fetchOAuthCallbackURL.d.ts +1 -1
- package/build/src/components/Oauth/fetchOAuthCallbackURL.js +1 -1
- package/build/src/components/SuccessTextBox.js +1 -1
- package/build/src/services/version.d.ts +1 -1
- package/build/src/services/version.js +1 -1
- package/package.json +2 -2
|
@@ -43,7 +43,7 @@ function ObjectManagementNav({ children, }) {
|
|
|
43
43
|
const [tabIndex, setTabIndex] = (0, react_1.useState)(0);
|
|
44
44
|
const appName = (project === null || project === void 0 ? void 0 : project.appName) || '';
|
|
45
45
|
const config = installation === null || installation === void 0 ? void 0 : installation.config;
|
|
46
|
-
const readNavObjects = hydratedRevision && (0, utils_2.
|
|
46
|
+
const readNavObjects = hydratedRevision && (0, utils_2.generateReadNavObjects)(config, hydratedRevision);
|
|
47
47
|
const isNavObjectsReady = readNavObjects !== null; // null = hydratedRevision/config is not ready
|
|
48
48
|
const isWriteSupported = !!((_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.write);
|
|
49
49
|
const otherNavObject = isWriteSupported ? (0, utils_2.generateOtherNavObject)(config) : undefined;
|
|
@@ -52,7 +52,7 @@ function ObjectManagementNav({ children, }) {
|
|
|
52
52
|
allNavObjects.push(otherNavObject);
|
|
53
53
|
}
|
|
54
54
|
const selectedObject = getSelectedObject(allNavObjects, tabIndex);
|
|
55
|
-
return ((0, jsx_runtime_1.jsx)(exports.SelectedObjectNameContext.Provider, { value: selectedObject === null || selectedObject === void 0 ? void 0 : selectedObject.name, children: (0, jsx_runtime_1.jsxs)(react_2.Box, { p: 8, maxWidth: "55rem", border: "1px solid #EFEFEF", borderRadius: 6, boxShadow: "md", margin: "auto", bgColor: "whitesmoke", display: "flex", gap: "6", minHeight: "100%", children: [(0, jsx_runtime_1.jsxs)(react_2.Box, { width: "20rem", children: [(0, jsx_runtime_1.jsxs)(react_2.Text, { children: [(0, utils_1.capitalize)(provider), " integration"] }), (0, jsx_runtime_1.jsx)(react_2.Text, { marginBottom: "20px", fontSize: "1.125rem", fontWeight: "500", children: appName }), isNavObjectsReady && ((0, jsx_runtime_1.jsxs)(react_2.Tabs, { index: tabIndex, onChange: setTabIndex, orientation: "horizontal", children: [readNavObjects.map((object) => {
|
|
55
|
+
return ((0, jsx_runtime_1.jsx)(exports.SelectedObjectNameContext.Provider, { value: selectedObject === null || selectedObject === void 0 ? void 0 : selectedObject.name, children: (0, jsx_runtime_1.jsxs)(react_2.Box, { p: 8, maxWidth: "55rem", border: "1px solid #EFEFEF", borderRadius: 6, boxShadow: "md", margin: "auto", bgColor: "whitesmoke", display: "flex", gap: "6", minHeight: "100%", color: "gray.800", fontSize: "md", children: [(0, jsx_runtime_1.jsxs)(react_2.Box, { width: "20rem", children: [(0, jsx_runtime_1.jsxs)(react_2.Text, { children: [(0, utils_1.capitalize)(provider), " integration"] }), (0, jsx_runtime_1.jsx)(react_2.Text, { marginBottom: "20px", fontSize: "1.125rem", fontWeight: "500", children: appName }), isNavObjectsReady && ((0, jsx_runtime_1.jsxs)(react_2.Tabs, { index: tabIndex, onChange: setTabIndex, orientation: "horizontal", children: [readNavObjects.map((object) => {
|
|
56
56
|
var _a, _b, _c, _d;
|
|
57
57
|
return ((0, jsx_runtime_1.jsx)(NavObjectItem_1.NavObjectItem, { objectName: object.name, completed: object.completed, pending: ((_b = (_a = objectConfigurationsState[object.name]) === null || _a === void 0 ? void 0 : _a.read) === null || _b === void 0 ? void 0 : _b.isOptionalFieldsModified)
|
|
58
58
|
|| ((_d = (_c = objectConfigurationsState[object.name]) === null || _c === void 0 ? void 0 : _c.read) === null || _d === void 0 ? void 0 : _d.isRequiredMapFieldsModified) }, object.name));
|
|
@@ -83,7 +83,8 @@ exports.setHydrateConfigState = setHydrateConfigState;
|
|
|
83
83
|
* resets configure state for all objects in hydrated revision to hydrated revision values
|
|
84
84
|
*/
|
|
85
85
|
const resetAllObjectsConfigurationState = (hydratedRevision, config, setObjectConfiguresState) => {
|
|
86
|
-
|
|
86
|
+
// read nav objects from hydrated revision
|
|
87
|
+
const navObjects = (0, utils_1.generateAllNavObjects)(config, hydratedRevision);
|
|
87
88
|
const objectConfigurationsState = {};
|
|
88
89
|
navObjects.forEach(({ name, completed }) => {
|
|
89
90
|
if (completed) {
|
|
@@ -20,8 +20,15 @@ export declare function getRequiredMapFieldsFromObject(object: HydratedIntegrati
|
|
|
20
20
|
export declare function getOptionalFieldsFromObject(object: HydratedIntegrationObject): HydratedIntegrationField[] | null;
|
|
21
21
|
export declare const getReadObject: (config: Config, objectName: string) => any;
|
|
22
22
|
export declare function getFieldKeyValue(field: HydratedIntegrationField): string;
|
|
23
|
+
/**
|
|
24
|
+
* generates Nav Objects for read action
|
|
25
|
+
* @param config
|
|
26
|
+
* @param hydratedRevision
|
|
27
|
+
* @returns NavObject[]
|
|
28
|
+
*/
|
|
29
|
+
export declare const generateReadNavObjects: (config: Config | undefined, hydratedRevision: HydratedRevision) => NavObject[];
|
|
23
30
|
export declare const generateOtherNavObject: (config: Config | undefined) => NavObject;
|
|
24
|
-
export declare function
|
|
31
|
+
export declare function generateAllNavObjects(config: Config | undefined, hydratedRevision: HydratedRevision): NavObject[];
|
|
25
32
|
export declare function validateFieldMappings(requiredMapFields: IntegrationFieldMapping[] | null | undefined, selectedRequiredMapFields: SelectMappingFields | null | undefined, setErrors: (boundary: ErrorBoundary, errors: string[]) => void): {
|
|
26
33
|
errorList: string[];
|
|
27
34
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateFieldMappings = exports.
|
|
3
|
+
exports.validateFieldMappings = exports.generateAllNavObjects = exports.generateOtherNavObject = exports.generateReadNavObjects = exports.getFieldKeyValue = exports.getReadObject = exports.getOptionalFieldsFromObject = exports.getRequiredMapFieldsFromObject = exports.getRequiredFieldsFromObject = exports.getStandardObjectFromAction = exports.isIntegrationFieldMapping = void 0;
|
|
4
4
|
const ErrorContextProvider_1 = require("../../context/ErrorContextProvider");
|
|
5
5
|
const constant_1 = require("./nav/ObjectManagementNav/constant");
|
|
6
6
|
/**
|
|
@@ -73,6 +73,7 @@ const generateReadNavObjects = (config, hydratedRevision) => {
|
|
|
73
73
|
});
|
|
74
74
|
return navObjects;
|
|
75
75
|
};
|
|
76
|
+
exports.generateReadNavObjects = generateReadNavObjects;
|
|
76
77
|
const generateOtherNavObject = (config) => {
|
|
77
78
|
var _a;
|
|
78
79
|
const navObject = {
|
|
@@ -83,11 +84,17 @@ const generateOtherNavObject = (config) => {
|
|
|
83
84
|
};
|
|
84
85
|
exports.generateOtherNavObject = generateOtherNavObject;
|
|
85
86
|
// generates standard objects and whether they are complete based on config and hydrated revision
|
|
86
|
-
function
|
|
87
|
-
|
|
87
|
+
function generateAllNavObjects(config, hydratedRevision) {
|
|
88
|
+
var _a;
|
|
89
|
+
const navObjects = (0, exports.generateReadNavObjects)(config, hydratedRevision);
|
|
90
|
+
const isWriteSupported = !!((_a = hydratedRevision === null || hydratedRevision === void 0 ? void 0 : hydratedRevision.content) === null || _a === void 0 ? void 0 : _a.write);
|
|
91
|
+
const otherNavObject = isWriteSupported ? (0, exports.generateOtherNavObject)(config) : undefined;
|
|
92
|
+
if (otherNavObject) {
|
|
93
|
+
navObjects.push(otherNavObject);
|
|
94
|
+
}
|
|
88
95
|
return navObjects;
|
|
89
96
|
}
|
|
90
|
-
exports.
|
|
97
|
+
exports.generateAllNavObjects = generateAllNavObjects;
|
|
91
98
|
// validates whether required fields are filled out or throws error
|
|
92
99
|
function validateFieldMappings(requiredMapFields, selectedRequiredMapFields, setErrors) {
|
|
93
100
|
// check if fields with requirements are met
|
|
@@ -6,6 +6,6 @@ const react_1 = require("@chakra-ui/react");
|
|
|
6
6
|
function ErrorTextBox({ message }) {
|
|
7
7
|
return ((0, jsx_runtime_1.jsxs)(react_1.Box, { minHeight: "300px", padding: "30px", display: "flex", flexDirection: "column", justifyContent: "space-evenly", alignItems: "center", children: [(0, jsx_runtime_1.jsxs)("svg", { width: "48", height: "48", viewBox: "0 0 48 48", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("path", {
|
|
8
8
|
// eslint-disable-next-line max-len
|
|
9
|
-
d: "M20.5796 7.72236L3.63955 36.0024C3.29029 36.6072 3.10549 37.293 3.10353 37.9914C3.10158 38.6898 3.28254 39.3766 3.62841 39.9834C3.97428 40.5902 4.473 41.0959 5.07497 41.4501C5.67693 41.8043 6.36115 41.9947 7.05955 42.0024H40.9396C41.638 41.9947 42.3222 41.8043 42.9241 41.4501C43.5261 41.0959 44.0248 40.5902 44.3707 39.9834C44.7166 39.3766 44.8975 38.6898 44.8956 37.9914C44.8936 37.293 44.7088 36.6072 44.3596 36.0024L27.4196 7.72236C27.063 7.13458 26.561 6.6486 25.9619 6.31133C25.3629 5.97406 24.687 5.79688 23.9996 5.79688C23.3121 5.79688 22.6362 5.97406 22.0372 6.31133C21.4381 6.6486 20.9361 7.13458 20.5796 7.72236Z", stroke: "#7F1D1D", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" }), (0, jsx_runtime_1.jsx)("path", { d: "M24 18V26", stroke: "#7F1D1D", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" }), (0, jsx_runtime_1.jsx)("path", { d: "M24 34H24.02", stroke: "#7F1D1D", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" })] }), (0, jsx_runtime_1.jsx)(react_1.Box, { boxSizing: "border-box", display: "flex", justifyContent: "center", alignItems: "center", "align-self": "stretch", padding: "12px 50px 12px 50px", borderRadius: "8px", border: "2px solid #FECACA", background: "#FEF2F2", children: (0, jsx_runtime_1.jsx)(react_1.Text, { color: "#991B1B", children: message }) })] }));
|
|
9
|
+
d: "M20.5796 7.72236L3.63955 36.0024C3.29029 36.6072 3.10549 37.293 3.10353 37.9914C3.10158 38.6898 3.28254 39.3766 3.62841 39.9834C3.97428 40.5902 4.473 41.0959 5.07497 41.4501C5.67693 41.8043 6.36115 41.9947 7.05955 42.0024H40.9396C41.638 41.9947 42.3222 41.8043 42.9241 41.4501C43.5261 41.0959 44.0248 40.5902 44.3707 39.9834C44.7166 39.3766 44.8975 38.6898 44.8956 37.9914C44.8936 37.293 44.7088 36.6072 44.3596 36.0024L27.4196 7.72236C27.063 7.13458 26.561 6.6486 25.9619 6.31133C25.3629 5.97406 24.687 5.79688 23.9996 5.79688C23.3121 5.79688 22.6362 5.97406 22.0372 6.31133C21.4381 6.6486 20.9361 7.13458 20.5796 7.72236Z", stroke: "#7F1D1D", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" }), (0, jsx_runtime_1.jsx)("path", { d: "M24 18V26", stroke: "#7F1D1D", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" }), (0, jsx_runtime_1.jsx)("path", { d: "M24 34H24.02", stroke: "#7F1D1D", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round" })] }), (0, jsx_runtime_1.jsx)(react_1.Box, { boxSizing: "border-box", display: "flex", justifyContent: "center", alignItems: "center", "align-self": "stretch", padding: "12px 50px 12px 50px", borderRadius: "8px", border: "2px solid #FECACA", background: "#FEF2F2", children: (0, jsx_runtime_1.jsx)(react_1.Text, { color: "#991B1B", fontSize: "md", children: message }) })] }));
|
|
10
10
|
}
|
|
11
11
|
exports.ErrorTextBox = ErrorTextBox;
|
|
@@ -28,15 +28,13 @@ function NoWorkspaceOauthFlow({ provider, consumerRef, consumerName, groupRef, g
|
|
|
28
28
|
const handleSubmit = async () => {
|
|
29
29
|
var _a;
|
|
30
30
|
setError(null);
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
setError((_a = err.message) !== null && _a !== void 0 ? _a : 'Unexpected error');
|
|
39
|
-
}
|
|
31
|
+
try {
|
|
32
|
+
const url = await (0, fetchOAuthCallbackURL_1.fetchOAuthCallbackURL)(projectId, consumerRef, groupRef, apiKey, provider, undefined, consumerName, groupName);
|
|
33
|
+
setOAuthCallbackURL(url);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
console.error(err);
|
|
37
|
+
setError((_a = err.message) !== null && _a !== void 0 ? _a : 'Unexpected error');
|
|
40
38
|
}
|
|
41
39
|
};
|
|
42
40
|
const onClose = (0, react_1.useCallback)((err) => {
|
|
@@ -4,6 +4,6 @@ exports.OauthCardLayout = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_1 = require("@chakra-ui/react");
|
|
6
6
|
function OauthCardLayout({ children }) {
|
|
7
|
-
return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsx)(react_1.Box, { p: 8, maxWidth: "600px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", textAlign: ['left'], margin: "auto", marginTop: "40px", bgColor: "white", children: children }) }));
|
|
7
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsx)(react_1.Box, { p: 8, maxWidth: "600px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", textAlign: ['left'], margin: "auto", marginTop: "40px", bgColor: "white", color: "gray.800", fontSize: "md", children: children }) }));
|
|
8
8
|
}
|
|
9
9
|
exports.OauthCardLayout = OauthCardLayout;
|
|
@@ -33,15 +33,13 @@ function WorkspaceOauthFlow({ provider, consumerRef, consumerName, groupRef, gro
|
|
|
33
33
|
setError('Workspace is required');
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
setError((_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unexpected error');
|
|
44
|
-
}
|
|
36
|
+
try {
|
|
37
|
+
const url = await (0, fetchOAuthCallbackURL_1.fetchOAuthCallbackURL)(projectId, consumerRef, groupRef, apiKey, provider, workspace, consumerName, groupName);
|
|
38
|
+
setOAuthCallbackURL(url);
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
console.error(err);
|
|
42
|
+
setError((_a = err === null || err === void 0 ? void 0 : err.message) !== null && _a !== void 0 ? _a : 'Unexpected error');
|
|
45
43
|
}
|
|
46
44
|
};
|
|
47
45
|
const onClose = (0, react_1.useCallback)((err) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const fetchOAuthCallbackURL: (projectId: string, consumerRef: string, groupRef: string,
|
|
1
|
+
export declare const fetchOAuthCallbackURL: (projectId: string, consumerRef: string, groupRef: string, apiKey: string, provider: string, workspace?: string, consumerName?: string, groupName?: string) => Promise<string>;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.fetchOAuthCallbackURL = void 0;
|
|
4
4
|
const api_1 = require("../../services/api");
|
|
5
5
|
const utils_1 = require("../../utils");
|
|
6
|
-
const fetchOAuthCallbackURL = async (projectId, consumerRef, groupRef,
|
|
6
|
+
const fetchOAuthCallbackURL = async (projectId, consumerRef, groupRef, apiKey, provider, workspace, consumerName, groupName) => {
|
|
7
7
|
const providerApps = await (0, api_1.api)().providerAppApi.listProviderApps({ projectId }, {
|
|
8
8
|
headers: { 'X-Api-Key': apiKey !== null && apiKey !== void 0 ? apiKey : '' },
|
|
9
9
|
});
|
|
@@ -5,6 +5,6 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const react_1 = require("@chakra-ui/react");
|
|
6
6
|
const SuccessIcon_1 = require("../assets/SuccessIcon");
|
|
7
7
|
function SuccessTextBox({ text }) {
|
|
8
|
-
return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsxs)(react_1.Box, { p: 8, maxWidth: "600px", minHeight: "290px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", margin: "auto", marginTop: "40px", bgColor: "white", paddingTop: "100px", children: [(0, jsx_runtime_1.jsx)(react_1.Box, { width: "100%", display: "flex", alignContent: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(react_1.Box, { margin: "auto", children: (0, jsx_runtime_1.jsx)(SuccessIcon_1.SuccessCheckmarkIcon, {}) }) }), (0, jsx_runtime_1.jsx)(react_1.Box, { textAlign: "center", paddingTop: "25px", children: text })] }) }));
|
|
8
|
+
return ((0, jsx_runtime_1.jsx)(react_1.Container, { children: (0, jsx_runtime_1.jsxs)(react_1.Box, { p: 8, maxWidth: "600px", minHeight: "290px", borderWidth: 1, borderRadius: 8, boxShadow: "lg", margin: "auto", marginTop: "40px", bgColor: "white", paddingTop: "100px", color: "gray.800", fontSize: "md", children: [(0, jsx_runtime_1.jsx)(react_1.Box, { width: "100%", display: "flex", alignContent: "center", justifyContent: "center", children: (0, jsx_runtime_1.jsx)(react_1.Box, { margin: "auto", children: (0, jsx_runtime_1.jsx)(SuccessIcon_1.SuccessCheckmarkIcon, {}) }) }), (0, jsx_runtime_1.jsx)(react_1.Box, { textAlign: "center", paddingTop: "25px", children: text })] }) }));
|
|
9
9
|
}
|
|
10
10
|
exports.SuccessTextBox = SuccessTextBox;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const LIB_VERSION = "1.4.
|
|
1
|
+
export declare const LIB_VERSION = "1.4.2";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amp-labs/react",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Ampersand React library.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Ampersand Labs",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"eslint-config-airbnb-typescript": "^17.1.0",
|
|
58
58
|
"eslint-plugin-import": "^2.29.0",
|
|
59
59
|
"eslint-plugin-jsx-a11y": "^6.8.0",
|
|
60
|
-
"eslint-plugin-n": "^
|
|
60
|
+
"eslint-plugin-n": "^17.2.0",
|
|
61
61
|
"eslint-plugin-promise": "^6.1.1",
|
|
62
62
|
"eslint-plugin-react": "^7.33.2",
|
|
63
63
|
"eslint-plugin-react-hooks": "^4.6.0",
|