@ebubekirylmaz/link-test 1.2.44 → 1.2.46

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.
Files changed (121) hide show
  1. package/package.json +13 -6
  2. package/src/Platform.jsx +14 -15
  3. package/src/assets/illustrations/avatar-shape.jsx +6 -7
  4. package/src/assets/illustrations/booking-illustration.jsx +4 -14
  5. package/src/assets/illustrations/check-in-illustration.jsx +4 -10
  6. package/src/assets/illustrations/check-out-illustration.jsx +4 -3
  7. package/src/assets/illustrations/coming-soon-illustration.jsx +4 -17
  8. package/src/assets/illustrations/forbidden-illustration.jsx +4 -12
  9. package/src/assets/illustrations/maintenance-illustration.jsx +4 -24
  10. package/src/assets/illustrations/motivation-illustration.jsx +4 -9
  11. package/src/assets/illustrations/order-complete-illustration.jsx +4 -12
  12. package/src/assets/illustrations/page-not-found-illustration.jsx +4 -9
  13. package/src/assets/illustrations/seo-illustration.jsx +4 -16
  14. package/src/assets/illustrations/sever-error-illustration.jsx +4 -21
  15. package/src/assets/illustrations/upgrade-storage-illustration.jsx +4 -20
  16. package/src/assets/illustrations/upload-illustration.jsx +4 -81
  17. package/src/components/NucleoidLoginForm/NucleoidLoginForm.jsx +1 -0
  18. package/src/components/TopNavBar/TopNavBar.jsx +6 -2
  19. package/src/components/file-thumbnail/file-thumbnail.jsx +5 -6
  20. package/src/components/nav-section/horizontal/nav-section-horizontal.jsx +5 -6
  21. package/src/components/settings/drawer/layout-options.jsx +5 -4
  22. package/src/components/settings/drawer/presets-options.jsx +6 -5
  23. package/src/components/settings/drawer/settings-drawer.jsx +7 -4
  24. package/src/components/settings/drawer/stretch-options.jsx +5 -5
  25. package/src/config/schemas.js +1 -0
  26. package/src/context/Context.js +98 -0
  27. package/src/context/reducer.js +590 -10
  28. package/src/hooks/index.js +2 -1
  29. package/src/hooks/use-beta.js +8 -0
  30. package/src/layouts/DashboardLayout/header.jsx +5 -4
  31. package/src/layouts/DashboardLayout/nav-mini.jsx +5 -7
  32. package/src/layouts/DashboardLayout/nav-vertical.jsx +11 -11
  33. package/src/layouts/FullScreenLayout/FullScreenLayout.jsx +5 -1
  34. package/src/layouts/FullScreenLayout/nav-vertical.jsx +11 -11
  35. package/src/layouts/MainLayout/footer.jsx +7 -7
  36. package/src/layouts/MainLayout/header.jsx +3 -2
  37. package/src/layouts/MainLayout/nav/desktop/nav-list.jsx +8 -8
  38. package/src/layouts/MainLayout/nav/mobile/index.jsx +7 -6
  39. package/src/layouts/auth/classic.jsx +6 -6
  40. package/src/layouts/auth/modern.jsx +7 -6
  41. package/src/layouts/common/ProjectBar/index.jsx +13 -11
  42. package/src/layouts/common/account-popover.jsx +1 -2
  43. package/src/layouts/common/header-sim.jsx +3 -2
  44. package/src/layouts/common/header-simple.jsx +6 -3
  45. package/src/layouts/common/notifications-popover/index.jsx +18 -13
  46. package/src/layouts/common/notifications-popover/notification-item.jsx +28 -16
  47. package/src/lib/APIDialogAction/APIDialogAction.jsx +109 -0
  48. package/src/lib/APIDialogAction/index.js +1 -0
  49. package/src/lib/APIDialogAction/styles.js +6 -0
  50. package/src/lib/APIParams/APIParams.jsx +57 -0
  51. package/src/lib/APIParams/index.js +1 -0
  52. package/src/lib/APIPath/APIPath.jsx +82 -0
  53. package/src/lib/APIPath/index.js +1 -0
  54. package/src/lib/APIPath/styles.js +19 -0
  55. package/src/lib/APITree/APITree.jsx +411 -0
  56. package/src/lib/APITree/Arrow.jsx +21 -0
  57. package/src/lib/APITree/DeleteMethodDialog.jsx +41 -0
  58. package/src/lib/APITree/index.js +1 -0
  59. package/src/lib/APITree/styles.js +19 -0
  60. package/src/lib/APITypes/APITypes.jsx +141 -0
  61. package/src/lib/APITypes/TypeEditor.jsx +46 -0
  62. package/src/lib/APITypes/TypeList.jsx +180 -0
  63. package/src/lib/APITypes/index.js +1 -0
  64. package/src/lib/AddItemWizard/AddItemWizard.jsx +21 -10
  65. package/src/lib/BlankTreeMessage/BlankTreeMessage.jsx +39 -0
  66. package/src/lib/BlankTreeMessage/index.js +1 -0
  67. package/src/lib/CustomBreadcrumbs/CustomBreadcrumbs.jsx +3 -2
  68. package/src/lib/DialogTootip/DialogTooltip.jsx +67 -0
  69. package/src/lib/DialogTootip/index.js +1 -0
  70. package/src/lib/DialogTootip/styles.js +9 -0
  71. package/src/lib/Flow/connectors/DynamicConnector.jsx +179 -107
  72. package/src/lib/Flow/core/Flow.jsx +2 -0
  73. package/src/lib/Flow/core/FlowNode.jsx +2 -0
  74. package/src/lib/Flow/core/FlowViewport.jsx +41 -9
  75. package/src/lib/Flow/hooks/useNodeStyle.js +14 -0
  76. package/src/lib/Flow/layouts/CardLayout.jsx +4 -3
  77. package/src/lib/Flow/nodes/DefaultCard.jsx +6 -8
  78. package/src/lib/Flow/nodes/FlowNodeView.jsx +105 -21
  79. package/src/lib/Flow/styles.js +4 -0
  80. package/src/lib/IconSelector/IconSelector.jsx +5 -1
  81. package/src/lib/ItemSummary/ItemSummary.jsx +11 -6
  82. package/src/lib/ItemSummary/ItemsSummary.jsx +38 -26
  83. package/src/lib/NewApiBody/NewAPIBody.jsx +97 -0
  84. package/src/lib/NewApiBody/ParamView.jsx +38 -0
  85. package/src/lib/NucDialog/NucDialog.jsx +108 -0
  86. package/src/lib/NucDialog/index.js +1 -0
  87. package/src/lib/ParamTable/ParamTable.jsx +133 -0
  88. package/src/lib/ParamTable/TypeMenu.jsx +102 -0
  89. package/src/lib/ParamTable/defaults.js +47 -0
  90. package/src/lib/ParamTable/index.js +1 -0
  91. package/src/lib/ParamTable/styles.js +12 -0
  92. package/src/lib/ResourceMenu/AlertMassage.jsx +28 -0
  93. package/src/lib/ResourceMenu/DeleteResourceDialog.jsx +60 -0
  94. package/src/lib/ResourceMenu/ResourceMenu.jsx +158 -0
  95. package/src/lib/ResourceMenu/index.js +1 -0
  96. package/src/lib/ResourceMenu/styles.js +5 -0
  97. package/src/lib/Schema/Schema.jsx +204 -0
  98. package/src/lib/Schema/index.js +1 -0
  99. package/src/lib/SchemaEditor/SchemaEditor.jsx +258 -0
  100. package/src/lib/SchemaEditor/SchemaEditor.test.js +193 -0
  101. package/src/lib/SchemaEditor/SchemaPropertyEditor.jsx +135 -0
  102. package/src/lib/SchemaEditor/SchemaUtils.js +152 -0
  103. package/src/lib/SchemaEditor/index.js +1 -0
  104. package/src/lib/SparkleInput/SparkleInput.jsx +31 -28
  105. package/src/lib/TableSelectedAction/TableSelectedAction.jsx +7 -8
  106. package/src/lib/ToggleableMenu/ToggleableMenu.jsx +35 -0
  107. package/src/lib/ToggleableMenu/index.js +1 -0
  108. package/src/lib/index.js +14 -0
  109. package/src/pages/Callback.jsx +6 -8
  110. package/src/pages/ConfigError.jsx +3 -1
  111. package/src/pages/LoginPage.jsx +3 -12
  112. package/src/stories/APITree.stories.jsx +429 -0
  113. package/src/stories/FlowChart.stories.jsx +1 -1
  114. package/src/templates/ActionTemplate.js +24 -0
  115. package/src/theme/overrides/default-props.jsx +17 -11
  116. package/src/widgets/Login/CognitoLogin.jsx +165 -173
  117. package/src/widgets/Login/DemoLogin.jsx +43 -38
  118. package/src/widgets/Login/amplifyAuth.js +6 -6
  119. package/src/widgets/Login/amplifyConfig.js +3 -0
  120. package/src/widgets/LoginForm/LoginForm.jsx +8 -3
  121. package/src/widgets/SettingsDialog.jsx +206 -16
