Add history view, rework to use history status, remove old classes

Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
Sanjula Ganepola
2024-10-17 19:38:47 -04:00
parent 05caeafbb2
commit 0e6baaaad1
13 changed files with 368 additions and 218 deletions

View File

@@ -0,0 +1,46 @@
import { ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
import { History, HistoryStatus } from "../../act";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
export default class HistoryTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
static contextValue = 'githubLocalActions.history';
history: History;
constructor(history: History) {
super(history.name, TreeItemCollapsibleState.None);
this.history = history;
let totalDuration: string | undefined;
if (history.start) {
const start = new Date(history.start).getTime();
const end = history.end ? new Date(history.end).getTime() : new Date().getTime();
totalDuration = `${((end - start) / 1000).toFixed(0).toString()}s`;
this.description = totalDuration;
}
this.contextValue = `${HistoryTreeItem.contextValue}_${history.status}`;
switch (history.status) {
case HistoryStatus.Running:
this.iconPath = new ThemeIcon('loading~spin');
break;
case HistoryStatus.Success:
this.iconPath = new ThemeIcon('pass', new ThemeColor('GitHubLocalActions.green'));
break;
case HistoryStatus.Failed:
this.iconPath = new ThemeIcon('error', new ThemeColor('GitHubLocalActions.red'));
break;
case HistoryStatus.Cancelled:
this.iconPath = new ThemeIcon('circle-slash', new ThemeColor('GitHubLocalActions.yellow'));
break;
}
this.tooltip = `Name: ${history.name}\n` +
`Status: ${history.status}\n` +
`Started: ${history.start ? history.start : 'N/A'}\n` +
`Ended: ${history.end ? history.end : 'N/A'}\n` +
(totalDuration ? `Total Duration: ${totalDuration}\n` : ``);
}
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
return [];
}
}