Init log tracking

Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
Sanjula Ganepola
2024-10-01 23:06:48 -04:00
parent 41a19ab041
commit 986e958a9c
8 changed files with 210 additions and 55 deletions

View File

@@ -0,0 +1,30 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
import { JobLog } from "../../act";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
import StepTreeItem from "./stepLog";
export default class JobLogTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
static contextValue = 'githubLocalActions.jobLog';
jobLog: JobLog;
constructor(jobLog: JobLog) {
super(jobLog.name, TreeItemCollapsibleState.Collapsed);
this.jobLog = jobLog;
this.contextValue = JobLogTreeItem.contextValue;
this.iconPath = new ThemeIcon('pass-filled');
// this.tooltip = `Name: ${workflow.name}\n` +
// `Path: ${workflow.uri.fsPath}\n` +
// (workflow.error ? `Error: ${workflow.error}` : ``);
// TODO: Add tooltip and resourceUri
}
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
const stepLogs = this.jobLog.stepLogs;
if (stepLogs) {
return this.jobLog.stepLogs.map(step => new StepTreeItem(step));
} else {
return [];
}
}
}

View File

@@ -0,0 +1,24 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
import { StepLog } from "../../act";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
export default class StepLogTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
static contextValue = 'githubLocalActions.stepLog';
stepLog: StepLog;
constructor(stepLog: StepLog) {
super(stepLog.name, TreeItemCollapsibleState.None);
this.stepLog = stepLog;
this.contextValue = StepLogTreeItem.contextValue;
this.iconPath = new ThemeIcon('pass-filled');
// this.tooltip = `Name: ${workflow.name}\n` +
// `Path: ${workflow.uri.fsPath}\n` +
// (workflow.error ? `Error: ${workflow.error}` : ``);
// TODO: Add tooltip and resourceUri
}
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
return [];
}
}

View File

@@ -1,6 +1,8 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from "vscode";
import { act } from "../../extension";
import { Workflow } from "../../workflowsManager";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
import WorkflowLogTreeItem from "./workflowLog";
export default class WorkflowTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
static contextValue = 'githubLocalActions.workflow';
@@ -15,12 +17,17 @@ export default class WorkflowTreeItem extends TreeItem implements GithubLocalAct
`Path: ${workflow.uri.fsPath}\n` +
(workflow.error ? `Error: ${workflow.error}` : ``);
if(workflow.error) {
if (workflow.error) {
this.resourceUri = Uri.parse(`${WorkflowTreeItem.contextValue}:${workflow.name}?error=${workflow.error}`, true);
}
}
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
return [];
const workflowLogs = act.workflowLogs[this.workflow.uri.fsPath];
if (workflowLogs) {
return workflowLogs.map(workflowLog => new WorkflowLogTreeItem(workflowLog));
} else {
return [];
}
}
}

View File

@@ -0,0 +1,25 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
import { WorkflowLog } from "../../act";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
import JobLogTreeItem from "./jobLog";
export default class WorkflowLogTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
static contextValue = 'githubLocalActions.workflowLog';
workflowLog: WorkflowLog;
constructor(workflowLog: WorkflowLog) {
super(workflowLog.name, TreeItemCollapsibleState.Collapsed);
this.workflowLog = workflowLog;
this.contextValue = WorkflowLogTreeItem.contextValue;
this.iconPath = new ThemeIcon('pass-filled');
// this.tooltip = `Name: ${workflow.name}\n` +
// `Path: ${workflow.uri.fsPath}\n` +
// (workflow.error ? `Error: ${workflow.error}` : ``);
// TODO: Add tooltip and resourceUri
}
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
return this.workflowLog.jobLogs.map(jobLog => new JobLogTreeItem(jobLog));
}
}