@orchestrator-ui/orchestrator-ui-components 0.4.0 → 0.5.1

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 (64) hide show
  1. package/.turbo/turbo-build.log +5 -5
  2. package/.turbo/turbo-lint.log +1 -1
  3. package/.turbo/turbo-test.log +5 -5
  4. package/CHANGELOG.md +14 -0
  5. package/dist/index.d.ts +213 -56
  6. package/dist/index.js +7335 -1613
  7. package/package.json +8 -9
  8. package/src/components/WfoBadges/WfoEngineStatusBadge/WfoEngineStatusBadge.tsx +8 -5
  9. package/src/components/WfoBadges/WfoEnvironmentBadge/WfoEnvironmentBadge.tsx +2 -1
  10. package/src/components/WfoDateTime/WfoDateTime.tsx +2 -9
  11. package/src/components/WfoErrorBoundary/WfoErrorBoundary.tsx +45 -0
  12. package/src/components/WfoErrorBoundary/index.ts +1 -0
  13. package/src/components/WfoForms/formFields/OrganisationField.tsx +10 -10
  14. package/src/components/WfoProcessList/WfoProcessesList.tsx +30 -35
  15. package/src/components/WfoProcessList/processListObjectMappers.ts +41 -1
  16. package/src/components/WfoSettings/WfoEngineStatusButton.tsx +11 -13
  17. package/src/components/WfoSettings/WfoFlushSettings.tsx +23 -35
  18. package/src/components/WfoSettings/WfoModifySettings.tsx +3 -16
  19. package/src/components/WfoSettings/WfoStatus.tsx +4 -9
  20. package/src/components/WfoSettings/index.ts +4 -1
  21. package/src/components/WfoSubscription/WfoSubscriptionGeneral.tsx +8 -6
  22. package/src/components/WfoSubscriptionsList/WfoSubscriptionsList.tsx +5 -5
  23. package/src/components/WfoTable/WfoBasicTable/WfoBasicTable.tsx +5 -0
  24. package/src/components/WfoToastsList/WfoToastsList.tsx +11 -11
  25. package/src/components/index.ts +1 -0
  26. package/src/contexts/OrchestratorConfigContext.tsx +2 -4
  27. package/src/contexts/index.ts +0 -1
  28. package/src/graphqlQueries/index.ts +1 -1
  29. package/src/graphqlQueries/processListQuery.ts +29 -29
  30. package/src/graphqlQueries/subscriptionsListQuery.ts +4 -1
  31. package/src/hooks/index.ts +1 -2
  32. package/src/hooks/useCheckEngineStatus.ts +10 -9
  33. package/src/hooks/useOrchestratorConfig.ts +1 -16
  34. package/src/hooks/useShowToastMessage.ts +43 -0
  35. package/src/hooks/useStoredTableConfig.ts +5 -4
  36. package/src/index.ts +1 -0
  37. package/src/messages/en-GB.json +4 -1
  38. package/src/messages/nl-NL.json +4 -1
  39. package/src/pages/metadata/WfoProductBlocksPage.tsx +5 -5
  40. package/src/pages/metadata/WfoProductsPage.tsx +5 -5
  41. package/src/pages/metadata/WfoResourceTypesPage.tsx +5 -5
  42. package/src/pages/metadata/WfoWorkflowsPage.tsx +5 -5
  43. package/src/pages/settings/WfoSettingsPage.tsx +14 -23
  44. package/src/pages/startPage/WfoStartPage.tsx +6 -6
  45. package/src/rtk/api.ts +40 -0
  46. package/src/rtk/endpoints/customers.ts +27 -0
  47. package/src/rtk/endpoints/index.ts +3 -0
  48. package/src/rtk/endpoints/processList.ts +89 -0
  49. package/src/rtk/endpoints/settings.ts +72 -0
  50. package/src/rtk/hooks.ts +7 -0
  51. package/src/rtk/index.ts +5 -0
  52. package/src/rtk/slices/index.ts +1 -0
  53. package/src/rtk/slices/orchestratorConfig.ts +16 -0
  54. package/src/rtk/slices/toastMessages.ts +56 -0
  55. package/src/rtk/store.ts +40 -0
  56. package/src/rtk/storeProvider.tsx +26 -0
  57. package/src/types/types.ts +31 -0
  58. package/src/utils/csvDownload.ts +15 -19
  59. package/src/utils/date.ts +8 -0
  60. package/src/components/WfoSettings/WfoSettings.tsx +0 -40
  61. package/src/contexts/ToastContext.tsx +0 -136
  62. package/src/graphqlQueries/customersQuery.ts +0 -20
  63. package/src/hooks/useEngineStatusQuery.ts +0 -64
  64. package/src/hooks/useToastMessage.ts +0 -5
