1717
1818import React from 'react' ;
1919import { useState , useCallback } from 'react' ;
20+ import { useIntl , FormattedMessage } from 'react-intl' ;
21+ import { useQueryClient } from '@tanstack/react-query' ;
22+ import { toDateObject } from 'util/DateTime' ;
23+ import StreamsStore from 'stores/streams/StreamsStore' ;
2024import { PaginatedEntityTable , Timestamp } from 'components/common' ;
25+ import ButtonToEventDefinition from 'wizard/components/buttons/ButtonToEventDefinition' ;
26+ import ButtonToNotification from 'wizard/components/buttons/ButtonToNotification' ;
27+ import ButtonToSearch from 'wizard/components/buttons/ButtonToSearch' ;
28+ import ButtonToUpdateRule from 'wizard/components/buttons/ButtonToUpdateRule' ;
29+ import EventDefinitionResources from 'wizard/resources/EventDefinitionResource' ;
2130import AlertRuleActions from 'wizard/actions/AlertRuleActions' ;
22- import { useQueryClient } from '@tanstack/react-query' ;
23- import { keyFn , fetchAlertRules , KEY_PREFIX } from './hooks/useAlertRules' ;
24- import { useIntl , FormattedMessage } from 'react-intl' ;
31+ import AlertValidation from 'wizard/logic/AlertValidation' ;
32+ import { keyFn , fetchAlertRules } from './hooks/useAlertRules' ;
2533import AlertRuleBulkActions from './AlertRuleBulkActions' ;
26- import { toDateObject } from 'util/DateTime' ;
2734import AlertRuleText from './AlertRuleText' ;
28- import ButtonToEventDefinition from '../buttons/ButtonToEventDefinition' ;
29- import ButtonToNotification from '../buttons/ButtonToNotification' ;
3035import AlertRuleCloneForm from './AlertRuleCloneForm' ;
31- import EventDefinitionResources from '../../resources/EventDefinitionResource' ;
32- import StreamsStore from 'stores/streams/StreamsStore' ;
33- import ButtonToSearch from '../buttons/ButtonToSearch' ;
34- import AlertValidation from '../../logic/AlertValidation' ;
35- import ButtonToUpdateRule from '../buttons/ButtonToUpdateRule' ;
3636import { DEFAULT_LAYOUT } from "./Constants" ;
3737
3838function _convertAlertToElement ( alert ) {
@@ -84,7 +84,7 @@ const AlertRulesContainer = ({ fieldOrder }) => {
8484 const intl = useIntl ( ) ;
8585 const queryClient = useQueryClient ( ) ;
8686
87- const _loadAlertRules = ( ) => queryClient . invalidateQueries ( KEY_PREFIX ) ;
87+ const _loadAlertRules = ( ) => queryClient . invalidateQueries ( keyFn ( ) ) ;
8888 const fieldsTitle = [
8989 { key : 'title' , label : intl . formatMessage ( { id : 'wizard.title' , defaultMessage : 'Title' } ) , config : 'title' , sortable : true } ,
9090 { key : 'priority' , label : intl . formatMessage ( { id : 'wizard.priority' , defaultMessage : 'Priority' } ) , config : 'Priority' , sortable : true } ,
@@ -169,7 +169,6 @@ const AlertRulesContainer = ({ fieldOrder }) => {
169169 disableAlertRulesFunction = { disableAlertRules }
170170 enableAlertRulesFunction = { enableAlertRules } />
171171 ) ;
172- const onSortChange = useCallback ( ( ) => { } , [ ] ) ;
173172 const renderAlertRuleActions = useCallback ( ( alert ) => {
174173 const element = _convertAlertToElement ( alert ) ;
175174
@@ -182,22 +181,21 @@ const AlertRulesContainer = ({ fieldOrder }) => {
182181 </ div > ) ;
183182 } , [ ] ) ;
184183
185- const deleteAlertRules = ( alertRulesTitles ) => {
186- const promises = alertRulesTitles . map ( name => AlertRuleActions . deleteByName ( name ) ) ;
184+ const deleteAlertRules = ( alertRulesIds ) => {
185+ const promises = alertRulesIds . map ( id => AlertRuleActions . delete ( id ) ) ;
187186 Promise . all ( promises ) . then ( ( ) => _loadAlertRules ( ) ) ;
188187 }
189188
190- const disableAlertRules = ( alertRulesTitles ) => {
191- console . log ( alertRulesTitles ) ;
192- const tempElements = alertRulesTitles . map ( name => elements . find ( x => x . id === name ) ) ;
189+ const disableAlertRules = ( alertRulesIds ) => {
190+ const tempElements = alertRulesIds . map ( name => elements . find ( x => x . id === name ) ) ;
193191
194192 for ( const elt of tempElements ) {
195193 _onPause ( elt . title , elt . condition , elt . streamId , elt . secondEventDefinition , elt . streamId2 ) ;
196194 }
197195 }
198196
199- const enableAlertRules = ( alertRulesTitles ) => {
200- const tempElements = alertRulesTitles . map ( name => elements . find ( x => x . id === name ) ) ;
197+ const enableAlertRules = ( alertRulesIds ) => {
198+ const tempElements = alertRulesIds . map ( name => elements . find ( x => x . id === name ) ) ;
201199
202200 for ( const elt of tempElements ) {
203201 _onResume ( elt . condition , elt . streamId , elt . secondEventDefinition , elt . streamId2 ) ;
0 commit comments