Major refactoring to use ShellExecution

Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
Sanjula Ganepola
2024-11-16 19:56:01 -05:00
parent 4e95a0bdcd
commit 13b8eb92bd
6 changed files with 139 additions and 224 deletions

View File

@@ -8,12 +8,17 @@ export default class HistoryTreeItem extends TreeItem implements GithubLocalActi
history: History;
constructor(public workspaceFolder: WorkspaceFolder, history: History) {
super(history.name, TreeItemCollapsibleState.None);
super(`${history.name} #${history.count}`, TreeItemCollapsibleState.None);
this.history = history;
let endTime: string | undefined;
let totalDuration: string | undefined;
if (history.date) {
totalDuration = Utils.getTimeDuration(history.date.start, history.date.end);
if (history.date.end) {
endTime = history.date.end;
totalDuration = Utils.getTimeDuration(history.date.start, endTime);
} else if (history.status == HistoryStatus.Running) {
endTime = new Date().toString();
totalDuration = Utils.getTimeDuration(history.date.start, endTime);
}
this.description = totalDuration;
@@ -34,9 +39,9 @@ export default class HistoryTreeItem extends TreeItem implements GithubLocalActi
}
this.tooltip = `Name: ${history.name}\n` +
`Status: ${history.status}\n` +
`Started: ${history.date ? Utils.getDateString(history.date.start) : 'N/A'}\n` +
`Ended: ${history.date ? Utils.getDateString(history.date.end) : 'N/A'}\n` +
(totalDuration ? `Total Duration: ${totalDuration}\n` : ``);
`Started: ${Utils.getDateString(history.date.start)}\n` +
`Ended: ${endTime ? Utils.getDateString(endTime) : 'N/A'}\n` +
`Total Duration: ${totalDuration ? totalDuration : 'N/A'}`;
}
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {

View File

@@ -71,13 +71,19 @@ export default class HistoryTreeDataProvider implements TreeDataProvider<GithubL
if (workspaceFolders) {
if (workspaceFolders.length === 1) {
items.push(...await new WorkspaceFolderHistoryTreeItem(workspaceFolders[0]).getChildren());
const workspaceHistory = act.historyManager.workspaceHistory[workspaceFolders[0].uri.fsPath];
if (workspaceHistory.length > 0) {
isRunning = act.historyManager.workspaceHistory[workspaceFolders[0].uri.fsPath].find(workspaceHistory => workspaceHistory.status === HistoryStatus.Running) !== undefined;
noHistory = false;
}
} else if (workspaceFolders.length > 1) {
for (const workspaceFolder of workspaceFolders) {
items.push(new WorkspaceFolderHistoryTreeItem(workspaceFolder));
const workspaceHistory = act.historyManager.workspaceHistory[workspaceFolders[0].uri.fsPath];
const workspaceHistory = act.historyManager.workspaceHistory[workspaceFolder.uri.fsPath];
if (workspaceHistory.length > 0) {
isRunning = act.historyManager.workspaceHistory[workspaceFolders[0].uri.fsPath].find(workspaceHistory => workspaceHistory.status === HistoryStatus.Running) !== undefined;
isRunning = act.historyManager.workspaceHistory[workspaceFolder.uri.fsPath].find(workspaceHistory => workspaceHistory.status === HistoryStatus.Running) !== undefined;
noHistory = false;
}
}

View File

@@ -63,6 +63,11 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
if (workspaceFolders) {
if (workspaceFolders.length === 1) {
items.push(...await new WorkspaceFolderSettingsTreeItem(workspaceFolders[0]).getChildren());
const workflows = await act.workflowsManager.getWorkflows(workspaceFolders[0]);
if (workflows.length > 0) {
noSettings = false;
}
} else if (workspaceFolders.length > 1) {
for (const workspaceFolder of workspaceFolders) {
items.push(new WorkspaceFolderSettingsTreeItem(workspaceFolder));

View File

@@ -76,6 +76,11 @@ export default class WorkflowsTreeDataProvider implements TreeDataProvider<Githu
if (workspaceFolders) {
if (workspaceFolders.length === 1) {
items.push(...await new WorkspaceFolderWorkflowsTreeItem(workspaceFolders[0]).getChildren());
const workflows = await act.workflowsManager.getWorkflows(workspaceFolders[0]);
if (workflows.length > 0) {
noWorkflows = false;
}
} else if (workspaceFolders.length > 1) {
for (const workspaceFolder of workspaceFolders) {
items.push(new WorkspaceFolderWorkflowsTreeItem(workspaceFolder));