@orchestrator-ui/orchestrator-ui-components 7.1.0 → 7.2.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 (35) hide show
  1. package/.turbo/turbo-build.log +8 -8
  2. package/.turbo/turbo-lint.log +1 -1
  3. package/.turbo/turbo-test.log +8 -8
  4. package/CHANGELOG.md +12 -0
  5. package/dist/index.d.ts +930 -6
  6. package/dist/index.js +2340 -1942
  7. package/dist/index.js.map +1 -1
  8. package/package.json +2 -2
  9. package/src/components/WfoBadges/WfoScheduledTasksBadges/WfoScheduledTasksBadges.tsx +38 -0
  10. package/src/components/WfoBadges/WfoScheduledTasksBadges/WfoScheduledTasksBadgesContainer.tsx +27 -0
  11. package/src/components/WfoBadges/WfoScheduledTasksBadges/index.ts +2 -0
  12. package/src/components/WfoBadges/index.ts +1 -0
  13. package/src/components/WfoPageTemplate/WfoSidebar/WfoSidebar.tsx +19 -0
  14. package/src/components/WfoPageTemplate/paths.ts +1 -0
  15. package/src/components/WfoTable/WfoAdvancedTable/WfoAdvancedTable.tsx +16 -10
  16. package/src/components/WfoTable/utils/constants.ts +1 -0
  17. package/src/configuration/constants.ts +1 -0
  18. package/src/configuration/version.ts +1 -1
  19. package/src/hooks/index.ts +2 -0
  20. package/src/hooks/useGetSchedulesForWorkflow.tsx +30 -0
  21. package/src/hooks/useGetWorkflowNameById.tsx +23 -0
  22. package/src/icons/heroicons/WfoScheduledTaskOnce.tsx +32 -0
  23. package/src/icons/heroicons/WfoScheduledTaskRecurring.tsx +32 -0
  24. package/src/icons/heroicons/index.ts +2 -0
  25. package/src/messages/en-GB.json +11 -1
  26. package/src/messages/nl-NL.json +10 -1
  27. package/src/pages/metadata/WfoMetadataPageLayout.tsx +6 -1
  28. package/src/pages/metadata/WfoScheduledTasksPage.tsx +223 -0
  29. package/src/pages/metadata/WfoTasksPage.tsx +20 -3
  30. package/src/pages/metadata/index.ts +1 -0
  31. package/src/pages/metadata/taskListObjectMapper.ts +3 -0
  32. package/src/rtk/endpoints/metadata/index.ts +1 -0
  33. package/src/rtk/endpoints/metadata/scheduledTasks.ts +66 -0
  34. package/src/rtk/endpoints/metadata/tasks.ts +1 -1
  35. package/src/types/types.ts +18 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orchestrator-ui/orchestrator-ui-components",
