init settings view and refresh action
Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
16
src/views/settings/environments.ts
Normal file
16
src/views/settings/environments.ts
Normal 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 [];
|
||||
}
|
||||
}
|
||||
16
src/views/settings/secrets.ts
Normal file
16
src/views/settings/secrets.ts
Normal 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 [];
|
||||
}
|
||||
}
|
||||
47
src/views/settings/settingsTreeDataProvider.ts
Normal file
47
src/views/settings/settingsTreeDataProvider.ts
Normal 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()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
16
src/views/settings/variables.ts
Normal file
16
src/views/settings/variables.ts
Normal 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 [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user