@orchestrator-ui/orchestrator-ui-components 0.2.7 → 0.3.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 (120) hide show
  1. package/.turbo/turbo-build.log +6 -6
  2. package/.turbo/turbo-lint.log +0 -6
  3. package/.turbo/turbo-test.log +10 -9
  4. package/CHANGELOG.md +6 -0
  5. package/dist/index.d.ts +1005 -123
  6. package/dist/index.js +33849 -6199
  7. package/package.json +14 -12
  8. package/src/api/index.ts +55 -0
  9. package/src/components/WfoDiff/WfoDiff.tsx +119 -0
  10. package/src/components/WfoDiff/index.ts +1 -0
  11. package/src/components/WfoDiff/unidiff.d.ts +1 -0
  12. package/src/components/WfoForms/AutoFieldLoader.tsx +5 -1
  13. package/src/components/WfoForms/CreateForm.tsx +1 -0
  14. package/src/components/WfoForms/UserInputForm.tsx +75 -44
  15. package/src/components/WfoForms/UserInputFormWizard.tsx +11 -4
  16. package/src/components/WfoForms/formFields/AcceptField.tsx +8 -5
  17. package/src/components/WfoForms/formFields/BoolField.tsx +1 -1
  18. package/src/components/WfoForms/formFields/ImsNodeIdField.tsx +2 -2
  19. package/src/components/WfoForms/formFields/ImsPortIdField.tsx +238 -0
  20. package/src/components/WfoForms/formFields/ImsPortIdFieldStyling.ts +17 -0
  21. package/src/components/WfoForms/formFields/ListAddField.tsx +1 -1
  22. package/src/components/WfoForms/formFields/ListDelField.tsx +1 -1
  23. package/src/components/WfoForms/formFields/OptGroupField.tsx +1 -1
  24. package/src/components/WfoForms/formFields/SubscriptionField.tsx +2 -1
  25. package/src/components/WfoForms/formFields/SummaryField.tsx +103 -0
  26. package/src/components/WfoForms/formFields/SummaryFieldStyling.ts +46 -0
  27. package/src/components/WfoForms/formFields/VlanField.tsx +10 -10
  28. package/src/components/WfoForms/formFields/index.ts +2 -0
  29. package/src/components/WfoForms/formFields/surf/types.ts +26 -0
  30. package/src/components/WfoForms/formFields/utils.spec.ts +1 -0
  31. package/src/components/WfoJsonCodeBlock/index.ts +1 -0
  32. package/src/components/WfoPageTemplate/WfoPageHeader/WfoPageHeader.tsx +4 -3
  33. package/src/components/WfoPageTemplate/WfoSidebar/WfoSidebar.tsx +14 -14
  34. package/src/components/WfoPageTemplate/WfoSidebar/WfoStartCreateWorkflowButtonComboBox.tsx +15 -9
  35. package/src/components/WfoPageTemplate/paths.ts +3 -2
  36. package/src/components/{WfoProcessesList → WfoProcessList}/WfoProcessList.tsx +18 -14
  37. package/src/components/WfoProcessList/index.ts +1 -0
  38. package/src/components/{WfoProcessesList → WfoProcessList}/processListObjectMappers.ts +4 -2
  39. package/src/components/WfoSearchBar/WfoSearchField.tsx +27 -37
  40. package/src/components/{WfoSettingsPage → WfoSettings}/WfoEngineStatusButton.tsx +7 -4
  41. package/src/components/{WfoSettingsPage → WfoSettings}/WfoFlushSettings.tsx +13 -12
  42. package/src/components/WfoSettings/WfoModifySettings.tsx +38 -0
  43. package/src/components/WfoSettings/WfoSettings.tsx +40 -0
  44. package/src/components/{WfoSettingsPage → WfoSettings}/WfoStatus.tsx +21 -14
  45. package/src/components/WfoStartPage/WfoListStartPage.tsx +3 -3
  46. package/src/components/WfoStartTaskButtonComboBox/WfoStartTaskButtonComboBox.tsx +14 -8
  47. package/src/components/WfoSubscription/WfoProcessesTimeline.tsx +11 -18
  48. package/src/components/WfoSubscription/WfoSubscription.tsx +1 -1
  49. package/src/components/WfoSubscription/WfoSubscriptionActions.tsx +41 -33
  50. package/src/components/WfoSubscription/WfoSubscriptionDetailTree.tsx +32 -22
  51. package/src/components/WfoSubscription/WfoSubscriptionProductBlock.tsx +94 -90
  52. package/src/components/WfoSubscription/WfoTargetTypeIcon.tsx +26 -0
  53. package/src/components/WfoSubscription/utils/utils.spec.ts +24 -0
  54. package/src/components/WfoSubscription/utils/utils.ts +16 -0
  55. package/src/components/WfoSubscriptionsList/WfoSubscriptionsList.tsx +17 -37
  56. package/src/components/WfoTable/WfoTableWithFilter/WfoTableWithFilter.tsx +20 -19
  57. package/src/components/WfoTable/WfoTableWithFilter/updateQueryString.spec.ts +95 -0
  58. package/src/components/WfoTable/WfoTableWithFilter/updateQueryString.ts +60 -0
  59. package/src/components/WfoTable/utils/tableUtils.ts +3 -3
  60. package/src/components/WfoTextAnchor/WfoTextAnchor.stories.tsx +18 -0
  61. package/src/components/WfoTextAnchor/WfoTextAnchor.tsx +22 -0
  62. package/src/components/WfoTextAnchor/index.ts +1 -0
  63. package/src/components/WfoTextAnchor/styles.ts +17 -0
  64. package/src/components/WfoTimeline/styles.ts +10 -4
  65. package/src/components/WfoWorkflowSteps/WfoStep/WfoStep.tsx +39 -24
  66. package/src/components/WfoWorkflowSteps/WfoStep/WfoStepForm.tsx +48 -0
  67. package/src/components/WfoWorkflowSteps/WfoStepList/WfoStepList.tsx +10 -10
  68. package/src/components/WfoWorkflowSteps/WfoWorkflowStepList/WfoStepListHeader.tsx +22 -23
  69. package/src/components/WfoWorkflowSteps/WfoWorkflowStepList/WfoWorkflowStepList.tsx +97 -17
  70. package/src/components/WfoWorkflowSteps/stepListUtils.ts +1 -28
  71. package/src/components/confirmationDialog/WfoConfirmationDialog.tsx +3 -3
  72. package/src/components/index.ts +6 -1
  73. package/src/contexts/ConfirmationDialogProvider.tsx +2 -2
  74. package/src/contexts/TreeContext.tsx +5 -0
  75. package/src/graphqlQueries/index.ts +1 -0
  76. package/src/graphqlQueries/processDetailQuery.ts +8 -0
  77. package/src/graphqlQueries/processListQuery.ts +7 -6
  78. package/src/graphqlQueries/processStepsQuery.ts +22 -0
  79. package/src/graphqlQueries/productBlocksQuery.ts +9 -5
  80. package/src/graphqlQueries/productsQuery.ts +7 -3
  81. package/src/graphqlQueries/relatedSubscriptionsQuery.ts +2 -2
  82. package/src/graphqlQueries/resourceTypesQuery.ts +8 -4
  83. package/src/graphqlQueries/subscriptionDetailQuery.ts +1 -0
  84. package/src/graphqlQueries/subscriptionsListQuery.ts +5 -3
  85. package/src/graphqlQueries/workflows/workflowsQuery.ts +8 -4
  86. package/src/graphqlQueries/workflows/workflowsQueryForDropdownList.ts +2 -2
  87. package/src/hooks/DataFetchHooks.ts +9 -4
  88. package/src/hooks/index.ts +3 -0
  89. package/src/hooks/useCheckEngineStatus.ts +30 -0
  90. package/src/hooks/useDataDisplayParams.ts +3 -3
  91. package/src/hooks/useEngineStatusQuery.ts +9 -7
  92. package/src/hooks/useMutateProcess.ts +96 -0
  93. package/src/messages/{en-US.json → en-GB.json} +85 -37
  94. package/src/messages/getTranslationMessages.spec.ts +25 -40
  95. package/src/messages/index.ts +1 -1
  96. package/src/messages/nl-NL.json +95 -48
  97. package/src/messages/useGetTranslationMessages.ts +51 -0
  98. package/src/pages/metadata/WfoProductBlocksPage.tsx +12 -10
  99. package/src/pages/metadata/WfoProductsPage.tsx +24 -25
  100. package/src/pages/metadata/WfoResourceTypesPage.tsx +12 -10
  101. package/src/pages/metadata/WfoWorkflowsPage.tsx +12 -10
  102. package/src/pages/processes/WfoProcessDetail.tsx +96 -79
  103. package/src/pages/processes/WfoProcessDetailPage.tsx +5 -3
  104. package/src/pages/{workflow/WfoStartWorkflowPage.tsx → processes/WfoStartProcessPage.tsx} +100 -50
  105. package/src/pages/processes/index.ts +1 -3
  106. package/src/pages/settings/WfoSettingsPage.tsx +30 -0
  107. package/src/pages/settings/index.ts +1 -0
  108. package/src/pages/tasks/WfoTaskListPage.tsx +35 -9
  109. package/src/pages/{processes/WfoProcessListPage.tsx → workflow/WfoWorkflowListPage.tsx} +22 -23
  110. package/src/pages/workflow/getWorkflowListTabTypeFromString.ts +19 -0
  111. package/src/pages/workflow/index.ts +1 -1
  112. package/src/pages/{processes → workflow}/tabConfig.ts +6 -6
  113. package/src/types/types.ts +33 -3
  114. package/src/utils/getDefaultTableConfig.ts +1 -1
  115. package/src/components/WfoSettingsPage/WfoModifySettings.tsx +0 -33
  116. package/src/components/WfoSettingsPage/WfoSettings.tsx +0 -40
  117. package/src/hooks/ProcessesHooks/useDeleteProcess.ts +0 -37
  118. package/src/messages/getTranslationMessages.ts +0 -26
  119. package/src/pages/processes/getProcessListTabTypeFromString.ts +0 -19
  120. /package/src/components/{WfoSettingsPage → WfoSettings}/index.ts +0 -0
