-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
552754a
commit ab98c8d
Showing
7 changed files
with
49 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
ui/components/app/alert-system/contexts/alertMetricsContext.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React, { createContext, useContext, ReactNode } from 'react'; | ||
import { ALERTS_NAME_METRICS, UseAlertSystemMetricsProps, useConfirmAlertMetrics } from '../useConfirmAlertMetrics'; | ||
import { Alert } from '../../../../ducks/confirm-alerts/confirm-alerts'; | ||
|
||
const AlertMetricsContext = createContext<{ | ||
trackAlertMetrics: (props?: UseAlertSystemMetricsProps) => void; | ||
} | null>(null); | ||
|
||
export const AlertMetricsProvider: React.FC<{ children: ReactNode }> = ({ children }) => { | ||
|
||
const {trackAlertMetrics} = useConfirmAlertMetrics(); | ||
|
||
return ( | ||
<AlertMetricsContext.Provider value={{ trackAlertMetrics }}> | ||
{children} | ||
</AlertMetricsContext.Provider> | ||
); | ||
}; | ||
|
||
export const useAlertMetrics = () => { | ||
const context = useContext(AlertMetricsContext); | ||
if (!context) { | ||
throw new Error('useAlertMetrics must be used within an AlertMetricsProvider'); | ||
} | ||
return context; | ||
}; | ||
|
||
function getAlertsName(alerts: Alert[]): string[] { | ||
return alerts.map(alert => ALERTS_NAME_METRICS[alert.key]); | ||
} |
143 changes: 0 additions & 143 deletions
143
ui/components/app/alert-system/useAlertSystemMetrics.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters