@@ -109,6 +109,12 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
109109 return OpenShiftExplorer . instance ;
110110 }
111111
112+ private static generateOpenshiftProjectContextValue ( namespace : string ) : Thenable < string > {
113+ const contextValue = `openshift.project.${ namespace } ` ;
114+ return Oc . Instance . canDeleteNamespace ( namespace )
115+ . then ( result => ( result ? `${ contextValue } .canDelete` : contextValue ) ) ;
116+ }
117+
112118 // eslint-disable-next-line class-methods-use-this
113119 getTreeItem ( element : ExplorerItem ) : TreeItem | Thenable < TreeItem > {
114120
@@ -162,12 +168,15 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
162168 // otherwise it is a KubernetesObject instance
163169 if ( 'kind' in element ) {
164170 if ( element . kind === 'project' ) {
165- return {
166- contextValue : 'openshift.project' ,
167- label : element . metadata . name ,
168- collapsibleState : TreeItemCollapsibleState . Collapsed ,
169- iconPath : path . resolve ( __dirname , '../../images/context/project-node.png' )
170- }
171+ return OpenShiftExplorer . generateOpenshiftProjectContextValue ( element . metadata . name )
172+ . then ( namespace => {
173+ return {
174+ contextValue : namespace ,
175+ label : element . metadata . name ,
176+ collapsibleState : TreeItemCollapsibleState . Collapsed ,
177+ iconPath : path . resolve ( __dirname , '../../images/context/project-node.png' )
178+ }
179+ } ) ;
171180 } else if ( element . kind === 'helm' ) {
172181 return {
173182 contextValue : 'openshift.helm.repos' ,
@@ -205,8 +214,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
205214 result = [ this . kubeContext ] ;
206215 if ( this . kubeContext ) {
207216 const config = getKubeConfigFiles ( ) ;
208- const canCreateNamespace = await Oc . Instance . canCreateNamespace ( ) ;
209- void commands . executeCommand ( 'setContext' , 'canCreateNamespace' , canCreateNamespace ) ;
217+ void commands . executeCommand ( 'setContext' , 'canCreateNamespace' , await Oc . Instance . canCreateNamespace ( ) ) ;
210218 result . unshift ( { label : process . env . KUBECONFIG ? 'Custom KubeConfig' : 'Default KubeConfig' , description : config . join ( ':' ) } )
211219 }
212220 } catch ( err ) {
0 commit comments