Add settings view
Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
17
src/views/settings/environment.ts
Normal file
17
src/views/settings/environment.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
|
||||
import { Environment } from "../../settingsManager";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
|
||||
export default class EnvironmentTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.environment';
|
||||
|
||||
constructor(environment: Environment) {
|
||||
super(environment.name, TreeItemCollapsibleState.None);
|
||||
this.contextValue = EnvironmentTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('server');
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
|
||||
import { act } from "../../extension";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
import EnvironmentTreeItem from "./environment";
|
||||
|
||||
export default class EnvironmentsTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.environments';
|
||||
@@ -11,6 +13,8 @@ export default class EnvironmentsTreeItem extends TreeItem implements GithubLoca
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
return [];
|
||||
const workflows = await act.workflowsManager.getWorkflows();
|
||||
const environments = [...new Set(workflows.map(workflow => act.settingsManager.getEnvironments(workflow)).flat())];
|
||||
return environments.map(environment => new EnvironmentTreeItem(environment));
|
||||
}
|
||||
}
|
||||
18
src/views/settings/input.ts
Normal file
18
src/views/settings/input.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
|
||||
import { Input } from "../../settingsManager";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
|
||||
export default class InputTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.input';
|
||||
|
||||
constructor(input: Input) {
|
||||
super(input.key, TreeItemCollapsibleState.None);
|
||||
this.description = input.value;
|
||||
this.contextValue = InputTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('symbol-parameter');
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
20
src/views/settings/inputs.ts
Normal file
20
src/views/settings/inputs.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
|
||||
import { act } from "../../extension";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
import InputTreeItem from "./input";
|
||||
|
||||
export default class InputsTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.inputs';
|
||||
|
||||
constructor() {
|
||||
super('Inputs', TreeItemCollapsibleState.Collapsed);
|
||||
this.contextValue = InputsTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('record-keys');
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
const workflows = await act.workflowsManager.getWorkflows();
|
||||
const inputs = [...new Set(workflows.map(workflow => act.settingsManager.getInputs(workflow)).flat())];
|
||||
return inputs.map(input => new InputTreeItem(input));
|
||||
}
|
||||
}
|
||||
18
src/views/settings/secret.ts
Normal file
18
src/views/settings/secret.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
|
||||
import { Secret } from "../../settingsManager";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
|
||||
export default class SecretTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.secret';
|
||||
|
||||
constructor(secret: Secret) {
|
||||
super(secret.key, TreeItemCollapsibleState.None);
|
||||
this.description = secret.value;
|
||||
this.contextValue = SecretTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('key');
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
|
||||
import { act } from "../../extension";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
import SecretTreeItem from "./secret";
|
||||
|
||||
export default class SecretsTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.secrets';
|
||||
@@ -11,6 +13,8 @@ export default class SecretsTreeItem extends TreeItem implements GithubLocalActi
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
return [];
|
||||
const workflows = await act.workflowsManager.getWorkflows();
|
||||
const secrets = [...new Set(workflows.map(workflow => act.settingsManager.getSecrets(workflow)).flat())];
|
||||
return secrets.map(secret => new SecretTreeItem(secret));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { CancellationToken, commands, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem } from "vscode";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
import EnvironmentsTreeItem from "./environments";
|
||||
import InputsTreeItem from "./inputs";
|
||||
import SecretsTreeItem from "./secrets";
|
||||
import VariablesTreeItem from "./variables";
|
||||
|
||||
@@ -40,7 +41,8 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
|
||||
return [
|
||||
new EnvironmentsTreeItem(),
|
||||
new SecretsTreeItem(),
|
||||
new VariablesTreeItem()
|
||||
new VariablesTreeItem(),
|
||||
new InputsTreeItem()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
18
src/views/settings/variable.ts
Normal file
18
src/views/settings/variable.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
|
||||
import { Variable } from "../../settingsManager";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
|
||||
export default class VariableTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.variable';
|
||||
|
||||
constructor(variable: Variable) {
|
||||
super(variable.key, TreeItemCollapsibleState.None);
|
||||
this.description = variable.value;
|
||||
this.contextValue = VariableTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('symbol-variable');
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState } from "vscode";
|
||||
import { act } from "../../extension";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
import VariableTreeItem from "./variable";
|
||||
|
||||
export default class VariablesTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.variables';
|
||||
@@ -11,6 +13,8 @@ export default class VariablesTreeItem extends TreeItem implements GithubLocalAc
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
return [];
|
||||
const workflows = await act.workflowsManager.getWorkflows();
|
||||
const variables = [...new Set(workflows.map(workflow => act.settingsManager.getVariables(workflow)).flat())];
|
||||
return variables.map(variable => new VariableTreeItem(variable));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user