init settings view and refresh action

Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
Sanjula Ganepola
2024-09-26 20:19:24 -04:00
parent 003d2c39b4
commit 800420307d
8 changed files with 170 additions and 10 deletions

View File

@@ -1,4 +1,4 @@
import { CancellationToken, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem } from "vscode";
import { CancellationToken, commands, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem } from "vscode";
import { ComponentManager } from "../componentManager";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
import ComponentTreeItem from "./component";
@@ -11,6 +11,12 @@ export default class ComponentsTreeDataProvider implements TreeDataProvider<Gith
constructor(context: ExtensionContext) {
this.componentManager = new ComponentManager();
context.subscriptions.push(
commands.registerCommand('githubLocalActions.refreshComponents', async () => {
this.refresh();
}),
);
}
refresh(element?: GithubLocalActionsTreeItem) {

View File

@@ -0,0 +1,16 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
export default class EnvironmentsTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
static contextValue = 'environments';
constructor() {
super('Environments', TreeItemCollapsibleState.Collapsed);
this.contextValue = EnvironmentsTreeItem.contextValue;
this.iconPath = new ThemeIcon('server-environment');
}
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
return [];
}
}

View File

@@ -0,0 +1,16 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
export default class SecretsTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
static contextValue = 'secrets';
constructor() {
super('Secrets', TreeItemCollapsibleState.Collapsed);
this.contextValue = SecretsTreeItem.contextValue;
this.iconPath = new ThemeIcon('lock');
}
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
return [];
}
}

View File

@@ -0,0 +1,47 @@
import { CancellationToken, commands, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem } from "vscode";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
import EnvironmentsTreeItem from "./environments";
import SecretsTreeItem from "./secrets";
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';
constructor(context: ExtensionContext) {
context.subscriptions.push(
commands.registerCommand('githubLocalActions.refreshSettings', async () => {
this.refresh();
}),
);
}
refresh(element?: GithubLocalActionsTreeItem) {
this._onDidChangeTreeData.fire(element);
}
getTreeItem(element: GithubLocalActionsTreeItem): GithubLocalActionsTreeItem | Thenable<GithubLocalActionsTreeItem> {
return element;
}
async resolveTreeItem(item: TreeItem, element: GithubLocalActionsTreeItem, token: CancellationToken): Promise<GithubLocalActionsTreeItem> {
if (element.getToolTip) {
element.tooltip = await element.getToolTip();
}
return element;
}
async getChildren(element?: GithubLocalActionsTreeItem): Promise<GithubLocalActionsTreeItem[]> {
if (element) {
return element.getChildren();
} else {
return [
new EnvironmentsTreeItem(),
new SecretsTreeItem(),
new VariablesTreeItem()
];
}
}
}

View File

@@ -0,0 +1,16 @@
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
export default class VariablesTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
static contextValue = 'variables';
constructor() {
super('Variables', TreeItemCollapsibleState.Collapsed);
this.contextValue = VariablesTreeItem.contextValue;
this.iconPath = new ThemeIcon('symbol-key');
}
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
return [];
}
}

View File

@@ -1,4 +1,4 @@
import { CancellationToken, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem } from "vscode";
import { CancellationToken, commands, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem } from "vscode";
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
import { WorkflowManager } from "../workflowManager";
import WorkflowTreeItem from "./workflow";
@@ -11,6 +11,12 @@ export default class WorkflowsTreeDataProvider implements TreeDataProvider<Githu
constructor(context: ExtensionContext) {
this.workflowManager = new WorkflowManager();
context.subscriptions.push(
commands.registerCommand('githubLocalActions.refreshWorkflows', async () => {
this.refresh();
}),
);
}
refresh(element?: GithubLocalActionsTreeItem) {