@orchestrator-ui/orchestrator-ui-components 1.26.0 → 1.27.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 (40) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/.turbo/turbo-lint.log +1 -1
  3. package/.turbo/turbo-test.log +34 -33
  4. package/CHANGELOG.md +9 -0
  5. package/dist/index.d.ts +75 -66
  6. package/dist/index.js +596 -536
  7. package/jest.config.cjs +13 -2
  8. package/package.json +1 -1
  9. package/src/components/WfoForms/UserInputForm.tsx +18 -13
  10. package/src/components/WfoForms/UserInputFormWizard.tsx +3 -3
  11. package/src/components/WfoPageTemplate/WfoBreadcrumbs/WfoBreadcrumbs.tsx +52 -10
  12. package/src/components/WfoPageTemplate/WfoPageHeader/WfoPageHeader.tsx +1 -11
  13. package/src/components/WfoPageTemplate/WfoPageTemplate/WfoPageTemplate.tsx +5 -4
  14. package/src/components/WfoSubscription/WfoInSyncField.tsx +1 -1
  15. package/src/components/WfoSubscription/WfoSubscriptionDetailTree.tsx +4 -1
  16. package/src/components/WfoTree/WfoTree.tsx +4 -3
  17. package/src/components/WfoTree/WfoTreeBranch.tsx +10 -3
  18. package/src/components/WfoTree/treeUtils.ts +13 -0
  19. package/src/components/confirmationDialog/WfoConfirmationDialog.tsx +61 -68
  20. package/src/contexts/ConfirmationDialogProvider.tsx +57 -60
  21. package/src/messages/en-GB.json +3 -1
  22. package/src/messages/nl-NL.json +3 -1
  23. package/src/pages/processes/WfoProcessDetail.tsx +3 -3
  24. package/src/pages/tasks/WfoTasksListPage.tsx +1 -1
  25. package/src/rtk/api.ts +5 -21
  26. package/src/rtk/endpoints/processDetail.ts +11 -11
  27. package/src/rtk/endpoints/processList.ts +8 -2
  28. package/src/rtk/endpoints/processListSummary.ts +7 -3
  29. package/src/rtk/endpoints/processStatusCounts.ts +4 -3
  30. package/src/rtk/endpoints/settings.ts +5 -5
  31. package/src/rtk/endpoints/streamMessages.ts +13 -45
  32. package/src/rtk/endpoints/subscriptionActions.ts +1 -2
  33. package/src/rtk/endpoints/subscriptionDetail.ts +12 -7
  34. package/src/rtk/endpoints/subscriptionInUseByRelationsList.ts +4 -2
  35. package/src/rtk/endpoints/subscriptionList.ts +4 -2
  36. package/src/rtk/endpoints/subscriptionListSummary.ts +4 -2
  37. package/src/rtk/endpoints/translations.ts +1 -2
  38. package/src/types/types.ts +11 -0
  39. package/src/utils/cacheTag.spec.ts +14 -0
  40. package/src/utils/cacheTag.ts +11 -0
@@ -1,83 +1,75 @@
1
- import React from 'react';
1
+ import React, { ReactNode } from 'react';
2
2
  import { createContext, useState } from 'react';
3
3
 
4
4
  import WfoConfirmationDialog from '../components/confirmationDialog/WfoConfirmationDialog';
5
5
 
6
- export interface ConfirmDialogActions {
7
- showConfirmDialog: ShowConfirmDialogType;
8
- closeConfirmDialog: (
9
- e:
10
- | React.KeyboardEvent<HTMLDivElement>
11
- | React.MouseEvent<HTMLButtonElement, MouseEvent>
12
- | React.MouseEvent<HTMLDivElement, MouseEvent>
13
- | undefined,
14
- confirm?: boolean,
15
- ) => void;
16
- }
6
+ export type ConfirmDialogHandler = (
7
+ e:
8
+ | React.KeyboardEvent<HTMLDivElement>
9
+ | React.MouseEvent<HTMLButtonElement, MouseEvent>
10
+ | undefined,
11
+ ) => void;
17
12
 
