diff --git a/packages/orchestrator-ui-components/src/contexts/WfoErrorMonitoringProvider.tsx b/packages/orchestrator-ui-components/src/contexts/WfoErrorMonitoringProvider.tsx new file mode 100644 index 000000000..544a47c25 --- /dev/null +++ b/packages/orchestrator-ui-components/src/contexts/WfoErrorMonitoringProvider.tsx @@ -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( + emptyWfoErrorMonitoring, +); + +export type WfoErrorMonitoringProviderProps = { + errorMonitoringHandler?: WfoErrorMonitoring; + children: ReactNode; +}; + +export const WfoErrorMonitoringProvider: FC< + WfoErrorMonitoringProviderProps +> = ({ errorMonitoringHandler, children }) => { + return ( + + {children} + + ); +}; diff --git a/packages/orchestrator-ui-components/src/contexts/index.ts b/packages/orchestrator-ui-components/src/contexts/index.ts index 1bc763544..b6be7517c 100644 --- a/packages/orchestrator-ui-components/src/contexts/index.ts +++ b/packages/orchestrator-ui-components/src/contexts/index.ts @@ -2,3 +2,4 @@ export * from './ConfirmationDialogProvider'; export * from './OrchestratorConfigContext'; export * from './PolicyContext'; export * from './TreeContext'; +export * from './WfoErrorMonitoringProvider'; diff --git a/packages/orchestrator-ui-components/src/hooks/index.ts b/packages/orchestrator-ui-components/src/hooks/index.ts index 6a12b92fb..5e33a38de 100644 --- a/packages/orchestrator-ui-components/src/hooks/index.ts +++ b/packages/orchestrator-ui-components/src/hooks/index.ts @@ -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'; diff --git a/packages/orchestrator-ui-components/src/hooks/useWfoErrorMonitoring.ts b/packages/orchestrator-ui-components/src/hooks/useWfoErrorMonitoring.ts new file mode 100644 index 000000000..11032553c --- /dev/null +++ b/packages/orchestrator-ui-components/src/hooks/useWfoErrorMonitoring.ts @@ -0,0 +1,6 @@ +import { useContext } from 'react'; + +import { WfoErrorMonitoringContext } from '@/contexts'; + +export const useWfoErrorMonitoring = () => + useContext(WfoErrorMonitoringContext);