11import * as vscode from "vscode" ;
22
33import { GitHubRepoContext } from "../../git/repository" ;
4+ import { RepositoryPermission , hasWritePermission } from "../../git/repository-permissions" ;
45import { RunStore } from "../../store/store" ;
56import { WorkflowRun } from "../../store/workflowRun" ;
67import { getIconForWorkflowRun } from "../icons" ;
@@ -20,18 +21,22 @@ export class WorkflowRunNode extends vscode.TreeItem {
2021 ) {
2122 super ( WorkflowRunNode . _getLabel ( run , workflowName ) , vscode . TreeItemCollapsibleState . Collapsed ) ;
2223
23- this . updateRun ( run ) ;
24+ this . updateRun ( run , gitHubRepoContext . permissionLevel ) ;
2425 }
2526
26- updateRun ( run : WorkflowRun ) {
27+ updateRun ( run : WorkflowRun , permissionLevel : RepositoryPermission ) {
2728 this . run = run ;
2829 this . label = WorkflowRunNode . _getLabel ( run , this . workflowName ) ;
2930
30- if ( this . run . run . status === "completed" ) {
31- this . contextValue = "run rerunnable completed";
32- } else {
33- this . contextValue = "run cancelable";
31+ const contextValues = [ "run" ] ;
32+ const completed = this . run . run . status === " completed";
33+ if ( hasWritePermission ( permissionLevel ) ) {
34+ contextValues . push ( completed ? "rerunnable" : " cancelable") ;
3435 }
36+ if ( completed ) {
37+ contextValues . push ( "completed" ) ;
38+ }
39+ this . contextValue = contextValues . join ( " " ) ;
3540
3641 this . iconPath = getIconForWorkflowRun ( this . run . run ) ;
3742 this . tooltip = this . getTooltip ( ) ;
0 commit comments