@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
@@ -0,0 +1,51 @@
1
+ // Custom components
2
+ import { Wizard } from "@evenicanpm/admin-integrate/components/templates";
3
+ // Types
4
+ import type { ProcessConfigMerge } from "@evenicanpm/admin-integrate/components/templates/types";
5
+ // Mui
6
+ import { Box } from "@mui/material";
7
+ // Util
8
+ import { usePathname, useRouter, useSearchParams } from "next/navigation";
9
+
10
+ const metadata = {
11
+ name: "",
12
+ code: "",
13
+ parallelProcessingGroup: 1,
14
+ sort: 1,
15
+ };
16
+
17
+ interface Props {
18
+ setStep: React.Dispatch<React.SetStateAction<number>>;
19
+ setProcessConfigMerge: React.Dispatch<
20
+ React.SetStateAction<ProcessConfigMerge | null>
21
+ >;
22
+ }
23
+
24
+ export default function WizardStep(props: Readonly<Props>) {
25
+ const router = useRouter();
26
+ const pathname = usePathname();
27
+ const searchParams = useSearchParams();
28
+
29
+ const handleBack = () => {
30
+ props.setStep(1);
31
+ router.replace(pathname);
32
+ };
33
+
34
+ const handleFinish = () => {
35
+ props.setStep(3);
36
+ router.replace(pathname);
37
+ };
38
+
39
+ return (
40
+ <Box>
41
+ <Wizard
42
+ metadata={metadata}
43
+ processTemplateGroupId={searchParams.get("group")?.toString()}
44
+ handleBack={handleBack}
45
+ handleFinish={handleFinish}
46
+ setProcessConfigMerge={props.setProcessConfigMerge}
47
+ isCreateMode
48
+ />
49
+ </Box>
50
+ );
51
+ }
@@ -0,0 +1,265 @@
1
+ import type {
2
+ GetProcessByIdWithTasksQuery,
3
+ ProcessTask,
4
+ } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
5
+ import { getQueryClient } from "@evenicanpm/admin-core/api/sdk/get-query-client";
6
+ import { copyProcess } from "@evenicanpm/admin-integrate/api/process/mutations";
7
+ import { buildProcessByIdQueryKey } from "@evenicanpm/admin-integrate/api/process/queries/get-process-by-id.query";
8
+ import {
9
+ TableHeader,
10
+ TableSkeleton,
11
+ } from "@evenicanpm/admin-integrate/components/data-table";
12
+ import type { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
13
+ import { ArrowLeft } from "@mui/icons-material";
14
+ import {
15
+ Box,
16
+ Button,
17
+ Card,
18
+ Skeleton,
19
+ Stack,
20
+ Table,
21
+ TableBody,
22
+ TableContainer,
23
+ type Theme,
24
+ Typography,
25
+ useTheme,
26
+ } from "@mui/material";
27
+ import { useParams } from "next/navigation";
28
+ import { useTranslations } from "next-intl";
29
+ import { useEffect, useState } from "react";
30
+ import CopyTasksRow from "./copy-tasks-row";
31
+ import {
32
+ type AlertAction,
33
+ type ImportAction,
34
+ ImportActionType,
35
+ type ImportState,
36
+ } from "./import-process-reducer";
37
+
38
+ interface Props {
39
+ data: GetProcessByIdWithTasksQuery;
40
+ loading: boolean;
41
+ importState: ImportState;
42
+ dispatch: React.Dispatch<ImportAction>;
43
+ }
44
+
45
+ export default function CopyTasksList(props: Readonly<Props>) {
46
+ const t = useTranslations("Integrate.IntegrationDetails.ImportProcess");
47
+
48
+ const params = useParams<{ processId: string }>();
49
+ const theme = useTheme();
50
+ const styles = getStyles(theme);
51
+
52
+ const heading: Head[] = [
53
+ {
54
+ id: "actions",
55
+ label: t("TaskList.actions"),
56
+ align: "center",
57
+ width: "5%",
58
+ },
59
+ {
60
+ id: "name",
61
+ label: t("TaskList.name"),
62
+ align: "left",
63
+ width: "45%",
64
+ },
65
+ {
66
+ id: "endpoint",
67
+ label: t("TaskList.endpoint"),
68
+ align: "left",
69
+ width: "45%",
70
+ },
71
+ ];
72
+
73
+ const [checked, setChecked] = useState<{ [key: string]: boolean } | null>(
74
+ null,
75
+ );
76
+ const anyChecked =
77
+ checked === null ? false : Object.values(checked).some(Boolean);
78
+ const disableConfirm =
79
+ props.loading || !!props.importState.alert || !anyChecked;
80
+
81
+ useEffect(() => {
82
+ if (props.data?.processById?.processTasks) {
83
+ if (props.data.processById.processTasks.length === 0) {
84
+ props.dispatch({
85
+ type: ImportActionType.ALERT,
86
+ alert: t("Alert.targetEmpty"),
87
+ } as AlertAction);
88
+ } else {
89
+ const ids = props.data.processById.processTasks.map((pt) => pt?.id);
90
+ const newChecked: { [key: string]: boolean } = {};
91
+ for (const id of ids) {
92
+ newChecked[id as string] = true;
93
+ }
94
+ setChecked(newChecked);
95
+ }
96
+ }
97
+ }, [props.data]);
98
+
99
+ const toggleChecked = (id: string) => {
100
+ const newChecked = { ...checked };
101
+ newChecked[id] = !newChecked[id];
102
+ setChecked(newChecked);
103
+ };
104
+
105
+ const copy = copyProcess();
106
+
107
+ const handleConfirm = () => {
108
+ if (props.data?.processById && checked) {
109
+ const idsToCopy: string[] = [];
110
+ for (const id of Object.keys(checked)) {
111
+ if (checked[id]) {
112
+ idsToCopy.push(id as string);
113
+ }
114
+ }
115
+
116
+ props.dispatch({ type: ImportActionType.SAVE });
117
+
118
+ copy.mutate(
119
+ {
120
+ sourceId: props.data.processById.id,
121
+ targetId: params.processId,
122
+ processTaskIds: idsToCopy,
123
+ },
124
+ {
125
+ onSuccess: async () => {
126
+ props.dispatch({ type: ImportActionType.CLOSE });
127
+ const qc = getQueryClient();
128
+ props.dispatch({ type: ImportActionType.SAVESUCCESS });
129
+
130
+ return qc.invalidateQueries({
131
+ queryKey: buildProcessByIdQueryKey.byInput({
132
+ id: params.processId,
133
+ }),
134
+ });
135
+ },
136
+ onError: (error) => {
137
+ props.dispatch({ type: ImportActionType.SAVESUCCESS });
138
+
139
+ console.error("CopyProcess failed:", error);
140
+ },
141
+ },
142
+ );
143
+ }
144
+ };
145
+
146
+ return (
147
+ <Box>
148
+ {(props.loading || !props.data) && (
149
+ <Box>
150
+ <Typography sx={styles.name} variant="h6">
151
+ <Skeleton />
152
+ </Typography>
153
+ <Card>
154
+ <TableSkeleton
155
+ heading={heading}
156
+ perPage={10}
157
+ rowSx={styles.rowSx}
158
+ />
159
+ </Card>
160
+ </Box>
161
+ )}
162
+ {!props.loading && props.data?.processById?.processTasks && (
163
+ <Box>
164
+ <Typography sx={styles.name} variant="h6">
165
+ {props.data.processById.name as string}
166
+ </Typography>
167
+ <Card>
168
+ {props.data.processById.processTasks.length > 0 && checked && (
169
+ <TableContainer>
170
+ <Table>
171
+ <TableHeader
172
+ heading={heading}
173
+ orderBy={"name"}
174
+ order={"asc"}
175
+ rowSx={styles.rowSx}
176
+ />
177
+ <TableBody>
178
+ {props.data.processById.processTasks.map((pt) =>
179
+ pt ? (
180
+ <CopyTasksRow
181
+ key={pt.id}
182
+ item={pt as ProcessTask}
183
+ heading={heading}
184
+ checked={checked[pt.id]}
185
+ toggleChecked={toggleChecked}
186
+ alert={props.importState.alert}
187
+ />
188
+ ) : (
189
+ <></>
190
+ ),
191
+ )}
192
+ </TableBody>
193
+ </Table>
194
+ </TableContainer>
195
+ )}
196
+ {props.data.processById.processTasks.length === 0 && (
197
+ <Box
198
+ display="flex"
199
+ justifyContent="center"
200
+ alignItems="center"
201
+ sx={{
202
+ minHeight: theme.spacing(20),
203
+ marginBottom: theme.spacing(2),
204
+ }}
205
+ >
206
+ <Stack spacing={1} justifyContent="center" alignItems="center">
207
+ <Typography variant="h6" color="info">
208
+ {t("TaskList.listEmptyTitle")}
209
+ </Typography>
210
+ <Typography variant="body1">
211
+ {t("TaskList.listEmptyBody")}
212
+ </Typography>
213
+ </Stack>
214
+ </Box>
215
+ )}
216
+ </Card>
217
+ </Box>
218
+ )}
219
+
220
+ <Box sx={styles.buttons} display="flex" justifyContent="space-between">
221
+ <Button
222
+ variant="contained"
223
+ color="primary"
224
+ onClick={() => {
225
+ props.dispatch({ type: ImportActionType.DESELECT });
226
+ props.dispatch({
227
+ type: ImportActionType.ALERT,
228
+ alert: null,
229
+ } as AlertAction);
230
+ }}
231
+ startIcon={<ArrowLeft />}
232
+ >
233
+ {t("back")}
234
+ </Button>
235
+ <Button
236
+ sx={{
237
+ "&.Mui-disabled": {
238
+ transitionDuration: "0s",
239
+ },
240
+ }}
241
+ variant="contained"
242
+ color="success"
243
+ disabled={disableConfirm}
244
+ onClick={handleConfirm}
245
+ >
246
+ {t("confirm")}
247
+ </Button>
248
+ </Box>
249
+ </Box>
250
+ );
251
+ }
252
+
253
+ const getStyles = (theme: Theme) => {
254
+ return {
255
+ name: {
256
+ marginBottom: theme.spacing(2),
257
+ },
258
+ rowSx: {
259
+ height: theme.spacing(7.5),
260
+ },
261
+ buttons: {
262
+ margin: theme.spacing(2, 0, 4),
263
+ },
264
+ };
265
+ };
@@ -0,0 +1,77 @@
1
+ import type { ProcessTask } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
2
+ import type { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
3
+ import {
4
+ StyledTableCell,
5
+ StyledTableRow,
6
+ } from "@evenicanpm/admin-integrate/components/data-table/table-row";
7
+ import {
8
+ Box,
9
+ Checkbox,
10
+ Stack,
11
+ type SxProps,
12
+ type TableCellProps,
13
+ Typography,
14
+ } from "@mui/material";
15
+
16
+ interface Props {
17
+ item: ProcessTask;
18
+ heading: Head[]; // for alignment
19
+ checked: boolean;
20
+ toggleChecked: (id: string) => void;
21
+ alert: string | null;
22
+ sx?: SxProps;
23
+ }
24
+
25
+ export default function CopyTasksRow(props: Readonly<Props>) {
26
+ const headings = {
27
+ actions: props.heading.find((h) => h.id === "actions"),
28
+ name: props.heading.find((h) => h.id === "name"),
29
+ endpoint: props.heading.find((h) => h.id === "endpoint"),
30
+ };
31
+
32
+ const toggleChecked = () => {
33
+ props.toggleChecked(props.item.id);
34
+ };
35
+
36
+ return (
37
+ <StyledTableRow sx={props.sx}>
38
+ {headings.actions && (
39
+ <StyledTableCell
40
+ align={headings.actions.align as TableCellProps["align"]}
41
+ width={headings.actions.width}
42
+ >
43
+ <Checkbox
44
+ checked={props.checked}
45
+ onClick={toggleChecked}
46
+ disabled={!!props.alert}
47
+ />
48
+ </StyledTableCell>
49
+ )}
50
+ {headings.name && (
51
+ <StyledTableCell
52
+ align={headings.name.align as TableCellProps["align"]}
53
+ width={headings.name.width}
54
+ >
55
+ <Stack spacing={1} direction="row">
56
+ <Box display="flex" justifyContent="flex-start" alignItems="center">
57
+ {/* TODO: icon here */}
58
+ </Box>
59
+ <Box display="flex" justifyContent="flex-start" alignItems="center">
60
+ <Typography>{props.item.name ?? ""}</Typography>
61
+ </Box>
62
+ </Stack>
63
+ </StyledTableCell>
64
+ )}
65
+ {headings.endpoint && (
66
+ <StyledTableCell
67
+ align={headings.endpoint.align as TableCellProps["align"]}
68
+ width={headings.endpoint.width}
69
+ >
70
+ <Box display="flex" justifyContent="flex-start" alignItems="center">
71
+ <Typography>{props.item.endpoint?.name ?? ""}</Typography>
72
+ </Box>
73
+ </StyledTableCell>
74
+ )}
75
+ </StyledTableRow>
76
+ );
77
+ }
@@ -0,0 +1,61 @@
1
+ import type { GetProcessByIdWithTasksQuery } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
2
+ import { getProcessByIdWithTasks } from "@evenicanpm/admin-integrate/api/process/queries";
3
+ import { Box, type Theme, useTheme } from "@mui/material";
4
+ import { useParams } from "next/navigation";
5
+ import { useTranslations } from "next-intl";
6
+ import { useEffect } from "react";
7
+ import CopyTasksList from "./copy-tasks-list";
8
+ import {
9
+ type AlertAction,
10
+ type ImportAction,
11
+ ImportActionType,
12
+ type ImportState,
13
+ } from "./import-process-reducer";
14
+
15
+ interface Props {
16
+ importState: ImportState;
17
+ dispatch: React.Dispatch<ImportAction>;
18
+ }
19
+
20
+ export default function ImportConfirm(props: Readonly<Props>) {
21
+ const t = useTranslations("Integrate.IntegrationDetails.ImportProcess");
22
+ const params = useParams<{ processId: string }>();
23
+
24
+ const theme = useTheme();
25
+ const styles = getStyles(theme);
26
+
27
+ const { data, isLoading } = getProcessByIdWithTasks.useData({
28
+ id: props.importState.selectedId ?? "",
29
+ });
30
+
31
+ useEffect(() => {
32
+ const typedData = data as GetProcessByIdWithTasksQuery;
33
+ if (typedData?.processById) {
34
+ if (typedData.processById.id === params.processId) {
35
+ props.dispatch({
36
+ type: ImportActionType.ALERT,
37
+ alert: t("Alert.same"),
38
+ } as AlertAction);
39
+ }
40
+ }
41
+ }, [data]);
42
+
43
+ return (
44
+ <Box sx={styles.main}>
45
+ <CopyTasksList
46
+ data={data as GetProcessByIdWithTasksQuery}
47
+ loading={isLoading}
48
+ importState={props.importState}
49
+ dispatch={props.dispatch}
50
+ />
51
+ </Box>
52
+ );
53
+ }
54
+
55
+ const getStyles = (theme: Theme) => {
56
+ return {
57
+ main: {
58
+ marginTop: theme.spacing(2),
59
+ },
60
+ };
61
+ };
@@ -0,0 +1,48 @@
1
+ import { DrawerButtons } from "@evenicanpm/admin-integrate/components/core";
2
+ import {
3
+ Box,
4
+ Drawer,
5
+ type DrawerProps,
6
+ type Theme,
7
+ useTheme,
8
+ } from "@mui/material";
9
+ import ImportProcess from "./import-process";
10
+ import {
11
+ type ImportAction,
12
+ ImportActionType,
13
+ type ImportState,
14
+ } from "./import-process-reducer";
15
+
16
+ interface Props extends DrawerProps {
17
+ importState: ImportState;
18
+ dispatch: React.Dispatch<ImportAction>;
19
+ }
20
+
21
+ export default function ImportDrawer({
22
+ importState,
23
+ dispatch,
24
+ ...props
25
+ }: Readonly<Props>) {
26
+ const theme = useTheme();
27
+ const styles = getStyles(theme);
28
+
29
+ return (
30
+ <Drawer {...props}>
31
+ <DrawerButtons
32
+ handleClose={() => dispatch({ type: ImportActionType.CLOSE })}
33
+ />
34
+ <Box sx={styles.main}>
35
+ <ImportProcess importState={importState} dispatch={dispatch} />
36
+ </Box>
37
+ </Drawer>
38
+ );
39
+ }
40
+
41
+ const getStyles = (theme: Theme) => {
42
+ return {
43
+ main: {
44
+ maxWidth: `100vw`,
45
+ minWidth: `min(${theme.spacing(100)}, 100vw)`,
46
+ },
47
+ };
48
+ };
@@ -0,0 +1,90 @@
1
+ export enum ImportActionType {
2
+ CLOSE = "CLOSE",
3
+ OPEN = "OPEN",
4
+ SELECT = "SELECT",
5
+ DESELECT = "DESELECT",
6
+ ALERT = "ALERT",
7
+ SAVE = "SAVE",
8
+ SAVESUCCESS = "SAVESUCCESS",
9
+ }
10
+
11
+ export interface ImportAction {
12
+ type: ImportActionType;
13
+ }
14
+
15
+ export interface SelectProcessAction extends ImportAction {
16
+ selectedId: string;
17
+ }
18
+
19
+ export interface AlertAction extends ImportAction {
20
+ alert: string | null;
21
+ }
22
+
23
+ export interface ImportState {
24
+ open: boolean;
25
+ step: number | null;
26
+ selectedId?: string | null;
27
+ alert: string | null;
28
+ loading: boolean;
29
+ }
30
+
31
+ export function importReducer(
32
+ state: ImportState,
33
+ action: ImportAction,
34
+ ): ImportState {
35
+ switch (action.type) {
36
+ case ImportActionType.CLOSE: {
37
+ return {
38
+ open: false,
39
+ step: null,
40
+ selectedId: null,
41
+ alert: null,
42
+ loading: false,
43
+ };
44
+ }
45
+ case ImportActionType.OPEN: {
46
+ return {
47
+ ...state,
48
+ open: true,
49
+ step: 0,
50
+ selectedId: null,
51
+ };
52
+ }
53
+ case ImportActionType.ALERT: {
54
+ return {
55
+ ...state,
56
+ alert: (action as AlertAction).alert,
57
+ };
58
+ }
59
+ case ImportActionType.SELECT: {
60
+ return {
61
+ ...state,
62
+ selectedId: (action as SelectProcessAction).selectedId,
63
+ step: 1,
64
+ };
65
+ }
66
+ case ImportActionType.DESELECT: {
67
+ return {
68
+ ...state,
69
+ selectedId: null,
70
+ step: 0,
71
+ };
72
+ }
73
+ case ImportActionType.SAVE: {
74
+ return {
75
+ ...state,
76
+ loading: true,
77
+ };
78
+ }
79
+ case ImportActionType.SAVESUCCESS: {
80
+ return {
81
+ ...state,
82
+ loading: false,
83
+ };
84
+ }
85
+ default: {
86
+ console.error(`${action.type} is not a valid action for importReducer`);
87
+ return state;
88
+ }
89
+ }
90
+ }