@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.
- package/documents/ConfigImport/configuration-import.ts +54 -0
- package/documents/CopyProcess/copy.ts +25 -0
- package/documents/Endpoint/fragments.ts +9 -0
- package/documents/Endpoint/list.ts +30 -0
- package/documents/Process/fragments.ts +22 -0
- package/documents/Process/get-process-details.ts +72 -0
- package/documents/Process/list.ts +24 -0
- package/documents/ProcessConfig/fragments.ts +116 -0
- package/documents/ProcessConfig/read.ts +35 -0
- package/documents/ProcessExecution/fragments.ts +12 -0
- package/documents/ProcessExecution/list.ts +30 -1
- package/documents/ProcessExecutionDetails/fragments.ts +96 -0
- package/documents/ProcessExecutionDetails/read.ts +12 -0
- package/documents/ProcessExport/read.ts +108 -0
- package/documents/ProcessScheduleGroup/read.ts +43 -0
- package/documents/ProcessTask/fragments.ts +288 -0
- package/documents/ProcessTask/read.ts +12 -0
- package/documents/ProcessTemplate/fragments.ts +74 -0
- package/documents/ProcessTemplate/list.ts +67 -0
- package/documents/ProcessTemplate/read.ts +12 -0
- package/documents/RunProcess/run.ts +11 -0
- package/package.json +4 -3
- package/src/api/Integrations/queries/get-process.query.ts +12 -12
- package/src/api/Integrations/queries/get-process.server.ts +7 -2
- package/src/api/configuration/queries/configuration-export.query.ts +48 -0
- package/src/api/configuration/queries/configuration-export.server.ts +9 -0
- package/src/api/configuration/queries/index.ts +1 -0
- package/src/api/dashboard/queries/get-process-executions.query.ts +6 -3
- package/src/api/dashboard/queries/get-process-executions.server.ts +1 -1
- package/src/api/execution-details/queries/get-process-execution-details.query.ts +46 -0
- package/src/api/execution-details/queries/get-process-execution-details.server.ts +11 -0
- package/src/api/execution-details/queries/get-process-executions-by-process.query.ts +48 -0
- package/src/api/execution-details/queries/get-process-executions-by-process.server.ts +11 -0
- package/src/api/execution-details/queries/index.ts +2 -0
- package/src/api/process/mutations/copy-process.mutation.ts +45 -0
- package/src/api/process/mutations/copy-process.server.ts +14 -0
- package/src/api/process/mutations/index.ts +2 -0
- package/src/api/process/mutations/run-process.mutation.ts +41 -0
- package/src/api/process/mutations/run-process.server.ts +14 -0
- package/src/api/process/queries/get-process-by-id.query.ts +85 -0
- package/src/api/process/queries/get-process-by-id.server.ts +20 -0
- package/src/api/process/queries/index.ts +4 -0
- package/src/api/process-config/mutation/index.ts +2 -0
- package/src/api/process-config/mutation/process-config-import.mutation.ts +42 -0
- package/src/api/process-config/mutation/process-config-import.server.ts +14 -0
- package/src/api/process-config/mutation/process-config-merge.mutation.ts +33 -0
- package/src/api/process-config/mutation/process-config-merge.server.ts +14 -0
- package/src/api/process-task/queries/get-process-task-by-id.query.ts +46 -0
- package/src/api/process-task/queries/get-process-task-by-id.server.ts +9 -0
- package/src/api/process-task/queries/index.ts +1 -0
- package/src/api/scheduler/mutation/create-process-schedule-group-details.mutation.ts +47 -0
- package/src/api/scheduler/mutation/create-process-schedule-group-details.server.ts +14 -0
- package/src/api/scheduler/mutation/index.ts +2 -0
- package/src/api/scheduler/mutation/update-process-schedule-group-details.mutation.ts +47 -0
- package/src/api/scheduler/mutation/update-process-schedule-group-details.server.ts +14 -0
- package/src/api/scheduler/queries/get-non-scheduled-processes.query.ts +48 -0
- package/src/api/scheduler/queries/get-non-scheduled-processes.server.ts +11 -0
- package/src/api/scheduler/queries/get-process-schedule-group-details.query.ts +6 -3
- package/src/api/scheduler/queries/get-process-schedule-group-details.server.ts +3 -3
- package/src/api/scheduler/queries/get-process-schedule.query.ts +6 -3
- package/src/api/scheduler/queries/get-process-schedule.server.ts +3 -3
- package/src/api/scheduler/queries/get-scheduled-processes.query.ts +6 -3
- package/src/api/scheduler/queries/get-scheduled-processes.server.ts +1 -1
- package/src/api/scheduler/queries/index.ts +3 -2
- package/src/api/templates/queries/get-process-template-groups.query.ts +48 -0
- package/src/api/templates/queries/get-process-template-groups.server.ts +11 -0
- package/src/api/templates/queries/get-process-template-records.query.ts +48 -0
- package/src/api/templates/queries/get-process-template-records.server.ts +11 -0
- package/src/api/templates/queries/get-process-template.query.ts +48 -0
- package/src/api/templates/queries/get-process-template.server.ts +9 -0
- package/src/api/templates/queries/get-process-templates.query.ts +45 -0
- package/src/api/templates/queries/get-process-templates.server.ts +9 -0
- package/src/api/templates/queries/index.ts +5 -0
- package/src/api/templates/queries/template-input-search.query.ts +39 -0
- package/src/api/templates/queries/template-input-search.server.ts +42 -0
- package/src/api/templates/queries/types.ts +34 -0
- package/src/components/breadcrumbs/breadcrumbs.tsx +33 -6
- package/src/components/button/outlined-icon-button.tsx +2 -2
- package/src/components/core/date-time-popover.tsx +12 -5
- package/src/components/core/drawer-buttons.tsx +52 -0
- package/src/components/core/edited-typography.tsx +2 -2
- package/src/components/core/index.ts +4 -2
- package/src/components/core/loading.tsx +1 -1
- package/src/components/core/status-tag.tsx +97 -0
- package/src/components/core/title-edit.tsx +31 -22
- package/src/components/dashboard-list/dashboard-list-row.tsx +22 -29
- package/src/components/dashboard-list/dashboard-list.tsx +20 -16
- package/src/components/data-table/table-header.tsx +6 -8
- package/src/components/data-table/table-pagination.tsx +1 -1
- package/src/components/data-table/table-row.tsx +1 -1
- package/src/components/data-table/table-skeleton.tsx +10 -5
- package/src/components/execution/execution-filter.ts +1 -1
- package/src/components/execution/execution-status-icon.tsx +7 -7
- package/src/components/execution/execution-tag.tsx +12 -77
- package/src/components/execution/index.ts +1 -1
- package/src/components/execution-history-drawer/execution-history-drawer.tsx +202 -0
- package/src/components/execution-history-drawer/executions-card.tsx +85 -0
- package/src/components/execution-history-drawer/index.ts +1 -0
- package/src/components/footer/footer.tsx +10 -6
- package/src/components/header/dashboard-list-header.tsx +12 -7
- package/src/components/header/execution-details-header.tsx +35 -26
- package/src/components/header/header.tsx +10 -3
- package/src/components/header/index.ts +1 -1
- package/src/components/header/integration-details-header.tsx +108 -45
- package/src/components/integration-list/index.ts +2 -1
- package/src/components/integration-list/integration-filter.ts +1 -1
- package/src/components/integration-list/integration-status-icon.tsx +7 -8
- package/src/components/integration-list/integration-tag.tsx +6 -50
- package/src/components/integration-list/list/integration-list-row.tsx +161 -0
- package/src/components/integration-list/list/integration-list-table.tsx +62 -0
- package/src/{pages/integrations/integration-list → components/integration-list/list}/integration-list.tsx +47 -51
- package/src/components/integration-view/animated-svg.tsx +31 -0
- package/src/components/integration-view/edges/default-edge.tsx +2 -6
- package/src/components/integration-view/elk-layout-options.ts +2 -2
- package/src/components/integration-view/elk-types.ts +35 -6
- package/src/components/integration-view/flow-types.tsx +12 -0
- package/src/components/integration-view/integration-view.tsx +562 -56
- package/src/components/integration-view/nodes/add-node.tsx +20 -0
- package/src/components/integration-view/nodes/empty-node.tsx +65 -0
- package/src/components/integration-view/nodes/entry-node.tsx +98 -4
- package/src/components/integration-view/nodes/execution-entry-node.tsx +107 -0
- package/src/components/integration-view/nodes/execution-task-node.tsx +88 -0
- package/src/components/integration-view/nodes/group-node.tsx +33 -13
- package/src/components/integration-view/nodes/row-node.tsx +19 -0
- package/src/components/integration-view/nodes/task-node.tsx +50 -16
- package/src/components/integration-view/task-icon.tsx +193 -0
- package/src/components/integration-view/temp-data/initialElements.tsx +34 -32
- package/src/components/integration-view/types.ts +2 -2
- package/src/components/integration-view/utils/mapping.ts +404 -0
- package/src/components/layouts/main-layout.tsx +3 -4
- package/src/components/layouts/root-container.tsx +5 -11
- package/src/components/link-cards/link-card.tsx +15 -4
- package/src/components/link-cards/styles.ts +1 -1
- package/src/components/list-filter/date-filter.tsx +7 -4
- package/src/components/list-filter/date-range-filter.tsx +15 -7
- package/src/components/list-filter/index.ts +1 -1
- package/src/components/list-filter/list-filter.tsx +31 -26
- package/src/components/list-filter/multi-select-filter.tsx +11 -10
- package/src/components/list-filter/select-filter.tsx +23 -12
- package/src/components/scheduler/day-selector.tsx +29 -15
- package/src/components/scheduler/day-tag.tsx +14 -51
- package/src/components/scheduler/index.ts +2 -1
- package/src/components/scheduler/schedule-drawer/details-reducer.ts +217 -0
- package/src/components/scheduler/schedule-drawer/schedule-details-integrations.tsx +501 -0
- package/src/{pages → components}/scheduler/schedule-drawer/schedule-details-main.tsx +137 -100
- package/src/components/scheduler/schedule-drawer/schedule-details-name.tsx +94 -0
- package/src/{pages → components}/scheduler/schedule-drawer/schedule-details-skeleton.tsx +1 -2
- package/src/{pages → components}/scheduler/schedule-drawer/schedule-details.tsx +10 -14
- package/src/components/scheduler/schedule-drawer/schedule-drawer-group.tsx +214 -0
- package/src/{pages → components}/scheduler/schedule-drawer/schedule-drawer-legacy.tsx +7 -26
- package/src/components/scheduler/schedule-drawer/schedule-drawer.tsx +116 -0
- package/src/components/scheduler/schedule-drawer/sortable-integration-row.tsx +130 -0
- package/src/components/scheduler/schedule-filter.ts +1 -1
- package/src/components/scheduler/schedule-icon.tsx +5 -6
- package/src/components/scheduler/schedule-integration-icon.tsx +31 -0
- package/src/components/templates/index.ts +1 -0
- package/src/components/templates/inputs/index.tsx +1392 -0
- package/src/components/templates/template-filter.ts +5 -0
- package/src/components/templates/templates-list/index.ts +1 -0
- package/src/components/templates/templates-list/templates-list-row.tsx +55 -0
- package/src/components/templates/templates-list/templates-list-table.tsx +58 -0
- package/src/components/templates/templates-list/templates-list.tsx +253 -0
- package/src/components/templates/types.tsx +76 -0
- package/src/components/templates/wizard.tsx +737 -0
- package/src/hooks/use-breadcrumbs.ts +1 -1
- package/src/hooks/use-recurrence.tsx +1 -2
- package/src/pages/dashboard/dashboard-link-cards.tsx +8 -11
- package/src/pages/dashboard/dashboard-list-sections.tsx +8 -10
- package/src/pages/dashboard/dashboard.tsx +1 -2
- package/src/pages/execution-details/execution-details.tsx +212 -14
- package/src/pages/execution-details/task-execution-details.tsx +160 -0
- package/src/pages/execution-details/task-execution-drawer.tsx +54 -0
- package/src/pages/executions/executions-list/executions-list-row.tsx +21 -27
- package/src/pages/executions/executions-list/executions-list-table.tsx +29 -36
- package/src/pages/executions/executions-list/executions-list.tsx +24 -18
- package/src/pages/executions/executions.tsx +11 -15
- package/src/pages/integration-create/index.ts +1 -0
- package/src/pages/integration-create/integration-create.tsx +216 -0
- package/src/pages/integration-create/pre-creation-step.tsx +84 -0
- package/src/pages/integration-create/select-step.tsx +105 -0
- package/src/pages/integration-create/template-list-step.tsx +77 -0
- package/src/pages/integration-create/wizard-step.tsx +51 -0
- package/src/pages/integration-details/import-process/copy-tasks-list.tsx +265 -0
- package/src/pages/integration-details/import-process/copy-tasks-row.tsx +77 -0
- package/src/pages/integration-details/import-process/import-confirm.tsx +61 -0
- package/src/pages/integration-details/import-process/import-drawer.tsx +48 -0
- package/src/pages/integration-details/import-process/import-process-reducer.ts +90 -0
- package/src/pages/integration-details/import-process/import-process.tsx +149 -0
- package/src/pages/integration-details/index.ts +1 -0
- package/src/pages/integration-details/integration-details.tsx +468 -0
- package/src/pages/integration-details/task-drawer/add-task.tsx +172 -0
- package/src/pages/integration-details/task-drawer/edit-task.tsx +161 -0
- package/src/pages/integration-details/task-drawer/task-drawer.tsx +157 -0
- package/src/pages/integration-details/task-drawer/task-reducer.ts +103 -0
- package/src/pages/integrations/integrations.tsx +11 -14
- package/src/pages/scheduler/scheduler.tsx +12 -24
- package/src/pages/scheduler/schedules-list/schedules-list-row.tsx +27 -37
- package/src/pages/scheduler/schedules-list/schedules-list-table.tsx +28 -43
- package/src/pages/scheduler/schedules-list/schedules-list.tsx +48 -21
- package/src/utils/date-functions.ts +69 -0
- package/src/utils/slugify.ts +3 -0
- package/tsconfig.json +12 -4
- package/src/hooks/use-timestamp.tsx +0 -25
- package/src/pages/integrations/integration-list/integration-list-row.tsx +0 -147
- package/src/pages/integrations/integration-list/integration-list-table.tsx +0 -78
- package/src/pages/scheduler/schedule-drawer/schedule-details-integrations.tsx +0 -227
- package/src/pages/scheduler/schedule-drawer/schedule-details-name.tsx +0 -77
- package/src/pages/scheduler/schedule-drawer/schedule-drawer-buttons.tsx +0 -72
- package/src/pages/scheduler/schedule-drawer/schedule-drawer-group.tsx +0 -103
- package/src/pages/scheduler/schedule-drawer/schedule-drawer.tsx +0 -101
- package/src/pages/scheduler/schedule-drawer/sortable-integration-row.tsx +0 -93
- /package/src/{pages/integrations/integration-list → components/integration-list/list}/index.ts +0 -0
- /package/src/{pages → components}/scheduler/schedule-drawer/edited/edited-types.ts +0 -0
- /package/src/{pages → components}/scheduler/schedule-drawer/edited/index.ts +0 -0
- /package/src/{pages → components}/scheduler/schedule-drawer/index.ts +0 -0
|
@@ -0,0 +1,501 @@
|
|
|
1
|
+
// Dnd
|
|
2
|
+
import {
|
|
3
|
+
closestCenter,
|
|
4
|
+
DndContext,
|
|
5
|
+
type DragEndEvent,
|
|
6
|
+
KeyboardSensor,
|
|
7
|
+
PointerSensor,
|
|
8
|
+
useSensor,
|
|
9
|
+
useSensors,
|
|
10
|
+
} from "@dnd-kit/core";
|
|
11
|
+
import { restrictToFirstScrollableAncestor } from "@dnd-kit/modifiers";
|
|
12
|
+
import {
|
|
13
|
+
arrayMove,
|
|
14
|
+
SortableContext,
|
|
15
|
+
sortableKeyboardCoordinates,
|
|
16
|
+
verticalListSortingStrategy,
|
|
17
|
+
} from "@dnd-kit/sortable";
|
|
18
|
+
import type {
|
|
19
|
+
GetNonScheduledProcessesQuery,
|
|
20
|
+
GetProcessScheduleByIdQuery,
|
|
21
|
+
GetProcessScheduleGroupDetailsQuery,
|
|
22
|
+
ProcessScheduleGroupDetailsUpdate,
|
|
23
|
+
} from "@evenicanpm/admin-core/api/e4/graphqlRequestSdk";
|
|
24
|
+
import { FlexBox } from "@evenicanpm/admin-core/components/flex-box";
|
|
25
|
+
import { getNonScheduledProcesses } from "@evenicanpm/admin-integrate/api/scheduler/queries";
|
|
26
|
+
import { EditedTypography } from "@evenicanpm/admin-integrate/components/core";
|
|
27
|
+
import {
|
|
28
|
+
TableHeader,
|
|
29
|
+
TablePagination,
|
|
30
|
+
TableSkeleton,
|
|
31
|
+
} from "@evenicanpm/admin-integrate/components/data-table";
|
|
32
|
+
import type { Head } from "@evenicanpm/admin-integrate/components/data-table/table-header";
|
|
33
|
+
import { Search } from "@mui/icons-material";
|
|
34
|
+
import {
|
|
35
|
+
Box,
|
|
36
|
+
Card,
|
|
37
|
+
Grid2 as Grid,
|
|
38
|
+
InputAdornment,
|
|
39
|
+
Stack,
|
|
40
|
+
Table,
|
|
41
|
+
TableBody,
|
|
42
|
+
TableContainer,
|
|
43
|
+
TextField,
|
|
44
|
+
type Theme,
|
|
45
|
+
Typography,
|
|
46
|
+
useTheme,
|
|
47
|
+
} from "@mui/material";
|
|
48
|
+
import { debounce } from "lodash";
|
|
49
|
+
import { useTranslations } from "next-intl";
|
|
50
|
+
import type React from "react";
|
|
51
|
+
import { useEffect, useState } from "react";
|
|
52
|
+
|
|
53
|
+
// Types
|
|
54
|
+
|
|
55
|
+
import {
|
|
56
|
+
type DefaultScheduledProcess,
|
|
57
|
+
type DetailsAction,
|
|
58
|
+
DetailsActionType,
|
|
59
|
+
type EditIntegrationsAction,
|
|
60
|
+
type ErrorsState,
|
|
61
|
+
type SetErrorsAction,
|
|
62
|
+
} from "./details-reducer";
|
|
63
|
+
|
|
64
|
+
import type { Edited } from "./edited";
|
|
65
|
+
import SortableIntegrationRow from "./sortable-integration-row";
|
|
66
|
+
|
|
67
|
+
export type Process = {
|
|
68
|
+
id: string;
|
|
69
|
+
sort: number;
|
|
70
|
+
name: string;
|
|
71
|
+
processIcon: string;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
interface Props {
|
|
75
|
+
data: GetProcessScheduleGroupDetailsQuery | GetProcessScheduleByIdQuery;
|
|
76
|
+
details: ProcessScheduleGroupDetailsUpdate;
|
|
77
|
+
errors?: ErrorsState;
|
|
78
|
+
dispatchDetails?: (value: DetailsAction) => void;
|
|
79
|
+
edited: Edited;
|
|
80
|
+
setEdited: (newEdited: Edited) => void;
|
|
81
|
+
readOnly?: boolean;
|
|
82
|
+
defaultScheduledProcess?: DefaultScheduledProcess;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export default function ScheduleDetailsIntegrations(props: Readonly<Props>) {
|
|
86
|
+
const t = useTranslations("Integrate.Scheduler");
|
|
87
|
+
const l = useTranslations("Integrate.Filter");
|
|
88
|
+
|
|
89
|
+
const theme = useTheme();
|
|
90
|
+
const styles = getStyles(theme);
|
|
91
|
+
const { label: searchLabel = l("defaultSearchLabel") } = {};
|
|
92
|
+
|
|
93
|
+
// items state holds result of nonScheduledProcess nodes
|
|
94
|
+
const [items, setItems] = useState<Process[]>([]);
|
|
95
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
96
|
+
const [nonScheduledMode, setNonScheduledMode] = useState<boolean>(false);
|
|
97
|
+
const [nonScheduledProcessesResult, setNonScheduledProcessesResult] =
|
|
98
|
+
useState<GetNonScheduledProcessesQuery | null>(null);
|
|
99
|
+
const [input, setInput] = useState({
|
|
100
|
+
sortDesc: true,
|
|
101
|
+
top: 5,
|
|
102
|
+
skip: 0,
|
|
103
|
+
});
|
|
104
|
+
const [page, setPage] = useState((input.skip || 0) / (input.top || 5) + 1);
|
|
105
|
+
|
|
106
|
+
const sensors = useSensors(
|
|
107
|
+
useSensor(PointerSensor),
|
|
108
|
+
useSensor(KeyboardSensor, {
|
|
109
|
+
coordinateGetter: sortableKeyboardCoordinates,
|
|
110
|
+
}),
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
// Drag and drop
|
|
114
|
+
function handleDragEnd(event: DragEndEvent) {
|
|
115
|
+
if (props.dispatchDetails && props.details.processes) {
|
|
116
|
+
const { active, over } = event;
|
|
117
|
+
|
|
118
|
+
if (over && active.id !== over.id) {
|
|
119
|
+
const items = props.details.processes as Process[];
|
|
120
|
+
|
|
121
|
+
const oldIndex = items.findIndex((process) => process.id === active.id);
|
|
122
|
+
const newIndex = items.findIndex((process) => process.id === over.id);
|
|
123
|
+
const reordered: Process[] = arrayMove(items, oldIndex, newIndex);
|
|
124
|
+
|
|
125
|
+
const action: EditIntegrationsAction = {
|
|
126
|
+
type: DetailsActionType.EDIT_INTEGRATIONS,
|
|
127
|
+
processes: reordered,
|
|
128
|
+
};
|
|
129
|
+
props.dispatchDetails(action);
|
|
130
|
+
|
|
131
|
+
if (!props.edited.integrations) {
|
|
132
|
+
props.setEdited({
|
|
133
|
+
...props.edited,
|
|
134
|
+
integrations: true,
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// fetch non-scheduled processes
|
|
142
|
+
const { data, refetch, isFetching } = getNonScheduledProcesses.useData({
|
|
143
|
+
input: { search: searchTerm || null, ...input },
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
// Pagination
|
|
147
|
+
const handleChangePage = async (
|
|
148
|
+
_event: React.ChangeEvent<unknown>,
|
|
149
|
+
value: number,
|
|
150
|
+
) => {
|
|
151
|
+
if (page !== value) {
|
|
152
|
+
const newSkip = (input.top || 5) * (value - 1);
|
|
153
|
+
|
|
154
|
+
const newInput = { ...input, skip: newSkip };
|
|
155
|
+
|
|
156
|
+
setPage(value);
|
|
157
|
+
setInput(newInput);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
useEffect(() => {
|
|
162
|
+
const typedData = data as GetNonScheduledProcessesQuery;
|
|
163
|
+
if (typedData?.nonScheduledProcesses?.nodes && nonScheduledMode) {
|
|
164
|
+
setNonScheduledProcessesResult(typedData);
|
|
165
|
+
setItems(typedData.nonScheduledProcesses.nodes as Process[]);
|
|
166
|
+
}
|
|
167
|
+
}, [data]);
|
|
168
|
+
|
|
169
|
+
// Search
|
|
170
|
+
const fetchNonScheduledProcesses = async (_search: string) => {
|
|
171
|
+
const result = await refetch();
|
|
172
|
+
const typedData = result.data as GetNonScheduledProcessesQuery;
|
|
173
|
+
if (typedData?.nonScheduledProcesses?.nodes) {
|
|
174
|
+
setNonScheduledMode(true);
|
|
175
|
+
setNonScheduledProcessesResult(typedData);
|
|
176
|
+
setItems(typedData.nonScheduledProcesses.nodes as Process[]);
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const debounceFetch = debounce(fetchNonScheduledProcesses, 400);
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
if (searchTerm === "") {
|
|
183
|
+
setItems([]);
|
|
184
|
+
setNonScheduledProcessesResult(null);
|
|
185
|
+
setNonScheduledMode(false);
|
|
186
|
+
} else {
|
|
187
|
+
debounceFetch(searchTerm);
|
|
188
|
+
}
|
|
189
|
+
return debounceFetch.cancel;
|
|
190
|
+
}, [searchTerm]);
|
|
191
|
+
|
|
192
|
+
// Add integration
|
|
193
|
+
const handleClickAddIntegration = (item: Process) => {
|
|
194
|
+
if (props.dispatchDetails && props.details) {
|
|
195
|
+
const updatedItem = {
|
|
196
|
+
...item,
|
|
197
|
+
sort:
|
|
198
|
+
(props.details.processes ? props.details.processes.length : 0) + 1,
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
if (!props.edited.integrations) {
|
|
202
|
+
props.setEdited({
|
|
203
|
+
...props.edited,
|
|
204
|
+
integrations: true,
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const newProcesses = [...(props.details.processes || []), updatedItem];
|
|
209
|
+
const action: EditIntegrationsAction = {
|
|
210
|
+
type: DetailsActionType.EDIT_INTEGRATIONS,
|
|
211
|
+
processes: newProcesses,
|
|
212
|
+
};
|
|
213
|
+
props.dispatchDetails(action);
|
|
214
|
+
|
|
215
|
+
const clearErrorAction: SetErrorsAction = {
|
|
216
|
+
type: DetailsActionType.SET_ERRORS,
|
|
217
|
+
errors: { processes: false },
|
|
218
|
+
};
|
|
219
|
+
props.dispatchDetails(clearErrorAction);
|
|
220
|
+
|
|
221
|
+
setNonScheduledMode(false);
|
|
222
|
+
setSearchTerm("");
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const handleDeleteIntegration = (item: Process) => {
|
|
227
|
+
if (props.dispatchDetails && props.details.processes) {
|
|
228
|
+
if (!props.edited.integrations) {
|
|
229
|
+
props.setEdited({
|
|
230
|
+
...props.edited,
|
|
231
|
+
integrations: true,
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const newProcesses = props.details.processes.filter(
|
|
236
|
+
(process) => process.id !== item.id,
|
|
237
|
+
);
|
|
238
|
+
const action: EditIntegrationsAction = {
|
|
239
|
+
type: DetailsActionType.EDIT_INTEGRATIONS,
|
|
240
|
+
processes: newProcesses,
|
|
241
|
+
};
|
|
242
|
+
props.dispatchDetails(action);
|
|
243
|
+
|
|
244
|
+
if (newProcesses.length === 0) {
|
|
245
|
+
const clearErrorAction: SetErrorsAction = {
|
|
246
|
+
type: DetailsActionType.SET_ERRORS,
|
|
247
|
+
errors: { processes: true },
|
|
248
|
+
};
|
|
249
|
+
props.dispatchDetails(clearErrorAction);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
useEffect(() => {
|
|
255
|
+
if (
|
|
256
|
+
props.dispatchDetails &&
|
|
257
|
+
props.defaultScheduledProcess &&
|
|
258
|
+
props?.details?.processes?.length === 0
|
|
259
|
+
) {
|
|
260
|
+
handleClickAddIntegration({
|
|
261
|
+
...props.defaultScheduledProcess,
|
|
262
|
+
sort: 1,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}, [props.defaultScheduledProcess]);
|
|
266
|
+
|
|
267
|
+
// Table heading
|
|
268
|
+
let heading: Head[] = [
|
|
269
|
+
{
|
|
270
|
+
id: "name",
|
|
271
|
+
label: nonScheduledMode ? t("availableIntegrations") : t("integration"),
|
|
272
|
+
align: "left",
|
|
273
|
+
width: "92%",
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
id: "actions",
|
|
277
|
+
label: t("ListHeader.actions"),
|
|
278
|
+
align: "right",
|
|
279
|
+
width: "7%",
|
|
280
|
+
},
|
|
281
|
+
];
|
|
282
|
+
|
|
283
|
+
heading = [
|
|
284
|
+
!nonScheduledMode && {
|
|
285
|
+
id: "drag",
|
|
286
|
+
label: "",
|
|
287
|
+
align: "right",
|
|
288
|
+
width: "1%",
|
|
289
|
+
},
|
|
290
|
+
...heading,
|
|
291
|
+
].filter(Boolean) as Head[];
|
|
292
|
+
|
|
293
|
+
const readOnly = props.readOnly || !!props.defaultScheduledProcess;
|
|
294
|
+
|
|
295
|
+
return (
|
|
296
|
+
<Box sx={styles.main}>
|
|
297
|
+
<Box>
|
|
298
|
+
<Stack
|
|
299
|
+
direction="row"
|
|
300
|
+
spacing={1}
|
|
301
|
+
alignItems="center"
|
|
302
|
+
sx={props.errors?.processes ? {} : { marginBottom: theme.spacing(2) }}
|
|
303
|
+
>
|
|
304
|
+
<Typography variant="body1">{t("scheduledIntegrations")}</Typography>
|
|
305
|
+
<EditedTypography edited={props.edited.integrations} />
|
|
306
|
+
</Stack>
|
|
307
|
+
<Typography
|
|
308
|
+
variant="caption"
|
|
309
|
+
color="error"
|
|
310
|
+
display={props.errors?.processes ? "block" : "none"}
|
|
311
|
+
sx={{ marginBottom: theme.spacing(2) }}
|
|
312
|
+
>
|
|
313
|
+
{t("emptyProcesses")}
|
|
314
|
+
</Typography>
|
|
315
|
+
{!readOnly && (
|
|
316
|
+
<TextField
|
|
317
|
+
sx={styles.search}
|
|
318
|
+
variant="outlined"
|
|
319
|
+
label={searchLabel}
|
|
320
|
+
value={searchTerm}
|
|
321
|
+
onChange={(e) => setSearchTerm(e.target.value)}
|
|
322
|
+
slotProps={{
|
|
323
|
+
input: {
|
|
324
|
+
startAdornment: (
|
|
325
|
+
<InputAdornment position="start">
|
|
326
|
+
<Search />
|
|
327
|
+
</InputAdornment>
|
|
328
|
+
),
|
|
329
|
+
},
|
|
330
|
+
}}
|
|
331
|
+
/>
|
|
332
|
+
)}
|
|
333
|
+
</Box>
|
|
334
|
+
{isFetching && (
|
|
335
|
+
<Card sx={{ marginTop: theme.spacing(2) }}>
|
|
336
|
+
<TableSkeleton
|
|
337
|
+
heading={heading}
|
|
338
|
+
perPage={3}
|
|
339
|
+
rowSx={{ height: theme.spacing(7) }}
|
|
340
|
+
/>
|
|
341
|
+
</Card>
|
|
342
|
+
)}
|
|
343
|
+
|
|
344
|
+
{!isFetching &&
|
|
345
|
+
((nonScheduledMode && items.length > 0) ||
|
|
346
|
+
(!nonScheduledMode &&
|
|
347
|
+
props.details.processes &&
|
|
348
|
+
props.details.processes.length > 0)) ? (
|
|
349
|
+
<>
|
|
350
|
+
<Box sx={styles.list}>
|
|
351
|
+
<DndContext
|
|
352
|
+
sensors={sensors}
|
|
353
|
+
collisionDetection={closestCenter}
|
|
354
|
+
onDragEnd={handleDragEnd}
|
|
355
|
+
modifiers={[restrictToFirstScrollableAncestor]}
|
|
356
|
+
>
|
|
357
|
+
<SortableContext
|
|
358
|
+
items={
|
|
359
|
+
nonScheduledMode
|
|
360
|
+
? items
|
|
361
|
+
: (props.details.processes as Process[])
|
|
362
|
+
}
|
|
363
|
+
strategy={verticalListSortingStrategy}
|
|
364
|
+
>
|
|
365
|
+
<TableContainer>
|
|
366
|
+
<Table>
|
|
367
|
+
<TableHeader
|
|
368
|
+
heading={heading}
|
|
369
|
+
orderBy={"sort"}
|
|
370
|
+
order={"asc"}
|
|
371
|
+
/>
|
|
372
|
+
<TableBody>
|
|
373
|
+
{
|
|
374
|
+
// Processes found in details state (using props.details.processes)
|
|
375
|
+
!nonScheduledMode &&
|
|
376
|
+
props?.details?.processes?.map((item) => (
|
|
377
|
+
<SortableIntegrationRow
|
|
378
|
+
key={item.id}
|
|
379
|
+
item={item as Process}
|
|
380
|
+
processes={props.details.processes as Process[]}
|
|
381
|
+
heading={heading}
|
|
382
|
+
handleDeleteIntegration={handleDeleteIntegration}
|
|
383
|
+
handleClickAddIntegration={
|
|
384
|
+
handleClickAddIntegration
|
|
385
|
+
}
|
|
386
|
+
readOnly={readOnly}
|
|
387
|
+
nonScheduledMode={nonScheduledMode}
|
|
388
|
+
/>
|
|
389
|
+
))
|
|
390
|
+
}
|
|
391
|
+
{
|
|
392
|
+
// Non Scheduled Processes - when search term is not empty (using items state)
|
|
393
|
+
nonScheduledMode &&
|
|
394
|
+
items.map((item) => (
|
|
395
|
+
<SortableIntegrationRow
|
|
396
|
+
key={item.id}
|
|
397
|
+
item={item}
|
|
398
|
+
processes={props.details.processes as Process[]}
|
|
399
|
+
heading={heading}
|
|
400
|
+
handleDeleteIntegration={handleDeleteIntegration}
|
|
401
|
+
handleClickAddIntegration={
|
|
402
|
+
handleClickAddIntegration
|
|
403
|
+
}
|
|
404
|
+
readOnly={readOnly}
|
|
405
|
+
nonScheduledMode={nonScheduledMode}
|
|
406
|
+
/>
|
|
407
|
+
))
|
|
408
|
+
}
|
|
409
|
+
</TableBody>
|
|
410
|
+
</Table>
|
|
411
|
+
</TableContainer>
|
|
412
|
+
</SortableContext>
|
|
413
|
+
</DndContext>
|
|
414
|
+
</Box>
|
|
415
|
+
{!isFetching &&
|
|
416
|
+
nonScheduledProcessesResult &&
|
|
417
|
+
((nonScheduledMode && items.length > 0) ||
|
|
418
|
+
(!nonScheduledMode &&
|
|
419
|
+
props.details.processes &&
|
|
420
|
+
props.details.processes.length > 0)) ? (
|
|
421
|
+
<Grid container spacing={1} sx={styles.pagination}>
|
|
422
|
+
<Grid size={{ xs: 10.5 }}>
|
|
423
|
+
<FlexBox
|
|
424
|
+
justifyContent="center"
|
|
425
|
+
alignItems="center"
|
|
426
|
+
sx={styles.paginationBox}
|
|
427
|
+
>
|
|
428
|
+
<TablePagination
|
|
429
|
+
page={page}
|
|
430
|
+
onChange={handleChangePage}
|
|
431
|
+
count={Math.ceil(
|
|
432
|
+
(nonScheduledProcessesResult.nonScheduledProcesses
|
|
433
|
+
?.recordCount || 5) / (input.top || 5),
|
|
434
|
+
)}
|
|
435
|
+
/>
|
|
436
|
+
</FlexBox>
|
|
437
|
+
</Grid>
|
|
438
|
+
</Grid>
|
|
439
|
+
) : null}
|
|
440
|
+
</>
|
|
441
|
+
) : null}
|
|
442
|
+
{!isFetching &&
|
|
443
|
+
((nonScheduledMode && items.length === 0) ||
|
|
444
|
+
(!nonScheduledMode && props.details.processes?.length === 0)) ? (
|
|
445
|
+
<Card>
|
|
446
|
+
<FlexBox
|
|
447
|
+
justifyContent="center"
|
|
448
|
+
alignItems="center"
|
|
449
|
+
sx={{
|
|
450
|
+
minHeight: "85px",
|
|
451
|
+
marginTop: theme.spacing(2),
|
|
452
|
+
background: theme.palette.grey[100],
|
|
453
|
+
}}
|
|
454
|
+
>
|
|
455
|
+
<Stack spacing={1} justifyContent="center" alignItems="center">
|
|
456
|
+
<Typography variant="inherit" color="textSecondary">
|
|
457
|
+
{nonScheduledMode
|
|
458
|
+
? t("ListEmpty.searchEmpty")
|
|
459
|
+
: t("ListEmpty.scheduled")}
|
|
460
|
+
</Typography>
|
|
461
|
+
</Stack>
|
|
462
|
+
</FlexBox>
|
|
463
|
+
</Card>
|
|
464
|
+
) : null}
|
|
465
|
+
</Box>
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
const getStyles = (theme: Theme) => {
|
|
470
|
+
return {
|
|
471
|
+
main: {
|
|
472
|
+
padding: theme.spacing(2, 3),
|
|
473
|
+
|
|
474
|
+
maxHeight: "50vh",
|
|
475
|
+
overflow: "auto",
|
|
476
|
+
},
|
|
477
|
+
list: {
|
|
478
|
+
margin: theme.spacing(1, 0),
|
|
479
|
+
borderColor: theme.palette.grey[200],
|
|
480
|
+
borderWidth: theme.spacing(0.25),
|
|
481
|
+
borderStyle: "solid",
|
|
482
|
+
borderRadius: "1%",
|
|
483
|
+
},
|
|
484
|
+
pagination: {
|
|
485
|
+
marginTop: theme.spacing(2),
|
|
486
|
+
},
|
|
487
|
+
paginationBox: {
|
|
488
|
+
paddingLeft: theme.spacing(15),
|
|
489
|
+
},
|
|
490
|
+
search: {
|
|
491
|
+
"& .MuiOutlinedInput-root": {
|
|
492
|
+
"& input": {
|
|
493
|
+
padding: theme.spacing(1.5),
|
|
494
|
+
},
|
|
495
|
+
},
|
|
496
|
+
backgroundColor: theme.palette.common.white,
|
|
497
|
+
width: "auto",
|
|
498
|
+
flexGrow: "1",
|
|
499
|
+
},
|
|
500
|
+
};
|
|
501
|
+
};
|