@evenicanpm/admin-integrate 1.2.2 → 1.4.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.
Files changed (215) hide show
  1. package/documents/ConfigImport/configuration-import.ts +54 -0
  2. package/documents/CopyProcess/copy.ts +25 -0
  3. package/documents/Endpoint/fragments.ts +9 -0
  4. package/documents/Endpoint/list.ts +30 -0
  5. package/documents/Process/fragments.ts +22 -0
  6. package/documents/Process/get-process-details.ts +72 -0
  7. package/documents/Process/list.ts +24 -0
  8. package/documents/ProcessConfig/fragments.ts +116 -0
  9. package/documents/ProcessConfig/read.ts +35 -0
  10. package/documents/ProcessExecution/fragments.ts +12 -0
  11. package/documents/ProcessExecution/list.ts +30 -1
  12. package/documents/ProcessExecutionDetails/fragments.ts +96 -0
  13. package/documents/ProcessExecutionDetails/read.ts +12 -0
  14. package/documents/ProcessExport/read.ts +108 -0
  15. package/documents/ProcessScheduleGroup/read.ts +43 -0
  16. package/documents/ProcessTask/fragments.ts +288 -0
  17. package/documents/ProcessTask/read.ts +12 -0
  18. package/documents/ProcessTemplate/fragments.ts +74 -0
  19. package/documents/ProcessTemplate/list.ts +67 -0
  20. package/documents/ProcessTemplate/read.ts +12 -0
  21. package/documents/RunProcess/run.ts +11 -0
  22. package/package.json +4 -3
  23. package/src/api/Integrations/queries/get-process.query.ts +12 -12
  24. package/src/api/Integrations/queries/get-process.server.ts +7 -2
  25. package/src/api/configuration/queries/configuration-export.query.ts +48 -0
  26. package/src/api/configuration/queries/configuration-export.server.ts +9 -0
  27. package/src/api/configuration/queries/index.ts +1 -0
  28. package/src/api/dashboard/queries/get-process-executions.query.ts +6 -3
  29. package/src/api/dashboard/queries/get-process-executions.server.ts +1 -1
  30. package/src/api/execution-details/queries/get-process-execution-details.query.ts +46 -0
  31. package/src/api/execution-details/queries/get-process-execution-details.server.ts +11 -0
  32. package/src/api/execution-details/queries/get-process-executions-by-process.query.ts +48 -0
  33. package/src/api/execution-details/queries/get-process-executions-by-process.server.ts +11 -0
  34. package/src/api/execution-details/queries/index.ts +2 -0
  35. package/src/api/process/mutations/copy-process.mutation.ts +45 -0
  36. package/src/api/process/mutations/copy-process.server.ts +14 -0
  37. package/src/api/process/mutations/index.ts +2 -0
  38. package/src/api/process/mutations/run-process.mutation.ts +41 -0
  39. package/src/api/process/mutations/run-process.server.ts +14 -0
  40. package/src/api/process/queries/get-process-by-id.query.ts +85 -0
  41. package/src/api/process/queries/get-process-by-id.server.ts +20 -0
  42. package/src/api/process/queries/index.ts +4 -0
  43. package/src/api/process-config/mutation/index.ts +2 -0
  44. package/src/api/process-config/mutation/process-config-import.mutation.ts +42 -0
  45. package/src/api/process-config/mutation/process-config-import.server.ts +14 -0
  46. package/src/api/process-config/mutation/process-config-merge.mutation.ts +33 -0
  47. package/src/api/process-config/mutation/process-config-merge.server.ts +14 -0
  48. package/src/api/process-task/queries/get-process-task-by-id.query.ts +46 -0
  49. package/src/api/process-task/queries/get-process-task-by-id.server.ts +9 -0
  50. package/src/api/process-task/queries/index.ts +1 -0
  51. package/src/api/scheduler/mutation/create-process-schedule-group-details.mutation.ts +47 -0
  52. package/src/api/scheduler/mutation/create-process-schedule-group-details.server.ts +14 -0
  53. package/src/api/scheduler/mutation/index.ts +2 -0
  54. package/src/api/scheduler/mutation/update-process-schedule-group-details.mutation.ts +47 -0
  55. package/src/api/scheduler/mutation/update-process-schedule-group-details.server.ts +14 -0
  56. package/src/api/scheduler/queries/get-non-scheduled-processes.query.ts +48 -0
  57. package/src/api/scheduler/queries/get-non-scheduled-processes.server.ts +11 -0
  58. package/src/api/scheduler/queries/get-process-schedule-group-details.query.ts +6 -3
  59. package/src/api/scheduler/queries/get-process-schedule-group-details.server.ts +3 -3
  60. package/src/api/scheduler/queries/get-process-schedule.query.ts +6 -3
  61. package/src/api/scheduler/queries/get-process-schedule.server.ts +3 -3
  62. package/src/api/scheduler/queries/get-scheduled-processes.query.ts +6 -3
  63. package/src/api/scheduler/queries/get-scheduled-processes.server.ts +1 -1
  64. package/src/api/scheduler/queries/index.ts +3 -2
  65. package/src/api/templates/queries/get-process-template-groups.query.ts +48 -0
  66. package/src/api/templates/queries/get-process-template-groups.server.ts +11 -0
  67. package/src/api/templates/queries/get-process-template-records.query.ts +48 -0
  68. package/src/api/templates/queries/get-process-template-records.server.ts +11 -0
  69. package/src/api/templates/queries/get-process-template.query.ts +48 -0
  70. package/src/api/templates/queries/get-process-template.server.ts +9 -0
  71. package/src/api/templates/queries/get-process-templates.query.ts +45 -0
  72. package/src/api/templates/queries/get-process-templates.server.ts +9 -0
  73. package/src/api/templates/queries/index.ts +5 -0
  74. package/src/api/templates/queries/template-input-search.query.ts +39 -0
  75. package/src/api/templates/queries/template-input-search.server.ts +42 -0
  76. package/src/api/templates/queries/types.ts +34 -0
  77. package/src/components/breadcrumbs/breadcrumbs.tsx +33 -6
  78. package/src/components/button/outlined-icon-button.tsx +2 -2
  79. package/src/components/core/date-time-popover.tsx +12 -5
  80. package/src/components/core/drawer-buttons.tsx +52 -0
  81. package/src/components/core/edited-typography.tsx +2 -2
  82. package/src/components/core/index.ts +4 -2
  83. package/src/components/core/loading.tsx +1 -1
  84. package/src/components/core/status-tag.tsx +97 -0
  85. package/src/components/core/title-edit.tsx +31 -22
  86. package/src/components/dashboard-list/dashboard-list-row.tsx +22 -29
  87. package/src/components/dashboard-list/dashboard-list.tsx +20 -16
  88. package/src/components/data-table/table-header.tsx +6 -8
  89. package/src/components/data-table/table-pagination.tsx +1 -1
  90. package/src/components/data-table/table-row.tsx +1 -1
  91. package/src/components/data-table/table-skeleton.tsx +10 -5
  92. package/src/components/execution/execution-filter.ts +1 -1
  93. package/src/components/execution/execution-status-icon.tsx +7 -7
  94. package/src/components/execution/execution-tag.tsx +12 -77
  95. package/src/components/execution/index.ts +1 -1
  96. package/src/components/execution-history-drawer/execution-history-drawer.tsx +202 -0
  97. package/src/components/execution-history-drawer/executions-card.tsx +85 -0
  98. package/src/components/execution-history-drawer/index.ts +1 -0
  99. package/src/components/footer/footer.tsx +10 -6
  100. package/src/components/header/dashboard-list-header.tsx +12 -7
  101. package/src/components/header/execution-details-header.tsx +35 -26
  102. package/src/components/header/header.tsx +10 -3
  103. package/src/components/header/index.ts +1 -1
  104. package/src/components/header/integration-details-header.tsx +108 -45
  105. package/src/components/integration-list/index.ts +2 -1
  106. package/src/components/integration-list/integration-filter.ts +1 -1
  107. package/src/components/integration-list/integration-status-icon.tsx +7 -8
  108. package/src/components/integration-list/integration-tag.tsx +6 -50
  109. package/src/components/integration-list/list/integration-list-row.tsx +161 -0
  110. package/src/components/integration-list/list/integration-list-table.tsx +62 -0
  111. package/src/{pages/integrations/integration-list → components/integration-list/list}/integration-list.tsx +47 -51
  112. package/src/components/integration-view/animated-svg.tsx +31 -0
  113. package/src/components/integration-view/edges/default-edge.tsx +2 -6
  114. package/src/components/integration-view/elk-layout-options.ts +2 -2
  115. package/src/components/integration-view/elk-types.ts +35 -6
  116. package/src/components/integration-view/flow-types.tsx +12 -0
  117. package/src/components/integration-view/integration-view.tsx +562 -56
  118. package/src/components/integration-view/nodes/add-node.tsx +20 -0
  119. package/src/components/integration-view/nodes/empty-node.tsx +65 -0
  120. package/src/components/integration-view/nodes/entry-node.tsx +98 -4
  121. package/src/components/integration-view/nodes/execution-entry-node.tsx +107 -0
  122. package/src/components/integration-view/nodes/execution-task-node.tsx +88 -0
  123. package/src/components/integration-view/nodes/group-node.tsx +33 -13
  124. package/src/components/integration-view/nodes/row-node.tsx +19 -0
  125. package/src/components/integration-view/nodes/task-node.tsx +50 -16
  126. package/src/components/integration-view/task-icon.tsx +193 -0
  127. package/src/components/integration-view/temp-data/initialElements.tsx +34 -32
  128. package/src/components/integration-view/types.ts +2 -2
  129. package/src/components/integration-view/utils/mapping.ts +404 -0
  130. package/src/components/layouts/main-layout.tsx +3 -4
  131. package/src/components/layouts/root-container.tsx +5 -11
  132. package/src/components/link-cards/link-card.tsx +15 -4
  133. package/src/components/link-cards/styles.ts +1 -1
  134. package/src/components/list-filter/date-filter.tsx +7 -4
  135. package/src/components/list-filter/date-range-filter.tsx +15 -7
  136. package/src/components/list-filter/index.ts +1 -1
  137. package/src/components/list-filter/list-filter.tsx +31 -26
  138. package/src/components/list-filter/multi-select-filter.tsx +11 -10
  139. package/src/components/list-filter/select-filter.tsx +23 -12
  140. package/src/components/scheduler/day-selector.tsx +29 -15
  141. package/src/components/scheduler/day-tag.tsx +14 -51
  142. package/src/components/scheduler/index.ts +2 -1
  143. package/src/components/scheduler/schedule-drawer/details-reducer.ts +217 -0
  144. package/src/components/scheduler/schedule-drawer/schedule-details-integrations.tsx +501 -0
  145. package/src/{pages → components}/scheduler/schedule-drawer/schedule-details-main.tsx +137 -100
  146. package/src/components/scheduler/schedule-drawer/schedule-details-name.tsx +94 -0
  147. package/src/{pages → components}/scheduler/schedule-drawer/schedule-details-skeleton.tsx +1 -2
  148. package/src/{pages → components}/scheduler/schedule-drawer/schedule-details.tsx +10 -14
  149. package/src/components/scheduler/schedule-drawer/schedule-drawer-group.tsx +214 -0
  150. package/src/{pages → components}/scheduler/schedule-drawer/schedule-drawer-legacy.tsx +7 -26
  151. package/src/components/scheduler/schedule-drawer/schedule-drawer.tsx +116 -0
  152. package/src/components/scheduler/schedule-drawer/sortable-integration-row.tsx +130 -0
  153. package/src/components/scheduler/schedule-filter.ts +1 -1
  154. package/src/components/scheduler/schedule-icon.tsx +5 -6
  155. package/src/components/scheduler/schedule-integration-icon.tsx +31 -0
  156. package/src/components/templates/index.ts +1 -0
  157. package/src/components/templates/inputs/index.tsx +1392 -0
  158. package/src/components/templates/template-filter.ts +5 -0
  159. package/src/components/templates/templates-list/index.ts +1 -0
  160. package/src/components/templates/templates-list/templates-list-row.tsx +55 -0
  161. package/src/components/templates/templates-list/templates-list-table.tsx +58 -0
  162. package/src/components/templates/templates-list/templates-list.tsx +253 -0
  163. package/src/components/templates/types.tsx +76 -0
  164. package/src/components/templates/wizard.tsx +737 -0
  165. package/src/hooks/use-breadcrumbs.ts +1 -1
  166. package/src/hooks/use-recurrence.tsx +1 -2
  167. package/src/pages/dashboard/dashboard-link-cards.tsx +8 -11
  168. package/src/pages/dashboard/dashboard-list-sections.tsx +8 -10
  169. package/src/pages/dashboard/dashboard.tsx +1 -2
  170. package/src/pages/execution-details/execution-details.tsx +212 -14
  171. package/src/pages/execution-details/task-execution-details.tsx +160 -0
  172. package/src/pages/execution-details/task-execution-drawer.tsx +54 -0
  173. package/src/pages/executions/executions-list/executions-list-row.tsx +21 -27
  174. package/src/pages/executions/executions-list/executions-list-table.tsx +29 -36
  175. package/src/pages/executions/executions-list/executions-list.tsx +24 -18
  176. package/src/pages/executions/executions.tsx +11 -15
  177. package/src/pages/integration-create/index.ts +1 -0
  178. package/src/pages/integration-create/integration-create.tsx +216 -0
  179. package/src/pages/integration-create/pre-creation-step.tsx +84 -0
  180. package/src/pages/integration-create/select-step.tsx +105 -0
  181. package/src/pages/integration-create/template-list-step.tsx +77 -0
  182. package/src/pages/integration-create/wizard-step.tsx +51 -0
  183. package/src/pages/integration-details/import-process/copy-tasks-list.tsx +265 -0
  184. package/src/pages/integration-details/import-process/copy-tasks-row.tsx +77 -0
  185. package/src/pages/integration-details/import-process/import-confirm.tsx +61 -0
  186. package/src/pages/integration-details/import-process/import-drawer.tsx +48 -0
  187. package/src/pages/integration-details/import-process/import-process-reducer.ts +90 -0
  188. package/src/pages/integration-details/import-process/import-process.tsx +149 -0
  189. package/src/pages/integration-details/index.ts +1 -0
  190. package/src/pages/integration-details/integration-details.tsx +468 -0
  191. package/src/pages/integration-details/task-drawer/add-task.tsx +172 -0
  192. package/src/pages/integration-details/task-drawer/edit-task.tsx +161 -0
  193. package/src/pages/integration-details/task-drawer/task-drawer.tsx +157 -0
  194. package/src/pages/integration-details/task-drawer/task-reducer.ts +103 -0
  195. package/src/pages/integrations/integrations.tsx +11 -14
  196. package/src/pages/scheduler/scheduler.tsx +12 -24
  197. package/src/pages/scheduler/schedules-list/schedules-list-row.tsx +27 -37
  198. package/src/pages/scheduler/schedules-list/schedules-list-table.tsx +28 -43
  199. package/src/pages/scheduler/schedules-list/schedules-list.tsx +48 -21
  200. package/src/utils/date-functions.ts +69 -0
  201. package/src/utils/slugify.ts +3 -0
  202. package/tsconfig.json +12 -4
  203. package/src/hooks/use-timestamp.tsx +0 -25
  204. package/src/pages/integrations/integration-list/integration-list-row.tsx +0 -147
  205. package/src/pages/integrations/integration-list/integration-list-table.tsx +0 -78
  206. package/src/pages/scheduler/schedule-drawer/schedule-details-integrations.tsx +0 -227
  207. package/src/pages/scheduler/schedule-drawer/schedule-details-name.tsx +0 -77
  208. package/src/pages/scheduler/schedule-drawer/schedule-drawer-buttons.tsx +0 -72
  209. package/src/pages/scheduler/schedule-drawer/schedule-drawer-group.tsx +0 -103
  210. package/src/pages/scheduler/schedule-drawer/schedule-drawer.tsx +0 -101
  211. package/src/pages/scheduler/schedule-drawer/sortable-integration-row.tsx +0 -93
  212. /package/src/{pages/integrations/integration-list → components/integration-list/list}/index.ts +0 -0
  213. /package/src/{pages → components}/scheduler/schedule-drawer/edited/edited-types.ts +0 -0
  214. /package/src/{pages → components}/scheduler/schedule-drawer/edited/index.ts +0 -0
  215. /package/src/{pages → components}/scheduler/schedule-drawer/index.ts +0 -0
