Add run workflow support

Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
Sanjula Ganepola
2024-09-26 22:22:56 -04:00
parent e96159f211
commit 7bd3c448c2
14 changed files with 142 additions and 51 deletions

View File

@@ -1,9 +1,9 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri } from "vscode";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
import { Component } from "../../componentManager";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
export default class ComponentTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
static contextValue = 'component';
static contextValue = 'githubLocalActions.component';
component: Component;
constructor(component: Component) {

View File

@@ -6,12 +6,9 @@ import ComponentTreeItem from "./component";
export default class ComponentsTreeDataProvider implements TreeDataProvider<GithubLocalActionsTreeItem> {
private _onDidChangeTreeData = new EventEmitter<GithubLocalActionsTreeItem | undefined | null | void>();
readonly onDidChangeTreeData = this._onDidChangeTreeData.event;
public static VIEW_ID = 'components';
private componentManager: ComponentManager;
static VIEW_ID = 'components';
constructor(context: ExtensionContext) {
this.componentManager = new ComponentManager();
context.subscriptions.push(
commands.registerCommand('githubLocalActions.refreshComponents', async () => {
this.refresh();
@@ -39,7 +36,7 @@ export default class ComponentsTreeDataProvider implements TreeDataProvider<Gith
if (element) {
return element.getChildren();
} else {
const components = await this.componentManager.getComponents();
const components = await ComponentManager.getComponents();
return components.map(component => new ComponentTreeItem(component));
}
}

View File

@@ -1,5 +1,5 @@
import { CancellationToken, Event, FileDecoration, FileDecorationProvider, ProviderResult, ThemeColor, Uri } from "vscode";
import { Status } from "../types";
import { Status } from "../componentManager";
import ComponentTreeItem from "./components/component";
import WorkflowTreeItem from "./workflows/workflow";

View File

@@ -2,7 +2,7 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
export default class EnvironmentsTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
static contextValue = 'environments';
static contextValue = 'githubLocalActions.environments';
constructor() {
super('Environments', TreeItemCollapsibleState.Collapsed);

View File

@@ -2,7 +2,7 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
export default class SecretsTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
static contextValue = 'secrets';
static contextValue = 'githubLocalActions.secrets';
constructor() {
super('Secrets', TreeItemCollapsibleState.Collapsed);

View File

@@ -7,7 +7,7 @@ import VariablesTreeItem from "./variables";
export default class SettingsTreeDataProvider implements TreeDataProvider<GithubLocalActionsTreeItem> {
private _onDidChangeTreeData = new EventEmitter<GithubLocalActionsTreeItem | undefined | null | void>();
readonly onDidChangeTreeData = this._onDidChangeTreeData.event;
public static VIEW_ID = 'settings';
static VIEW_ID = 'settings';
constructor(context: ExtensionContext) {
context.subscriptions.push(

View File

@@ -2,7 +2,7 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
export default class VariablesTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
static contextValue = 'variables';
static contextValue = 'githubLocalActions.variables';
constructor() {
super('Variables', TreeItemCollapsibleState.Collapsed);

View File

@@ -3,7 +3,7 @@ import { Workflow } from "../../workflowManager";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
export default class WorkflowTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
static contextValue = 'workflow';
static contextValue = 'githubLocalActions.workflow';
workflow: Workflow;
constructor(workflow: Workflow) {

View File

@@ -1,4 +1,5 @@
import { CancellationToken, commands, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, window, workspace } from "vscode";
import { Act } from "../../act";
import { WorkflowManager } from "../../workflowManager";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
import WorkflowTreeItem from "./workflow";
@@ -6,13 +7,13 @@ import WorkflowTreeItem from "./workflow";
export default class WorkflowsTreeDataProvider implements TreeDataProvider<GithubLocalActionsTreeItem> {
private _onDidChangeTreeData = new EventEmitter<GithubLocalActionsTreeItem | undefined | null | void>();
readonly onDidChangeTreeData = this._onDidChangeTreeData.event;
public static VIEW_ID = 'workflows';
private workflowManager: WorkflowManager;
static VIEW_ID = 'workflows';
constructor(context: ExtensionContext) {
this.workflowManager = new WorkflowManager();
context.subscriptions.push(
commands.registerCommand('githubLocalActions.runAllWorkflows', async () => {
await Act.runAllWorkflows();
}),
commands.registerCommand('githubLocalActions.refreshWorkflows', async () => {
this.refresh();
}),
@@ -21,7 +22,7 @@ export default class WorkflowsTreeDataProvider implements TreeDataProvider<Githu
await window.showTextDocument(document);
}),
commands.registerCommand('githubLocalActions.runWorkflow', async (workflowTreeItem: WorkflowTreeItem) => {
await Act.runWorkflow(workflowTreeItem.workflow);
})
);
}
@@ -46,7 +47,7 @@ export default class WorkflowsTreeDataProvider implements TreeDataProvider<Githu
if (element) {
return element.getChildren();
} else {
const workflows = await this.workflowManager.getWorkflows();
const workflows = await WorkflowManager.getWorkflows();
return workflows.map(workflow => new WorkflowTreeItem(workflow));
}
}