@orchestrator-ui/orchestrator-ui-components 2.12.0 → 2.13.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orchestrator-ui/orchestrator-ui-components",
3
- "version": "2.12.0",
3
+ "version": "2.13.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Library of UI Components used to display the workflow orchestrator frontend",
6
6
  "author": {
@@ -34,7 +34,7 @@ import {
34
34
  } from '@elastic/eui';
35
35
 
36
36
  import { ConfirmDialogHandler, ConfirmationDialogContext } from '@/contexts';
37
- import { useOrchestratorTheme } from '@/hooks';
37
+ import { useOrchestratorTheme, useWfoErrorMonitoring } from '@/hooks';
38
38
  import { WfoPlayFill } from '@/icons';
39
39
  import { FormValidationError, ValidationError } from '@/types/forms';
40
40
 
@@ -429,6 +429,7 @@ export function WfoUserInputForm({
429
429
  const [processing, setProcessing] = useState<boolean>(false);
430
430
  const [nrOfValidationErrors, setNrOfValidationErrors] = useState<number>(0);
431
431
  const [rootErrors, setRootErrors] = useState<string[]>([]);
432
+ const { reportError } = useWfoErrorMonitoring();
432
433
 
433
434
  const openLeavePageDialog = (
434
435
  leaveAction: ConfirmDialogHandler,
@@ -457,7 +458,7 @@ export function WfoUserInputForm({
457
458
  await validSubmit(userInput);
458
459
  setProcessing(false);
459
460
  return null;
460
- } catch (error: unknown) {
461
+ } catch (error) {
461
462
  setProcessing(false);
462
463
  if (typeof error === 'object' && error !== null) {
463
464
  const validationError = error as FormValidationError;
@@ -485,6 +486,9 @@ export function WfoUserInputForm({
485
486
  }
486
487
  // Let the error escape, so it can be caught by our own onerror handler instead of being silenced by uniforms
487
488
  setTimeout(() => {
489
+ reportError(
490
+ new Error(`Forms error: ${JSON.stringify({ error })}`),
491
+ );
488
492
  throw error;
489
493
  }, 0);
490
494
 
@@ -34,18 +34,23 @@ export const getSubscriptionDetailStyles = ({ theme }: WfoTheme) => {
34
34
  });
35
35
  const workflowTargetStyle = css({ fontWeight: theme.font.weight.bold });
36
36
 
37
- const lastContentCellStyle = css({
38
- ...contentCellStyle,
39
- border: 0,
40
- });
37
+ const lastContentCellStyle = css([
38
+ {
39
+ ...contentCellStyle,
40
+ },
41
+ {
42
+ borderBottom: 0,
43
+ },
44
+ ]);
41
45
 
42
- const lastHeaderCellStyle = css({
43
- padding: theme.base,
44
- paddingLeft: 0,
45
- width: 250,
46
- fontWeight: theme.font.weight.medium,
47
- border: 0,
48
- });
46
+ const lastHeaderCellStyle = css([
47
+ {
48
+ ...headerCellStyle,
49
+ },
50
+ {
51
+ borderBottomWidth: 0,
52
+ },
53
+ ]);
49
54
 
50
55
  const inUseByRelationDetailsStyle = css({
51
56
  borderColor: theme.colors.lightShade,
@@ -1 +1 @@
1
- export const ORCHESTRATOR_UI_LIBRARY_VERSION = '2.12.0';
1
+ export const ORCHESTRATOR_UI_LIBRARY_VERSION = '2.13.0';
@@ -0,0 +1,37 @@
1
+ import React, { FC, ReactNode, createContext } from 'react';
2
+
3
+ export type WfoErrorMonitoring = {
4
+ reportError: (error: Error | string) => void;
5
+ reportMessage: (message: string) => void;
6
+ };
7
+
8
+ export const emptyWfoErrorMonitoring: WfoErrorMonitoring = {
9
+ reportError: () => {},
10
+ reportMessage: () => {},
11
+ };
12
+
13
+ export const WfoErrorMonitoringContext = createContext<WfoErrorMonitoring>(
14
+ emptyWfoErrorMonitoring,
15
+ );
16
+
17
+ export type WfoErrorMonitoringProviderProps = {
18
+ errorMonitoringHandler?: WfoErrorMonitoring;
19
+ children: ReactNode;
20
+ };
21
+
22
+ /**
23
+ *
24
+ * @param errorMonitoringHandler for implementing the error monitoring. When not provided, all report calls are no-ops.
25
+ * @param children
26
+ */
27
+ export const WfoErrorMonitoringProvider: FC<
28
+ WfoErrorMonitoringProviderProps
29
+ > = ({ errorMonitoringHandler, children }) => {
30
+ return (
31
+ <WfoErrorMonitoringContext.Provider
32
+ value={errorMonitoringHandler ?? emptyWfoErrorMonitoring}
33
+ >
34
+ {children}
35
+ </WfoErrorMonitoringContext.Provider>
36
+ );
37
+ };
@@ -2,3 +2,4 @@ export * from './ConfirmationDialogProvider';
2
2
  export * from './OrchestratorConfigContext';
3
3
  export * from './PolicyContext';
4
4
  export * from './TreeContext';
5
+ export * from './WfoErrorMonitoringProvider';
@@ -6,5 +6,6 @@ export * from './useDataDisplayParams';
6
6
  export * from './useShowToastMessage';
7
7
  export * from './useStoredTableConfig';
8
8
  export * from './useWithOrchestratorTheme';
9
+ export * from './useWfoErrorMonitoring';
9
10
  export * from './useWfoSession';
10
11
  export * from './useGetOrchestratorConfig';
@@ -0,0 +1,6 @@
1
+ import { useContext } from 'react';
2
+
3
+ import { WfoErrorMonitoringContext } from '@/contexts';
4
+
5
+ export const useWfoErrorMonitoring = () =>
6
+ useContext(WfoErrorMonitoringContext);
@@ -97,7 +97,7 @@ const streamMessagesApi = orchestratorApi.injectEndpoints({
97
97
  const getDebounce = (delay: number) => {
98
98
  return debounce(() => {
99
99
  webSocket.close();
100
- // note: websocket.close doesnt trigger the onclose handler when losing
100
+ // note: websocket.close doesn't trigger the onClose handler when closing
101
101
  // internet connection so we call the cleanup event from here to be sure it's called
102
102
  cleanUp();
103
103
  }, delay);