3
- "version": "7.1.0",
3
+ "version": "7.2.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Library of UI Components used to display the workflow orchestrator frontend",
6
6
  "author": {
@@ -55,7 +55,7 @@
55
55
  "next-query-params": "^5.0.0",
56
56
  "object-hash": "^3.0.0",
57
57
  "prism-themes": "^1.9.0",
58
- "pydantic-forms": "^1.0.0",
58
+ "pydantic-forms": "^1.0.1",
59
59
  "react-diff-view": "^3.2.0",
60
60
  "react-draggable": "^4.4.6",
61
61
  "react-redux": "^9.1.2",
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+
3
+ import { EuiFlexGroup, EuiFlexItem, EuiToolTip } from '@elastic/eui';
4
+
5
+ import { WfoScheduledTaskOnce, WfoScheduledTaskRecurring } from '@/icons';
6
+
7
+ const WfoWorkflowScheduleIcon = ({
8
+ workflowSchedule,
9
+ }: {
10
+ workflowSchedule: string;
11
+ }) => {
12
+ if (workflowSchedule.includes('date[')) {
13
+ return <WfoScheduledTaskOnce />;
14
+ }
15
+ return <WfoScheduledTaskRecurring />;
16
+ };
17
+
18
+ export const WfoScheduledTasksBadges = ({
19
+ workflowSchedules,
20
+ }: {
21
+ workflowSchedules?: string[];
22
+ }) => {
23
+ return (
24
+ <EuiFlexGroup gutterSize="s" justifyContent="flexStart">
25
+ {workflowSchedules?.map((workflowSchedule) => {
26
+ return (
27
+ <EuiFlexItem grow={0} key={workflowSchedule}>
28
+ <EuiToolTip content={workflowSchedule}>
29
+ <WfoWorkflowScheduleIcon
30
+ workflowSchedule={workflowSchedule}
31
+ />
32
+ </EuiToolTip>
33
+ </EuiFlexItem>
34
+ );
35
+ })}
36
+ </EuiFlexGroup>
37
+ );
38
+ };
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+
3
+ import { WfoError } from '@/components/WfoError';
4
+ import { WfoLoading } from '@/components/WfoLoading';
5
+ import { useGetSchedulesForWorkflow } from '@/hooks';
6
+ import { ScheduledTaskDefinition } from '@/types';
7
+
8
+ import { WfoScheduledTasksBadges } from './WfoScheduledTasksBadges';
9
+
10
+ export const WfoScheduledTasksBadgesContainer = ({
11
+ workflowId,
12
+ }: {
13
+ workflowId: ScheduledTaskDefinition['workflowId'];
14
+ }) => {
15
+ const { workflowSchedules, isFetching, isError } =
16
+ useGetSchedulesForWorkflow(workflowId);
17
+
18
+ if (isFetching) {
19
+ return <WfoLoading />;
20
+ }
21
+
22
+ if (isError) {
23
+ return <WfoError />;
24
+ }
25
+
26
+ return <WfoScheduledTasksBadges workflowSchedules={workflowSchedules} />;
27
+ };
@@ -0,0 +1,2 @@
1
+ export * from './WfoScheduledTasksBadgesContainer';
2
+ export * from './WfoScheduledTasksBadges';
@@ -10,3 +10,4 @@ export * from './WfoHeaderBadge';
10
10
  export * from './WfoProductStatusBadge';
11
11
  export * from './WfoWorkflowTargetBadge';
12
12
  export * from './WfoWebsocketStatusBadge';
13
+ export * from './WfoScheduledTasksBadges';
@@ -24,6 +24,7 @@ import {
24
24
  PATH_METADATA_PRODUCTS,
25
25
  PATH_METADATA_PRODUCT_BLOCKS,
26
26
  PATH_METADATA_RESOURCE_TYPES,
27
+ PATH_METADATA_SCHEDULED_TASKS,
27
28
  PATH_METADATA_TASKS,
28
29
  PATH_METADATA_WORKFLOWS,
29
30
  PATH_SETTINGS,
@@ -220,6 +221,24 @@ export const WfoSidebar: FC<WfoSidebarProps> = ({
220
221
  />
221
222
  ),
222
223
  },
224
+ {
225
+ name: t('metadataScheduledTasks'),
226
+ id: 'metadata-scheduled-tasks',
227
+ isSelected:
228
+ router.pathname === PATH_METADATA_SCHEDULED_TASKS,
229
+ href: PATH_METADATA_SCHEDULED_TASKS,
230
+ renderItem: () => (
231
+ <WfoMenuItemLink
232
+ path={PATH_METADATA_SCHEDULED_TASKS}
233
+ translationString="metadataScheduledTasks"
234
+ isSelected={
235
+ router.pathname ===
236
+ PATH_METADATA_SCHEDULED_TASKS
237
+ }
238
+ isSubItem={true}
239
+ />
240
+ ),
241
+ },
223
242
  ],
224
243
  },
