11// Libraries
22import React , { FunctionComponent } from 'react'
3- import { connect } from 'react-redux'
4- import { withRouter , RouteComponentProps } from 'react-router-dom'
3+ import { useDispatch , useSelector } from 'react-redux'
54
65// Types
7- import {
8- NotificationEndpoint ,
9- NotificationRuleDraft ,
10- AppState ,
11- ResourceType ,
12- } from 'src/types'
6+ import { ResourceType } from 'src/types'
137
148// Components
159import {
@@ -20,34 +14,30 @@ import {
2014} from '@influxdata/clockface'
2115import NotificationRuleCards from 'src/notifications/rules/components/RuleCards'
2216import AlertsColumn from 'src/alerting/components/AlertsColumn'
17+ import { showOverlay , dismissOverlay } from 'src/overlays/actions/overlays'
2318
2419// Constants
2520import { DOCS_URL_VERSION } from 'src/shared/constants/fluxFunctions'
2621
2722// Selectors
28- import { getAll } from 'src/resources/selectors'
23+ import { getAllActiveEndpoints } from 'src/notifications/endpoints/selectors'
24+ import { getAllRules } from 'src/notifications/rules/selectors'
2925
30- interface OwnProps {
31- tabIndex : number
32- }
26+ // Utils
27+ import { event } from 'src/cloud/utils/reporting'
3328
34- interface StateProps {
35- rules : NotificationRuleDraft [ ]
36- endpoints : NotificationEndpoint [ ]
29+ interface Props {
30+ tabIndex : number
3731}
3832
39- type Props = OwnProps & StateProps & RouteComponentProps < { orgID : string } >
33+ const NotificationRulesColumn : FunctionComponent < Props > = ( { tabIndex} ) => {
34+ const dispatch = useDispatch ( )
35+ const endpoints = useSelector ( getAllActiveEndpoints )
36+ const rules = useSelector ( getAllRules )
4037
41- const NotificationRulesColumn : FunctionComponent < Props > = ( {
42- rules,
43- history,
44- match,
45- endpoints,
46- tabIndex,
47- } ) => {
4838 const handleOpenOverlay = ( ) => {
49- const newRuleRoute = `/orgs/ ${ match . params . orgID } /alerting/rules/new`
50- history . push ( newRuleRoute )
39+ event ( 'Create Notification Rule opened' )
40+ dispatch ( showOverlay ( 'create-rule' , null , ( ) => dispatch ( dismissOverlay ( ) ) ) )
5141 }
5242
5343 const tooltipContents = (
@@ -106,21 +96,4 @@ const NotificationRulesColumn: FunctionComponent<Props> = ({
10696 )
10797}
10898
109- const mstp = ( state : AppState ) => {
110- const rules = getAll < NotificationRuleDraft > (
111- state ,
112- ResourceType . NotificationRules
113- )
114-
115- const endpoints = getAll < NotificationEndpoint > (
116- state ,
117- ResourceType . NotificationEndpoints
118- )
119-
120- return { rules, endpoints}
121- }
122-
123- export default connect < StateProps > (
124- mstp ,
125- null
126- ) ( withRouter ( NotificationRulesColumn ) )
99+ export default NotificationRulesColumn
0 commit comments