18
- export interface ShowConfirmDialog {
13
+ interface ConfirmDialogState {
14
+ onConfirm: ConfirmDialogHandler;
19
15
  question: string;
20
- confirmAction: ConfirmDialogActions['closeConfirmDialog'];
21
- cancelAction?: ConfirmDialogActions['closeConfirmDialog'];
22
- leavePage?: boolean;
23
16
  isError?: boolean;
17
+ subQuestion?: string;
18
+ cancelButtonText?: string;
19
+ confirmButtonText?: string;
24
20
  }
25
21
 
26
- export type ShowConfirmDialogType = ({
27
- question,
28
- confirmAction,
29
- cancelAction,
30
- leavePage,
31
- isError,
32
- }: ShowConfirmDialog) => void;
22
+ interface ConfirmDialogContext {
23
+ showConfirmDialog: (props: ConfirmDialogState) => void;
24
+ closeConfirmDialog: () => void;
25
+ }
33
26
 
34
- export const ConfirmationDialogContext = createContext<ConfirmDialogActions>({
27
+ export const ConfirmationDialogContext = createContext<ConfirmDialogContext>({
35
28
  showConfirmDialog: () => {},
36
29
  closeConfirmDialog: () => {},
37
30
  });
38
31
 
39
32
  export const ConfirmationDialogProvider = ConfirmationDialogContext.Provider;
40
33
 
41
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
42
- export function ConfirmationDialogContextWrapper({ children }: any) {
34
+ export function ConfirmationDialogContextWrapper({
35
+ children,
36
+ }: {
37
+ children: ReactNode;
38
+ }) {
43
39
  const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false);
44
- const [state, setState] = useState<{
45
- confirmationDialogQuestion: string;
46
- confirmDialogAction: ConfirmDialogActions['closeConfirmDialog'];
47
- leavePage: boolean;
48
- isError: boolean;
49
- }>({
50
- confirmationDialogQuestion: '',
51
- confirmDialogAction: () => {},
52
- leavePage: false,
53
- isError: false,
40
+ const [
41
+ {
42
+ onConfirm,
43
+ question,
44
+ isError,
45
+ subQuestion,
46
+ cancelButtonText,
47
+ confirmButtonText,
48
+ },
49
+ setState,
50
+ ] = useState<ConfirmDialogState>({
51
+ onConfirm: () => {},
52
+ question: '',
54
53
  });
55
54
 
56
55
  const closeConfirmDialog = () => setConfirmationDialogOpen(false);
57
56
 
58
57
  const showConfirmDialog = ({
58
+ onConfirm,
59
59
  question,
60
- confirmAction,
61
- cancelAction,
62
- leavePage,
63
- isError,
64
- }: ShowConfirmDialog) => {
60
+ isError = false,
61
+ subQuestion = '',
62
+ cancelButtonText = '',
63
+ confirmButtonText = '',
64
+ }: ConfirmDialogState) => {
65
65
  setConfirmationDialogOpen(true);
66
66
  setState({
67
- confirmationDialogQuestion: question,
68
- leavePage: !!leavePage,
69
- isError: !!isError,
70
- confirmDialogAction: (e, cancelConfirm = false) => {
71
- closeConfirmDialog();
72
-
73
- if (!cancelConfirm) {
74
- return confirmAction(e);
75
- }
76
-
77
- if (cancelAction) {
78
- return cancelAction(e);
79
- }
80
- },
67
+ onConfirm,
68
+ question,
69
+ isError,
70
+ subQuestion,
71
+ cancelButtonText,
72
+ confirmButtonText,
81
73
  });
82
74
  };
83
75
 
@@ -87,11 +79,16 @@ export function ConfirmationDialogContextWrapper({ children }: any) {
87
79
  >
88
80
  <WfoConfirmationDialog
89
81
  isOpen={confirmationDialogOpen}
90
- cancel={(e) => state.confirmDialogAction(e, true)}
91
- confirm={state.confirmDialogAction}
92
- question={state.confirmationDialogQuestion}
93
- leavePage={state.leavePage}
94
- isError={state.isError}
82
+ onCancel={() => setConfirmationDialogOpen(false)}
83
+ onConfirm={(e) => {
84
+ onConfirm(e);
85
+ setConfirmationDialogOpen(false);
86
+ }}
87
+ question={question}
88
+ isError={isError}
89
+ subQuestion={subQuestion}
90
+ cancelButtonText={cancelButtonText}
91
+ confirmButtonText={confirmButtonText}
95
92
  />
96
93
  {children}
97
94
  </ConfirmationDialogProvider>
@@ -1,5 +1,8 @@
1
1
  {
2
2
  "main": {
3
+ "start": "Start",
4
+ "ariaLabelToggleSideMenu": "Show/Hide side menu",
5
+ "ariaLabelCurrentPage": "Current page",
3
6
  "metadata": "Metadata",
4
7
  "metadataProducts": "Products",
5
8
  "metadataProductblocks": "Product blocks",
@@ -8,7 +11,6 @@
8
11
  "metadataTasks": "Tasks",
9
12
  "mobileTitle": "Main menu",
10
13
  "settings": "Settings",
11
- "start": "Start",
12
14
  "subscriptions": "Subscriptions",
13
15
  "tasks": "Tasks",
14
16
  "title": "Workflow Orchestrator",
@@ -1,5 +1,8 @@
1
1
  {
2
2
  "main": {
3
+ "start": "Start",
4
+ "ariaLabelToggleSideMenu": "Toon/Verberg menu",
5
+ "ariaLabelCurrentPage": "Huidige pagina",
3
6
  "metadata": "Metadata",
4
7
  "metadataProducts": "Products",
5
8
  "metadataProductblocks": "Product blocks",
@@ -8,7 +11,6 @@
8
11
  "metadataTasks": "Taken",
9
12
  "mobileTitle": "Hoofdmenu",
10
13
  "settings": "Settings",
11
- "start": "Start",
12
14
  "subscriptions": "Subscriptions",
13
15
  "tasks": "Taken",
14
16
  "title": "Workflow Orchestrator",
@@ -157,7 +157,7 @@ export const WfoProcessDetail = ({
157
157
  workflowName: processDetail?.workflowName,
158
158
  },
159
159
  ),
160
- confirmAction: () => {
160
+ onConfirm: () => {
161
161
  processDetail?.processId &&
162
162
  retryProcess({ processId: processDetail.processId });
163
163
  },
@@ -171,7 +171,7 @@ export const WfoProcessDetail = ({
171
171
  workflowName: processDetail?.workflowName,
172
172
  },
173
173
  ),
174
- confirmAction: () => {
174
+ onConfirm: () => {
175
175
  processDetail?.processId &&
176
176
  abortProcess({ processId: processDetail.processId });
177
177
  router.push(processIsTask ? PATH_TASKS : PATH_WORKFLOWS);
@@ -183,7 +183,7 @@ export const WfoProcessDetail = ({
183
183
  question: t('deleteQuestion', {
184
184
  workflowName: processDetail?.workflowName,
185
185
  }),
186
- confirmAction: () => {
186
+ onConfirm: () => {
187
187
  processDetail?.processId &&
188
188
  deleteProcess({ processId: processDetail.processId });
189
189
  router.push(PATH_TASKS);
@@ -107,7 +107,7 @@ export const WfoTasksListPage = () => {
107
107
  if (await isEngineRunningNow()) {
108
108
  showConfirmDialog({
109
109
  question: t('rerunAllQuestion'),
110
- confirmAction: () => {
110
+ onConfirm: () => {
111
111
  retryAllProcesses(null);
112
112
  },
113
113
  });
package/src/rtk/api.ts CHANGED
@@ -4,6 +4,7 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
4
4
  import { graphqlRequestBaseQuery } from '@rtk-query/graphql-request-base-query';
5
5
 
6
6
  import type { WfoSession } from '@/hooks';
7
+ import { CacheTagType } from '@/types';
7
8
 
8
9
  import type { RootState } from './store';
9
10
 
@@ -13,18 +14,6 @@ export enum BaseQueryTypes {
13
14
  custom = 'custom',
14
15
  }
15
16
 
16
- export enum CacheTags {
17
- engineStatus = 'engineStatus',
18
- cacheNames = 'cacheNames',
19
- processes = 'processes',
20
- processListSummary = 'processListSummary',
21
- subscription = 'subscription',
22
- subscriptionList = 'subscriptionList',
23
- backendTranslations = 'backendTranslations',
24
- processStatusCounts = 'processStatusCounts',
25
- subscriptionActions = 'subscriptionActions',
26
- }
27
-
28
17
  export enum HttpStatus {
29
18
  FormNotComplete = 510,
30
19
  BadGateway = 502,
@@ -106,14 +95,9 @@ export const orchestratorApi = createApi({
106
95
  },
107
96
  endpoints: () => ({}),
108
97
  tagTypes: [
109
- CacheTags.engineStatus,
110
- CacheTags.cacheNames,
111
- CacheTags.processes,
112
- CacheTags.processListSummary,
113
- CacheTags.subscriptionList,
114
- CacheTags.subscription,
115
- CacheTags.backendTranslations,
116
- CacheTags.processStatusCounts,
117
- CacheTags.subscriptionActions,
98
+ CacheTagType.engineStatus,
99
+ CacheTagType.processes,
100
+ CacheTagType.processStatusCounts,
101
+ CacheTagType.subscriptions,
118
102
  ],
119
103
  });
@@ -8,12 +8,14 @@ import {
8
8
  PROCESS_ABORT_ENDPOINT,
9
9
  PROCESS_RESUME_ENDPOINT,
10
10
  } from '@/configuration';
11
- import { BaseQueryTypes, CacheTags, orchestratorApi } from '@/rtk';
11
+ import { BaseQueryTypes, orchestratorApi } from '@/rtk';
12
12
  import {
13
+ CacheTagType,
13
14
  ProcessDetail,
14
15
  ProcessDetailResultRaw,
15
16
  ProcessesDetailResult,
16
17
  } from '@/types';
18
+ import { getCacheTag } from '@/utils/cacheTag';
17
19
 
18
20
  export const processDetailQuery = `query ProcessDetail($processId: String!) {
19
21
  processes(filterBy: { value: $processId, field: "processId" }) {
@@ -88,12 +90,10 @@ const processDetailApi = orchestratorApi.injectEndpoints({
88
90
  },
89
91
  providesTags: (result, error, queryArguments) => {
90
92
  if (!error && result) {
91
- return [
92
- {
93
- type: CacheTags.processes,
94
- id: queryArguments.processId,
95
- },
96
- ];
93
+ return getCacheTag(
94
+ CacheTagType.processes,
95
+ queryArguments.processId,
96
+ );
97
97
  }
98
98
  return [];
99
99
  },
@@ -122,7 +122,7 @@ const processDetailApi = orchestratorApi.injectEndpoints({
122
122
  extraOptions: {
123
123
  baseQueryType: BaseQueryTypes.fetch,
124
124
  },
125
- invalidatesTags: [CacheTags.processes],
125
+ invalidatesTags: getCacheTag(CacheTagType.processes),
126
126
  }),
127
127
  retryProcess: builder.mutation<void, { processId: string }>({
128
128
  query: ({ processId }) => ({
@@ -137,7 +137,7 @@ const processDetailApi = orchestratorApi.injectEndpoints({
137
137
  extraOptions: {
138
138
  baseQueryType: BaseQueryTypes.fetch,
139
139
  },
140
- invalidatesTags: [CacheTags.processes],
140
+ invalidatesTags: getCacheTag(CacheTagType.processes),
141
141
  }),
142
142
  deleteProcess: builder.mutation<void, { processId: string }>({
143
143
  query: ({ processId }) => ({
@@ -148,7 +148,7 @@ const processDetailApi = orchestratorApi.injectEndpoints({
148
148
  extraOptions: {
149
149
  baseQueryType: BaseQueryTypes.fetch,
150
150
  },
151
- invalidatesTags: [CacheTags.processes],
151
+ invalidatesTags: getCacheTag(CacheTagType.processes),
152
152
  }),
153
153
  abortProcess: builder.mutation<void, { processId: string }>({
154
154
  query: ({ processId }) => ({
@@ -159,7 +159,7 @@ const processDetailApi = orchestratorApi.injectEndpoints({
159
159
  extraOptions: {
160
160
  baseQueryType: BaseQueryTypes.fetch,
161
161
  },
162
- invalidatesTags: [CacheTags.processes],
162
+ invalidatesTags: getCacheTag(CacheTagType.processes),
163
163
  }),
164
164
  }),
165
165
  });
@@ -1,11 +1,14 @@
1
1
  import {
2
2
  BaseGraphQlResult,
3
+ CACHETAG_TYPE_LIST,
4
+ CacheTagType,
3
5
  GraphqlQueryVariables,
4
6
  Process,
5
7
  ProcessListResult,
6
8
  } from '@/types';
9
+ import { getCacheTag } from '@/utils/cacheTag';
7
10
 
8
- import { CacheTags, orchestratorApi } from '../api';
11
+ import { orchestratorApi } from '../api';
9
12
 
10
13
  export const processListQuery = `
11
14
  query ProcessList(
@@ -82,7 +85,10 @@ const processApi = orchestratorApi.injectEndpoints({
82
85
  pageInfo: response.processes?.pageInfo || {},
83
86
  };
84
87
  },
85
- providesTags: [CacheTags.processes],
88
+ providesTags: getCacheTag(
89
+ CacheTagType.processes,
90
+ CACHETAG_TYPE_LIST,
91
+ ),
86
92
  }),
87
93
  }),
88
94
  });
@@ -1,11 +1,12 @@
1
+ import { orchestratorApi } from '@/rtk';
1
2
  import {
2
3
  BaseGraphQlResult,
3
4
  GraphqlQueryVariables,
4
5
  Process,
5
6
  ProcessListResult,
6
7
  } from '@/types';
7
-
8
- import { CacheTags, orchestratorApi } from '../api';
8
+ import { CACHETAG_TYPE_LIST, CacheTagType } from '@/types';
9
+ import { getCacheTag } from '@/utils/cacheTag';
9
10
 
10
11
  export const processListSummaryQuery = `
11
12
  query ProcessListSummary(
@@ -65,7 +66,10 @@ const processApi = orchestratorApi.injectEndpoints({
65
66
  pageInfo: response.processes?.pageInfo || {},
66
67
  };
67
68
  },
68
- providesTags: [CacheTags.processListSummary],
69
+ providesTags: getCacheTag(
70
+ CacheTagType.processes,
71
+ CACHETAG_TYPE_LIST,
72
+ ),
69
73
  }),
70
74
  }),
71
75
  });
@@ -1,6 +1,7 @@
1
1
  import { PROCESS_STATUS_COUNTS_ENDPOINT } from '@/configuration';
2
- import { BaseQueryTypes, CacheTags, orchestratorApi } from '@/rtk';
3
- import { ProcessStatus } from '@/types';
2
+ import { BaseQueryTypes, orchestratorApi } from '@/rtk';
3
+ import { CacheTagType, ProcessStatus } from '@/types';
4
+ import { getCacheTag } from '@/utils/cacheTag';
4
5
 
5
6
  export type ProcessStatusCounts = {
6
7
  process_counts: Record<ProcessStatus, number>;
@@ -20,7 +21,7 @@ const processStatusApi = orchestratorApi.injectEndpoints({
20
21
  extraOptions: {
21
22
  baseQueryType: BaseQueryTypes.fetch,
22
23
  },
23
- providesTags: [CacheTags.processStatusCounts],
24
+ providesTags: getCacheTag(CacheTagType.processStatusCounts),
24
25
  }),
25
26
  }),
26
27
  });
@@ -4,8 +4,9 @@ import {
4
4
  SETTINGS_SEARCH_INDEX_RESET_ENDPOINT,
5
5
  SETTINGS_STATUS_ENDPOINT,
6
6
  } from '@/configuration';
7
- import { BaseQueryTypes, CacheTags, orchestratorApi } from '@/rtk';
8
- import { CacheNames, EngineStatus } from '@/types';
7
+ import { BaseQueryTypes, orchestratorApi } from '@/rtk';
8
+ import { CacheNames, CacheTagType, EngineStatus } from '@/types';
9
+ import { getCacheTag } from '@/utils/cacheTag';
9
10
 
10
11
  interface EngineStatusReturnValue {
11
12
  engineStatus: EngineStatus;
@@ -40,14 +41,13 @@ const statusApi = orchestratorApi.injectEndpoints({
40
41
  runningProcesses: data?.running_processes || 0,
41
42
  };
42
43
  },
43
- providesTags: [CacheTags.engineStatus],
44
+ providesTags: getCacheTag(CacheTagType.engineStatus),
44
45
  }),
45
46
  getCacheNames: build.query<CacheNames, void>({
46
47
  query: () => SETTINGS_CACHE_NAMES_ENDPOINT,
47
48
  extraOptions: {
48
49
  baseQueryType: BaseQueryTypes.fetch,
49
50
  },
50
- providesTags: [CacheTags.cacheNames],
51
51
  }),
52
52
  clearCache: build.mutation<void, string>({
53
53
  query: (settingName) => ({
@@ -81,7 +81,7 @@ const statusApi = orchestratorApi.injectEndpoints({
81
81
  extraOptions: {
82
82
  baseQueryType: BaseQueryTypes.fetch,
83
83
  },
84
- invalidatesTags: [CacheTags.engineStatus],
84
+ invalidatesTags: getCacheTag(CacheTagType.engineStatus),
85
85
  }),
86
86
  }),
87
87
  });
@@ -5,9 +5,10 @@ import type { WfoSession } from '@/hooks';
5
5
  import { addToastMessage } from '@/rtk/slices/toastMessages';
6
6
  import type { RootState } from '@/rtk/store';
7
7
  import { ToastTypes } from '@/types';
8
+ import { CacheTag, CacheTagType } from '@/types';
8
9
  import { getToastMessage } from '@/utils/getToastMessage';
9
10
 
10
- import { CacheTags, orchestratorApi } from '../api';
11
+ import { orchestratorApi } from '../api';
11
12
 
12
13
  const getWebSocket = async (url: string) => {
13
14
  const session = (await getSession()) as WfoSession;
@@ -24,11 +25,9 @@ const DEBOUNCE_CLOSE_INTERVAL_MS = 60000;
24
25
 
25
26
  type WebSocketMessage = {
26
27
  name: MessageTypes;
27
- value: string[] | string;
28
+ value: CacheTag;
28
29
  };
29
30
 
30
- type CacheInvalidationTag = CacheTags | { type: CacheTags; id: string };
31
-
32
31
  enum MessageTypes {
33
32
  invalidateCache = 'invalidateCache',
34
33
  }
@@ -68,53 +67,18 @@ const streamMessagesApi = orchestratorApi.injectEndpoints({
68
67
  updateCachedData(() => false);
69
68
  };
70
69
 
71
- const invalidateTag = (cacheTag: CacheTags, id?: string) => {
72
- if (validCacheTags.includes(cacheTag)) {
73
- // If we receive an object with cacheTag and id we both invalidate the cache key and the cache key with the id
74
- // invalidating both the general and specific caches
75
- const cacheTags: CacheInvalidationTag[] = [cacheTag];
76
-
77
- if (id) {
78
- cacheTags.push({
79
- type: cacheTag,
80
- id,
81
- });
82
- }
83
-
70
+ const invalidateTag = (cacheTag: CacheTag) => {
71
+ if (validCacheTags.includes(cacheTag.type)) {
84
72
  const cacheInvalidationAction =
85
- orchestratorApi.util.invalidateTags(cacheTags);
73
+ orchestratorApi.util.invalidateTags([cacheTag]);
86
74
  dispatch(cacheInvalidationAction);
87
75
  } else {
88
76
  console.error(
89
- `Trying to invalidate a cache entry with an unknown tag: ${cacheTag}`,
77
+ `Trying to invalidate a cache entry with an unknown tag: ${cacheTag.type}`,
90
78
  );
91
79
  }
92
80
  };
93
81
 
94
- const handleInvalidateCacheMessage = (
95
- message: WebSocketMessage,
96
- ) => {
97
- if (message.name === MessageTypes.invalidateCache) {
98
- const messageValue = message.value;
99
-
100
- if (typeof messageValue === 'string') {
101
- invalidateTag(messageValue as CacheTags);
102
- } else if (
103
- Array.isArray(messageValue) &&
104
- messageValue.length === 2
105
- ) {
106
- const [tag, id] = messageValue;
107
- const cacheTag = tag as CacheTags;
108
- invalidateTag(cacheTag, id);
109
- } else {
110
- console.error(
111
- 'invalid message value type',
112
- messageValue,
113
- );
114
- }
115
- }
116
- };
117
-
118
82
  // Send a ping message every to the websocket server to keep the connection alive
119
83
  const pingInterval = setInterval(() => {
120
84
  webSocket.send('__ping__');
@@ -130,7 +94,7 @@ const streamMessagesApi = orchestratorApi.injectEndpoints({
130
94
 
131
95
  const state = getState() as RootState;
132
96
  const { orchestratorWebsocketUrl } = state.orchestratorConfig;
133
- const validCacheTags = Object.values(CacheTags);
97
+ const validCacheTags = Object.values(CacheTagType);
134
98
 
135
99
  // Starts the websocket
136
100
  const webSocket = await getWebSocket(orchestratorWebsocketUrl);
@@ -151,7 +115,11 @@ const streamMessagesApi = orchestratorApi.injectEndpoints({
151
115
  return;
152
116
  }
153
117
  const message = JSON.parse(data) as WebSocketMessage;
154
- handleInvalidateCacheMessage(message);
118
+ if (message.name === MessageTypes.invalidateCache) {
119
+ invalidateTag(message.value);
120
+ } else {
121
+ console.error('Unknown message type', message);
122
+ }
155
123
  },
156
124
  );
157
125
 
@@ -1,5 +1,5 @@
1
1
  import { SUBSCRIPTION_ACTIONS_ENDPOINT } from '@/configuration';
2
- import { BaseQueryTypes, CacheTags, orchestratorApi } from '@/rtk';
2
+ import { BaseQueryTypes, orchestratorApi } from '@/rtk';
3
3
  import { SubscriptionActions } from '@/types';
4
4
 
5
5
  const subscriptionActionsApi = orchestratorApi.injectEndpoints({
@@ -13,7 +13,6 @@ const subscriptionActionsApi = orchestratorApi.injectEndpoints({
13
13
  extraOptions: {
14
14
  baseQueryType: BaseQueryTypes.fetch,
15
15
  },
16
- providesTags: [CacheTags.subscriptionActions],
17
16
  }),
18
17
  }),
19
18
  });
@@ -1,9 +1,11 @@
1
- import { CacheTags, orchestratorApi } from '@/rtk';
1
+ import { orchestratorApi } from '@/rtk';
2
+ import { CacheTagType } from '@/types';
2
3
  import {
3
4
  BaseGraphQlResult,
4
5
  SubscriptionDetail,
5
6
  SubscriptionDetailResult,
6
7
  } from '@/types';
8
+ import { getCacheTag } from '@/utils/cacheTag';
7
9
 
8
10
  export const subscriptionDetailQuery = `
9
11
  query SubscriptionDetail($subscriptionId: String!) {
@@ -93,12 +95,15 @@ const subscriptionDetailApi = orchestratorApi.injectEndpoints({
93
95
  pageInfo,
94
96
  };
95
97
  },
96
- providesTags: (result, error, arg) => [
97
- {
98
- type: CacheTags.subscription,
99
- id: arg.subscriptionId,
100
- },
101
- ],
98
+ providesTags: (result, error, queryArguments) => {
99
+ if (!error && result) {
100
+ return getCacheTag(
101
+ CacheTagType.subscriptions,
102
+ queryArguments.subscriptionId,
103
+ );
104
+ }
105
+ return [];
106
+ },
102
107
  }),
103
108
  }),
104
109
  });
@@ -1,10 +1,12 @@
1
1
  import { NUMBER_OF_ITEMS_REPRESENTING_ALL_ITEMS } from '@/configuration';
2
- import { CacheTags, orchestratorApi } from '@/rtk';
2
+ import { orchestratorApi } from '@/rtk';
3
+ import { CacheTagType } from '@/types';
3
4
  import {
4
5
  InUseByRelationDetail,
5
6
  InUseByRelationsDetailResult,
6
7
  SubscriptionStatus,
7
8
  } from '@/types';
9
+ import { getCacheTag } from '@/utils/cacheTag';
8
10
 
9
11
  const nonTerminalSubscriptionStatuses = [
10
12
  SubscriptionStatus.INITIAL,
@@ -58,7 +60,7 @@ const subscriptionInUseByRelationsListApi = orchestratorApi.injectEndpoints({
58
60
  inUseByRelationDetails: subscriptions,
59
61
  };
60
62
  },
61
- providesTags: [CacheTags.subscriptionList],
63
+ providesTags: getCacheTag(CacheTagType.subscriptions),
62
64
  }),
63
65
  }),
64
66
  });
@@ -1,11 +1,13 @@
1
1
  import { SubscriptionListItem } from '@/components/WfoSubscriptionsList';
2
- import { CacheTags, orchestratorApi } from '@/rtk';
2
+ import { orchestratorApi } from '@/rtk';
3
3
  import {
4
4
  BaseGraphQlResult,
5
+ CacheTagType,
5
6
  GraphqlQueryVariables,
6
7
  Subscription,
7
8
  SubscriptionsResult,
8
9
  } from '@/types';
10
+ import { getCacheTag } from '@/utils/cacheTag';
9
11
 
10
12
  export const subscriptionListQuery = `query SubscriptionsList(
11
13
  $first: Int!
@@ -78,7 +80,7 @@ const subscriptionListApi = orchestratorApi.injectEndpoints({
78
80
  pageInfo,
79
81
  };
80
82
  },
81
- providesTags: [CacheTags.subscriptionList],
83
+ providesTags: getCacheTag(CacheTagType.subscriptions),
82
84
  }),
83
85
  }),
84
86
  });