@@ -1,136 +0,0 @@
1
- import React, { createContext, useReducer } from 'react';
2
- import type { ReactElement, ReactNode, Reducer } from 'react';
3
-
4
- import type { Toast } from '@elastic/eui/src/components/toast/global_toast_list';
5
-
6
- export enum ToastTypes {
7
- ERROR = 'ERROR',
8
- SUCCESS = 'SUCCESS',
9
- }
10
-
11
- enum ToastActionTypes {
12
- ADD = 'ADD',
13
- REMOVE = 'REMOVE',
14
- }
15
-
16
- type ToastAddAction = {
17
- type: ToastActionTypes.ADD;
18
- payload: Toast; // From eui
19
- };
20
-
21
- type ToastRemoveAction = {
22
- type: ToastActionTypes.REMOVE;
23
- payload: {
24
- id: string;
25
- };
26
- };
27
-
28
- type ToastsState = {
29
- toasts: Toast[];
30
- };
31
-
32
- export interface ToastContextProps {
33
- addToast: (
34
- type: ToastTypes,
35
- text: ReactElement | string,
36
- title: string,
37
- ) => void;
38
- removeToast: (id: string) => void;
39
- toasts: Toast[];
40
- }
41
-
42
- export const ToastContext = createContext<ToastContextProps>({
43
- addToast: () => {},
44
- removeToast: () => {},
45
- toasts: [],
46
- });
47
-
48
- interface ToastsContextProviderProps {
49
- children: ReactNode;
50
- }
51
-
52
- const toastsReducer = (
53
- state: ToastsState,
54
- action: ToastAddAction | ToastRemoveAction,
55
- ): ToastsState => {
56
- switch (action.type) {
57
- case ToastActionTypes.ADD:
58
- return {
59
- toasts: [...state.toasts, action.payload],
60
- };
61
- case ToastActionTypes.REMOVE:
62
- const toasts = state.toasts.filter(
63
- (toast) => toast.id !== action.payload.id,
64
- );
65
- return {
66
- toasts: [...toasts],
67
- };
68
-
69
- default:
70
- throw new Error('Unhandled notification action type');
71
- }
72
- };
73
-
74
- export const ToastsContextProvider = ({
75
- children,
76
- }: ToastsContextProviderProps) => {
77
- const initialState: ToastsState = {
78
- toasts: [],
79
- };
80
-
81
- const [state, dispatch] = useReducer<
82
- Reducer<ToastsState, ToastAddAction | ToastRemoveAction>
83
- >(toastsReducer, initialState);
84
-
85
- const getTypeProps = (type: ToastTypes): Partial<Toast> => {
86
- switch (type) {
87
- case ToastTypes.ERROR:
88
- return {
89
- color: 'danger',
90
- iconType: 'warning',
91
- };
92
- case ToastTypes.SUCCESS:
93
- return {
94
- color: 'success',
95
- iconType: 'check',
96
- };
97
- }
98
- };
99
-
100
- const addToast = (
101
- type: ToastTypes,
102
- text: ReactElement | string,
103
- title: string,
104
- ) => {
105
- const typeProps = getTypeProps(type);
106
- const id = Math.floor(Math.random() * 10000000).toString();
107
- dispatch({
108
- type: ToastActionTypes.ADD,
109
- payload: {
110
- id,
111
- text,
112
- title,
113
- ...typeProps,
114
- },
115
- });
116
- };
117
-
118
- const removeToast = (id: string) => {
119
- dispatch({
120
- type: ToastActionTypes.REMOVE,
121
- payload: { id },
122
- });
123
- };
124
-
125
- return (
126
- <ToastContext.Provider
127
- value={{
128
- addToast,
129
- removeToast,
130
- toasts: state.toasts,
131
- }}
132
- >
133
- {children}
134
- </ToastContext.Provider>
135
- );
136
- };
@@ -1,20 +0,0 @@
1
- import { parse } from 'graphql';
2
- import { gql } from 'graphql-request';
3
-
4
- import { TypedDocumentNode } from '@graphql-typed-document-node/core';
5
-
6
- import { CustomersResult } from '../types';
7
-
8
- // Avoiding pagination by passing a large number to first. TODO: Fix this better
9
- export const GET_CUSTOMER_GRAPHQL_QUERY: TypedDocumentNode<CustomersResult> =
10
- parse(gql`
11
- query Customers {
12
- customers(first: 1000000, after: 0) {
13
- page {
14
- fullname
15
- customerId
16
- shortcode
17
- }
18
- }
19
- }
20
- `);
@@ -1,64 +0,0 @@
1
- import { useContext } from 'react';
2
- import { useMutation, useQueryClient } from 'react-query';
3
-
4
- import { OrchestratorConfigContext } from '@/contexts';
5
- import { EngineStatus } from '@/types';
6
-
7
- import { useQueryWithFetch } from './useQueryWithFetch';
8
- import { useSessionWithToken } from './useSessionWithToken';
9
-
10
- export interface EngineStatusReturnValue {
11
- global_lock: boolean;
12
- running_processes: number;
13
- global_status: EngineStatus;
14
- }
15
-
16
- interface EngineStatusPayload {
17
- global_lock: boolean;
18
- }
19
-
20
- export const useEngineStatusQuery = () => {
21
- const { engineStatusEndpoint } = useContext(OrchestratorConfigContext);
22
-
23
- return useQueryWithFetch<EngineStatusReturnValue, Record<string, never>>(
24
- engineStatusEndpoint,
25
- {},
26
- 'engineStatus',
27
- );
28
- };
29
-
30
- export const useEngineStatusMutation = () => {
31
- const { engineStatusEndpoint } = useContext(OrchestratorConfigContext);
32
- const queryClient = useQueryClient();
33
- const { session } = useSessionWithToken();
34
- let requestHeaders = {};
35
-
36
- if (session) {
37
- const { accessToken } = session;
38
-
39
- requestHeaders = {
40
- Authorization: `Bearer ${accessToken}`,
41
- };
42
- }
43
-
44
- const setEngineStatus = async (data: EngineStatusPayload) => {
45
- const response = await fetch(engineStatusEndpoint, {
46
- method: 'PUT',
47
- body: JSON.stringify(data),
48
- headers: {
49
- 'Content-Type': 'application/json',
50
- ...requestHeaders,
51
- },
52
- });
53
- return (await response.json()) as EngineStatusReturnValue;
54
- };
55
-
56
- return useMutation('engineStatus', setEngineStatus, {
57
- onMutate: () => {
58
- queryClient.setQueryData(['engineStatus'], null); // Set loading state of the button
59
- },
60
- onSuccess: (data: EngineStatusReturnValue) => {
61
- queryClient.setQueryData(['engineStatus'], data); // Set global status
62
- },
63
- });
64
- };
@@ -1,5 +0,0 @@
1
- import { useContext } from 'react';
2
-
3
- import { ToastContext } from '../contexts/ToastContext';
4
-
5
- export const useToastMessage = () => useContext(ToastContext);