Add clear all, restart, stop, remove actions for history

Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
Sanjula Ganepola
2024-10-17 21:30:04 -04:00
parent 0e6baaaad1
commit f215c03697
4 changed files with 220 additions and 60 deletions

View File

@@ -1,4 +1,5 @@
import { CancellationToken, commands, EventEmitter, ExtensionContext, extensions, TreeDataProvider, TreeItem, workspace } from "vscode";
import { HistoryStatus } from "../../act";
import { act } from "../../extension";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
import HistoryTreeItem from "./history";
@@ -14,8 +15,20 @@ export default class HistoryTreeDataProvider implements TreeDataProvider<GithubL
});
context.subscriptions.push(
commands.registerCommand('githubLocalActions.clearAll', async () => {
await act.clearAll();
}),
commands.registerCommand('githubLocalActions.refreshHistory', async () => {
this.refresh();
}),
commands.registerCommand('githubLocalActions.restart', async (historyTreeItem: HistoryTreeItem) => {
await act.runCommand(historyTreeItem.history.commandArgs);
}),
commands.registerCommand('githubLocalActions.stop', async (historyTreeItem: HistoryTreeItem) => {
await act.stop(historyTreeItem.history);
}),
commands.registerCommand('githubLocalActions.remove', async (historyTreeItem: HistoryTreeItem) => {
await act.remove(historyTreeItem.history);
})
);
}
@@ -43,15 +56,22 @@ export default class HistoryTreeDataProvider implements TreeDataProvider<GithubL
const items: GithubLocalActionsTreeItem[] = [];
const workspaceFolders = workspace.workspaceFolders;
let isRunning: boolean = false;
if (workspaceFolders && workspaceFolders.length > 0) {
const workspaceHistory = act.workspaceHistory[workspaceFolders[0].uri.fsPath]; //TODO: Fix for multi workspace support
//TODO: Fix for multi workspace support
const workspaceHistory = act.workspaceHistory[workspaceFolders[0].uri.fsPath];
if (workspaceHistory) {
for (const history of workspaceHistory) {
items.push(new HistoryTreeItem(history));
if (history.status === HistoryStatus.Running) {
isRunning = true;
}
}
}
}
await commands.executeCommand('setContext', 'githubLocalActions:isRunning', isRunning);
await commands.executeCommand('setContext', 'githubLocalActions:noHistory', items.length == 0);
return items;
}