@orchestrator-ui/orchestrator-ui-components 0.3.0 → 0.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 (159) hide show
  1. package/.turbo/turbo-build.log +9 -8
  2. package/.turbo/turbo-lint.log +4 -1
  3. package/.turbo/turbo-test.log +14 -8
  4. package/CHANGELOG.md +24 -0
  5. package/dist/index.d.ts +624 -241
  6. package/dist/index.js +4774 -3116
  7. package/package.json +31 -26
  8. package/src/api/axios.ts +2 -8
  9. package/src/api/index.ts +4 -4
  10. package/src/components/WfoBadges/WfoBadge/WfoBadge.tsx +4 -1
  11. package/src/components/WfoBadges/index.ts +1 -0
  12. package/src/components/WfoError/WfoError.stories.tsx +26 -0
  13. package/src/components/WfoError/WfoError.tsx +19 -0
  14. package/src/components/WfoError/index.ts +1 -0
  15. package/src/components/WfoFilterTabs/WfoFilterTabs.tsx +4 -2
  16. package/src/components/WfoForms/UserInputForm.tsx +14 -2
  17. package/src/components/WfoForms/formFields/OrganisationField.tsx +1 -1
  18. package/src/components/WfoForms/formFields/SplitPrefix.tsx +12 -4
  19. package/src/components/WfoForms/formFields/SubscriptionField.tsx +9 -4
  20. package/src/components/WfoForms/formFields/utils.spec.ts +88 -9
  21. package/src/components/WfoKeyValueTable/WfoValueCell.tsx +2 -2
  22. package/src/components/WfoOptionalLink/WfoOptionalLink.tsx +20 -0
  23. package/src/components/WfoOptionalLink/index.ts +1 -0
  24. package/src/components/WfoPageTemplate/WfoBreadcrumbs/WfoBreadcrumbs.tsx +5 -2
  25. package/src/components/WfoPageTemplate/WfoPageHeader/WfoAppLogo.tsx +28 -0
  26. package/src/components/WfoPageTemplate/WfoPageHeader/WfoPageHeader.tsx +19 -16
  27. package/src/components/WfoPageTemplate/WfoPageHeader/styles.ts +29 -0
  28. package/src/components/WfoPageTemplate/WfoPageHeader/utils/toHexColorWithOpacity.spec.ts +12 -0
  29. package/src/components/WfoPageTemplate/WfoPageHeader/utils/toHexColorWithOpacity.ts +5 -0
  30. package/src/components/WfoPageTemplate/WfoSidebar/WfoCopyright.tsx +22 -0
  31. package/src/components/WfoPageTemplate/WfoSidebar/WfoSidebar.tsx +10 -6
  32. package/src/components/WfoPageTemplate/WfoSidebar/WfoStartCreateWorkflowButtonComboBox.tsx +0 -3
  33. package/src/components/WfoPageTemplate/WfoSidebar/styles.ts +17 -0
  34. package/src/components/WfoProcessList/{WfoProcessList.tsx → WfoProcessesList.tsx} +79 -36
  35. package/src/components/WfoProcessList/index.ts +1 -1
  36. package/src/components/WfoProcessList/processListObjectMappers.ts +5 -1
  37. package/src/components/WfoSettings/WfoFlushSettings.tsx +16 -6
  38. package/src/components/WfoSettings/WfoModifySettings.tsx +1 -1
  39. package/src/components/WfoSettingsModal/WfoSubmitModal.tsx +61 -0
  40. package/src/components/WfoSettingsModal/index.tsx +1 -0
  41. package/src/components/WfoStartTaskButtonComboBox/WfoStartTaskButtonComboBox.tsx +0 -3
  42. package/src/components/WfoSubscription/WfoRelatedSubscriptions.tsx +4 -1
  43. package/src/components/WfoSubscription/WfoSubscription.tsx +41 -66
  44. package/src/components/WfoSubscription/WfoSubscriptionDetailTree.tsx +3 -6
  45. package/src/components/WfoSubscription/WfoSubscriptionGeneral.tsx +1 -1
  46. package/src/components/WfoSubscription/WfoSubscriptionProductBlock.tsx +2 -1
  47. package/src/components/WfoSubscription/subscriptionDetailTabs.tsx +59 -0
  48. package/src/components/WfoSubscription/utils/utils.ts +5 -5
  49. package/src/components/WfoSubscriptionsList/WfoSubscriptionsList.tsx +69 -24
  50. package/src/components/WfoSubscriptionsList/index.ts +1 -1
  51. package/src/components/WfoSubscriptionsList/subscriptionListTabs.ts +8 -30
  52. package/src/components/WfoSubscriptionsList/{mapGrapghQlSubscriptionsResultToSubscriptionListItems.ts → subscriptionResultMappers.ts} +14 -1
  53. package/src/components/WfoSummary/WfoSummaryCardHeader/WfoSummaryCardHeader.tsx +55 -0
  54. package/src/components/WfoSummary/WfoSummaryCardHeader/index.ts +1 -0
  55. package/src/components/WfoSummary/WfoSummaryCardHeader/styles.ts +26 -0
  56. package/src/components/WfoSummary/WfoSummaryCardList/WfoSummaryCardList.tsx +86 -0
  57. package/src/components/WfoSummary/WfoSummaryCardList/WfoSummaryCardListItem.tsx +59 -0
  58. package/src/components/WfoSummary/WfoSummaryCardList/index.ts +2 -0
  59. package/src/components/WfoSummary/WfoSummaryCardList/styles.ts +52 -0
  60. package/src/components/WfoSummary/WfoSummaryCards.tsx +111 -0
  61. package/src/components/WfoSummary/getNumberOfColumns.ts +14 -0
  62. package/src/components/WfoSummary/index.ts +4 -0
  63. package/src/components/WfoSummary/styles.ts +13 -0
  64. package/src/components/WfoTable/WfoBasicTable/WfoBasicTable.tsx +18 -16
  65. package/src/components/WfoTable/WfoBasicTable/WfoTableHeaderCell.tsx +2 -2
  66. package/src/components/WfoTable/WfoBasicTable/index.ts +1 -0
  67. package/src/components/WfoTable/WfoBasicTable/styles.ts +28 -2
  68. package/src/components/WfoTable/WfoFirstPartUUID/WfoFirstPartUUID.tsx +12 -3
  69. package/src/components/WfoTable/WfoFirstPartUUID/styles.ts +12 -0
  70. package/src/components/WfoTable/WfoTableWithFilter/WfoTableWithFilter.tsx +24 -4
  71. package/src/components/WfoTable/index.ts +2 -0
  72. package/src/components/WfoTable/utils/columns.ts +21 -15
  73. package/src/components/WfoTable/utils/constants.ts +4 -2
  74. package/src/components/WfoTable/utils/mapSortableAndFilterableValuesToTableColumnConfig.ts +5 -3
  75. package/src/components/WfoTree/WfoTreeNode.tsx +3 -4
  76. package/src/components/WfoWorkflowSteps/WfoStep/WfoStep.tsx +4 -3
  77. package/src/components/WfoWorkflowSteps/index.ts +1 -0
  78. package/src/components/index.ts +3 -1
  79. package/src/configuration/constants.ts +1 -0
  80. package/src/contexts/ApiClientContext.tsx +5 -1
  81. package/src/contexts/OrchestratorConfigContext.tsx +0 -3
  82. package/src/contexts/ToastContext.tsx +1 -1
  83. package/src/contexts/TreeContext.tsx +1 -1
  84. package/src/graphqlQueries/customersQuery.ts +3 -2
  85. package/src/graphqlQueries/processListQuery.ts +46 -6
  86. package/src/graphqlQueries/productBlocksQuery.ts +3 -1
  87. package/src/graphqlQueries/productsQuery.ts +40 -9
  88. package/src/graphqlQueries/resourceTypesQuery.ts +3 -1
  89. package/src/graphqlQueries/subscriptionDetailQuery.ts +5 -2
  90. package/src/graphqlQueries/subscriptionsDropdownOptionsQuery.ts +3 -2
  91. package/src/graphqlQueries/subscriptionsListQuery.ts +41 -4
  92. package/src/graphqlQueries/workflows/workflowsQuery.ts +3 -1
  93. package/src/graphqlQueries/workflows/workflowsQueryForDropdownList.ts +3 -6
  94. package/src/hooks/DataFetchHooks.ts +17 -63
  95. package/src/hooks/surf/useGetSubscriptionDropdownOptions.ts +1 -0
  96. package/src/hooks/surf/useIsTaggedPort.ts +1 -2
  97. package/src/hooks/useOrchestratorConfig.ts +0 -3
  98. package/src/hooks/useQueryWithGraphql.ts +47 -13
  99. package/src/hooks/useSessionWithToken.ts +3 -5
  100. package/src/hooks/useSubscriptionActions.ts +8 -2
  101. package/src/icons/WfoBell.tsx +34 -0
  102. package/src/icons/WfoCogFill.tsx +23 -25
  103. package/src/icons/WfoContactEnvelopeFill.tsx +29 -0
  104. package/src/icons/WfoCubeSolid.tsx +33 -0
  105. package/src/icons/WfoPencil.tsx +21 -0
  106. package/src/icons/WfoPlayCircle.tsx +35 -0
  107. package/src/icons/WfoShare.tsx +35 -0
  108. package/src/icons/WfoSideMenu.stories.tsx +13 -0
  109. package/src/icons/WfoSideMenu.tsx +39 -0
  110. package/src/icons/WfoStatistic.tsx +3 -3
  111. package/src/icons/WfoViewList.tsx +24 -0
  112. package/src/icons/index.ts +9 -0
  113. package/src/messages/en-GB.json +37 -4
  114. package/src/messages/nl-NL.json +38 -5
  115. package/src/pages/index.ts +2 -1
  116. package/src/pages/metadata/WfoProductBlocksPage.tsx +45 -15
  117. package/src/pages/metadata/WfoProductsPage.tsx +45 -19
  118. package/src/pages/metadata/WfoResourceTypesPage.tsx +40 -13
  119. package/src/pages/metadata/WfoWorkflowsPage.tsx +46 -18
  120. package/src/pages/processes/WfoProcessDetail.tsx +5 -1
  121. package/src/pages/processes/WfoProcessDetailPage.tsx +31 -15
  122. package/src/pages/processes/WfoStartProcessPage.tsx +41 -17
  123. package/src/pages/startPage/WfoStartPage.tsx +239 -0
  124. package/src/pages/startPage/index.ts +1 -0
  125. package/src/pages/subscriptions/WfoSubscriptionsListPage.tsx +22 -26
  126. package/src/pages/tasks/{WfoTaskListPage.tsx → WfoTasksListPage.tsx} +67 -44
  127. package/src/pages/tasks/getTasksListTabTypeFromString.ts +19 -0
  128. package/src/pages/tasks/index.ts +3 -1
  129. package/src/pages/tasks/tabConfig.ts +51 -0
  130. package/src/pages/{workflow/WfoWorkflowListPage.tsx → workflows/WfoWorkflowsListPage.tsx} +18 -19
  131. package/src/pages/workflows/getWorkflowsListTabTypeFromString.ts +19 -0
  132. package/src/pages/workflows/index.ts +1 -0
  133. package/src/pages/{workflow → workflows}/tabConfig.ts +9 -9
  134. package/src/theme/defaultOrchestratorTheme.ts +8 -0
  135. package/src/types/types.ts +10 -55
  136. package/src/utils/csvDownload.ts +87 -0
  137. package/src/utils/date.ts +39 -0
  138. package/src/utils/getDefaultTableConfig.ts +20 -12
  139. package/src/utils/getQueryVariablesForExport.spec.ts +19 -0
  140. package/src/utils/getQueryVariablesForExport.ts +11 -0
  141. package/src/utils/index.ts +1 -0
  142. package/src/utils/sortObjectKeys.spec.ts +34 -0
  143. package/src/utils/sortObjectKeys.ts +33 -0
  144. package/tsconfig.json +4 -4
  145. package/src/components/WfoStartPage/WfoFrequentlyUsed.stories.tsx +0 -16
  146. package/src/components/WfoStartPage/WfoFrequentlyUsed.tsx +0 -21
  147. package/src/components/WfoStartPage/WfoListItemStartPage.stories.tsx +0 -40
  148. package/src/components/WfoStartPage/WfoListItemStartPage.tsx +0 -95
  149. package/src/components/WfoStartPage/WfoListStartPage.stories.tsx +0 -98
  150. package/src/components/WfoStartPage/WfoListStartPage.tsx +0 -45
  151. package/src/components/WfoStartPage/WfoMultiListSection.stories.tsx +0 -90
  152. package/src/components/WfoStartPage/WfoMultiListSection.tsx +0 -25
  153. package/src/components/WfoStartPage/WfoNewProcessPanel.stories.tsx +0 -13
  154. package/src/components/WfoStartPage/WfoNewProcessPanel.tsx +0 -45
  155. package/src/components/WfoStartPage/WfoStatCards.stories.tsx +0 -13
  156. package/src/components/WfoStartPage/WfoStatCards.tsx +0 -75
  157. package/src/components/WfoStartPage/index.ts +0 -6
  158. package/src/pages/workflow/getWorkflowListTabTypeFromString.ts +0 -19
  159. package/src/pages/workflow/index.ts +0 -1
