Add multi-workspace support
Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { ThemeColor, ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||
import { DateUtils } from "../../dateUtils";
|
||||
import { History, HistoryStatus } from "../../historyManager";
|
||||
import { Utils } from "../../utils";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
|
||||
export default class HistoryTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
@@ -13,7 +13,7 @@ export default class HistoryTreeItem extends TreeItem implements GithubLocalActi
|
||||
|
||||
let totalDuration: string | undefined;
|
||||
if (history.date) {
|
||||
totalDuration = DateUtils.getTimeDuration(history.date.start, history.date.end);
|
||||
totalDuration = Utils.getTimeDuration(history.date.start, history.date.end);
|
||||
}
|
||||
|
||||
this.description = totalDuration;
|
||||
@@ -34,8 +34,8 @@ export default class HistoryTreeItem extends TreeItem implements GithubLocalActi
|
||||
}
|
||||
this.tooltip = `Name: ${history.name}\n` +
|
||||
`Status: ${history.status}\n` +
|
||||
`Started: ${history.date ? DateUtils.getDateString(history.date.start) : 'N/A'}\n` +
|
||||
`Ended: ${history.date ? DateUtils.getDateString(history.date.end) : 'N/A'}\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` : ``);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { CancellationToken, commands, EventEmitter, ExtensionContext, extensions, TreeDataProvider, TreeItem, workspace } from "vscode";
|
||||
import { act } from "../../extension";
|
||||
import { HistoryStatus } from "../../historyManager";
|
||||
import { Utils } from "../../utils";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
import HistoryTreeItem from "./history";
|
||||
import WorkspaceFolderHistoryTreeItem from "./workspaceFolderHistory";
|
||||
@@ -16,8 +17,11 @@ export default class HistoryTreeDataProvider implements TreeDataProvider<GithubL
|
||||
});
|
||||
|
||||
context.subscriptions.push(
|
||||
commands.registerCommand('githubLocalActions.clearAll', async () => {
|
||||
await act.historyManager.clearAll();
|
||||
commands.registerCommand('githubLocalActions.clearAll', async (workspaceFolderHistoryTreeItem?: WorkspaceFolderHistoryTreeItem) => {
|
||||
const workspaceFolder = await Utils.getWorkspaceFolder(workspaceFolderHistoryTreeItem?.workspaceFolder);
|
||||
if (workspaceFolder) {
|
||||
await act.historyManager.clearAll(workspaceFolder);
|
||||
}
|
||||
}),
|
||||
commands.registerCommand('githubLocalActions.refreshHistory', async () => {
|
||||
this.refresh();
|
||||
@@ -65,13 +69,17 @@ export default class HistoryTreeDataProvider implements TreeDataProvider<GithubL
|
||||
|
||||
const workspaceFolders = workspace.workspaceFolders;
|
||||
if (workspaceFolders) {
|
||||
for (const workspaceFolder of workspaceFolders) {
|
||||
items.push(new WorkspaceFolderHistoryTreeItem(workspaceFolder));
|
||||
if (workspaceFolders.length === 1) {
|
||||
return await new WorkspaceFolderHistoryTreeItem(workspaceFolders[0]).getChildren();
|
||||
} else if (workspaceFolders.length > 1) {
|
||||
for (const workspaceFolder of workspaceFolders) {
|
||||
items.push(new WorkspaceFolderHistoryTreeItem(workspaceFolder));
|
||||
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,12 +61,16 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
|
||||
|
||||
const workspaceFolders = workspace.workspaceFolders;
|
||||
if (workspaceFolders) {
|
||||
for (const workspaceFolder of workspaceFolders) {
|
||||
items.push(new WorkspaceFolderSettingsTreeItem(workspaceFolder));
|
||||
if (workspaceFolders.length === 1) {
|
||||
return await new WorkspaceFolderSettingsTreeItem(workspaceFolders[0]).getChildren();
|
||||
} else if (workspaceFolders.length > 1) {
|
||||
for (const workspaceFolder of workspaceFolders) {
|
||||
items.push(new WorkspaceFolderSettingsTreeItem(workspaceFolder));
|
||||
|
||||
const workflows = await act.workflowsManager.getWorkflows(workspaceFolder);
|
||||
if (workflows.length > 0) {
|
||||
noSettings = false;
|
||||
const workflows = await act.workflowsManager.getWorkflows(workspaceFolder);
|
||||
if (workflows.length > 0) {
|
||||
noSettings = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { CancellationToken, commands, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, window, workspace } from "vscode";
|
||||
import { Event } from "../../act";
|
||||
import { act } from "../../extension";
|
||||
import { Utils } from "../../utils";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
import JobTreeItem from "./job";
|
||||
import WorkflowTreeItem from "./workflow";
|
||||
import WorkspaceFolderWorkflowsTreeItem from "./workspaceFolderWorkflows";
|
||||
|
||||
@@ -12,18 +14,23 @@ export default class WorkflowsTreeDataProvider implements TreeDataProvider<Githu
|
||||
|
||||
constructor(context: ExtensionContext) {
|
||||
context.subscriptions.push(
|
||||
commands.registerCommand('githubLocalActions.runAllWorkflows', async () => {
|
||||
await act.runAllWorkflows();
|
||||
commands.registerCommand('githubLocalActions.runAllWorkflows', async (workspaceFolderWorkflowsTreeItem?: WorkspaceFolderWorkflowsTreeItem) => {
|
||||
const workspaceFolder = await Utils.getWorkspaceFolder(workspaceFolderWorkflowsTreeItem?.workspaceFolder);
|
||||
if (workspaceFolder) {
|
||||
await act.runAllWorkflows(workspaceFolder);
|
||||
}
|
||||
}),
|
||||
commands.registerCommand('githubLocalActions.runEvent', async () => {
|
||||
const event = await window.showQuickPick(Object.values(Event), {
|
||||
title: 'Select the event to run',
|
||||
placeHolder: 'Event'
|
||||
});
|
||||
commands.registerCommand('githubLocalActions.runEvent', async (workspaceFolderWorkflowsTreeItem?: WorkspaceFolderWorkflowsTreeItem) => {
|
||||
const workspaceFolder = await Utils.getWorkspaceFolder(workspaceFolderWorkflowsTreeItem?.workspaceFolder);
|
||||
if (workspaceFolder) {
|
||||
const event = await window.showQuickPick(Object.values(Event), {
|
||||
title: 'Select the event to run',
|
||||
placeHolder: 'Event'
|
||||
});
|
||||
|
||||
if (event) {
|
||||
// TODO: Implement running event
|
||||
// await act.runEvent(event as Event);
|
||||
if (event) {
|
||||
await act.runEvent(workspaceFolder, event as Event);
|
||||
}
|
||||
}
|
||||
}),
|
||||
commands.registerCommand('githubLocalActions.refreshWorkflows', async () => {
|
||||
@@ -34,11 +41,10 @@ export default class WorkflowsTreeDataProvider implements TreeDataProvider<Githu
|
||||
await window.showTextDocument(document);
|
||||
}),
|
||||
commands.registerCommand('githubLocalActions.runWorkflow', async (workflowTreeItem: WorkflowTreeItem) => {
|
||||
await act.runWorkflow(workflowTreeItem.workflow);
|
||||
await act.runWorkflow(workflowTreeItem.workspaceFolder, workflowTreeItem.workflow);
|
||||
}),
|
||||
commands.registerCommand('githubLocalActions.runJob', async (workflowTreeItem: WorkflowTreeItem) => {
|
||||
// TODO: Implement running job
|
||||
// await act.runJob()
|
||||
commands.registerCommand('githubLocalActions.runJob', async (jobTreeItem: JobTreeItem) => {
|
||||
await act.runJob(jobTreeItem.workspaceFolder, jobTreeItem.workflow, jobTreeItem.job);
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -68,15 +74,18 @@ export default class WorkflowsTreeDataProvider implements TreeDataProvider<Githu
|
||||
|
||||
const workspaceFolders = workspace.workspaceFolders;
|
||||
if (workspaceFolders) {
|
||||
for (const workspaceFolder of workspaceFolders) {
|
||||
items.push(new WorkspaceFolderWorkflowsTreeItem(workspaceFolder));
|
||||
if (workspaceFolders.length === 1) {
|
||||
return await new WorkspaceFolderWorkflowsTreeItem(workspaceFolders[0]).getChildren();
|
||||
} else if (workspaceFolders.length > 1) {
|
||||
for (const workspaceFolder of workspaceFolders) {
|
||||
items.push(new WorkspaceFolderWorkflowsTreeItem(workspaceFolder));
|
||||
|
||||
const workflows = await act.workflowsManager.getWorkflows(workspaceFolder);
|
||||
if (workflows.length > 0) {
|
||||
noWorkflows = false;
|
||||
const workflows = await act.workflowsManager.getWorkflows(workspaceFolder);
|
||||
if (workflows.length > 0) {
|
||||
noWorkflows = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
await commands.executeCommand('setContext', 'githubLocalActions:noWorkflows', noWorkflows);
|
||||
|
||||
Reference in New Issue
Block a user