@orchestrator-ui/orchestrator-ui-components 1.22.0 → 1.24.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 (34) hide show
  1. package/.turbo/turbo-build.log +5 -5
  2. package/.turbo/turbo-lint.log +7 -1
  3. package/.turbo/turbo-test.log +14 -13
  4. package/CHANGELOG.md +24 -0
  5. package/dist/index.d.ts +47 -6
  6. package/dist/index.js +790 -700
  7. package/package.json +1 -1
  8. package/src/components/WfoBadges/WfoWebsocketStatusBadge/WfoWebsocketStatusBadge.tsx +24 -5
  9. package/src/components/WfoBadges/WfoWebsocketStatusBadge/styles.ts +22 -0
  10. package/src/components/WfoForms/CreateForm.tsx +1 -1
  11. package/src/components/WfoForms/UserInputForm.tsx +2 -2
  12. package/src/components/WfoForms/UserInputFormWizard.tsx +4 -1
  13. package/src/components/WfoForms/formFields/deprecated/ImsPortIdField.tsx +55 -49
  14. package/src/components/WfoForms/formFields/deprecated/VlanField.tsx +3 -2
  15. package/src/components/WfoSubscription/WfoSubscription.tsx +2 -2
  16. package/src/components/WfoSubscription/WfoSubscriptionProductBlock/WfoSubscriptionProductBlock.tsx +52 -38
  17. package/src/components/WfoSubscription/WfoSubscriptionProductBlock/styles.ts +1 -2
  18. package/src/components/index.ts +0 -1
  19. package/src/contexts/OrchestratorConfigContext.tsx +8 -4
  20. package/src/icons/WfoBoltFill.tsx +2 -2
  21. package/src/icons/WfoBoltSlashFill.tsx +2 -2
  22. package/src/messages/en-GB.json +2 -1
  23. package/src/messages/nl-NL.json +2 -1
  24. package/src/pages/processes/WfoStartProcessPage.tsx +4 -2
  25. package/src/rtk/endpoints/customers.ts +41 -2
  26. package/src/rtk/endpoints/streamMessages.ts +5 -3
  27. package/src/rtk/storeProvider.tsx +4 -2
  28. package/src/types/forms.ts +1 -1
  29. package/src/types/types.ts +12 -0
  30. package/src/utils/getEnvironmentVariables.spec.ts +51 -0
  31. package/src/utils/getEnvironmentVariables.ts +33 -0
  32. package/src/utils/index.ts +1 -0
  33. package/src/components/WfoRouteChangeListener/WfoRouteChangeListener.tsx +0 -22
  34. package/src/components/WfoRouteChangeListener/index.tsx +0 -1
@@ -11,7 +11,10 @@ import { CacheTags, orchestratorApi } from '../api';
11
11
 
12
12
  const getWebSocket = async (url: string) => {
13
13
  const session = (await getSession()) as WfoSession;
14
- const token = session?.accessToken ? [session?.accessToken] : [];
14
+
15
+ const token = session?.accessToken
16
+ ? ['base64.bearer.token', session?.accessToken]
17
+ : '';
15
18
  // Implemented authentication taking this into account: https://stackoverflow.com/questions/4361173/http-headers-in-websockets-client-api/77060459#77060459
16
19
  return new WebSocket(url, token);
17
20
  };
