@@ -2,8 +2,9 @@ import * as vscode from "vscode";
22
33import { canReachGitHubAPI } from "../api/canReachGitHubAPI" ;
44import { getGitHubContext } from "../git/repository" ;
5- import { logDebug , logError } from "../log" ;
5+ import { logError } from "../log" ;
66import { RunStore } from "../store/store" ;
7+ import { AutoRefreshManager } from "./combinedWorkflows/autoRefreshManager" ;
78import { CombinedWorkflowRunNode } from "./combinedWorkflows/combinedWorkflowRunNode" ;
89import { AttemptNode } from "./shared/attemptNode" ;
910import { AuthenticationNode } from "./shared/authenticationNode" ;
@@ -30,9 +31,33 @@ export class CombinedWorkflowsTreeProvider
3031{
3132 private _onDidChangeTreeData = new vscode . EventEmitter < CombinedWorkflowsTreeNode | null > ( ) ;
3233 readonly onDidChangeTreeData = this . _onDidChangeTreeData . event ;
34+ private autoRefreshManager : AutoRefreshManager ;
35+ private treeView ?: vscode . TreeView < CombinedWorkflowsTreeNode > ;
3336
3437 constructor ( store : RunStore ) {
3538 super ( store ) ;
39+ this . autoRefreshManager = new AutoRefreshManager (
40+ ( ) => this . refresh ( ) ,
41+ ( description : string ) => this . updateViewDescription ( description )
42+ ) ;
43+ }
44+
45+ setTreeView ( treeView : vscode . TreeView < CombinedWorkflowsTreeNode > ) : void {
46+ this . treeView = treeView ;
47+ this . updateViewDescription ( this . autoRefreshManager . getDescription ( ) ) ;
48+ this . updateAutoRefreshContext ( ) ;
49+ }
50+
51+ private updateViewDescription ( description : string ) : void {
52+ if ( this . treeView ) {
53+ this . treeView . description = description ;
54+ }
55+ this . updateAutoRefreshContext ( ) ;
56+ }
57+
58+ private updateAutoRefreshContext ( ) : void {
59+ const isActive = this . autoRefreshManager . isActive ( ) ;
60+ void vscode . commands . executeCommand ( "setContext" , "github-actions.combined-workflows.auto-refresh-active" , isActive ) ;
3661 }
3762
3863 protected _updateNode ( node : WorkflowRunNode ) : void {
@@ -47,18 +72,31 @@ export class CombinedWorkflowsTreeProvider
4772 }
4873 }
4974
75+ setVisible ( visible : boolean ) : void {
76+ this . autoRefreshManager . setVisible ( visible ) ;
77+ }
78+
79+ onPush ( ) : void {
80+ this . autoRefreshManager . onPush ( ) ;
81+ }
82+
83+ getAutoRefreshManager ( ) : AutoRefreshManager {
84+ return this . autoRefreshManager ;
85+ }
86+
87+ dispose ( ) : void {
88+ this . autoRefreshManager . dispose ( ) ;
89+ }
90+
5091 getTreeItem ( element : CombinedWorkflowsTreeNode ) : vscode . TreeItem | Thenable < vscode . TreeItem > {
5192 return element ;
5293 }
5394
5495 async getChildren ( element ?: CombinedWorkflowsTreeNode | undefined ) : Promise < CombinedWorkflowsTreeNode [ ] > {
5596 if ( ! element ) {
56- logDebug ( "Getting combined workflow runs from all repos" ) ;
57-
5897 try {
5998 const gitHubContext = await getGitHubContext ( ) ;
6099 if ( ! gitHubContext ) {
61- logDebug ( "could not get github context for combined workflows" ) ;
62100 return [ new GitHubAPIUnreachableNode ( ) ] ;
63101 }
64102
@@ -101,7 +139,7 @@ export class CombinedWorkflowsTreeProvider
101139
102140 return allRuns ;
103141 } catch ( e ) {
104- logError ( e as Error , "Failed to get GitHub context" ) ;
142+ logError ( e as Error , ( e as Error ) . message ) ;
105143
106144 if ( ( e as Error ) . message . startsWith ( "Could not get token from the GitHub authentication provider." ) ) {
107145 return [ new AuthenticationNode ( ) ] ;
0 commit comments