@@ -1,5 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
 
3
+ import { useTranslations } from 'next-intl';
3
4
  import { useRouter } from 'next/router';
4
5
  import { StringParam, useQueryParam, withDefault } from 'use-query-params';
5
6
 
@@ -9,33 +10,31 @@ import {
9
10
  ACTIVE_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY,
10
11
  COMPLETED_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY,
11
12
  DEFAULT_PAGE_SIZE,
12
- } from '../../components';
13
- import type { StoredTableConfig } from '../../components';
14
- import { WfoFilterTabs } from '../../components';
15
- import {
16
- ProcessListItem,
17
- WfoProcessList,
18
- } from '../../components/WfoProcessesList/WfoProcessList';
19
- import { useDataDisplayParams, useStoredTableConfig } from '../../hooks';
20
- import { SortOrder } from '../../types';
21
- import { getProcessListTabTypeFromString } from './getProcessListTabTypeFromString';
22
- import { WfoProcessListTabType, defaultProcessListTabs } from './tabConfig';
23
-
24
- export const WfoProcessListPage = () => {
25
- const router = useRouter();
13
+ PATH_WORKFLOWS,
14
+ } from '@/components';
15
+ import type { StoredTableConfig } from '@/components';
16
+ import { ProcessListItem, WfoFilterTabs, WfoProcessList } from '@/components';
17
+ import { useDataDisplayParams, useStoredTableConfig } from '@/hooks';
18
+ import { SortOrder } from '@/types';
26
19
 