@@ -55,7 +58,7 @@ const streamMessagesApi = orchestratorApi.injectEndpoints({
55
58
  const cleanUp = () => {
56
59
  const message = getToastMessage(
57
60
  ToastTypes.ERROR,
58
- 'Connection to the server was lost. Please refresh the page to reconnect.',
61
+ 'Connection to the server was lost. Please click the websocket icon or refresh the page to reconnect.',
59
62
  'WebSocket closed',
60
63
  );
61
64
  dispatch(addToastMessage(message));
@@ -139,7 +142,6 @@ const streamMessagesApi = orchestratorApi.injectEndpoints({
139
142
 
140
143
  webSocket.onerror = (event) => {
141
144
  console.error('WebSocket error', event);
142
- cleanUp();
143
145
  };
144
146
 
145
147
  webSocket.onclose = () => {
@@ -2,6 +2,7 @@ import React, { useState } from 'react';
2
2
  import type { ReactNode } from 'react';
3
3
  import { Provider } from 'react-redux';
4
4
 
5
+ import { emptyOrchestratorConfig } from '@/contexts';
5
6
  import { CustomApiConfig } from '@/rtk/slices/customApis';
6
7
  import { OrchestratorComponentOverride } from '@/rtk/slices/orchestratorComponentOverride';
7
8
  import type { OrchestratorConfig } from '@/types';
@@ -9,7 +10,7 @@ import type { OrchestratorConfig } from '@/types';
9
10
  import { getOrchestratorStore } from './store';
10
11
 
11
12
  export type StoreProviderProps = {
12
- initialOrchestratorConfig: OrchestratorConfig;
13
+ initialOrchestratorConfig: OrchestratorConfig | null;
13
14
  orchestratorComponentOverride?: OrchestratorComponentOverride;
14
15
  customApis?: CustomApiConfig[];
15
16
  children: ReactNode;
@@ -22,7 +23,8 @@ export const StoreProvider = ({
22
23
  children,
23
24
  }: StoreProviderProps) => {
24
25
  const store = getOrchestratorStore({
25
- orchestratorConfig: initialOrchestratorConfig,
26
+ orchestratorConfig:
27
+ initialOrchestratorConfig ?? emptyOrchestratorConfig,
26
28
  orchestratorComponentOverride,
27
29
  customApis,
28
30
  });
@@ -24,7 +24,7 @@ export interface Form {
24
24
  export type InputForm = JSONSchema6;
25
25
  export interface FormNotCompleteResponse {
26
26
  form: InputForm;
27
- hasNext?: boolean;
27
+ meta?: { hasNext?: boolean };
28
28
  }
29
29
 
30
30
  export type FieldProps<
@@ -24,6 +24,14 @@ export type Customer = {
24
24
  shortcode: string;
25
25
  };
26
26
 
27
+ export type CustomerWithSubscriptionCount = Customer & {
28
+ subscriptions: {
29
+ pageInfo: {
30
+ totalItems: number;
31
+ };
32
+ };
33
+ };
34
+
27
35
  export type InUseByRelation = {
28
36
  subscription_instance_id: string;
29
37
  subscription_id: string;
@@ -337,6 +345,10 @@ export interface CustomersResult {
337
345
  customers: GraphQlSinglePage<Customer>;
338
346
  }
339
347
 
348
+ export interface CustomersWithSubscriptionCountResult {
349
+ customers: GraphQlSinglePage<CustomerWithSubscriptionCount>;
350
+ }
351
+
340
352
  export interface TaskDefinitionsResult<T = TaskDefinition> {
341
353
  workflows: GraphQlResultPage<T>;
342
354
  }
@@ -0,0 +1,51 @@
1
+ import process from 'process';
2
+
3
+ import { getEnvironmentVariables } from './getEnvironmentVariables';
4
+
5
+ const originalEnv = process.env;
6
+
7
+ describe('getEnvironmentVariables()', () => {
8
+ const warnMock = jest.spyOn(console, 'warn');
9
+
10
+ jest.mock('process');
11
+
12
+ beforeEach(() => {
13
+ process.env = {
14
+ ...originalEnv,
15
+ };
16
+ jest.resetAllMocks();
17
+ });
18
+
19
+ afterEach(() => {
20
+ process.env = originalEnv;
21
+ });
22
+
23
+ it('returns an object with the environment variables and its values', () => {
24
+ process.env.test01 = 'value01';
25
+ process.env.test02 = 'value02';
26
+
27
+ const result = getEnvironmentVariables(['test01', 'test02']);
28
+
29
+ expect(warnMock).not.toHaveBeenCalled();
30
+ expect(result).toEqual({
31
+ test01: 'value01',
32
+ test02: 'value02',
33
+ });
34
+ });
35
+
36
+ it('returns an empty string as value in the result when the environment variable is not set', () => {
37
+ process.env.test01 = 'value01';
38
+ process.env.test03 = 'value03';
39
+
40
+ const result = getEnvironmentVariables(['test01', 'test02', 'test03']);
41
+
42
+ expect(warnMock).toHaveBeenCalledWith(
43
+ 'Warning: Missing required environment variables: test02',
44
+ );
45
+ expect(result).toEqual({
46
+ test01: 'value01',
47
+ test02: '',
48
+ test03: 'value03',
49
+ });
50
+ });
51
+ });
@@ -0,0 +1,33 @@
1
+ import process from 'process';
2
+
3
+ // By convention, only this function should be used to access the process.env object.
4
+ // It logs a warning if one or more variables are not set
5
+ export function getEnvironmentVariables<T>(
6
+ envVars: (keyof T)[],
7
+ ): Record<keyof T, string> {
8
+ const missingEnvironmentVariables: string[] = [];
9
+
10
+ const environmentVariablesWithValues = envVars.reduce(
11
+ (acc, currentKey) => {
12
+ const value = process.env[currentKey.toString()];
13
+
14
+ if (value === undefined) {
15
+ missingEnvironmentVariables.push(currentKey.toString());
16
+ }
17
+
18
+ return {
19
+ ...acc,
20
+ [currentKey]: value || '',
21
+ };
22
+ },
23
+ {} as Record<keyof T, string>,
24
+ );
25
+
26
+ if (missingEnvironmentVariables.length > 0) {
27
+ console.warn(
28
+ `Warning: Missing required environment variables: ${missingEnvironmentVariables.join(', ')}`,
29
+ );
30
+ }
31
+
32
+ return environmentVariablesWithValues;
33
+ }
@@ -1,6 +1,7 @@
1
1
  export * from './csvDownload';
2
2
  export * from './date';
3
3
  export * from './environmentVariables';
4
+ export * from './getEnvironmentVariables';
4
5
  export * from './getProductNamesFromProcess';
5
6
  export * from './getQueryVariablesForExport';
6
7
  export * from './getStatusBadgeColor';
@@ -1,22 +0,0 @@
1
- import React, { useEffect } from 'react';
2
-
3
- import { getSession, signIn } from 'next-auth/react';
4
- import { useRouter } from 'next/router';
5
-
6
- import { useGetOrchestratorConfig } from '@/hooks';
7
-
8
- export const WfoRouteChangeListener = () => {
9
- const router = useRouter();
10
- const { authActive } = useGetOrchestratorConfig();
11
-
12
- useEffect(() => {
13
- if (authActive) {
14
- getSession().then((session) => {
15
- if (!session) {
16
- signIn();
17
- }
18
- });
19
- }
20
- }, [authActive, router]);
21
- return <></>;
22
- };
@@ -1 +0,0 @@
1
- export * from './WfoRouteChangeListener';