@@ -27,6 +27,7 @@ import {
27
27
CHECKBOX_VALUE ,
28
28
getIsRequestAborted ,
29
29
CiPipelineSourceConfig ,
30
+ SelectAllGroupedResourceIdentifiers ,
30
31
} from '@devtron-labs/devtron-fe-common-lib'
31
32
import { RouteComponentProps , Link } from 'react-router-dom'
32
33
import { toast } from 'react-toastify'
@@ -55,13 +56,15 @@ import { getAppListMin, getEnvironmentListMin } from '../../services/service'
55
56
import { SMTPConfigModal } from './SMTPConfigModal'
56
57
import { EMAIL_AGENT } from './types'
57
58
import { WebhookConfigModal } from './WebhookConfigModal'
59
+ import { getClusterListMin } from '@Components/ClusterNodes/clusterNodes.service'
58
60
59
61
interface AddNotificationsProps extends RouteComponentProps < { } > { }
60
62
61
- enum FilterOptions {
63
+ export enum FilterOptions {
62
64
ENVIRONMENT = 'environment' ,
63
65
APPLICATION = 'application' ,
64
66
PROJECT = 'project' ,
67
+ CLUSTER = 'cluster'
65
68
}
66
69
interface Options {
67
70
environment : {
@@ -79,6 +82,11 @@ interface Options {
79
82
label : string
80
83
type : string
81
84
} [ ]
85
+ cluster : {
86
+ value : number
87
+ label : string
88
+ type : string
89
+ } [ ]
82
90
}
83
91
export interface PipelineType {
84
92
checkbox : {
@@ -144,6 +152,7 @@ export class AddNotification extends Component<AddNotificationsProps, AddNotific
144
152
{ value : 1 , label : 'application' , type : 'main' } ,
145
153
{ value : 2 , label : 'project' , type : 'main' } ,
146
154
{ value : 3 , label : 'environment' , type : 'main' } ,
155
+ { value : 4 , label : 'cluster' , type : 'main' } ,
147
156
]
148
157
149
158
filterOptionsInner = [ ]
@@ -168,7 +177,7 @@ export class AddNotification extends Component<AddNotificationsProps, AddNotific
168
177
selectedChannels : [ ] ,
169
178
pipelineList : [ ] ,
170
179
emailAgentConfigId : 0 ,
171
- options : { environment : [ ] , application : [ ] , project : [ ] } ,
180
+ options : { environment : [ ] , application : [ ] , project : [ ] , cluster : [ ] } ,
172
181
selectedEmailAgent : EMAIL_AGENT . SES ,
173
182
showWebhookConfigModal : false ,
174
183
}
@@ -191,7 +200,7 @@ export class AddNotification extends Component<AddNotificationsProps, AddNotific
191
200
}
192
201
193
202
getInitialData ( ) {
194
- this . getEnvTeamData ( )
203
+ this . getEnvTeamAndClusterData ( )
195
204
getAddNotificationInitData ( ) . then ( ( result ) => {
196
205
this . setState ( {
197
206
sesConfigOptions : result . sesConfigOptions ,
@@ -509,23 +518,41 @@ export class AddNotification extends Component<AddNotificationsProps, AddNotific
509
518
}
510
519
}
511
520
512
- getEnvTeamData ( ) : void {
513
- Promise . all ( [ getEnvironmentListMin ( ) , getTeamListMin ( ) ] ) . then ( ( [ environments , teams ] ) => {
521
+ getEnvTeamAndClusterData ( ) : void {
522
+ Promise . all ( [ getEnvironmentListMin ( ) , getTeamListMin ( ) , getClusterListMin ( ) ] ) . then ( ( [ environments , teams , clusters ] ) => {
514
523
const state = { ...this . state }
515
- state . options . environment = environments . result . map ( ( elem ) => {
524
+ state . options . environment = [
525
+ {
526
+ environment_name : 'All non-prod environments' ,
527
+ // parseInt can be removed once BE supports identifiers instead
528
+ id : parseInt ( SelectAllGroupedResourceIdentifiers . allExistingAndFutureNonProdEnvironments ) ,
529
+ } ,
530
+ {
531
+ environment_name : 'All prod environments' ,
532
+ id : parseInt ( SelectAllGroupedResourceIdentifiers . allExistingAndFutureProdEnvironments ) ,
533
+ } ,
534
+ ...( environments ?. result ?? [ ] ) ,
535
+ ] . map ( ( elem ) => {
516
536
return {
517
537
label : `${ elem . environment_name . toLowerCase ( ) } ` ,
518
538
value : elem . id ,
519
539
type : FilterOptions . ENVIRONMENT ,
520
540
}
521
541
} )
522
- state . options . project = teams . result . map ( ( elem ) => {
542
+ state . options . project = ( teams ? .result ?? [ ] ) . map ( ( elem ) => {
523
543
return {
524
544
label : `${ elem . name . toLowerCase ( ) } ` ,
525
545
value : elem . id ,
526
546
type : FilterOptions . PROJECT ,
527
547
}
528
548
} )
549
+ state . options . cluster = ( clusters ?. result ?? [ ] ) . map ( ( { name, id } ) => {
550
+ return {
551
+ label : `${ name . toLowerCase ( ) } ` ,
552
+ value : id ,
553
+ type : FilterOptions . CLUSTER ,
554
+ }
555
+ } )
529
556
this . setState ( state )
530
557
} )
531
558
}
@@ -582,10 +609,16 @@ export class AddNotification extends Component<AddNotificationsProps, AddNotific
582
609
input . length === 0
583
610
? this . state . options . project
584
611
: this . state . options . project . filter ( ( filter ) => filter . label . indexOf ( input ) >= 0 )
612
+ } else if ( unsavedFilter . type === FilterOptions . CLUSTER ) {
613
+ options =
614
+ input . length === 0
615
+ ? this . state . options . cluster
616
+ : this . state . options . cluster . filter ( ( filter ) => filter . label . indexOf ( input ) >= 0 )
585
617
} else {
586
618
options = input . length <= 2 ? [ ] : this . state . options . application
587
619
}
588
620
}
621
+
589
622
return (
590
623
< div className = "dc__position-rel" >
591
624
< div
0 commit comments