20
+ import { getWorkflowListTabTypeFromString } from './getWorkflowListTabTypeFromString';
21
+ import { WfoWorkflowListTabType, defaultWorkflowListTabs } from './tabConfig';
22
+
23
+ export const WfoWorkflowListPage = () => {
24
+ const router = useRouter();
25
+ const t = useTranslations('workflows.index');
27
26
  const [activeTab, setActiveTab] = useQueryParam(
28
27
  'activeTab',
29
- withDefault(StringParam, WfoProcessListTabType.ACTIVE),
28
+ withDefault(StringParam, WfoWorkflowListTabType.ACTIVE),
30
29
  );
31
30
 
32
31
  const [tableDefaults, setTableDefaults] =
33
32
  useState<StoredTableConfig<ProcessListItem>>();
34
33
 
35
- const selectedProcessListTab = getProcessListTabTypeFromString(activeTab);
34
+ const selectedProcessListTab = getWorkflowListTabTypeFromString(activeTab);
36
35
 
37
36
  const localStorageKey =
38
- selectedProcessListTab === WfoProcessListTabType.ACTIVE
37
+ selectedProcessListTab === WfoWorkflowListTabType.ACTIVE
39
38
  ? ACTIVE_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY
40
39
  : COMPLETED_PROCESSES_LIST_TABLE_LOCAL_STORAGE_KEY;
41
40
 
@@ -64,18 +63,18 @@ export const WfoProcessListPage = () => {
64
63
  });
