@@ -109,8 +109,16 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
109109 return OpenShiftExplorer . instance ;
110110 }
111111
112+ private static async generateOpenshiftProjectContextValue ( namespace : string ) : Promise < string > {
113+ let contextValue = `openshift.project.${ namespace } ` ;
114+ if ( await Oc . Instance . canDeleteNamespace ( namespace ) ) {
115+ contextValue += `${ contextValue } .canDelete` ;
116+ }
117+ return contextValue ;
118+ }
119+
112120 // eslint-disable-next-line class-methods-use-this
113- getTreeItem ( element : ExplorerItem ) : TreeItem | Thenable < TreeItem > {
121+ async getTreeItem ( element : ExplorerItem ) : Promise < TreeItem | Thenable < TreeItem > > {
114122
115123 if ( 'command' in element ) {
116124 return element ;
@@ -163,7 +171,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
163171 if ( 'kind' in element ) {
164172 if ( element . kind === 'project' ) {
165173 return {
166- contextValue : 'openshift.project' ,
174+ contextValue : await OpenShiftExplorer . generateOpenshiftProjectContextValue ( element . metadata . name ) ,
167175 label : element . metadata . name ,
168176 collapsibleState : TreeItemCollapsibleState . Collapsed ,
169177 iconPath : path . resolve ( __dirname , '../../images/context/project-node.png' )
@@ -205,8 +213,7 @@ export class OpenShiftExplorer implements TreeDataProvider<ExplorerItem>, Dispos
205213 result = [ this . kubeContext ] ;
206214 if ( this . kubeContext ) {
207215 const config = getKubeConfigFiles ( ) ;
208- const canCreateNamespace = await Oc . Instance . canCreateNamespace ( ) ;
209- void commands . executeCommand ( 'setContext' , 'canCreateNamespace' , canCreateNamespace ) ;
216+ void commands . executeCommand ( 'setContext' , 'canCreateNamespace' , await Oc . Instance . canCreateNamespace ( ) ) ;
210217 result . unshift ( { label : process . env . KUBECONFIG ? 'Custom KubeConfig' : 'Default KubeConfig' , description : config . join ( ':' ) } )
211218 }
212219 } catch ( err ) {
0 commit comments