@@ -25,6 +25,7 @@ export const getBaseStyleForVariant = (v) => {
25
25
  animationSpeed: 1,
26
26
  gradient: null,
27
27
  curvature: 0.5,
28
+ connectorType: "curved",
28
29
  };
29
30
  case "pill":
30
31
  return {
@@ -44,6 +45,7 @@ export const getBaseStyleForVariant = (v) => {
44
45
  animationSpeed: 1,
45
46
  gradient: null,
46
47
  curvature: 0.4,
48
+ connectorType: "curved",
47
49
  };
48
50
  case "n8n":
49
51
  return {
@@ -63,6 +65,7 @@ export const getBaseStyleForVariant = (v) => {
63
65
  animationSpeed: 1,
64
66
  gradient: null,
65
67
  curvature: 0.5,
68
+ connectorType: "curved",
66
69
  };
67
70
  case "simple":
68
71
  default:
@@ -83,6 +86,7 @@ export const getBaseStyleForVariant = (v) => {
83
86
  animationSpeed: 1,
84
87
  gradient: null,
85
88
  curvature: 0.5,
89
+ connectorType: "curved",
86
90
  };
87
91
  }
88
92
  };
@@ -18,7 +18,11 @@ export default function IconSelector({
18
18
  setEmojiDialogOpen(true);
19
19
  };
20
20
  return (
21
- <Stack alignContent={"center"} justifyContent={"center"}>
21
+ <Stack
22
+ sx={{
23
+ alignContent: "center",
24
+ justifyContent: "center"
25
+ }}>
22
26
  <Stack>
23
27
  <IconButton
24
28
  data-cy="avatar-select-button"
@@ -17,15 +17,15 @@ export default function ItemSummary({ newItem }) {
17
17
  <DialogContentText sx={{ textAlign: "center", mb: 2 }}>
18
18
  Summary
19
19
  </DialogContentText>
20
- <Grid container spacing={1} mb={4}>
20
+ <Grid container spacing={1} sx={{
21
+ mb: 4
22
+ }}>
21
23
  <Grid
22
- item
23
- xs={newItem.description ? 4 : 12}
24
24
  sx={{
25
25
  justifyContent: "center",
26
26
  display: "flex",
27
27
  }}
28
- >
28
+ size={newItem.description ? 4 : 12}>
29
29
  <Card
30
30
  sx={{
31
31
  bgcolor: (theme) => theme.palette.background.paper,
@@ -37,7 +37,12 @@ export default function ItemSummary({ newItem }) {
37
37
  <CardContent
38
38
  children={
39
39
  <>
40
- <Typography variant="h6" textAlign={"center"} mb={2}>
40
+ <Typography
41
+ variant="h6"
42
+ sx={{
43
+ textAlign: "center",
44
+ mb: 2
45
+ }}>
41
46
  {newItem.name}
42
47
  </Typography>
43
48
  <Stack
@@ -63,7 +68,7 @@ export default function ItemSummary({ newItem }) {
63
68
  </Card>
64
69
  </Grid>
65
70
  {newItem.description && (
66
- <Grid item xs={8}>
71
+ <Grid size={8}>
67
72
  <Card sx={{ minHeight: "100%" }}>
68
73
  <CardHeader title="Description" />
69
74
  <CardContent>
@@ -19,15 +19,15 @@ export default function ItemsSummary({ newItems }) {
19
19
  <DialogContentText sx={{ textAlign: "center", mb: 2 }}>
20
20
  Summary
21
21
  </DialogContentText>
22
- <Grid container mb={4}>
22
+ <Grid container sx={{
23
+ mb: 4
24
+ }}>
23
25
  <Grid
24
- item
25
- xs={5}
26
26
  sx={{
27
27
  justifyContent: "center",
28
28
  display: "flex",
29
29
  }}
30
- >
30
+ size={5}>
31
31
  <Stack
32
32
  sx={{
33
33
  height: "100%",
@@ -45,27 +45,34 @@ export default function ItemsSummary({ newItems }) {
45
45
  >
46
46
  <CardHeader
47
47
  title={"Project Summary"}
48
- titleTypographyProps={{
49
- variant: "subtitle1",
50
- textAlign: "center",
51
- color: "text.secondary",
48
+ slotProps={{
49
+ title: {
50
+ variant: "subtitle1",
51
+ textAlign: "center",
52
+ color: "text.secondary",
53
+ }
52
54
  }}
53
55
  />
54
56
  <CardContent
55
57
  children={
56
58
  <>
57
- <Typography variant="h6" textAlign={"center"} mb={2}>
59
+ <Typography
60
+ variant="h6"
61
+ sx={{
62
+ textAlign: "center",
63
+ mb: 2
64
+ }}>
58
65
  {newItems[0].details.name}
59
66
  </Typography>
60
67
  <Stack
61
- padding={1}
62
68
  sx={{
69
+ padding: 1,
70
+
63
71
  "& .svg-color": {
64
72
  background: (theme) =>
65
73
  `linear-gradient(135deg, ${theme.palette.primary.light} 0%, ${theme.palette.primary.main} 100%)`,
66
- },
67
- }}
68
- >
74
+ }
75
+ }}>
69
76
  <SvgColor
70
77
  src={`https://api.iconify.design/${newItems[0].details.icon?.slice(
71
78
  1,
@@ -87,17 +94,15 @@ export default function ItemsSummary({ newItems }) {
87
94
  </Stack>
88
95
  </Grid>
89
96
  <Grid
90
- item
91
- xs={2}
92
97
  sx={{
93
98
  display: "flex",
94
99
  alignContent: "center",
95
100
  justifyContent: "center",
96
101
  }}
97
- >
102
+ size={2}>
98
103
  <Divider orientation="vertical" sx={{ borderStyle: "dashed" }} />
99
104
  </Grid>
100
- <Grid item xs={5}>
105
+ <Grid size={5}>
101
106
  <Stack
102
107
  sx={{
103
108
  height: "100%",
@@ -108,27 +113,34 @@ export default function ItemsSummary({ newItems }) {
108
113
  <Card>
109
114
  <CardHeader
110
115
  title={"Service Summary"}
111
- titleTypographyProps={{
112
- variant: "subtitle1",
113
- textAlign: "center",
114
- color: "text.secondary",
116
+ slotProps={{
117
+ title: {
118
+ variant: "subtitle1",
119
+ textAlign: "center",
120
+ color: "text.secondary",
121
+ }
115
122
  }}
116
123
  />
117
124
  <CardContent
118
125
  children={
119
126
  <>
120
- <Typography variant="h6" textAlign={"center"} mb={2}>
127
+ <Typography
128
+ variant="h6"
129
+ sx={{
130
+ textAlign: "center",
131
+ mb: 2
132
+ }}>
121
133
  {newItems[1].details.name}
122
134
  </Typography>
123
135
  <Stack
124
- padding={1}
125
136
  sx={{
137
+ padding: 1,
138
+
126
139
  "& .svg-color": {
127
140
  background: (theme) =>
128
141
  `linear-gradient(135deg, ${theme.palette.primary.light} 0%, ${theme.palette.primary.main} 100%)`,
129
- },
130
- }}
131
- >
142
+ }
143
+ }}>
132
144
  <SvgColor
133
145
  src={`https://api.iconify.design/${newItems[1].details.icon?.slice(
134
146
  1,
@@ -0,0 +1,97 @@
1
+ import ParamView from "./ParamView";
2
+ import React from "react";
3
+ import SchemaEditor from "../SchemaEditor";
4
+
5
+ import { Box, Divider, Paper, Typography } from "@mui/material";
6
+
7
+ const NewAPIBody = ({ types, api, requestSchemaRef, responseSchemaRef }) => {
8
+ return (
9
+ <Box
10
+ sx={{
11
+ display: "flex",
12
+ flexDirection: "row",
13
+ height: "85%",
14
+ p: 2,
15
+ }}
16
+ data-cy="api-body"
17
+ >
18
+ <Box
19
+ sx={{
20
+ flex: 1,
21
+ display: "flex",
22
+ flexDirection: "column",
23
+ }}
24
+ >
25
+ <Paper
26
+ elevation={3}
27
+ sx={{
28
+ width: "100%",
29
+ p: 2,
30
+ bgcolor: "background.paper",
31
+ borderRadius: 2,
32
+ height: "100%",
33
+ boxSizing: "border-box",
34
+ display: "flex",
35
+ flexDirection: "column",
36
+ justifyContent: "center",
37
+ alignItems: "center",
38
+ }}
39
+ data-cy="request-schema-editor"
40
+ >
41
+ {api.method === "GET" ? (
42
+ <Box sx={{ width: "100%", height: "100%" }}>
43
+ <ParamView params={api.params} />
44
+ </Box>
45
+ ) : (
46
+ <SchemaEditor
47
+ ref={requestSchemaRef}
48
+ initialData={api.request ? api.request.schema : ""}
49
+ customTypes={types}
50
+ />
51
+ )}
52
+ <Typography variant="h6" gutterBottom>
53
+ Request
54
+ </Typography>
55
+ </Paper>
56
+ </Box>
57
+
58
+ <Divider orientation="vertical" flexItem sx={{ width: "1rem" }} />
59
+
60
+ <Box
61
+ sx={{
62
+ flex: 1,
63
+ display: "flex",
64
+ flexDirection: "column",
65
+ }}
66
+ >
67
+ <Paper
68
+ elevation={3}
69
+ sx={{
70
+ width: "100%",
71
+ p: 2,
72
+ bgcolor: "background.paper",
73
+ borderRadius: 2,
74
+ height: "100%",
75
+ boxSizing: "border-box",
76
+ display: "flex",
77
+ flexDirection: "column",
78
+ justifyContent: "center",
79
+ alignItems: "center",
80
+ }}
81
+ data-cy="response-schema-editor"
82
+ >
83
+ <SchemaEditor
84
+ ref={responseSchemaRef}
85
+ customTypes={types}
86
+ initialData={api.response ? api.response.schema : ""}
87
+ />
88
+ <Typography variant="h6" gutterBottom>
89
+ Response
90
+ </Typography>
91
+ </Paper>
92
+ </Box>
93
+ </Box>
94
+ );
95
+ };
96
+
97
+ export default NewAPIBody;
@@ -0,0 +1,38 @@
1
+ import { v4 as uuid } from "uuid";
2
+
3
+ import {
4
+ Table,
5
+ TableBody,
6
+ TableCell,
7
+ TableHead,
8
+ TableRow,
9
+ } from "@mui/material";
10
+
11
+ function ParamView({ params }) {
12
+ params = params || [];
13
+
14
+ return (
15
+ <Table size={"small"} data-cy="param-view">
16
+ <colgroup>
17
+ <col style={{ width: "50%" }} />
18
+ <col style={{ width: "50%" }} />
19
+ </colgroup>
20
+ <TableHead>
21
+ <TableRow>
22
+ <TableCell>Parameter</TableCell>
23
+ <TableCell>Data Type</TableCell>
24
+ </TableRow>
25
+ </TableHead>
26
+ <TableBody>
27
+ {params.map((param) => (
28
+ <TableRow key={uuid()}>
29
+ <TableCell>{param.name}</TableCell>
30
+ <TableCell>{param.type}</TableCell>
31
+ </TableRow>
32
+ ))}
33
+ </TableBody>
34
+ </Table>
35
+ );
36
+ }
37
+
38
+ export default ParamView;
@@ -0,0 +1,108 @@
1
+ import { Close } from "@mui/icons-material";
2
+ import Fullscreen from "@mui/icons-material/Fullscreen";
3
+ import FullscreenExit from "@mui/icons-material/FullscreenExit";
4
+ import React from "react";
5
+
6
+ import {
7
+ Dialog,
8
+ DialogActions,
9
+ DialogContent,
10
+ DialogTitle,
11
+ IconButton,
12
+ } from "@mui/material";
13
+ import { storage, useStorage } from "@nucleoidjs/webstorage";
14
+
15
+ export default function NucDialog({
16
+ title,
17
+ minWidth = 600,
18
+ children,
19
+ action,
20
+ open,
21
+ handleClose,
22
+ maximizedDimensions = { width: "65rem", height: "50rem" },
23
+ minimizedDimensions = { width: "55rem", height: "40rem" },
24
+ }) {
25
+ const [maximized] = useStorage("platform", title, "maximized", false);
26
+ const currentDimensions = maximized
27
+ ? maximizedDimensions
28
+ : minimizedDimensions;
29
+
30
+ return (
31
+ <Dialog
32
+ open={open}
33
+ maxWidth={false}
34
+ onClose={handleClose}
35
+ sx={{
36
+ "& .MuiDialog-paper": {
37
+ width: currentDimensions.width,
38
+ height: currentDimensions.height,
39
+ transition: "width 0.3s ease-in-out, height 0.3s ease-in-out",
40
+ },
41
+ }}
42
+ >
43
+ <DialogTitle
44
+ sx={{
45
+ m: 0,
46
+ p: 2,
47
+ backgroundColor: (theme) => theme.palette.background.default,
48
+ }}
49
+ >
50
+ {title}
51
+ </DialogTitle>
52
+ <IconButton
53
+ aria-label="close"
54
+ onClick={handleClose}
55
+ sx={{
56
+ position: "absolute",
57
+ right: 8,
58
+ top: 8,
59
+ color: (theme) => theme.palette.grey[500],
60
+ }}
61
+ data-cy="close-dialog-button"
62
+ >
63
+ <Close />
64
+ </IconButton>
65
+ {maximized ? (
66
+ <IconButton
67
+ aria-label="collapse"
68
+ onClick={() => storage.set("platform", title, "maximized", false)}
69
+ sx={{
70
+ position: "absolute",
71
+ right: 48,
72
+ top: 8,
73
+ color: (theme) => theme.palette.grey[500],
74
+ }}
75
+ >
76
+ <FullscreenExit />
77
+ </IconButton>
78
+ ) : (
79
+ <IconButton
80
+ aria-label="expand"
81
+ onClick={() => storage.set("platform", title, "maximized", true)}
82
+ sx={{
83
+ position: "absolute",
84
+ right: 48,
85
+ top: 8,
86
+ color: (theme) => theme.palette.grey[500],
87
+ }}
88
+ >
89
+ <Fullscreen />
90
+ </IconButton>
91
+ )}
92
+
93
+ <DialogContent
94
+ sx={{
95
+ minWidth,
96
+ backgroundColor: (theme) => theme.palette.background.default,
97
+ }}
98
+ >
99
+ {children}
100
+ </DialogContent>
101
+ <DialogActions
102
+ sx={{ backgroundColor: (theme) => theme.palette.background.default }}
103
+ >
104
+ {action}
105
+ </DialogActions>
106
+ </Dialog>
107
+ );
108
+ }
@@ -0,0 +1 @@
1
+ export { default } from "./NucDialog";
@@ -0,0 +1,133 @@
1
+ import { DataGrid } from "@mui/x-data-grid";
2
+ import HighlightOffIcon from "@mui/icons-material/HighlightOff";
3
+ import React from "react";
4
+ import TypeMenu from "./TypeMenu";
5
+ import styles from "./styles";
6
+
7
+ import { Checkbox, IconButton, InputBase } from "@mui/material";
8
+
9
+ const ParamTable = ({ types, params, setParams }) => {
10
+ const columns = [
11
+ {
12
+ field: "name",
13
+ headerName: "Name",
14
+ renderCell: (param) => {
15
+ const { id } = param.row;
16
+ return (
17
+ <InputBase
18
+ disabled={param.row.in === "path"}
19
+ value={param.value || ""}
20
+ onChange={(event) => updateParam(id, "name", event.target.value)}
21
+ fullWidth
22
+ placeholder="Enter name"
23
+ data-cy={`param-name-field-${id}`}
24
+ />
25
+ );
26
+ },
27
+ flex: 1,
28
+ },
29
+ {
30
+ field: "type",
31
+ headerName: "Type",
32
+ renderCell: (param) => {
33
+ const { id } = param.row;
34
+ return (
35
+ <TypeMenu
36
+ disabled={param.row.in === "path"}
37
+ primitive
38
+ types={types}
39
+ id={id}
40
+ type={param.value}
41
+ onChange={(type) => updateParam(id, "type", type)}
42
+ />
43
+ );
44
+ },
45
+ flex: 1,
46
+ },
47
+ {
48
+ field: "in",
49
+ headerName: "Param",
50
+ flex: 1,
51
+ valueGetter: (param) => param.value || "query",
52
+ },
53
+ {
54
+ field: "required",
55
+ headerName: "Required",
56
+ renderCell: (param) => {
57
+ const { id } = param.row;
58
+ return (
59
+ <Checkbox
60
+ disabled={param.row.in === "path"}
61
+ checked={param.value}
62
+ onChange={(event) =>
63
+ updateParam(id, "required", event.target.checked)
64
+ }
65
+ data-cy={`param-required-checkbox-${id}`}
66
+ />
67
+ );
68
+ },
69
+ flex: 1,
70
+ },
71
+ {
72
+ field: "description",
73
+ headerName: "Description",
74
+ renderCell: (param) => {
75
+ const { id } = param.row;
76
+ return (
77
+ <InputBase
78
+ disabled={param.row.in === "path"}
79
+ value={param.value || ""}
80
+ onChange={(event) =>
81
+ updateParam(id, "description", event.target.value)
82
+ }
83
+ fullWidth
84
+ placeholder="Enter description"
85
+ data-cy={`param-description-field-${id}`}
86
+ />
87
+ );
88
+ },
89
+ flex: 2,
90
+ },
91
+ {
92
+ field: "action",
93
+ headerName: " ",
94
+ sortable: false,
95
+ renderCell: (param) => {
96
+ const { id } = param.row;
97
+ return (
98
+ <IconButton
99
+ disabled={param.row.in === "path"}
100
+ onClick={() => removeParam(id)}
101
+ size="large"
102
+ >
103
+ <HighlightOffIcon />
104
+ </IconButton>
105
+ );
106
+ },
107
+ },
108
+ ];
109
+
110
+ const removeParam = (id) => {
111
+ setParams((prevParams) => prevParams.filter((param) => param.id !== id));
112
+ };
113
+
114
+ const updateParam = (id, field, value) => {
115
+ setParams((prevParams) =>
116
+ prevParams.map((param) =>
117
+ param.id === id ? { ...param, [field]: value } : param
118
+ )
119
+ );
120
+ };
121
+
122
+ return (
123
+ <DataGrid
124
+ sx={styles.dataGrid}
125
+ columns={columns}
126
+ rows={params}
127
+ hideFooter
128
+ disableSelectionOnClick
129
+ />
130
+ );
131
+ };
132
+
133
+ export default ParamTable;
@@ -0,0 +1,102 @@
1
+ import Defaults from "./defaults";
2
+ import { v4 as uuid } from "uuid";
3
+
4
+ import { Divider, MenuItem, Select } from "@mui/material";
5
+ import { forwardRef, useState } from "react";
6
+
7
+ const TypeMenu = forwardRef(
8
+ (
9
+ {
10
+ id,
11
+ type,
12
+ types,
13
+ map,
14
+ edit,
15
+ setKey,
16
+ primitive,
17
+ objAndArr,
18
+ globalTypes,
19
+ disabled,
20
+ },
21
+ ref
22
+ ) => {
23
+ const [selectedType, setSelectedType] = useState(type);
24
+
25
+ function updateType(id, value) {
26
+ if (ref) {
27
+ ref[id].type = value;
28
+ } else {
29
+ switch (value) {
30
+ case "array":
31
+ if (map.type === "object") delete map["properties"];
32
+ map.type = "array";
33
+ map["items"] = Defaults.compiledObject(uuid(), uuid());
34
+
35
+ break;
36
+ case "object":
37
+ if (map.type === "array") delete map["items"];
38
+ map.type = "object";
39
+ map["properties"] = Defaults.compiledProperty(uuid());
40
+
41
+ break;
42
+ default:
43
+ if (map["properties"]) delete map["properties"];
44
+ if (map["items"]) delete map["items"];
45
+ map.type = value;
46
+
47
+ break;
48
+ }
49
+ }
50
+ setKey && setKey(uuid());
51
+ setSelectedType(value);
52
+ }
53
+
54
+ return (
55
+ <>
56
+ {edit && (
57
+ <Select
58
+ disabled={disabled}
59
+ value={selectedType}
60
+ onChange={(event) => {
61
+ updateType(id, event.target.value);
62
+ }}
63
+ >
64
+ {primitive && [
65
+ <MenuItem key={uuid()} value={"integer"}>
66
+ integer
67
+ </MenuItem>,
68
+ <MenuItem key={uuid()} value={"string"}>
69
+ string
70
+ </MenuItem>,
71
+ <MenuItem key={uuid()} value={"boolean"}>
72
+ boolean
73
+ </MenuItem>,
74
+ <Divider key={uuid()} id={uuid()} />,
75
+ ]}
76
+
77
+ {objAndArr && [
78
+ <MenuItem key={uuid()} id={uuid()} value={"object"}>
79
+ object
80
+ </MenuItem>,
81
+ <MenuItem key={uuid()} id={uuid()} value={"array"}>
82
+ array
83
+ </MenuItem>,
84
+ ]}
85
+ {globalTypes && <Divider />}
86
+ {globalTypes &&
87
+ types.map((item) => {
88
+ return (
89
+ <MenuItem key={uuid()} id={uuid()} value={item.name}>
90
+ {item.name}
91
+ </MenuItem>
92
+ );
93
+ })}
94
+ </Select>
95
+ )}
96
+ {!edit && <>{type}</>}
97
+ </>
98
+ );
99
+ }
100
+ );
101
+
102
+ export default TypeMenu;