65
64
 
66
65
  const handleChangeProcessListTab = (
67
- updatedProcessListTab: WfoProcessListTabType,
66
+ updatedProcessListTab: WfoWorkflowListTabType,
68
67
  ) => {
69
68
  setActiveTab(updatedProcessListTab);
70
69
  setDataDisplayParam('pageIndex', 0);
71
70
  };
72
71
 
73
- const alwaysOnFilters = defaultProcessListTabs.find(
72
+ const alwaysOnFilters = defaultWorkflowListTabs.find(
74
73
  ({ id }) => id === selectedProcessListTab,
75
74
  )?.alwaysOnFilters;
76
75
 
77
76
  if (!selectedProcessListTab) {
78
- router.replace('/processes');
77
+ router.replace(PATH_WORKFLOWS);
79
78
  return null;
80
79
  }
81
80
 
@@ -83,12 +82,12 @@ export const WfoProcessListPage = () => {
83
82
  <>
84
83
  <EuiSpacer />
85
84
 
86
- <EuiPageHeader pageTitle="Processes" />
85
+ <EuiPageHeader pageTitle={t('title')} />
87
86
  <EuiSpacer size="m" />
88
87
 
89
88
  <WfoFilterTabs
90
- tabs={defaultProcessListTabs}
91
- translationNamespace="processes.tabs"
89
+ tabs={defaultWorkflowListTabs}
90
+ translationNamespace="workflows.tabs"
92
91
  selectedTab={selectedProcessListTab}
93
92
  onChangeTab={handleChangeProcessListTab}
94
93
  />
@@ -0,0 +1,19 @@
1
+ import { WfoWorkflowListTabType } from './tabConfig';
2
+
3
+ export const getWorkflowListTabTypeFromString = (
4
+ tabId?: string,
5
+ ): WfoWorkflowListTabType | undefined => {
6
+ if (!tabId) {
7
+ return undefined;
8
+ }
9
+
10
+ switch (tabId.toUpperCase()) {
11
+ case WfoWorkflowListTabType.ACTIVE.toString():
12
+ return WfoWorkflowListTabType.ACTIVE;
13
+ case WfoWorkflowListTabType.COMPLETED.toString():
14
+ return WfoWorkflowListTabType.COMPLETED;
15
+
16
+ default:
17
+ return undefined;
18
+ }
19
+ };
@@ -1 +1 @@
1
- export * from './WfoStartWorkflowPage';
1
+ export * from './WfoWorkflowListPage';
@@ -1,17 +1,17 @@
1
1
  import { WfoFilterTab } from '../../components';
2
- import { ProcessListItem } from '../../components/WfoProcessesList/WfoProcessList';
2
+ import { ProcessListItem } from '../../components/WfoProcessList/WfoProcessList';
3
3
 
4
- export enum WfoProcessListTabType {
4
+ export enum WfoWorkflowListTabType {
5
5
  ACTIVE = 'ACTIVE',
6
6
  COMPLETED = 'COMPLETED',
7
7
  }
8
8
 
9
- export const defaultProcessListTabs: WfoFilterTab<
10
- WfoProcessListTabType,
9
+ export const defaultWorkflowListTabs: WfoFilterTab<
10
+ WfoWorkflowListTabType,
11
11
  ProcessListItem
12
12
  >[] = [
13
13
  {
14
- id: WfoProcessListTabType.ACTIVE,
14
+ id: WfoWorkflowListTabType.ACTIVE,
15
15
  translationKey: 'active',
16
16
  alwaysOnFilters: [
17
17
  {
@@ -30,7 +30,7 @@ export const defaultProcessListTabs: WfoFilterTab<
30
30
  ],
31
31
  },
32
32
  {
33
- id: WfoProcessListTabType.COMPLETED,
33
+ id: WfoWorkflowListTabType.COMPLETED,
34
34
  translationKey: 'completed',
35
35
  alwaysOnFilters: [
36
36
  {
@@ -1,11 +1,15 @@
1
1
  import { _EuiThemeColorsMode } from '@elastic/eui/src/global_styling/variables/colors';
2
2
 
3
+ import { InputForm } from './forms';
4
+
3
5
  export type UnionOfInterfaceTypes<T> = T[keyof T];
4
6
 
5
7
  export type Nullable<T> = T | null;
6
8
 
7
9
  type GenericField = { [key: string]: number | string | boolean };
8
10
 
11
+ type GenericResponse = { [key: string]: unknown };
12
+
9
13
  export type FieldValue = {
10
14
  field: string;
11
15
  value: string | number | boolean;
@@ -16,7 +20,11 @@ export type KeyValue = {
16
20
  value: string | number | boolean | undefined;
17
21
  };
18
22
 
19
- export type EngineStatusValue = 'RUNNING' | 'PAUSING' | 'PAUSED';
23
+ export enum EngineStatus {
24
+ RUNNING = 'RUNNING',
25
+ PAUSING = 'PAUSING',
26
+ PAUSED = 'PAUSED',
27
+ }
20
28
 
21
29
  export type Customer = {
22
30
  fullname: string;
@@ -169,6 +177,7 @@ export type Process = {
169
177
  processId: string;
170
178
  startedAt: string;
171
179
  lastModifiedAt: string;
180
+ isTask: boolean;
172
181
  subscriptions: {
173
182
  page: Pick<Subscription, 'subscriptionId' | 'description'>[];
174
183
  };
@@ -195,6 +204,7 @@ export interface ProcessDetail {
195
204
  createdBy: Process['createdBy'];
196
205
  startedAt: Process['startedAt'];
197
206
  lastStep: string;
207
+ form?: InputForm; // If there is a step that contains a form, this is the form
198
208
  lastModifiedAt: Process['lastModifiedAt'];
199
209
  workflowName: string;
200
210
  isTask: boolean;
@@ -289,6 +299,7 @@ export type GraphqlQueryVariables<Type> = {
289
299
  after?: number;
290
300
  sortBy?: GraphQLSort<Type>;
291
301
  filterBy?: GraphqlFilter<Type>[];
302
+ query?: string;
292
303
  };
293
304
 
294
305
  export type GraphQLPageInfo = {
@@ -316,6 +327,13 @@ export interface SubscriptionDetailResult {
316
327
  export interface ProductDefinitionsResult {
317
328
  products: GraphQlResultPage<ProductDefinition>;
318
329
  }
330
+ export interface StartProcessStep {
331
+ name: Step['name'];
332
+ }
333
+
334
+ export interface ProcessStepsResult {
335
+ workflows: GraphQlSinglePage<{ steps: StartProcessStep[] }>;
336
+ }
319
337
 
320
338
  export interface ProductBlockDefinitionsResult {
321
339
  productBlocks: GraphQlResultPage<ProductBlockDefinition>;
@@ -325,7 +343,7 @@ export interface ResourceTypeDefinitionsResult {
325
343
  resourceTypes: GraphQlResultPage<ResourceTypeDefinition>;
326
344
  }
327
345
 
328
- export interface ProcessesResult {
346
+ export interface ProcessListResult {
329
347
  processes: GraphQlResultPage<Process>;
330
348
  }
331
349
 
@@ -333,6 +351,17 @@ export interface ProcessesDetailResult {
333
351
  processes: GraphQlSinglePage<ProcessDetail>;
334
352
  }
335
353
 
354
+ export type ProcessDetailResultRaw = {
355
+ subscription?: object;
356
+ subscription_id?: string;
357
+ current_state: {
358
+ subscription?: {
359
+ subscription_id?: string;
360
+ } & GenericResponse;
361
+ __old_subscriptions__?: GenericResponse;
362
+ } & GenericResponse;
363
+ } & GenericResponse;
364
+
336
365
  export interface CustomersResult {
337
366
  customers: GraphQlSinglePage<Customer>;
338
367
  }
@@ -364,7 +393,7 @@ export interface CacheOption {
364
393
  }
365
394
 
366
395
  export enum Locale {
367
- enUS = 'en-Us',
396
+ enGB = 'en-GB',
368
397
  nlNL = 'nl-NL',
369
398
  }
370
399
 
@@ -438,6 +467,7 @@ export type SubscriptionDetailProcess = Pick<
438
467
  | 'createdBy'
439
468
  | 'workflowTarget'
440
469
  | 'workflowName'
470
+ | 'isTask'
441
471
  >;
442
472
 
443
473
  export type RelatedSubscription = Pick<
@@ -10,7 +10,7 @@ import {
10
10
  TASK_LIST_TABLE_LOCAL_STORAGE_KEY,
11
11
  } from '../components';
12
12
  import type { StoredTableConfig } from '../components';
13
- import { ProcessListItem } from '../components/WfoProcessesList/WfoProcessList';
13
+ import { ProcessListItem } from '../components/WfoProcessList/WfoProcessList';
14
14
  import { SubscriptionListItem } from '../components/WfoSubscriptionsList';
15
15
  import {
16
16
  ProductBlockDefinition,
@@ -1,33 +0,0 @@
1
- import React, { FC } from 'react';
2
-
3
- import { EuiPanel, EuiSpacer, EuiText } from '@elastic/eui';
4
-
5
- import { EngineStatusValue } from '../../types';
6
- import { WfoEngineStatusButton } from './WfoEngineStatusButton';
7
-
8
- export type WfoModifySettingsProps = {
9
- engineStatus?: EngineStatusValue;
10
- changeEngineStatus: () => void;
11
- };
12
-
13
- export const WfoModifySettings: FC<WfoModifySettingsProps> = ({
14
- engineStatus,
15
- changeEngineStatus,
16
- }) => (
17
- <EuiPanel
18
- hasShadow={false}
19
- color="subdued"
20
- paddingSize="l"
21
- css={{ width: '50%' }}
22
- >
23
- <EuiText size={'s'}>
24
- <h4>Modify the engine settings</h4>
25
- <p>Stop or start workflows through this menu</p>
26
- </EuiText>
27
- <EuiSpacer size="m"></EuiSpacer>
28
- <WfoEngineStatusButton
29
- engineStatus={engineStatus}
30
- changeEngineStatus={changeEngineStatus}
31
- />
32
- </EuiPanel>
33
- );
@@ -1,40 +0,0 @@
1
- import React, { FunctionComponent } from 'react';
2
-
3
- import { EuiHorizontalRule, EuiPageHeader, EuiSpacer } from '@elastic/eui';
4
-
5
- import { useEngineStatusMutation, useEngineStatusQuery } from '../../hooks';
6
- import { WfoFlushSettings } from './WfoFlushSettings';
7
- import { WfoModifySettings } from './WfoModifySettings';
8
- import { WfoStatus } from './WfoStatus';
9
-
10
- export const WfoSettings: FunctionComponent = () => {
11
- const { data: engineStatus } = useEngineStatusQuery();
12
- const { mutate, data: newEngineStatus } = useEngineStatusMutation();
13
-
14
- const isRunning =
15
- newEngineStatus?.global_status === 'RUNNING' ||
16
- engineStatus?.global_status === 'RUNNING';
17
- const currentEngineStatus =
18
- newEngineStatus?.global_status || engineStatus?.global_status;
19
-
20
- const changeEngineStatus = () => {
21
- mutate({ global_lock: isRunning });
22
- };
23
-
24
- return (
25
- <>
26
- <EuiSpacer />
27
-
28
- <EuiPageHeader pageTitle="Settings" />
29
- <EuiHorizontalRule />
30
- <WfoFlushSettings />
31
- <EuiSpacer />
32
- <WfoModifySettings
33
- engineStatus={currentEngineStatus}
34
- changeEngineStatus={changeEngineStatus}
35
- />
36
- <EuiSpacer />
37
- <WfoStatus engineStatus={currentEngineStatus} />
38
- </>
39
- );
40
- };
@@ -1,37 +0,0 @@
1
- import { useContext } from 'react';
2
- import { useMutation, useQueryClient } from 'react-query';
3
-
4
- import { signOut } from 'next-auth/react';
5
-
6
- import { OrchestratorConfigContext } from '../../contexts';
7
- import { useSessionWithToken } from '../useSessionWithToken';
8
-
9
- export const useDeleteProcess = () => {
10
- const { processesEndpoint } = useContext(OrchestratorConfigContext);
11
- const { session } = useSessionWithToken();
12
- const queryClient = useQueryClient();
13
-
14
- const requestHeaders = {
15
- authorization: session ? `Bearer ${session.accessToken}` : '',
16
- };
17
-
18
- const deleteProcess = async (id: string) => {
19
- const response = await fetch(`${processesEndpoint}/${id}`, {
20
- method: 'DELETE',
21
- headers: requestHeaders,
22
- });
23
-
24
- if (response.status < 200 || response.status >= 300) {
25
- console.error(response.status, response.body);
26
- if (response.status === 401 || response.status === 403) {
27
- signOut();
28
- }
29
- }
30
- };
31
-
32
- return useMutation(deleteProcess, {
33
- onSuccess: () => {
34
- queryClient.invalidateQueries('processList');
35
- },
36
- });
37
- };
@@ -1,26 +0,0 @@
1
- import { AbstractIntlMessages } from 'next-intl';
2
-
3
- import { Locale } from '../types';
4
- import enUS from './en-US.json';
5
- import nlNL from './nl-NL.json';
6
-
7
- export type TranslationMessagesMap = Map<Locale, AbstractIntlMessages>;
8
-
9
- const standardMessageMap: TranslationMessagesMap = new Map([
10
- [Locale.enUS, enUS],
11
- [Locale.nlNL, nlNL],
12
- ]);
13
-
14
- export const getTranslationMessages = (
15
- locale: string | undefined,
16
- messages: TranslationMessagesMap = standardMessageMap,
17
- ) => {
18
- switch (locale) {
19
- case Locale.enUS:
20
- return messages.get(Locale.enUS);
21
- case Locale.nlNL:
22
- return messages.get(Locale.nlNL);
23
- default:
24
- return messages.get(Locale.enUS);
25
- }
26
- };
@@ -1,19 +0,0 @@
1
- import { WfoProcessListTabType } from './tabConfig';
2
-
3
- export const getProcessListTabTypeFromString = (
4
- tabId?: string,
5
- ): WfoProcessListTabType | undefined => {
6
- if (!tabId) {
7
- return undefined;
8
- }
9
-
10
- switch (tabId.toUpperCase()) {
11
- case WfoProcessListTabType.ACTIVE.toString():
12
- return WfoProcessListTabType.ACTIVE;
13
- case WfoProcessListTabType.COMPLETED.toString():
14
- return WfoProcessListTabType.COMPLETED;
15
-
16
- default:
17
- return undefined;
18
- }
19
- };