@@ -24,18 +24,19 @@ import * as AppUtils from '../utils';
24
24
25
25
require ( './application-details.scss' ) ;
26
26
27
- export class ApplicationDetails extends React . Component < RouteComponentProps < { name : string ; namespace : string ; } > , { application : appModels . Application } > {
27
+ export class ApplicationDetails extends React . Component < RouteComponentProps < { name : string ; } > , { application : appModels . Application ; defaultKindFilter : string [ ] } > {
28
28
29
29
public static contextTypes = {
30
30
apis : PropTypes . object ,
31
31
} ;
32
32
33
33
private changesSubscription : Subscription ;
34
+ private viewPrefSubscription : Subscription ;
34
35
private formApi : FormApi ;
35
36
36
- constructor ( props : RouteComponentProps < { name : string ; namespace : string ; } > ) {
37
+ constructor ( props : RouteComponentProps < { name : string ; } > ) {
37
38
super ( props ) ;
38
- this . state = { application : null } ;
39
+ this . state = { application : null , defaultKindFilter : [ ] } ;
39
40
}
40
41
41
42
private get showOperationState ( ) {
@@ -82,6 +83,11 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{ na
82
83
this . changesSubscription = appUpdates . subscribe ( ( application ) => {
83
84
this . setState ( { application } ) ;
84
85
} ) ;
86
+ this . viewPrefSubscription = services . viewPreferences . getPreferences ( )
87
+ . map ( ( preferences ) => preferences . appDetails . defaultKindFilter )
88
+ . subscribe ( ( filter ) => {
89
+ this . setState ( { defaultKindFilter : filter } ) ;
90
+ } ) ;
85
91
}
86
92
87
93
public componentWillUnmount ( ) {
@@ -106,6 +112,11 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{ na
106
112
selectedValues : kindsFilter ,
107
113
selectionChanged : ( items ) => {
108
114
this . appContext . apis . navigation . goto ( '.' , { kinds : `${ items . join ( ',' ) } ` } ) ;
115
+ services . viewPreferences . updatePreferences ( {
116
+ appDetails : {
117
+ defaultKindFilter : items ,
118
+ } ,
119
+ } ) ;
109
120
} ,
110
121
} ;
111
122
@@ -233,7 +244,7 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{ na
233
244
private getKindsFilter ( ) {
234
245
let kinds = new URLSearchParams ( this . props . history . location . search ) . get ( 'kinds' ) ;
235
246
if ( kinds === null ) {
236
- kinds = 'Deployment,Service,Pod,StatefulSet' ;
247
+ kinds = this . state . defaultKindFilter . join ( ',' ) ;
237
248
}
238
249
return kinds . split ( ',' ) . filter ( ( item ) => ! ! item ) ;
239
250
}
@@ -387,5 +398,9 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{ na
387
398
this . changesSubscription . unsubscribe ( ) ;
388
399
}
389
400
this . changesSubscription = null ;
401
+ if ( this . viewPrefSubscription ) {
402
+ this . viewPrefSubscription . unsubscribe ( ) ;
403
+ this . viewPrefSubscription = null ;
404
+ }
390
405
}
391
406
}
0 commit comments