@@ -2,14 +2,17 @@ import React, { useContext, useEffect, useState } from 'react';
2
2
 
3
3
  import { useTranslations } from 'next-intl';
4
4
  import Link from 'next/link';
5
+ import { useRouter } from 'next/router';
6
+ import { StringParam, useQueryParam, withDefault } from 'use-query-params';
5
7
 
6
- import { EuiButton, EuiHorizontalRule, EuiSpacer } from '@elastic/eui';
8
+ import { EuiButton, EuiSpacer } from '@elastic/eui';
7
9
 
8
10
  import {
11
+ ACTIVE_TASKS_LIST_TABLE_LOCAL_STORAGE_KEY,
12
+ COMPLETED_TASKS_LIST_TABLE_LOCAL_STORAGE_KEY,
9
13
  DEFAULT_PAGE_SIZE,
10
- FilterQuery,
11
14
  StoredTableConfig,
12
- TASK_LIST_TABLE_LOCAL_STORAGE_KEY,
15
+ WfoFilterTabs,
13
16
  WfoStartTaskButtonComboBox,
14
17
  WfoTableColumns,
15
18
  } from '@/components';
@@ -17,8 +20,8 @@ import { PATH_TASKS } from '@/components';
17
20
  import { WfoPageHeader } from '@/components/WfoPageHeader/WfoPageHeader';