@@ -1,18 +1,13 @@
1
- import React from "react";
2
-
3
- // Types
4
- import { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
5
- import { Item } from "./executions-list";
6
-
7
1
  // API
8
- import { ProcessExecutionInput } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
9
-
10
- // MUI
11
- import { TableContainer, Table, TableBody } from "@mui/material";
12
- import { SxProps } from "@mui/material";
13
-
2
+ import type { ProcessExecutionInput } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
14
3
  // Custom components
15
4
  import { TableHeader } from "@evenicanpm/admin-integrate/components/data-table";
5
+ // Types
6
+ import type { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
7
+ // MUI
8
+ import { type SxProps, Table, TableBody, TableContainer } from "@mui/material";
9
+ import React from "react";
10
+ import type { Item } from "./executions-list";
16
11
 
17
12
  // Local components
18
13
  import ExecutionsListRow from "./executions-list-row";
@@ -25,7 +20,7 @@ interface Props {
25
20
  rowSx?: SxProps;
26
21
  }
27
22
 
28
- export default function ExecutionsListTable(props: Props) {
23
+ export default function ExecutionsListTable(props: Readonly<Props>) {
29
24
  const handleRequestSort = (property: string) => {
30
25
  const current = props.input.sort;
31
26
  if (property === current) {
@@ -43,28 +38,26 @@ export default function ExecutionsListTable(props: Props) {
43
38
  };
44
39
 
45
40
  return (
46
- <>
47
- <TableContainer>
48
- <Table>
49
- <TableHeader
50
- heading={props.heading}
51
- orderBy={props.input.sort || ""}
52
- order={props.input.sortDesc ? "desc" : "asc"}
53
- onRequestSort={handleRequestSort}
54
- rowSx={props.rowSx}
55
- />
56
- <TableBody>
57
- {props.items.map((item, index) => (
58
- <ExecutionsListRow
59
- key={index}
60
- item={item}
61
- heading={props.heading}
62
- sx={props.rowSx}
63
- />
64
- ))}
65
- </TableBody>
66
- </Table>
67
- </TableContainer>
68
- </>
41
+ <TableContainer>
42
+ <Table>
43
+ <TableHeader
44
+ heading={props.heading}
45
+ orderBy={props.input.sort || ""}
46
+ order={props.input.sortDesc ? "desc" : "asc"}
47
+ onRequestSort={handleRequestSort}
48
+ rowSx={props.rowSx}
49
+ />
50
+ <TableBody>
51
+ {props.items.map((item) => (
52
+ <ExecutionsListRow
53
+ key={item.id}
54
+ item={item}
55
+ heading={props.heading}
56
+ sx={props.rowSx}
57
+ />
58
+ ))}
59
+ </TableBody>
60
+ </Table>
61
+ </TableContainer>
69
62
  );
70
63
  }
@@ -1,38 +1,44 @@
1
- import React, { useState, useEffect } from "react";
2
- import { useTranslations } from "next-intl";
3
-
4
1
  // API
5
- import { GetProcessExecutionsQuery } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
6
- import { ProcessExecutionInput } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
7
-
8
- // MUI
9
- import { Theme, useTheme } from "@mui/material";
10
- import { Card, Box, Stack, Typography, Grid2 as Grid } from "@mui/material";
11
-
2
+ import type {
3
+ GetProcessExecutionsQuery,
4
+ ProcessExecutionInput,
5
+ } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
12
6
  // Custom components
13
7
  import { FlexBox } from "@evenicanpm/admin-core/components/flex-box";
14
8
  import {
15
9
  TablePagination,
16
10
  TableSkeleton,
17
11
  } from "@evenicanpm/admin-integrate/components/data-table";
18
- import { ListFilter } from "@evenicanpm/admin-integrate/components/list-filter";
19
-
20
- // Local components
21
- import ExecutionsListTable from "./executions-list-table";
22
-
23
12
  // Types
24
- import { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
25
- import { ListFilterOutput } from "@evenicanpm/admin-integrate/components/list-filter/list-filter-types";
13
+ import type { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
26
14
  import {
27
- ExecutionsListFilters,
15
+ type ExecutionsListFilters,
28
16
  executionListFilters,
29
17
  } from "@evenicanpm/admin-integrate/components/execution/execution-filter";
18
+ import { ListFilter } from "@evenicanpm/admin-integrate/components/list-filter";
19
+ import type { ListFilterOutput } from "@evenicanpm/admin-integrate/components/list-filter/list-filter-types";
20
+ // MUI
21
+ import {
22
+ Box,
23
+ Card,
24
+ Grid2 as Grid,
25
+ Stack,
26
+ type Theme,
27
+ Typography,
28
+ useTheme,
29
+ } from "@mui/material";
30
+ import { useTranslations } from "next-intl";
31
+ import type React from "react";
32
+ import { useEffect, useState } from "react";
33
+ // Local components
34
+ import ExecutionsListTable from "./executions-list-table";
30
35
 
31
36
  // Returned from processExecutions query
32
37
  export interface Item {
33
38
  id: string;
34
39
  name: string;
35
40
  startDate: string;
41
+ endDate?: string;
36
42
  executionStatus: {
37
43
  id: string;
38
44
  };
@@ -1,28 +1,24 @@
1
- import React, { useState } from "react";
2
- import { useTranslations } from "next-intl";
3
-
4
- // API
5
- import { getProcessExecutions } from "@evenicanpm/admin-integrate/api/dashboard/queries";
6
- import {
7
- ProcessExecutionInput,
1
+ import type {
8
2
  GetProcessExecutionsQuery,
3
+ ProcessExecutionInput,
9
4
  } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
10
-
11
- // MUI
12
- import { Box } from "@mui/material";
13
-
5
+ // API
6
+ import { getProcessExecutions } from "@evenicanpm/admin-integrate/api/dashboard/queries";
14
7
  // Custom components
15
8
  import {
9
+ type Crumb,
16
10
  IntegrateBreadcrumbs,
17
- Crumb,
18
11
  } from "@evenicanpm/admin-integrate/components/breadcrumbs";
12
+ // Types
13
+ import type { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
19
14
 
15
+ // MUI
16
+ import { Box } from "@mui/material";
17
+ import { useTranslations } from "next-intl";
18
+ import React, { useState } from "react";
20
19
  // Local components
21
20
  import ExecutionsList from "./executions-list";
22
21
 
23
- // Types
24
- import { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
25
-
26
22
  export default function Executions() {
27
23
  const t = useTranslations("Integrate");
28
24
  const l = useTranslations("Integrate.Executions.ListHeader");
@@ -0,0 +1 @@
1
+ export { default } from "./integration-create";
@@ -0,0 +1,216 @@
1
+ import type {
2
+ ConfigExport,
3
+ ConfigurationMergeMutationVariables,
4
+ } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
5
+ import {
6
+ processConfigImport,
7
+ processConfigMerge,
8
+ } from "@evenicanpm/admin-integrate/api/process-config/mutation";
9
+ import {
10
+ type Crumb,
11
+ IntegrateBreadcrumbs,
12
+ } from "@evenicanpm/admin-integrate/components/breadcrumbs";
13
+ import { IntegrationDetailsHeader } from "@evenicanpm/admin-integrate/components/header";
14
+ import { removeTemplateConfig } from "@evenicanpm/admin-integrate/components/templates/wizard";
15
+ import { slugify } from "@evenicanpm/admin-integrate/utils/slugify";
16
+ import { Clear, SaveOutlined } from "@mui/icons-material";
17
+ import { Box, Button, type Theme, useTheme } from "@mui/material";
18
+ import { usePathname, useRouter, useSearchParams } from "next/navigation";
19
+ import { useTranslations } from "next-intl";
20
+ import { useEffect, useState } from "react";
21
+ import PreCreationStep from "./pre-creation-step";
22
+ import SelectStep from "./select-step";
23
+ import TemplateListStep from "./template-list-step";
24
+ import WizardStep from "./wizard-step";
25
+
26
+ export default function IntegrationCreate() {
27
+ const t = useTranslations("Integrate");
28
+
29
+ const theme = useTheme();
30
+ const styles = getStyles(theme);
31
+
32
+ const router = useRouter();
33
+ const searchParams = useSearchParams();
34
+ const pathname = usePathname();
35
+ const processConfigMergeMutation = processConfigMerge();
36
+ const processConfigImportMutation = processConfigImport();
37
+
38
+ const breadcrumbs: Crumb[] = [
39
+ {
40
+ name: t("Header.dashboard"),
41
+ url: "/e4integrate",
42
+ },
43
+ {
44
+ name: t("Header.integrations"),
45
+ url: "/e4integrate/integrations",
46
+ },
47
+ {
48
+ name: t("Header.newIntegration"),
49
+ },
50
+ ];
51
+
52
+ const [name, setName] = useState<string>("");
53
+ const [step, setStep] = useState<number>(0);
54
+ const [processConfig, setProcessConfig] = useState<any | null>(null);
55
+
56
+ useEffect(() => {
57
+ if (searchParams.get("group")) {
58
+ setStep(2);
59
+ }
60
+ }, [searchParams]);
61
+
62
+ const handleCancel = () => {
63
+ if (step > 0) {
64
+ const confirmClose = confirm(t("Common.unsavedChanges"));
65
+ if (!confirmClose) return;
66
+ setStep(0);
67
+ router.replace(pathname);
68
+ } else {
69
+ router.push("/e4integrate/integrations");
70
+ }
71
+ };
72
+
73
+ const handleProcessConfigMerge = (configMergeInput: any) => {
74
+ const newProcessConfigMerge = { ...configMergeInput };
75
+ const code = slugify(name);
76
+ for (const c of newProcessConfigMerge.input.config) {
77
+ c.name = name;
78
+ c.code = code;
79
+ }
80
+
81
+ console.log("configMergeInput", configMergeInput);
82
+
83
+ let sourceName = configMergeInput?.input?.config?.find(
84
+ (item: any) => (item?.source as string)?.toLowerCase() === "source",
85
+ )?.uniqueIdentifier;
86
+
87
+ if (sourceName) {
88
+ configMergeInput.input.config = configMergeInput.input!.config!.map(
89
+ (item: any) => {
90
+ if (item?.queues) {
91
+ return {
92
+ ...item,
93
+ queues: `${sourceName}_endpoint`,
94
+ };
95
+ } else {
96
+ return item;
97
+ }
98
+ },
99
+ );
100
+ }
101
+
102
+ processConfigMergeMutation.mutate(
103
+ {
104
+ input:
105
+ removeTemplateConfig(newProcessConfigMerge?.input) ||
106
+ ({} as ConfigurationMergeMutationVariables),
107
+ },
108
+ {
109
+ onSuccess: ({ configurationMerge }) => {
110
+ console.log("configurationMerge", configurationMerge);
111
+ setProcessConfig({
112
+ ...configurationMerge,
113
+ CreateIntegrationProc: true,
114
+ });
115
+ },
116
+ onError: (error) => {
117
+ console.error("Update failed:", error);
118
+ },
119
+ },
120
+ );
121
+ };
122
+
123
+ const handleProcessConfigImport = () => {
124
+ processConfigImportMutation.mutate(
125
+ {
126
+ config: processConfig,
127
+ reRoutedFromMerge: true,
128
+ },
129
+ {
130
+ onSuccess: () => {
131
+ router.push("/e4integrate/integrations");
132
+ },
133
+ onError: (error) => {
134
+ console.error("Update failed:", error);
135
+ },
136
+ },
137
+ );
138
+ };
139
+
140
+ useEffect(() => {
141
+ // Case when name of process is edited after config merge has been called (ie on pre-creation step), when sending config to import.
142
+ // If name is changed during wizard step, name is already updated in payload to config merge.
143
+ if (processConfig?.Processes) {
144
+ const newConfig = { ...processConfig };
145
+ const code = slugify(name);
146
+ newConfig.Processes[0].Name = name;
147
+ newConfig.Processes[0].Process = code;
148
+ }
149
+ }, [name]);
150
+
151
+ useEffect(() => {
152
+ if (step === 3 && !processConfig) {
153
+ const blankConfig: ConfigExport = {
154
+ Processes: [
155
+ {
156
+ Process: slugify(name),
157
+ Name: name,
158
+ },
159
+ ],
160
+ };
161
+ setProcessConfig(blankConfig);
162
+ }
163
+ }, [step, processConfig]);
164
+
165
+ return (
166
+ <>
167
+ <IntegrateBreadcrumbs breadcrumbs={breadcrumbs} />
168
+ {/* <Card> */}
169
+ <Box sx={styles.header}>
170
+ <IntegrationDetailsHeader
171
+ name={name || t("Templates.defaultNewName")}
172
+ setName={setName}
173
+ toolbar={step === 3 ? "disabled" : "hidden"}
174
+ draft
175
+ untitled={name === ""}
176
+ >
177
+ <Button
178
+ color="error"
179
+ variant="contained"
180
+ startIcon={<Clear />}
181
+ onClick={handleCancel}
182
+ >
183
+ {t("Templates.cancel")}
184
+ </Button>
185
+ <Button
186
+ color="info"
187
+ variant="contained"
188
+ startIcon={<SaveOutlined />}
189
+ onClick={handleProcessConfigImport}
190
+ disabled={step !== 3}
191
+ >
192
+ {t("Templates.create")}
193
+ </Button>
194
+ </IntegrationDetailsHeader>
195
+ </Box>
196
+ {step === 0 && <SelectStep setStep={setStep} />}
197
+ {step === 1 && <TemplateListStep />}
198
+ {step === 2 && (
199
+ <WizardStep
200
+ setStep={setStep}
201
+ setProcessConfigMerge={handleProcessConfigMerge}
202
+ />
203
+ )}
204
+ {step === 3 && <PreCreationStep processConfig={processConfig} />}
205
+ {/* </Card> */}
206
+ </>
207
+ );
208
+ }
209
+
210
+ const getStyles = (_theme: Theme) => {
211
+ return {
212
+ header: {
213
+ //padding: theme.spacing(2),
214
+ },
215
+ };
216
+ };
@@ -0,0 +1,84 @@
1
+ import { Box, useTheme } from "@mui/material";
2
+ import { useReducer } from "react";
3
+ import type {
4
+ ConfigExport,
5
+ EndpointExport,
6
+ } from "../../../../admin-core/src/api/e4/graphqlRequestSdk";
7
+ import { IntegrationView } from "../../components/integration-view";
8
+ import {
9
+ type EditAction,
10
+ TaskActionType,
11
+ TaskMode,
12
+ taskReducer,
13
+ } from "../integration-details/task-drawer/task-reducer";
14
+
15
+ interface Props {
16
+ processConfig: any | null;
17
+ }
18
+
19
+ export default function PreCreationStep(props: Readonly<Props>) {
20
+ const theme = useTheme();
21
+
22
+ const [_taskState, dispatchTaskState] = useReducer(taskReducer, {
23
+ open: false,
24
+ mode: TaskMode.NONE,
25
+ step: null,
26
+ });
27
+
28
+ // TODO: render integration
29
+ return (
30
+ <Box
31
+ sx={{
32
+ display: "flex",
33
+ height: "80vh",
34
+ width: "100%",
35
+ overflow: "hidden",
36
+ backgroundColor: theme.palette.background.default,
37
+ border: `1px solid ${theme.palette.grey[400]}`,
38
+ alignItems: null,
39
+ justifyContent: null,
40
+ }}
41
+ className="integration-view-container"
42
+ >
43
+ <IntegrationView
44
+ canEdit={false}
45
+ //key={viewRefreshKey}
46
+ //data={(data as GetProcessByIdQuery)?.processById as Process}
47
+ config={props.processConfig as ConfigExport}
48
+ variant="process"
49
+ drawerOpen={false}
50
+ processTaskId={undefined}
51
+ onTaskClick={(processTask: any) => {
52
+ const endpoint = props.processConfig?.Endpoints.find(
53
+ (ep: EndpointExport) => ep.Name === processTask.endpoint,
54
+ );
55
+
56
+ let templateConfig: any;
57
+
58
+ if (typeof endpoint.TemplateConfig === "string") {
59
+ templateConfig = endpoint.TemplateConfig;
60
+ } else if (typeof endpoint.TemplateConfig === "object") {
61
+ templateConfig = JSON.stringify(endpoint.TemplateConfig);
62
+ }
63
+
64
+ dispatchTaskState({
65
+ type: TaskActionType.OPEN_EDIT,
66
+ processTaskId: processTask.id,
67
+ templateConfig: templateConfig,
68
+ sort: processTask.sort,
69
+ parallelProcessingGroup: processTask.parallelProcessingGroup,
70
+ processTemplateId: endpoint?.ProcessTemplateId,
71
+ } as EditAction);
72
+ }}
73
+ />
74
+ {/* <TaskDrawer
75
+ open={taskState.open}
76
+ onClose={() => dispatchTaskState({ type: TaskActionType.CLOSE })}
77
+ anchor="right"
78
+ taskState={taskState}
79
+ dispatch={dispatchTaskState}
80
+ //handleUpdateConfig={handleUpdateConfig}
81
+ /> */}
82
+ </Box>
83
+ );
84
+ }
@@ -0,0 +1,105 @@
1
+ // Custom components
2
+ import LinkCard from "@evenicanpm/admin-integrate/components/link-cards";
3
+ import {
4
+ DescriptionOutlined,
5
+ InsertDriveFileOutlined,
6
+ } from "@mui/icons-material";
7
+
8
+ // Mui
9
+ import {
10
+ Box,
11
+ Grid2 as Grid,
12
+ type Theme,
13
+ Typography,
14
+ useTheme,
15
+ } from "@mui/material";
16
+ import { useTranslations } from "next-intl";
17
+ import type React from "react";
18
+
19
+ interface Props {
20
+ setStep: React.Dispatch<React.SetStateAction<number>>;
21
+ }
22
+
23
+ export default function SelectStep(props: Readonly<Props>) {
24
+ const t = useTranslations("Integrate.Templates");
25
+
26
+ const theme = useTheme();
27
+ const styles = getStyles(theme);
28
+
29
+ const handleClickBlank = () => {
30
+ props.setStep(3);
31
+ };
32
+
33
+ const handleClickTemplate = () => {
34
+ props.setStep(1);
35
+ };
36
+
37
+ return (
38
+ <Box sx={styles.main}>
39
+ <Grid container spacing={1} maxWidth={theme.spacing(70)}>
40
+ <Grid size={{ xs: 12 }}>
41
+ <Typography variant="h6" align="center">
42
+ {t("selectStepTitle")}
43
+ </Typography>
44
+ </Grid>
45
+ <Grid size={{ xs: 12, md: 6 }}>
46
+ <LinkCard
47
+ title={t("selectBlank")}
48
+ description={t("selectBlankDescription")}
49
+ onClick={handleClickBlank}
50
+ >
51
+ <Box
52
+ sx={{
53
+ ...styles.iconSquare,
54
+ color: "grey.600",
55
+ backgroundColor: "grey.300",
56
+ }}
57
+ >
58
+ <InsertDriveFileOutlined sx={styles.icon} />
59
+ </Box>
60
+ </LinkCard>
61
+ </Grid>
62
+ <Grid size={{ xs: 12, md: 6 }}>
63
+ <LinkCard
64
+ title={t("selectTemplate")}
65
+ description={t("selectTemplateDescription")}
66
+ onClick={handleClickTemplate}
67
+ >
68
+ <Box
69
+ sx={{
70
+ ...styles.iconSquare,
71
+ color: "bluish.600",
72
+ backgroundColor: "bluish.300",
73
+ }}
74
+ >
75
+ <DescriptionOutlined sx={styles.icon} />
76
+ </Box>
77
+ </LinkCard>
78
+ </Grid>
79
+ </Grid>
80
+ </Box>
81
+ );
82
+ }
83
+
84
+ const getStyles = (theme: Theme) => {
85
+ return {
86
+ main: {
87
+ backgroundColor: theme.palette.grey[50],
88
+ padding: theme.spacing(2),
89
+ border: `1px solid ${theme.palette.grey[300]}`,
90
+ minHeight: `min(${theme.spacing(80)}, 60vh)`,
91
+ display: "flex",
92
+ alignItems: "center",
93
+ justifyContent: "center",
94
+ },
95
+ iconSquare: {
96
+ padding: theme.spacing(1),
97
+ paddingBottom: theme.spacing(0.5),
98
+ marginBottom: theme.spacing(1),
99
+ borderRadius: 1,
100
+ },
101
+ icon: {
102
+ fontSize: "h4.fontSize",
103
+ },
104
+ };
105
+ };
@@ -0,0 +1,77 @@
1
+ import type {
2
+ FilterQueryInput,
3
+ GetProcessTemplateGroupsQuery,
4
+ } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
5
+ import { getProcessTemplateGroups } from "@evenicanpm/admin-integrate/api/templates/queries";
6
+ import type { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
7
+ import TemplatesList from "@evenicanpm/admin-integrate/components/templates/templates-list";
8
+ import { Box, Typography, useTheme } from "@mui/material";
9
+ import { usePathname, useRouter, useSearchParams } from "next/navigation";
10
+ import { useTranslations } from "next-intl";
11
+ import { useState } from "react";
12
+
13
+ export default function TemplateListStep() {
14
+ const t = useTranslations("Integrate.Templates");
15
+
16
+ const router = useRouter();
17
+ const pathname = usePathname();
18
+ const searchParams = useSearchParams();
19
+ const theme = useTheme();
20
+
21
+ const heading: Head[] = [
22
+ {
23
+ id: "name",
24
+ label: t("ListHeader.name"),
25
+ align: "left",
26
+ width: "95%",
27
+ sortable: true,
28
+ },
29
+ {
30
+ id: "view",
31
+ label: t("ListHeader.actions"),
32
+ align: "right",
33
+ width: "5%",
34
+ },
35
+ ];
36
+
37
+ // TODO: initialize input based on url query params
38
+ const [input, setInput] = useState<FilterQueryInput>({
39
+ sort: "name",
40
+ sortDesc: false,
41
+ top: 10,
42
+ skip: 0,
43
+ });
44
+
45
+ const { data, isLoading } = getProcessTemplateGroups.useData({
46
+ input: input,
47
+ });
48
+
49
+ const handleRedirect = (id: string) => {
50
+ const currentParams = new URLSearchParams(searchParams.toString());
51
+ currentParams.set("group", id);
52
+ router.replace(`${pathname}?${currentParams.toString()}`);
53
+ };
54
+
55
+ return (
56
+ <Box
57
+ sx={{
58
+ backgroundColor: theme.palette.grey[50],
59
+ padding: theme.spacing(2),
60
+ border: `1px solid ${theme.palette.grey[300]}`,
61
+ }}
62
+ >
63
+ <Box sx={{ margin: theme.spacing(2, 0) }}>
64
+ <Typography variant="h6">{t("listStepTitle")}</Typography>
65
+ </Box>
66
+ <TemplatesList
67
+ heading={heading}
68
+ data={data as GetProcessTemplateGroupsQuery}
69
+ loading={isLoading}
70
+ input={input}
71
+ setInput={setInput}
72
+ handleRedirect={handleRedirect}
73
+ isTemplateGroupsList
74
+ />
75
+ </Box>
76
+ );
77
+ }