File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import * as vscode from "vscode" ;
22import { GitHubRepoContext } from "../../git/repository" ;
3+ import { hasAdminPermission } from "../../git/repository-permissions" ;
34import { Environment } from "../../model" ;
45import { EnvironmentSecretsNode } from "./environmentSecretsNode" ;
56import { EnvironmentVariablesNode } from "./environmentVariablesNode" ;
67import { SettingsExplorerNode } from "./types" ;
78
89export class EnvironmentNode extends vscode . TreeItem {
910 constructor ( public readonly gitHubRepoContext : GitHubRepoContext , public readonly environment : Environment ) {
10- super ( environment . name , vscode . TreeItemCollapsibleState . Collapsed ) ;
11+ const state = hasAdminPermission ( gitHubRepoContext . permissionLevel )
12+ ? vscode . TreeItemCollapsibleState . Collapsed
13+ : vscode . TreeItemCollapsibleState . None ;
14+ super ( environment . name , state ) ;
1115
1216 this . contextValue = "environment" ;
1317 }
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import * as vscode from "vscode";
22
33import { EnvironmentsNode } from "./environmentsNode" ;
44import { GitHubRepoContext } from "../../git/repository" ;
5+ import { hasWritePermission } from "../../git/repository-permissions" ;
56import { SecretsNode } from "./secretsNode" ;
67import { SettingsExplorerNode } from "./types" ;
78import { VariablesNode } from "./variablesNode" ;
@@ -22,8 +23,11 @@ export function getSettingNodes(gitHubContext: GitHubRepoContext): SettingsExplo
2223 const nodes : SettingsExplorerNode [ ] = [ ] ;
2324
2425 nodes . push ( new EnvironmentsNode ( gitHubContext ) ) ;
25- nodes . push ( new SecretsNode ( gitHubContext ) ) ;
26- nodes . push ( new VariablesNode ( gitHubContext ) ) ;
26+
27+ if ( hasWritePermission ( gitHubContext . permissionLevel ) ) {
28+ nodes . push ( new SecretsNode ( gitHubContext ) ) ;
29+ nodes . push ( new VariablesNode ( gitHubContext ) ) ;
30+ }
2731
2832 return nodes ;
2933}
You can’t perform that action at this time.
0 commit comments