18
21
  import {
19
22
  ProcessListItem,
20
- WfoProcessList,
21
- } from '@/components/WfoProcessList/WfoProcessList';
23
+ WfoProcessesList,
24
+ } from '@/components/WfoProcessList/WfoProcessesList';
22
25
  import { ConfirmationDialogContext } from '@/contexts';
23
26
  import {
24
27
  useCheckEngineStatus,
@@ -28,21 +31,35 @@ import {
28
31
  useStoredTableConfig,
29
32
  } from '@/hooks';
30
33
  import { WfoRefresh } from '@/icons';
34
+ import { WfoTasksListTabType, defaultTasksListTabs } from '@/pages';
35
+ import { getTasksListTabTypeFromString } from '@/pages/tasks/getTasksListTabTypeFromString';
31
36
  import { SortOrder } from '@/types';
32
37
 
33
- export const WfoTaskListPage = () => {
34
- const { theme } = useOrchestratorTheme();
38
+ export const WfoTasksListPage = () => {
39
+ const router = useRouter();
35
40
  const t = useTranslations('tasks.page');
36
- const { showConfirmDialog } = useContext(ConfirmationDialogContext);
37
- const { retryAllProcesses } = useMutateProcess();
38
- const { isEngineRunningNow } = useCheckEngineStatus();
41
+ const [activeTab, setActiveTab] = useQueryParam(
42
+ 'activeTab',
43
+ withDefault(StringParam, WfoTasksListTabType.ACTIVE),
44
+ );
39
45
 
40
46
  const [tableDefaults, setTableDefaults] =
41
47
  useState<StoredTableConfig<ProcessListItem>>();
42
48
 
43
- const getStoredTableConfig = useStoredTableConfig<ProcessListItem>(
44
- TASK_LIST_TABLE_LOCAL_STORAGE_KEY,
45
- );
49
+ const selectedTasksListTab = getTasksListTabTypeFromString(activeTab);
50
+
51
+ const localStorageKey =
52
+ selectedTasksListTab === WfoTasksListTabType.ACTIVE
53
+ ? ACTIVE_TASKS_LIST_TABLE_LOCAL_STORAGE_KEY
54
+ : COMPLETED_TASKS_LIST_TABLE_LOCAL_STORAGE_KEY;
55
+
56
+ const getStoredTableConfig =
57
+ useStoredTableConfig<ProcessListItem>(localStorageKey);
58
+
59
+ const { theme } = useOrchestratorTheme();
60
+ const { showConfirmDialog } = useContext(ConfirmationDialogContext);
61
+ const { retryAllProcesses } = useMutateProcess();
62
+ const { isEngineRunningNow } = useCheckEngineStatus();
46
63
 
47
64
  useEffect(() => {
48
65
  const storedConfig = getStoredTableConfig();
@@ -54,6 +71,8 @@ export const WfoTaskListPage = () => {
54
71
 
55
72
  const { dataDisplayParams, setDataDisplayParam } =
56
73
  useDataDisplayParams<ProcessListItem>({
74
+ // TODO: Improvement: A default pageSize value is set to avoid a graphql error when the query is executed
75
+ // https://github.com/workfloworchestrator/orchestrator-ui/issues/261
57
76
  pageSize: tableDefaults?.selectedPageSize || DEFAULT_PAGE_SIZE,
58
77
  sortBy: {
59
78
  field: 'lastModifiedAt',
@@ -61,21 +80,32 @@ export const WfoTaskListPage = () => {
61
80
  },
62
81
  });
63
82
 
64
- const alwaysOnFilters: FilterQuery<ProcessListItem>[] = [
65
- {
66
- // Todo: isTask is not a key of Process
67
- // However, backend still supports it. Field should not be a keyof ProcessListItem (or process)
68
- // https://github.com/workfloworchestrator/orchestrator-ui/issues/290
69
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
70
- // @ts-ignore waiting for fix in backend
71
- field: 'isTask',
72
- value: 'true',
73
- },
74
- {
75
- field: 'lastStatus',
76
- value: 'running-failed-api_unavailable-inconsistent_data',
77
- },
78
- ];
83
+ const handleChangeTasksListTab = (
84
+ updatedTasksListTab: WfoTasksListTabType,
85
+ ) => {
86
+ setActiveTab(updatedTasksListTab);
87
+ setDataDisplayParam('pageIndex', 0);
88
+ };
89
+
90
+ const alwaysOnFilters = defaultTasksListTabs.find(
91
+ ({ id }) => id === selectedTasksListTab,
92
+ )?.alwaysOnFilters;
93
+
94
+ if (!selectedTasksListTab) {
95
+ router.replace(PATH_TASKS);
96
+ return null;
97
+ }
98
+
99
+ const handleRerunAllButtonClick = async () => {
100
+ if (await isEngineRunningNow()) {
101
+ showConfirmDialog({
102
+ question: t('rerunAllQuestion'),
103
+ confirmAction: () => {
104
+ retryAllProcesses.mutate();
105
+ },
106
+ });
107
+ }
108
+ };
79
109
 
80
110
  // Changing the order of the keys, resulting in an updated column order in the table
81
111
  const handleOverrideTableColumns: (
@@ -103,17 +133,6 @@ export const WfoTaskListPage = () => {
103
133
  lastModifiedAt: defaultTableColumns.lastModifiedAt,
104
134
  });
105
135
 
106
- const handleRerunAllButtonClick = async () => {
107
- if (await isEngineRunningNow()) {
108
- showConfirmDialog({
109
- question: t('rerunAllQuestion'),
110
- confirmAction: () => {
111
- retryAllProcesses.mutate();
112
- },
113
- });
114
- }
115
- };
116
-
117
136
  return (
118
137
  <>
119
138
  <EuiSpacer />
@@ -129,16 +148,20 @@ export const WfoTaskListPage = () => {
129
148
  </EuiButton>
130
149
  <WfoStartTaskButtonComboBox />
131
150
  </WfoPageHeader>
132
- <EuiHorizontalRule />
133
-
151
+ <WfoFilterTabs
152
+ tabs={defaultTasksListTabs}
153
+ translationNamespace="tasks.tabs"
154
+ selectedTab={selectedTasksListTab}
155
+ onChangeTab={handleChangeTasksListTab}
156
+ />
134
157
  <EuiSpacer size="xxl" />
135
158
 
136
- <WfoProcessList
159
+ <WfoProcessesList
137
160
  defaultHiddenColumns={tableDefaults?.hiddenColumns}
138
- localStorageKey={TASK_LIST_TABLE_LOCAL_STORAGE_KEY}
161
+ localStorageKey={localStorageKey}
162
+ overrideDefaultTableColumns={handleOverrideTableColumns}
139
163
  dataDisplayParams={dataDisplayParams}
140
164
  setDataDisplayParam={setDataDisplayParam}
141
- overrideDefaultTableColumns={handleOverrideTableColumns}
142
165
  alwaysOnFilters={alwaysOnFilters}
143
166
  />
144
167
  </>
@@ -0,0 +1,19 @@
1
+ import { WfoTasksListTabType } from './tabConfig';
2
+
3
+ export const getTasksListTabTypeFromString = (
4
+ tabId?: string,
5
+ ): WfoTasksListTabType | undefined => {
6
+ if (!tabId) {
7
+ return undefined;
8
+ }
9
+
10
+ switch (tabId.toUpperCase()) {
11
+ case WfoTasksListTabType.ACTIVE.toString():
12
+ return WfoTasksListTabType.ACTIVE;
13
+ case WfoTasksListTabType.COMPLETED.toString():
14
+ return WfoTasksListTabType.COMPLETED;
15
+
16
+ default:
17
+ return undefined;
18
+ }
19
+ };
@@ -1 +1,3 @@
1
- export * from './WfoTaskListPage';
1
+ export * from './WfoTasksListPage';
2
+ export * from './tabConfig';
3
+ export * from './getTasksListTabTypeFromString';
@@ -0,0 +1,51 @@
1
+ import { WfoFilterTab } from '@/components';
2
+ import { ProcessListItem } from '@/components';
3
+
4
+ export enum WfoTasksListTabType {
5
+ ACTIVE = 'ACTIVE',
6
+ COMPLETED = 'COMPLETED',
7
+ }
8
+
9
+ export const defaultTasksListTabs: WfoFilterTab<
10
+ WfoTasksListTabType,
11
+ ProcessListItem
12
+ >[] = [
13
+ {
14
+ id: WfoTasksListTabType.ACTIVE,
15
+ translationKey: 'active',
16
+ alwaysOnFilters: [
17
+ {
18
+ // Todo: isTask is not a key of Process
19
+ // However, backend still supports it. Field should not be a keyof ProcessListItem (or process)
20
+ // https://github.com/workfloworchestrator/orchestrator-ui/issues/290
21
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
22
+ // @ts-ignore waiting for fix in backend
23
+ field: 'isTask',
24
+ value: 'true',
25
+ },
26
+ {
27
+ field: 'lastStatus',
28
+ value: 'created-running-suspended-waiting-failed-resumed-inconsistent_data-api_unavailable-awaiting_callback',
29
+ },
30
+ ],
31
+ },
32
+ {
33
+ id: WfoTasksListTabType.COMPLETED,
34
+ translationKey: 'completed',
35
+ alwaysOnFilters: [
36
+ {
37
+ // Todo: isTask is not a key of Process
38
+ // However, backend still supports it. Field should not be a keyof ProcessListItem (or process)
39
+ // https://github.com/workfloworchestrator/orchestrator-ui/issues/290
40
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
41
+ // @ts-ignore waiting for fix in backend
42
+ field: 'isTask',
43
+ value: 'true',
44
+ },
45
+ {
46
+ field: 'lastStatus',
47
+ value: 'completed-aborted',
48
+ },
49
+ ],
50
+ },
51
+ ];
@@ -13,28 +13,29 @@ import {
13
13
  PATH_WORKFLOWS,
14
14
  } from '@/components';
15
15
  import type { StoredTableConfig } from '@/components';
16
- import { ProcessListItem, WfoFilterTabs, WfoProcessList } from '@/components';
16
+ import { ProcessListItem, WfoFilterTabs, WfoProcessesList } from '@/components';
17
17
  import { useDataDisplayParams, useStoredTableConfig } from '@/hooks';
18
18
  import { SortOrder } from '@/types';
19
19
 
20
- import { getWorkflowListTabTypeFromString } from './getWorkflowListTabTypeFromString';
21
- import { WfoWorkflowListTabType, defaultWorkflowListTabs } from './tabConfig';
20
+ import { getWorkflowsListTabTypeFromString } from './getWorkflowsListTabTypeFromString';
21
+ import { WfoWorkflowsListTabType, defaultWorkflowsListTabs } from './tabConfig';
22
22
 
23
- export const WfoWorkflowListPage = () => {
23
+ export const WfoWorkflowsListPage = () => {
24
24
  const router = useRouter();
25
25
  const t = useTranslations('workflows.index');
26
26
  const [activeTab, setActiveTab] = useQueryParam(
27
27
  'activeTab',
28
- withDefault(StringParam, WfoWorkflowListTabType.ACTIVE),
28
+ withDefault(StringParam, WfoWorkflowsListTabType.ACTIVE),
29
29
  );
30
30
 
31
31
  const [tableDefaults, setTableDefaults] =
32
32
  useState<StoredTableConfig<ProcessListItem>>();
33
33
 
34
- const selectedProcessListTab = getWorkflowListTabTypeFromString(activeTab);
34
+ const selectedWorkflowsListTab =
35
+ getWorkflowsListTabTypeFromString(activeTab);
35
36
 
36
37
  const localStorageKey =
37
- selectedProcessListTab === WfoWorkflowListTabType.ACTIVE
38
+ selectedWorkflowsListTab === WfoWorkflowsListTabType.ACTIVE
38
39
  ? ACTIVE_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY
39
40
  : COMPLETED_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY;
40
41
 
@@ -52,8 +53,6 @@ export const WfoWorkflowListPage = () => {
52
53
  const { dataDisplayParams, setDataDisplayParam } =
53
54
  useDataDisplayParams<ProcessListItem>({
54
55
  // TODO: Improvement: A default pageSize value is set to avoid a graphql error when the query is executed
55
- // the fist time before the useEffect has populated the tableDefaults. Better is to create a way for
56
- // the query to wait for the values to be available
57
56
  // https://github.com/workfloworchestrator/orchestrator-ui/issues/261
58
57
  pageSize: tableDefaults?.selectedPageSize || DEFAULT_PAGE_SIZE,
59
58
  sortBy: {
@@ -62,18 +61,18 @@ export const WfoWorkflowListPage = () => {
62
61
  },
63
62
  });
64
63
 
65
- const handleChangeProcessListTab = (
66
- updatedProcessListTab: WfoWorkflowListTabType,
64
+ const handleChangeWorkflowsListTab = (
65
+ updatedWorkflowsListTab: WfoWorkflowsListTabType,
67
66
  ) => {
68
- setActiveTab(updatedProcessListTab);
67
+ setActiveTab(updatedWorkflowsListTab);
69
68
  setDataDisplayParam('pageIndex', 0);
70
69
  };
71
70
 
72
- const alwaysOnFilters = defaultWorkflowListTabs.find(
73
- ({ id }) => id === selectedProcessListTab,
71
+ const alwaysOnFilters = defaultWorkflowsListTabs.find(
72
+ ({ id }) => id === selectedWorkflowsListTab,
74
73
  )?.alwaysOnFilters;
75
74
 
76
- if (!selectedProcessListTab) {
75
+ if (!selectedWorkflowsListTab) {
77
76
  router.replace(PATH_WORKFLOWS);
78
77
  return null;
79
78
  }
@@ -86,14 +85,14 @@ export const WfoWorkflowListPage = () => {
86
85
  <EuiSpacer size="m" />
87
86
 
88
87
  <WfoFilterTabs
89
- tabs={defaultWorkflowListTabs}
88
+ tabs={defaultWorkflowsListTabs}
90
89
  translationNamespace="workflows.tabs"
91
- selectedTab={selectedProcessListTab}
92
- onChangeTab={handleChangeProcessListTab}
90
+ selectedTab={selectedWorkflowsListTab}
91
+ onChangeTab={handleChangeWorkflowsListTab}
93
92
  />
94
93
  <EuiSpacer size="xxl" />
95
94
 
96
- <WfoProcessList
95
+ <WfoProcessesList
97
96
  alwaysOnFilters={alwaysOnFilters}
98
97
  defaultHiddenColumns={tableDefaults?.hiddenColumns}
99
98
  localStorageKey={localStorageKey}
@@ -0,0 +1,19 @@
1
+ import { WfoWorkflowsListTabType } from './tabConfig';
2
+
3
+ export const getWorkflowsListTabTypeFromString = (
4
+ tabId?: string,
5
+ ): WfoWorkflowsListTabType | undefined => {
6
+ if (!tabId) {
7
+ return undefined;
8
+ }
9
+
10
+ switch (tabId.toUpperCase()) {
11
+ case WfoWorkflowsListTabType.ACTIVE.toString():
12
+ return WfoWorkflowsListTabType.ACTIVE;
13
+ case WfoWorkflowsListTabType.COMPLETED.toString():
14
+ return WfoWorkflowsListTabType.COMPLETED;
15
+
16
+ default:
17
+ return undefined;
18
+ }
19
+ };
@@ -0,0 +1 @@
1
+ export * from './WfoWorkflowsListPage';
@@ -1,17 +1,17 @@
1
- import { WfoFilterTab } from '../../components';
2
- import { ProcessListItem } from '../../components/WfoProcessList/WfoProcessList';
1
+ import { WfoFilterTab } from '@/components';
2
+ import { ProcessListItem } from '@/components';
3
3
 
4
- export enum WfoWorkflowListTabType {
4
+ export enum WfoWorkflowsListTabType {
5
5
  ACTIVE = 'ACTIVE',
6
6
  COMPLETED = 'COMPLETED',
7
7
  }
8
8
 
9
- export const defaultWorkflowListTabs: WfoFilterTab<
10
- WfoWorkflowListTabType,
9
+ export const defaultWorkflowsListTabs: WfoFilterTab<
10
+ WfoWorkflowsListTabType,
11
11
  ProcessListItem
12
12
  >[] = [
13
13
  {
14
- id: WfoWorkflowListTabType.ACTIVE,
14
+ id: WfoWorkflowsListTabType.ACTIVE,
15
15
  translationKey: 'active',
16
16
  alwaysOnFilters: [
17
17
  {
@@ -25,12 +25,12 @@ export const defaultWorkflowListTabs: WfoFilterTab<
25
25
  },
26
26
  {
27
27
  field: 'lastStatus',
28
- value: 'created-running-suspended-waiting-failed-resumed',
28
+ value: 'created-running-suspended-waiting-failed-resumed-inconsistent_data-api_unavailable-awaiting_callback',
29
29
  },
30
30
  ],
31
31
  },
32
32
  {
33
- id: WfoWorkflowListTabType.COMPLETED,
33
+ id: WfoWorkflowsListTabType.COMPLETED,
34
34
  translationKey: 'completed',
35
35
  alwaysOnFilters: [
36
36
  {
@@ -44,7 +44,7 @@ export const defaultWorkflowListTabs: WfoFilterTab<
44
44
  },
45
45
  {
46
46
  field: 'lastStatus',
47
- value: 'completed',
47
+ value: 'completed-aborted',
48
48
  },
49
49
  ],
50
50
  },
@@ -2,6 +2,14 @@ import { EuiThemeModifications } from '@elastic/eui';
2
2
 
3
3
  export const defaultOrchestratorTheme: EuiThemeModifications = {
4
4
  base: 16,
5
+ breakpoint: {
6
+ xs: 0,
7
+ s: 575,
8
+ m: 768,
9
+ l: 992,
10
+ xl: 1200,
11
+ xxl: 1600,
12
+ },
5
13
  size: {
6
14
  base: '16px',
7
15
  xxs: '2px',
@@ -1,13 +1,7 @@
1
- import { _EuiThemeColorsMode } from '@elastic/eui/src/global_styling/variables/colors';
2
-
3
1
  import { InputForm } from './forms';
4
2
 
5
- export type UnionOfInterfaceTypes<T> = T[keyof T];
6
-
7
3
  export type Nullable<T> = T | null;
8
4
 
9
- type GenericField = { [key: string]: number | string | boolean };
10
-
11
5
  type GenericResponse = { [key: string]: unknown };
12
6
 
13
7
  export type FieldValue = {
@@ -28,18 +22,10 @@ export enum EngineStatus {
28
22
 
29
23
  export type Customer = {
30
24
  fullname: string;
31
- identifier: string;
25
+ customerId: string;
32
26
  shortcode: string;
33
27
  };
34
28
 
35
- export type ResourceTypeBase = {
36
- name: string;
37
- title: string;
38
- subscriptionInstanceId: string;
39
- ownerSubscriptionId: string;
40
- label?: string;
41
- } & GenericField;
42
-
43
29
  export type InUseByRelation = {
44
30
  subscription_instance_id: string;
45
31
  subscription_id: string;
@@ -89,8 +75,6 @@ export enum BadgeType {
89
75
  PRODUCT_TAG = 'product_tag',
90
76
  }
91
77
 
92
- export type FixedInputsBase = GenericField;
93
-
94
78
  export interface FixedInputDefinition {
95
79
  fixedInputId: string;
96
80
  name: string;
@@ -110,36 +94,6 @@ export interface TreeBlock extends ProductBlockInstance {
110
94
  children: TreeBlock[];
111
95
  }
112
96
 
113
- export interface ItemsList {
114
- type: string;
115
- title: string;
116
- items: ProcessFromRestApi[];
117
- buttonName: string;
118
- }
119
-
120
- export interface TotalStat {
121
- icon: string;
122
- name: string;
123
- value: number;
124
- color: keyof _EuiThemeColorsMode;
125
- }
126
-
127
- // Todo: Temporary renamed this type, will be fixed in:
128
- // https://github.com/workfloworchestrator/orchestrator-ui/issues/216
129
- export interface ProcessFromRestApi {
130
- pid: string;
131
- workflow: string;
132
- assignee: string;
133
- last_status: string;
134
- failed_reason: Nullable<string>;
135
- traceback: string;
136
- step: string;
137
- created_by: string;
138
- started_at: number;
139
- last_modified_at: number;
140
- is_task: boolean;
141
- }
142
-
143
97
  export interface ProductDefinition {
144
98
  productId: string;
145
99
  name: string;
@@ -263,7 +217,7 @@ export interface Step {
263
217
  status: StepStatus;
264
218
  stepId: string; // sic backend
265
219
  executed: string;
266
- state: StepState;
220
+ state: StepState | undefined;
267
221
  stateDelta: StepState;
268
222
  }
269
223
 
@@ -312,8 +266,8 @@ export type GraphQLPageInfo = {
312
266
  filterFields: string[];
313
267
  };
314
268
 
315
- export interface SubscriptionsResult {
316
- subscriptions: GraphQlResultPage<Subscription>;
269
+ export interface SubscriptionsResult<T = Subscription> {
270
+ subscriptions: GraphQlResultPage<T>;
317
271
  }
318
272
 
319
273
  export interface SubscriptionDropdownOptionsResult {
@@ -324,8 +278,8 @@ export interface SubscriptionDetailResult {
324
278
  subscriptions: GraphQlResultPage<SubscriptionDetail>;
325
279
  }
326
280
 
327
- export interface ProductDefinitionsResult {
328
- products: GraphQlResultPage<ProductDefinition>;
281
+ export interface ProductDefinitionsResult<T = ProductDefinition> {
282
+ products: GraphQlResultPage<T>;
329
283
  }
330
284
  export interface StartProcessStep {
331
285
  name: Step['name'];
@@ -343,8 +297,8 @@ export interface ResourceTypeDefinitionsResult {
343
297
  resourceTypes: GraphQlResultPage<ResourceTypeDefinition>;
344
298
  }
345
299
 
346
- export interface ProcessListResult {
347
- processes: GraphQlResultPage<Process>;
300
+ export interface ProcessListResult<T = Process> {
301
+ processes: GraphQlResultPage<T>;
348
302
  }
349
303
 
350
304
  export interface ProcessesDetailResult {
@@ -416,13 +370,14 @@ export type Subscription = {
416
370
  status: SubscriptionStatus;
417
371
  product: Pick<ProductDefinition, 'name' | 'tag' | 'productType'>;
418
372
  productBlockInstances: ProductBlockInstance[];
373
+ customer: Pick<Customer, 'fullname' | 'shortcode'>;
419
374
  };
420
375
 
421
376
  export type SubscriptionDropdownOption = {
422
377
  description: Subscription['description'];
423
378
  subscriptionId: Subscription['subscriptionId'];
424
379
  product: Pick<ProductDefinition, 'tag' | 'productId'>;
425
- customer: Pick<Customer, 'fullname' | 'identifier'>;
380
+ customer: Pick<Customer, 'fullname' | 'customerId'>;
426
381
  productBlockInstances: ProductBlockInstance[];
427
382
  fixedInputs: FieldValue[];
428
383
  tag: string;
@@ -0,0 +1,87 @@
1
+ import { TranslationValues } from 'next-intl';
2
+
3
+ import { MAXIMUM_ITEMS_FOR_BULK_FETCHING } from '@/configuration/constants';
4
+ import { ToastTypes } from '@/contexts';
5
+ import { GraphQLPageInfo } from '@/types';
6
+ import { sortObjectKeys } from '@/utils/sortObjectKeys';
7
+
8
+ function toCsvFileContent<T extends object>(data: T[]): string {
9
+ const headers = Object.keys(data[0]).join(';');
10
+ const rows = data.map((row) =>
11
+ Object.values(row)
12
+ .map((value) => (value === null ? '' : `"${value}"`))
13
+ .join(';')
14
+ .split('\n')
15
+ .join(' '),
16
+ );
17
+ return [headers, ...rows].join('\n');
18
+ }
19
+
20
+ function startCsvDownload(csvFileContent: string, fileName: string) {
21
+ const blob = new Blob([csvFileContent], { type: 'text/csv' });
22
+ const url = URL.createObjectURL(blob);
23
+ const link = document.createElement('a');
24
+ link.href = url;
25
+ link.download = fileName.endsWith('.csv') ? fileName : `${fileName}.csv`;
26
+ link.click();
27
+ URL.revokeObjectURL(url);
28
+ }
29
+
30
+ export function initiateCsvFileDownload<T extends object>(
31
+ data: T[],
32
+ fileName: string,
33
+ ) {
34
+ const csvFileContent = toCsvFileContent(data);
35
+ startCsvDownload(csvFileContent, fileName);
36
+ }
37
+
38
+ export const getCsvFileNameWithDate = (fileNameWithoutExtension: string) => {
39
+ const date = new Date();
40
+ const year = date.getFullYear();
41
+ const month = (date.getMonth() + 1).toString().padStart(2, '0');
42
+ const day = date.getDate();
43
+
44
+ const hour = date.getHours();
45
+ const minute = date.getMinutes();
46
+ const second = date.getSeconds();
47
+
48
+ return `${fileNameWithoutExtension}_${year}-${month}-${day}-${hour}${minute}${second}.csv`;
49
+ };
50
+
51
+ export const csvDownloadHandler =
52
+ <T extends object, U extends object>(
53
+ dataFetchFunction: () => Promise<T | undefined>,
54
+ dataMapper: (data: T) => U[],
55
+ pageInfoMapper: (data: T) => GraphQLPageInfo,
56
+ keyOrder: string[],
57
+ filename: string,
58
+ addToastFunction: (
59
+ type: ToastTypes,
60
+ text: string,
61
+ title: string,
62
+ ) => void,
63
+ translationFunction: (
64
+ translationKey: string,
65
+ variables?: TranslationValues,
66
+ ) => string,
67
+ ) =>
68
+ async () => {
69
+ const data: T | undefined = await dataFetchFunction();
70
+
71
+ if (data) {
72
+ const dataForExport = dataMapper(data).map((d) =>
73
+ sortObjectKeys(d, keyOrder),
74
+ );
75
+ const pageInfo = pageInfoMapper(data);
76
+ (pageInfo.totalItems ?? 0) > MAXIMUM_ITEMS_FOR_BULK_FETCHING &&
77
+ addToastFunction(
78
+ ToastTypes.ERROR,
79
+ translationFunction('notAllResultsExported', {
80
+ totalResults: pageInfo.totalItems,
81
+ maximumExportedResults: MAXIMUM_ITEMS_FOR_BULK_FETCHING,
82
+ }),
83
+ translationFunction('notAllResultsExportedTitle'),
84
+ );
85
+ initiateCsvFileDownload(dataForExport, filename);
86
+ }
87
+ };