Skip to content

Commit

Permalink
692 Adds WfoErrorMonitoringProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardovdheijden committed Nov 30, 2024
1 parent 10f6334 commit dcb0fce
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React, { FC, ReactNode, createContext } from 'react';

export type WfoErrorMonitoring = {
reportError: (error: Error | string) => void;
reportMessage: (message: string) => void;
};

export const emptyWfoErrorMonitoring: WfoErrorMonitoring = {
reportError: () => {},
reportMessage: () => {},
};

export const WfoErrorMonitoringContext = createContext<WfoErrorMonitoring>(
emptyWfoErrorMonitoring,
);

export type WfoErrorMonitoringProviderProps = {
errorMonitoringHandler?: WfoErrorMonitoring;
children: ReactNode;
};

export const WfoErrorMonitoringProvider: FC<
WfoErrorMonitoringProviderProps
> = ({ errorMonitoringHandler, children }) => {
return (
<WfoErrorMonitoringContext.Provider
value={errorMonitoringHandler ?? emptyWfoErrorMonitoring}
>
{children}
</WfoErrorMonitoringContext.Provider>
);
};
1 change: 1 addition & 0 deletions packages/orchestrator-ui-components/src/contexts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './ConfirmationDialogProvider';
export * from './OrchestratorConfigContext';
export * from './PolicyContext';
export * from './TreeContext';
export * from './WfoErrorMonitoringProvider';
1 change: 1 addition & 0 deletions packages/orchestrator-ui-components/src/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export * from './useDataDisplayParams';
export * from './useShowToastMessage';
export * from './useStoredTableConfig';
export * from './useWithOrchestratorTheme';
export * from './useWfoErrorMonitoring';
export * from './useWfoSession';
export * from './useGetOrchestratorConfig';
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { useContext } from 'react';

import { WfoErrorMonitoringContext } from '@/contexts';

export const useWfoErrorMonitoring = () =>
useContext(WfoErrorMonitoringContext);

0 comments on commit dcb0fce

Please sign in to comment.