225
244
  {
@@ -9,5 +9,6 @@ export const PATH_METADATA_PRODUCT_BLOCKS = '/metadata/productblocks';
9
9
  export const PATH_METADATA_RESOURCE_TYPES = '/metadata/resource-types';
10
10
  export const PATH_METADATA_WORKFLOWS = '/metadata/workflows';
11
11
  export const PATH_METADATA_TASKS = '/metadata/tasks';
12
+ export const PATH_METADATA_SCHEDULED_TASKS = '/metadata/scheduled-tasks';
12
13
  export const PATH_TASKS = '/tasks';
13
14
  export const PATH_SETTINGS = '/settings';
@@ -50,6 +50,7 @@ export type WfoAdvancedTableProps<T extends object> = Omit<
50
50
  error?: WfoGraphqlError[];
51
51
  onUpdateQueryString: (queryString: string) => void;
52
52
  onExportData?: () => void;
53
+ disableSearch?: boolean;
53
54
  };
54
55
 
55
56
  export const WfoAdvancedTable = <T extends object>({
@@ -63,6 +64,7 @@ export const WfoAdvancedTable = <T extends object>({
63
64
  error,
64
65
  onUpdateQueryString,
65
66
  onExportData,
67
+ disableSearch = false,
66
68
  ...tableProps
67
69
  }: WfoAdvancedTableProps<T>) => {
68
70
  const { theme } = useOrchestratorTheme();
@@ -159,18 +161,22 @@ export const WfoAdvancedTable = <T extends object>({
159
161
  <>
160
162
  <EuiFlexGroup alignItems="center">
161
163
  <EuiFlexItem>
162
- <WfoSearchField
163
- queryString={queryString}
164
- onUpdateQueryString={onUpdateQueryString}
165
- />
164
+ {!disableSearch && (
165
+ <WfoSearchField
166
+ queryString={queryString}
167
+ onUpdateQueryString={onUpdateQueryString}
168
+ />
169
+ )}
166
170
  </EuiFlexItem>
167
171
  <EuiFlexItem grow={false}>
168
- <EuiButtonIcon
169
- onClick={() => setShowSearchModal(true)}
170
- iconSize={'xl'}
171
- iconType={'iInCircle'}
172
- aria-label={t('searchModalTitle')}
173
- />
172
+ {!disableSearch && (
173
+ <EuiButtonIcon
174
+ onClick={() => setShowSearchModal(true)}
175
+ iconSize={'xl'}
176
+ iconType={'iInCircle'}
177
+ aria-label={t('searchModalTitle')}
178
+ />
179
+ )}
174
180
  </EuiFlexItem>
175
181
  <EuiButton onClick={() => setShowSettingsModal(true)}>
176
182
  {t('editColumns')}
@@ -15,6 +15,7 @@ export const METADATA_RESOURCE_TYPES_TABLE_LOCAL_STORAGE_KEY =
15
15
  export const METADATA_PRODUCT_BLOCKS_TABLE_LOCAL_STORAGE_KEY =
16
16
  'metadataProductBlocksTable';
17
17
  export const METADATA_PRODUCT_TABLE_LOCAL_STORAGE_KEY = 'metadataProductTable';
18
+ export const METADATA_SCHEDULES_LOCAL_STORAGE_KEY = 'metadataScheduleTable';
18
19
  export const METADATA_WORKFLOWS_TABLE_LOCAL_STORAGE_KEY =
19
20
  'metadataWorkflowsTable';
20
21
  export const METADATA_TASKS_TABLE_LOCAL_STORAGE_KEY = 'metadataTasksTable';
@@ -36,3 +36,4 @@ export const METADATA_PRODUCT_ENDPOINT = 'products';
36
36
  export const METADATA_PRODUCT_BLOCK_ENDPOINT = 'product_blocks';
37
37
  export const METADATA_RESOURCE_TYPE_ENDPOINT = 'resource_types';
38
38
  export const METADATA_WORKFLOWS_ENDPOINT = 'workflows';
39
+ export const METADATA_SCHEDULE_ENDPOINT = 'schedule';
@@ -1 +1 @@
1
- export const ORCHESTRATOR_UI_LIBRARY_VERSION = '7.1.0';
1
+ export const ORCHESTRATOR_UI_LIBRARY_VERSION = '7.2.0';
@@ -11,3 +11,5 @@ export * from './useWfoErrorMonitoring';
11
11
  export * from './useWfoSession';
12
12
  export * from './useGetOrchestratorConfig';
13
13
  export * from './useBackendAvailability';
14
+ export * from './useGetSchedulesForWorkflow';
15
+ export * from './useGetWorkflowNameById';
@@ -0,0 +1,30 @@
1
+ import { NUMBER_OF_ITEMS_REPRESENTING_ALL_ITEMS } from '@/configuration';
2
+ import { useGetScheduledTasksQuery } from '@/rtk';
3
+ import { ScheduledTaskDefinition } from '@/types';
4
+
5
+ export type UseGetSchedulesForWorkflowReturnProps = {
6
+ workflowSchedules: ScheduledTaskDefinition['trigger'][];
7
+ isFetching: boolean;
8
+ isError: boolean;
9
+ };
10
+
11
+ export const useGetSchedulesForWorkflow = (
12
+ workflowId: ScheduledTaskDefinition['workflowId'],
13
+ ) => {
14
+ const { data, isFetching, isError } = useGetScheduledTasksQuery({
15
+ first: NUMBER_OF_ITEMS_REPRESENTING_ALL_ITEMS,
16
+ after: 0,
17
+ });
18
+
19
+ const workflowSchedules = isFetching
20
+ ? []
21
+ : data?.schedules
22
+ .filter((scheduledTaskDefinition) => {
23
+ return scheduledTaskDefinition.workflowId === workflowId;
24
+ })
25
+ .map((scheduledTaskDefinition) => {
26
+ return scheduledTaskDefinition.trigger;
27
+ });
28
+
29
+ return { workflowSchedules, isFetching, isError };
30
+ };
@@ -0,0 +1,23 @@
1
+ import { NUMBER_OF_ITEMS_REPRESENTING_ALL_ITEMS } from '@/configuration';
2
+ import { useGetTasksQuery } from '@/rtk';
3
+ import { ScheduledTaskDefinition } from '@/types';
4
+
5
+ export type UseGetWorkflowNameByIdReturnProps = {
6
+ workflowName: string;
7
+ };
8
+
9
+ export const useGetWorkflowNameById = (
10
+ workflowId: ScheduledTaskDefinition['workflowId'],
11
+ ) => {
12
+ const { data, isFetching, isError } = useGetTasksQuery({
13
+ first: NUMBER_OF_ITEMS_REPRESENTING_ALL_ITEMS,
14
+ after: 0,
15
+ });
16
+
17
+ const workflowName =
18
+ isFetching || isError
19
+ ? ''
20
+ : data?.tasks.find((task) => task.workflowId === workflowId)?.name;
21
+
22
+ return { workflowName };
23
+ };
@@ -0,0 +1,32 @@
1
+ import React, { FC } from 'react';
2
+
3
+ import { WfoIconProps } from '@/icons';
4
+
5
+ import { withWfoHeroIconsWrapper } from './WfoHeroIconsWrapper';
6
+
7
+ const WfoScheduledTaskOnceSvg: FC<WfoIconProps> = ({
8
+ width = 20,
9
+ height = 20,
10
+ color = 'currentColor',
11
+ }) => (
12
+ <svg
13
+ width={width}
14
+ height={height}
15
+ xmlns="http://www.w3.org/2000/svg"
16
+ fill="none"
17
+ viewBox="0 0 24 24"
18
+ strokeWidth={1.5}
19
+ stroke={color}
20
+ className="size-6"
21
+ >
22
+ <path
23
+ strokeLinecap="round"
24
+ strokeLinejoin="round"
25
+ d="M12 6v6h4.5m4.5 0a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"
26
+ />
27
+ </svg>
28
+ );
29
+
30
+ export const WfoScheduledTaskOnce = withWfoHeroIconsWrapper(
31
+ WfoScheduledTaskOnceSvg,
32
+ );
@@ -0,0 +1,32 @@
1
+ import React, { FC } from 'react';
2
+
3
+ import { WfoIconProps } from '@/icons';
4
+
5
+ import { withWfoHeroIconsWrapper } from './WfoHeroIconsWrapper';
6
+
7
+ export const WfoScheduledTaskRecurringSvg: FC<WfoIconProps> = ({
8
+ width = 20,
9
+ height = 20,
10
+ color = 'currentColor',
11
+ }) => (
12
+ <svg
13
+ width={width}
14
+ height={height}
15
+ xmlns="http://www.w3.org/2000/svg"
16
+ stroke={color}
17
+ fill="none"
18
+ viewBox="0 0 24 24"
19
+ strokeWidth={1.5}
20
+ className="size-6"
21
+ >
22
+ <path
23
+ strokeLinecap="round"
24
+ strokeLinejoin="round"
25
+ d="M19.5 12c0-1.232-.046-2.453-.138-3.662a4.006 4.006 0 0 0-3.7-3.7 48.678 48.678 0 0 0-7.324 0 4.006 4.006 0 0 0-3.7 3.7c-.017.22-.032.441-.046.662M19.5 12l3-3m-3 3-3-3m-12 3c0 1.232.046 2.453.138 3.662a4.006 4.006 0 0 0 3.7 3.7 48.656 48.656 0 0 0 7.324 0 4.006 4.006 0 0 0 3.7-3.7c.017-.22.032-.441.046-.662M4.5 12l3 3m-3-3-3 3"
26
+ />
27
+ </svg>
28
+ );
29
+
30
+ export const WfoScheduledTaskRecurring = withWfoHeroIconsWrapper(
31
+ WfoScheduledTaskRecurringSvg,
32
+ );
@@ -8,3 +8,5 @@ export * from './WfoSquareStack3dStack';
8
8
  export * from './WfoBracketSquare';
9
9
  export * from './WfoCommandLine';
10
10
  export * from './WfoTableCells';
11
+ export * from './WfoScheduledTaskRecurring';
12
+ export * from './WfoScheduledTaskOnce';
@@ -9,6 +9,7 @@
9
9
  "metadataResourceTypes": "Resource types",
10
10
  "metadataWorkflows": "Workflows",
11
11
  "metadataTasks": "Tasks",
12
+ "metadataScheduledTasks": "Scheduled tasks",
12
13
  "mobileTitle": "Main menu",
13
14
  "settings": "Settings",
14
15
  "subscriptions": "Subscriptions",
@@ -151,7 +152,8 @@
151
152
  "productBlocks": "Product blocks",
152
153
  "resourceTypes": "Resource types",
153
154
  "workflows": "Workflows",
154
- "tasks": "Tasks"
155
+ "tasks": "Tasks",
156
+ "scheduledTasks": "Scheduled tasks"
155
157
  },
156
158
  "products": {
157
159
  "id": "ID",
@@ -196,7 +198,15 @@
196
198
  "description": "Task description",
197
199
  "target": "Target",
198
200
  "productTags": "Product tags",
201
+ "scheduled": "Scheduled",
199
202
  "createdAt": "Created"
203
+ },
204
+ "scheduledTasks": {
205
+ "task": "Task",
206
+ "taskDescription": "Task description",
207
+ "nextRuntime": "Next runtime",
208
+ "schedule": "Schedule",
209
+ "interval": "Interval"
200
210
  }
201
211
  },
202
212
  "processes": {
@@ -9,6 +9,7 @@
9
9
  "metadataResourceTypes": "Resource types",
10
10
  "metadataWorkflows": "Workflows",
11
11
  "metadataTasks": "Taken",
12
+ "metadataScheduledTasks": "Scheduled tasks",
12
13
  "mobileTitle": "Hoofdmenu",
13
14
  "settings": "Settings",
14
15
  "subscriptions": "Subscriptions",
@@ -196,7 +197,15 @@
196
197
  "description": "Taak beschrijving",
197
198
  "target": "Target",
198
199
  "productTags": "Product tags",
199
- "createdAt": "Aangemaakt"
200
+ "createdAt": "Aangemaakt",
201
+ "scheduled": "Schedule"
202
+ },
203
+ "scheduledTasks": {
204
+ "task": "Taak",
205
+ "taskDescription": "Taak beschrijving",
206
+ "nextRuntime": "Volgende runtime",
207
+ "schedule": "Schedule",
208
+ "interval": "Interval"
200
209
  }
201
210
  },
202
211
  "processes": {
@@ -45,6 +45,11 @@ export const metaDataTabs: MetaDataTab[] = [
45
45
  translationKey: 'tasks',
46
46
  path: '/metadata/tasks',
47
47
  },
48
+ {
49
+ id: 6,
50
+ translationKey: 'scheduledTasks',
51
+ path: '/metadata/scheduled-tasks',
52
+ },
48
53
  ];
49
54
 
50
55
  export const WfoMetadataPageLayout = ({
@@ -70,7 +75,7 @@ export const WfoMetadataPageLayout = ({
70
75
  </EuiTab>
71
76
  ))}
72
77
  </EuiTabs>
73
- <EuiSpacer size="xxl" />
78
+ <EuiSpacer size="l" />
74
79
  {children}
75
80
  </>
76
81
  );
@@ -0,0 +1,223 @@
1
+ import React, { useEffect, useState } from 'react';
2
+
3
+ import { useTranslations } from 'next-intl';
4
+
5
+ import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
6
+
7
+ import {
8
+ WfoDataSorting,
9
+ WfoProductBlockBadge,
10
+ WfoScheduledTasksBadges,
11
+ getPageIndexChangeHandler,
12
+ getPageSizeChangeHandler,
13
+ } from '@/components';
14
+ import {
15
+ DEFAULT_PAGE_SIZE,
16
+ DEFAULT_PAGE_SIZES,
17
+ METADATA_SCHEDULES_LOCAL_STORAGE_KEY,
18
+ StoredTableConfig,
19
+ getDataSortHandler,
20
+ getQueryStringHandler,
21
+ } from '@/components';
22
+ import { WfoAdvancedTable } from '@/components/WfoTable/WfoAdvancedTable';
23
+ import { WfoAdvancedTableColumnConfig } from '@/components/WfoTable/WfoAdvancedTable/types';
24
+ import { ColumnType, Pagination } from '@/components/WfoTable/WfoTable';
25
+ import { mapSortableAndFilterableValuesToTableColumnConfig } from '@/components/WfoTable/WfoTable/utils';
26
+ import {
27
+ useDataDisplayParams,
28
+ useGetWorkflowNameById,
29
+ useShowToastMessage,
30
+ useStoredTableConfig,
31
+ } from '@/hooks';
32
+ import {
33
+ ScheduledTasksResponse,
34
+ useGetScheduledTasksQuery,
35
+ useLazyGetScheduledTasksQuery,
36
+ } from '@/rtk';
37
+ import { mapRtkErrorToWfoError } from '@/rtk/utils';
38
+ import { BadgeType } from '@/types';
39
+ import type { GraphqlQueryVariables, ScheduledTaskDefinition } from '@/types';
40
+ import { SortOrder } from '@/types';
41
+ import { formatDate } from '@/utils';
42
+ import {
43
+ getQueryVariablesForExport,
44
+ parseDateToLocaleDateTimeString,
45
+ parseIsoString,
46
+ } from '@/utils';
47
+ import {
48
+ csvDownloadHandler,
49
+ getCsvFileNameWithDate,
50
+ } from '@/utils/csvDownload';
51
+
52
+ import { WfoMetadataPageLayout } from './WfoMetadataPageLayout';
53
+
54
+ const TASK_NAME_FIELD: keyof ScheduledTaskDefinition = 'name';
55
+
56
+ type ScheduledTasksDefinitionExportItem = ScheduledTaskDefinition;
57
+
58
+ const WfoWorkflowNameById = ({ workflowId }: { workflowId: string }) => {
59
+ const { workflowName } = useGetWorkflowNameById(workflowId);
60
+ return workflowName ? (
61
+ <WfoProductBlockBadge badgeType={BadgeType.TASK}>
62
+ {workflowName}
63
+ </WfoProductBlockBadge>
64
+ ) : (
65
+ ''
66
+ );
67
+ };
68
+
69
+ export const WfoScheduledTasksPage = () => {
70
+ const t = useTranslations('metadata.scheduledTasks');
71
+ const tError = useTranslations('errors');
72
+ const { showToastMessage } = useShowToastMessage();
73
+ const [tableDefaults, setTableDefaults] =
74
+ useState<StoredTableConfig<ScheduledTaskDefinition>>();
75
+
76
+ const getStoredTableConfig = useStoredTableConfig<ScheduledTaskDefinition>(
77
+ METADATA_SCHEDULES_LOCAL_STORAGE_KEY,
78
+ );
79
+
80
+ useEffect(() => {
81
+ const storedConfig = getStoredTableConfig();
82
+
83
+ if (storedConfig) {
84
+ setTableDefaults(storedConfig);
85
+ }
86
+ }, [getStoredTableConfig]);
87
+
88
+ const { dataDisplayParams, setDataDisplayParam } =
89
+ useDataDisplayParams<ScheduledTaskDefinition>({
90
+ // TODO: Improvement: A default pageSize value is set to avoid a graphql error when the query is executed
91
+ // the fist time before the useEffect has populated the tableDefaults. Better is to create a way for
92
+ // the query to wait for the values to be available
93
+ // https://github.com/workfloworchestrator/orchestrator-ui/issues/261
94
+ pageSize: tableDefaults?.selectedPageSize || DEFAULT_PAGE_SIZE,
95
+ sortBy: {
96
+ field: TASK_NAME_FIELD,
97
+ order: SortOrder.ASC,
98
+ },
99
+ });
100
+
101
+ const tableColumns: WfoAdvancedTableColumnConfig<ScheduledTaskDefinition> =
102
+ {
103
+ workflowId: {
104
+ columnType: ColumnType.DATA,
105
+ label: t('task'),
106
+ width: '180px',
107
+ renderData: (workflowId) => (
108
+ <WfoWorkflowNameById workflowId={workflowId} />
109
+ ),
110
+ },
111
+ name: {
112
+ columnType: ColumnType.DATA,
113
+ label: t('taskDescription'),
114
+ width: '700px',
115
+ },
116
+ nextRunTime: {
117
+ columnType: ColumnType.DATA,
118
+ label: t('nextRuntime'),
119
+ width: '180px',
120
+ renderData: (date) => formatDate(date),
121
+ renderDetails: parseIsoString(parseDateToLocaleDateTimeString),
122
+ clipboardText: parseIsoString(parseDateToLocaleDateTimeString),
123
+ renderTooltip: parseIsoString(parseDateToLocaleDateTimeString),
124
+ },
125
+ trigger: {
126
+ columnType: ColumnType.DATA,
127
+ label: t('schedule'),
128
+ width: '255px',
129
+ isSortable: false,
130
+ renderData: (trigger) => (
131
+ <EuiFlexGroup
132
+ gutterSize="s"
133
+ justifyContent="flexStart"
134
+ alignItems="center"
135
+ >
136
+ <EuiFlexItem grow={0}>
137
+ <WfoScheduledTasksBadges
138
+ workflowSchedules={[trigger]}
139
+ />
140
+ </EuiFlexItem>
141
+ <EuiFlexItem>{trigger}</EuiFlexItem>
142
+ </EuiFlexGroup>
143
+ ),
144
+ },
145
+ };
146
+
147
+ const { pageSize, pageIndex, sortBy, queryString } = dataDisplayParams;
148
+ const graphqlQueryVariables: GraphqlQueryVariables<ScheduledTaskDefinition> =
149
+ {
150
+ first: pageSize,
151
+ after: pageIndex * pageSize,
152
+ sortBy: sortBy,
153
+ query: queryString || undefined,
154
+ };
155
+ const { data, isFetching, error } = useGetScheduledTasksQuery(
156
+ graphqlQueryVariables,
157
+ );
158
+ const [getSchedulesTrigger, { isFetching: isFetchingCsv }] =
159
+ useLazyGetScheduledTasksQuery();
160
+ const getSchedulesForExport = () =>
161
+ getSchedulesTrigger(
162
+ getQueryVariablesForExport(graphqlQueryVariables),
163
+ ).unwrap();
164
+
165
+ const { totalItems, sortFields, filterFields } = data?.pageInfo ?? {};
166
+
167
+ const pagination: Pagination = {
168
+ pageSize: pageSize,
169
+ pageIndex: pageIndex,
170
+ pageSizeOptions: DEFAULT_PAGE_SIZES,
171
+ totalItemCount: totalItems ? totalItems : 0,
172
+ onChangePage: getPageIndexChangeHandler(setDataDisplayParam),
173
+ onChangeItemsPerPage: getPageSizeChangeHandler(setDataDisplayParam),
174
+ };
175
+
176
+ const dataSorting: WfoDataSorting<ScheduledTaskDefinition> = {
177
+ field: sortBy?.field ?? TASK_NAME_FIELD,
178
+ sortOrder: sortBy?.order ?? SortOrder.ASC,
179
+ };
180
+
181
+ const mapToExportItems = ({
182
+ schedules,
183
+ }: ScheduledTasksResponse): ScheduledTasksDefinitionExportItem[] => {
184
+ return schedules;
185
+ };
186
+
187
+ return (
188
+ <WfoMetadataPageLayout>
189
+ <WfoAdvancedTable
190
+ data={data?.schedules ?? []}
191
+ tableColumnConfig={mapSortableAndFilterableValuesToTableColumnConfig(
192
+ tableColumns,
193
+ sortFields,
194
+ filterFields,
195
+ )}
196
+ dataSorting={[dataSorting]}
197
+ defaultHiddenColumns={tableDefaults?.hiddenColumns}
198
+ onUpdateDataSorting={getDataSortHandler<ScheduledTaskDefinition>(
199
+ setDataDisplayParam,
200
+ )}
201
+ onUpdateQueryString={getQueryStringHandler<ScheduledTaskDefinition>(
202
+ setDataDisplayParam,
203
+ )}
204
+ pagination={pagination}
205
+ isLoading={isFetching}
206
+ error={mapRtkErrorToWfoError(error)}
207
+ queryString={queryString}
208
+ localStorageKey={METADATA_SCHEDULES_LOCAL_STORAGE_KEY}
209
+ onExportData={csvDownloadHandler(
210
+ getSchedulesForExport,
211
+ mapToExportItems,
212
+ (data) => data?.pageInfo || {},
213
+ Object.keys(tableColumns),
214
+ getCsvFileNameWithDate('Schedules'),
215
+ showToastMessage,
216
+ tError,
217
+ )}
218
+ exportDataIsLoading={isFetchingCsv}
219
+ disableSearch={true}
220
+ />
221
+ </WfoMetadataPageLayout>
222
+ );
223
+ };