@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,172 @@
1
+ import type {
2
+ ConfigExport,
3
+ ConfigurationMergeMutation,
4
+ ConfigurationMergeMutationVariables,
5
+ FilterQueryInput,
6
+ GetProcessTemplatesQuery,
7
+ } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
8
+ import { processConfigMerge } from "@evenicanpm/admin-integrate/api/process-config/mutation";
9
+ import { getProcessTemplates } from "@evenicanpm/admin-integrate/api/templates/queries";
10
+ import type { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
11
+ import { Wizard } from "@evenicanpm/admin-integrate/components/templates";
12
+ import TemplatesList from "@evenicanpm/admin-integrate/components/templates/templates-list";
13
+ import type {
14
+ Metadata,
15
+ ProcessConfigMerge,
16
+ } from "@evenicanpm/admin-integrate/components/templates/types";
17
+ import { removeTemplateConfig } from "@evenicanpm/admin-integrate/components/templates/wizard";
18
+ import { Box, Typography, useTheme } from "@mui/material";
19
+ import { useTranslations } from "next-intl";
20
+ import { useEffect, useState } from "react";
21
+ import {
22
+ type TaskAction,
23
+ TaskActionType,
24
+ type TaskState,
25
+ } from "./task-reducer";
26
+
27
+ interface Props {
28
+ taskState: TaskState;
29
+ dispatch: React.Dispatch<TaskAction>;
30
+ handleUpdateConfig: (newConfig: ConfigExport) => void;
31
+ }
32
+
33
+ // steps:
34
+ // - 0: choose template from list
35
+ // - 1: wizard (finish --> update flowchart view with added task, close drawer)
36
+ export default function AddTask(props: Readonly<Props>) {
37
+ const t = useTranslations("Integrate");
38
+ const theme = useTheme();
39
+
40
+ const processConfigMergeMutation = processConfigMerge();
41
+
42
+ const heading: Head[] = [
43
+ {
44
+ id: "name",
45
+ label: t("Templates.ListHeader.name"),
46
+ align: "left",
47
+ width: "95%",
48
+ sortable: true,
49
+ },
50
+ {
51
+ id: "view",
52
+ label: t("Templates.ListHeader.actions"),
53
+ align: "right",
54
+ width: "5%",
55
+ },
56
+ ];
57
+
58
+ const [processConfigMergeInput, setProcessConfigMergeInput] =
59
+ useState<ProcessConfigMerge | null>(null);
60
+
61
+ useEffect(() => {
62
+ if (processConfigMergeInput) {
63
+ const input =
64
+ removeTemplateConfig(processConfigMergeInput?.input) ||
65
+ ({} as ConfigurationMergeMutationVariables);
66
+ processConfigMergeMutation.mutate(
67
+ {
68
+ input: input,
69
+ },
70
+ {
71
+ onSuccess: async (data: ConfigurationMergeMutation) => {
72
+ if (data.configurationMerge?.Processes?.[0]?.ProcessTasks)
73
+ data.configurationMerge.Processes[0].ProcessTasks =
74
+ data.configurationMerge.Processes[0].ProcessTasks.map(
75
+ (item, index) => ({
76
+ ...item,
77
+ Sort:
78
+ (item?.Sort ?? index) +
79
+ (props.taskState.sort as number) -
80
+ 1,
81
+ ParallelProcessingGroup:
82
+ props.taskState.parallelProcessingGroup,
83
+ }),
84
+ );
85
+ props.handleUpdateConfig(data?.configurationMerge as ConfigExport);
86
+ },
87
+ onError: (error) => {
88
+ console.error("Update failed:", error);
89
+ },
90
+ },
91
+ );
92
+ }
93
+ }, [processConfigMergeInput]);
94
+
95
+ // const [processConfigMerge, setProcessConfigMerge] =
96
+ // useState<ProcessConfigMerge | null>(null);
97
+ const [processTemplateId, setProcessTemplateId] = useState<string | null>(
98
+ null,
99
+ );
100
+
101
+ const [input, setInput] = useState<FilterQueryInput>({
102
+ sort: "name",
103
+ sortDesc: false,
104
+ top: 10,
105
+ skip: 0,
106
+ });
107
+
108
+ const { data, isLoading } = getProcessTemplates.useData({
109
+ input: input,
110
+ });
111
+
112
+ const handleNext = () => {
113
+ const action: TaskAction = { type: TaskActionType.INCREMENT_STEP };
114
+ props.dispatch(action);
115
+ };
116
+ const handleBack = () => {
117
+ const action: TaskAction = { type: TaskActionType.DECREMENT_STEP };
118
+ props.dispatch(action);
119
+ };
120
+
121
+ const handleRedirect = (id: string) => {
122
+ setProcessTemplateId(id);
123
+ handleNext();
124
+ };
125
+
126
+ return (
127
+ <>
128
+ {props.taskState.step === 0 && (
129
+ <Box sx={{ marginBottom: theme.spacing(3) }}>
130
+ <Typography variant="h6">
131
+ {t("IntegrationDetails.AddTask.title")}
132
+ </Typography>
133
+ <Typography variant="body1">
134
+ {t("IntegrationDetails.AddTask.descList")}
135
+ </Typography>
136
+ </Box>
137
+ )}
138
+ {props.taskState.step === 0 && (
139
+ <TemplatesList
140
+ heading={heading}
141
+ data={data as GetProcessTemplatesQuery}
142
+ loading={isLoading}
143
+ input={input}
144
+ setInput={setInput}
145
+ handleRedirect={handleRedirect}
146
+ />
147
+ )}
148
+ {props.taskState.step === 1 && (
149
+ <Wizard
150
+ // todo: should be set to metadata returned from api query for integration details
151
+ metadata={
152
+ {
153
+ name: "", // name/code of parent Process is not relevant when editing a single task.
154
+ code: "",
155
+ parallelProcessingGroup: props.taskState
156
+ .parallelProcessingGroup as number,
157
+ sort: props.taskState.sort as number,
158
+ } as Metadata
159
+ }
160
+ setProcessConfigMerge={setProcessConfigMergeInput}
161
+ processTemplateId={processTemplateId ?? undefined}
162
+ isCreateMode
163
+ handleBack={handleBack}
164
+ handleFinish={handleNext}
165
+ />
166
+ )}
167
+ {props.taskState.step === 2 && (
168
+ <Typography>{JSON.stringify(processConfigMerge)}</Typography>
169
+ )}
170
+ </>
171
+ );
172
+ }
@@ -0,0 +1,161 @@
1
+ import type {
2
+ ConfigExport,
3
+ ConfigurationMergeMutation,
4
+ ConfigurationMergeMutationVariables,
5
+ } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
6
+ import { processConfigMerge } from "@evenicanpm/admin-integrate/api/process-config/mutation";
7
+ import { TitleEdit } from "@evenicanpm/admin-integrate/components/core";
8
+ import { Wizard } from "@evenicanpm/admin-integrate/components/templates";
9
+ import type {
10
+ Metadata,
11
+ ProcessConfigMerge,
12
+ } from "@evenicanpm/admin-integrate/components/templates/types";
13
+ import { removeTemplateConfig } from "@evenicanpm/admin-integrate/components/templates/wizard";
14
+ import ReportProblemIcon from "@mui/icons-material/ReportProblem";
15
+ import {
16
+ Box,
17
+ CircularProgress,
18
+ Stack,
19
+ Typography,
20
+ useTheme,
21
+ } from "@mui/material";
22
+ import { useEffect, useState } from "react";
23
+ import {
24
+ type TaskAction,
25
+ TaskActionType,
26
+ type TaskState,
27
+ } from "./task-reducer";
28
+
29
+ interface Props {
30
+ taskState: TaskState;
31
+ dispatch: React.Dispatch<TaskAction>;
32
+ handleUpdateConfig: (newConfig: ConfigExport) => void;
33
+ editable?: boolean;
34
+ templateConfigInput?: any | null;
35
+ }
36
+
37
+ export default function EditTask(props: Readonly<Props>) {
38
+ const theme = useTheme();
39
+
40
+ const processConfigMergeMutation = processConfigMerge();
41
+
42
+ const [processConfigMergeInput, setProcessConfigMergeInput] =
43
+ useState<ProcessConfigMerge | null>(null);
44
+
45
+ const handleFinish = () => {
46
+ const action: TaskAction = { type: TaskActionType.INCREMENT_STEP };
47
+ props.dispatch(action);
48
+ };
49
+ const handleBack = () => {
50
+ const action: TaskAction = { type: TaskActionType.DECREMENT_STEP };
51
+ props.dispatch(action);
52
+ };
53
+
54
+ const [_name, setName] = useState<string>("");
55
+ const [sharedCount, setSharedCount] = useState<number>();
56
+
57
+ const handleNameEdit = (input: string) => {
58
+ setName(input);
59
+
60
+ // TODO: on name change confirm, update main config state in details pg w/ updated name/code for this task
61
+ // props.handleUpdateConfig(...)
62
+ };
63
+
64
+ useEffect(() => {
65
+ if (processConfigMergeInput) {
66
+ const input =
67
+ removeTemplateConfig(processConfigMergeInput?.input) ||
68
+ ({} as ConfigurationMergeMutationVariables);
69
+ processConfigMergeMutation.mutate(
70
+ {
71
+ input: input,
72
+ },
73
+ {
74
+ onSuccess: async (data: ConfigurationMergeMutation) => {
75
+ props.handleUpdateConfig(data?.configurationMerge as ConfigExport);
76
+ },
77
+ onError: (error) => {
78
+ console.error("Update failed:", error);
79
+ },
80
+ },
81
+ );
82
+ }
83
+ }, [processConfigMergeInput]);
84
+
85
+ return (
86
+ <>
87
+ {props.taskState.step === 0 &&
88
+ !!props.taskState.sort &&
89
+ !!props.taskState.parallelProcessingGroup && (
90
+ <Box sx={{ marginBottom: theme.spacing(1) }}>
91
+ <Stack
92
+ direction="row"
93
+ spacing={1}
94
+ sx={{ minHeight: theme.spacing(7) }}
95
+ >
96
+ <TitleEdit
97
+ title={props?.taskState?.name || "Edit Task"}
98
+ onConfirm={handleNameEdit}
99
+ fullWidth
100
+ variant="h6"
101
+ //readOnly={!props.editable}
102
+ readOnly={true}
103
+ />
104
+ </Stack>
105
+ {sharedCount !== undefined &&
106
+ sharedCount > 1 &&
107
+ props?.editable && (
108
+ <Typography
109
+ variant="body2"
110
+ color="error"
111
+ sx={{
112
+ display: "flex",
113
+ alignItems: "center",
114
+ gap: "5px",
115
+ fontSize: "12px",
116
+ }}
117
+ >
118
+ <ReportProblemIcon color="error" sx={{ fontSize: "18px" }} />{" "}
119
+ Changes to this integration tasks will affect other tasks
120
+ sharing the same <strong>Data Description</strong>
121
+ </Typography>
122
+ )}
123
+ </Box>
124
+ )}
125
+ {props.taskState.step === 0 &&
126
+ // (data as GetProcessTaskByIdQuery)?.processTaskById?.endpoint
127
+ // ?.templateConfig &&
128
+ !!props.taskState.parallelProcessingGroup &&
129
+ !!props.taskState.sort && (
130
+ <Wizard
131
+ metadata={
132
+ {
133
+ //name: "", // name/code of parent Process is not relevant when editing a single task.
134
+ //code: "",
135
+ parallelProcessingGroup: props.taskState
136
+ .parallelProcessingGroup as number,
137
+ sort: props.taskState.sort as number,
138
+ processTaskId: props?.taskState?.processTaskId
139
+ ? Number.parseInt(props.taskState.processTaskId)
140
+ : null,
141
+ } as Metadata
142
+ }
143
+ setProcessConfigMerge={setProcessConfigMergeInput}
144
+ handleBack={handleBack}
145
+ handleFinish={handleFinish}
146
+ templateConfig={props.taskState.templateConfig}
147
+ processTemplateId={props.taskState.processTemplateId as string}
148
+ isEditMode
149
+ isCreateMode={false}
150
+ disableBackToTemplates
151
+ readOnly={!props.editable}
152
+ sharedCount={(count: number) => setSharedCount(count)}
153
+ />
154
+ )}
155
+ {props.taskState.step === 1 && (
156
+ // <Typography>{JSON.stringify(processConfigMergeInput)}</Typography>
157
+ <CircularProgress sx={{ margin: theme.spacing(10, 0) }} />
158
+ )}
159
+ </>
160
+ );
161
+ }
@@ -0,0 +1,157 @@
1
+ import type { ConfigExport } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
2
+ import { DrawerButtons } from "@evenicanpm/admin-integrate/components/core";
3
+ import { EditOutlined } from "@mui/icons-material";
4
+ import {
5
+ Box,
6
+ Button,
7
+ type DrawerProps,
8
+ Drawer as MuiDrawer,
9
+ type Theme,
10
+ useTheme,
11
+ } from "@mui/material";
12
+ import { styled } from "@mui/material/styles";
13
+ import { usePathname, useRouter } from "next/navigation";
14
+ import { useTranslations } from "next-intl";
15
+ import { useEffect, useState } from "react";
16
+ import AddTask from "./add-task";
17
+ import EditTask from "./edit-task";
18
+ import {
19
+ type TaskAction,
20
+ TaskActionType,
21
+ TaskMode,
22
+ type TaskState,
23
+ } from "./task-reducer";
24
+
25
+ interface Props extends DrawerProps {
26
+ taskState: TaskState;
27
+ renderKey: any;
28
+ dispatch: React.Dispatch<TaskAction>;
29
+ handleUpdateConfig?: (newConfig: ConfigExport) => void;
30
+ templateConfigInput?: any | null;
31
+ config: ConfigExport;
32
+ }
33
+
34
+ const Drawer = styled(MuiDrawer)({
35
+ position: "relative", //imp
36
+ //width: 625, //drawer width
37
+ "& .MuiDrawer-paper": {
38
+ width: 625, //drawer width
39
+ position: "absolute", //imp
40
+ transition: "none !important",
41
+ },
42
+ });
43
+
44
+ export default function TaskDrawer({
45
+ taskState,
46
+ renderKey,
47
+ dispatch,
48
+ handleUpdateConfig,
49
+ ...props
50
+ }: Readonly<Props>) {
51
+ const t = useTranslations("Integrate.IntegrationDetails.TaskDrawer");
52
+
53
+ const theme = useTheme();
54
+ const styles = getStyles(theme);
55
+
56
+ const router = useRouter();
57
+ const pathname = usePathname();
58
+
59
+ const [editable, setEditable] = useState<boolean>(false);
60
+ const [reloadKey, setReloadKey] = useState<number>(Date.now());
61
+
62
+ const confirmCancel = () => {
63
+ if (editable) {
64
+ return confirm(t("confirmTaskUpdateText"));
65
+ }
66
+ return true;
67
+ };
68
+
69
+ const handleClose = () => {
70
+ if (!confirmCancel()) return;
71
+
72
+ const action: TaskAction = { type: TaskActionType.CLOSE };
73
+ dispatch(action);
74
+ setEditable(false);
75
+ };
76
+
77
+ const handleEdit = () => {
78
+ if (!confirmCancel()) return;
79
+
80
+ if (editable) setReloadKey(Date.now());
81
+ setEditable(!editable);
82
+ };
83
+
84
+ useEffect(() => {
85
+ if (taskState.step === null || taskState.step === 0) {
86
+ router.replace(pathname);
87
+ }
88
+ }, [taskState.step]);
89
+
90
+ return (
91
+ <Drawer
92
+ {...props}
93
+ variant="persistent"
94
+ sx={{ padding: theme.spacing(2), width: taskState.open ? 525 : 0 }}
95
+ >
96
+ <DrawerButtons handleClose={handleClose}>
97
+ {taskState.mode === TaskMode.EDIT && (
98
+ <Button
99
+ variant={editable ? "outlined" : "contained"}
100
+ color={editable ? "error" : "info"}
101
+ onClick={handleEdit}
102
+ endIcon={<EditOutlined />}
103
+ >
104
+ {editable ? t("cancel") : t("edit")}
105
+ </Button>
106
+ )}
107
+ </DrawerButtons>
108
+ <Box sx={styles.main}>
109
+ {taskState.mode === TaskMode.ADD && (
110
+ <AddTask
111
+ taskState={taskState}
112
+ dispatch={dispatch}
113
+ handleUpdateConfig={(newConfig: ConfigExport) => {
114
+ setEditable(false);
115
+ if (handleUpdateConfig) {
116
+ handleUpdateConfig(newConfig);
117
+ }
118
+ }}
119
+ />
120
+ )}
121
+ {taskState.mode === TaskMode.EDIT && (
122
+ <EditTask
123
+ key={reloadKey}
124
+ taskState={taskState}
125
+ dispatch={dispatch}
126
+ editable={editable}
127
+ handleUpdateConfig={(newConfig: ConfigExport) => {
128
+ setEditable(false);
129
+ if (handleUpdateConfig) {
130
+ handleUpdateConfig(newConfig);
131
+ }
132
+ }}
133
+ />
134
+ )}
135
+ </Box>
136
+ </Drawer>
137
+ );
138
+ }
139
+
140
+ const getStyles = (theme: Theme) => {
141
+ return {
142
+ main: {
143
+ //width: 600,
144
+ padding: theme.spacing(2),
145
+ },
146
+ drawer: {
147
+ //width: 600,
148
+ },
149
+ enableEdit: {
150
+ backgroundColor: "info.main",
151
+ "&:hover": {
152
+ backgroundColor: "info.400",
153
+ },
154
+ color: "white",
155
+ },
156
+ };
157
+ };
@@ -0,0 +1,103 @@
1
+ export enum TaskActionType {
2
+ CLOSE = "CLOSE",
3
+ OPEN_ADD = "OPEN_ADD",
4
+ OPEN_EDIT = "OPEN_EDIT",
5
+ INCREMENT_STEP = "INCREMENT_STEP",
6
+ DECREMENT_STEP = "DECREMENT_STEP",
7
+ }
8
+
9
+ export enum TaskMode {
10
+ NONE = "NONE",
11
+ ADD = "ADD",
12
+ EDIT = "EDIT",
13
+ }
14
+
15
+ export interface TaskAction {
16
+ type: TaskActionType;
17
+ }
18
+
19
+ export interface EditAction extends TaskAction {
20
+ processTaskId: string;
21
+ templateConfig?: string;
22
+ sort?: number;
23
+ parallelProcessingGroup?: number;
24
+ processTemplateId?: string;
25
+ name?: string;
26
+ }
27
+
28
+ export interface TaskState {
29
+ open: boolean;
30
+ mode: TaskMode;
31
+ step: number | null;
32
+ processTaskId?: string | null;
33
+ templateConfig?: string;
34
+ sort?: number;
35
+ parallelProcessingGroup?: number;
36
+ processTemplateId?: string;
37
+ name?: string;
38
+ }
39
+
40
+ export function taskReducer(state: TaskState, action: TaskAction): TaskState {
41
+ switch (action.type) {
42
+ case TaskActionType.CLOSE: {
43
+ return {
44
+ open: false,
45
+ mode: TaskMode.NONE,
46
+ step: null,
47
+ processTaskId: null,
48
+ };
49
+ }
50
+ case TaskActionType.OPEN_ADD: {
51
+ return {
52
+ open: true,
53
+ mode: TaskMode.ADD,
54
+ step: 0,
55
+ processTaskId: null,
56
+ sort: (action as EditAction).sort,
57
+ parallelProcessingGroup: (action as EditAction).parallelProcessingGroup,
58
+ name: undefined,
59
+ };
60
+ }
61
+ case TaskActionType.OPEN_EDIT: {
62
+ return {
63
+ open: true,
64
+ mode: TaskMode.EDIT,
65
+ step: 0,
66
+ processTaskId: (action as EditAction).processTaskId,
67
+ templateConfig: (action as EditAction).templateConfig,
68
+ sort: (action as EditAction).sort,
69
+ parallelProcessingGroup: (action as EditAction).parallelProcessingGroup,
70
+ processTemplateId: (action as EditAction).processTemplateId,
71
+ name: (action as EditAction).name,
72
+ };
73
+ }
74
+ case TaskActionType.INCREMENT_STEP: {
75
+ let step = null;
76
+
77
+ if (state.step !== null) {
78
+ step = state.step + 1;
79
+ }
80
+
81
+ return {
82
+ ...state,
83
+ step,
84
+ };
85
+ }
86
+ case TaskActionType.DECREMENT_STEP: {
87
+ let step = null;
88
+
89
+ if (state.step !== null) {
90
+ step = Math.max(state.step - 1, 0);
91
+ }
92
+
93
+ return {
94
+ ...state,
95
+ step,
96
+ };
97
+ }
98
+ default: {
99
+ console.error(`${action.type} is not a valid action for detailsReducer`);
100
+ return state;
101
+ }
102
+ }
103
+ }
@@ -1,20 +1,17 @@
1
- import React, { useState } from "react";
2
- import { useTranslations } from "next-intl";
3
-
4
- // MUI
5
- import { Box } from "@mui/material";
6
-
7
- // API
1
+ import type {
2
+ GetProcessesQuery,
3
+ ProcessInput,
4
+ } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
8
5
  import { getProcesses } from "@evenicanpm/admin-integrate/api/Integrations/queries";
9
- import { ProcessInput } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
10
-
11
- // Custom components
12
6
  import {
7
+ type Crumb,
13
8
  IntegrateBreadcrumbs,
14
- Crumb,
15
9
  } from "@evenicanpm/admin-integrate/components/breadcrumbs";
16
- import { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
17
- import IntegrationList from "./integration-list";
10
+ import type { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
11
+ import { IntegrationList } from "@evenicanpm/admin-integrate/components/integration-list";
12
+ import { Box } from "@mui/material";
13
+ import { useTranslations } from "next-intl";
14
+ import { useState } from "react";
18
15
 
19
16
  export default function Integrations() {
20
17
  const t = useTranslations("Integrate");
@@ -84,7 +81,7 @@ export default function Integrations() {
84
81
  <IntegrateBreadcrumbs breadcrumbs={breadcrumbs} />
85
82
  <IntegrationList
86
83
  heading={heading}
87
- data={data}
84
+ data={data as GetProcessesQuery}
88
85
  loading={isLoading}
89
86
  input={input}
90
87
  setInput={setInput}
@@ -1,31 +1,19 @@
1
- import React, { useState } from "react";
2
- import { useTranslations } from "next-intl";
3
-
4
- // API
5
- import { getScheduledProcesses } from "@evenicanpm/admin-integrate/api/scheduler/queries";
6
- import {
7
- ScheduledProcessInput,
1
+ import type {
8
2
  GetScheduledProcessesQuery,
3
+ ScheduledProcessInput,
9
4
  } from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
10
-
11
- // MUI
5
+ import { getScheduledProcesses } from "@evenicanpm/admin-integrate/api/scheduler/queries";
6
+ import {
7
+ type Crumb,
8
+ IntegrateBreadcrumbs,
9
+ } from "@evenicanpm/admin-integrate/components/breadcrumbs";
10
+ import type { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
11
+ import ScheduleDrawer from "@evenicanpm/admin-integrate/components/scheduler/schedule-drawer";
12
+ import type { DrawerOpen } from "@evenicanpm/admin-integrate/components/scheduler/schedule-drawer/schedule-drawer";
12
13
  import { Box } from "@mui/material";
13
-
14
- // Custom components
15
- import { IntegrateBreadcrumbs } from "@evenicanpm/admin-integrate/components/breadcrumbs";
16
-
17
- // Local components
14
+ import { useTranslations } from "next-intl";
15
+ import { useState } from "react";
18
16
  import SchedulesList from "./schedules-list";
19
- import ScheduleDrawer from "./schedule-drawer";
20
-
21
- // Types
22
- import { Crumb } from "@evenicanpm/admin-integrate/components/breadcrumbs";
23
- import { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
24
-
25
- export type DrawerOpen = {
26
- id: string;
27
- group?: boolean;
28
- };
29
17
 
30
18
  export default function Scheduler() {
31
19
  const t = useTranslations("Integrate");