Add secrets, variables, and inputs to storage
Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||
import { ContainerEngine } from "../../settingsManager";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
|
||||
export default class ContainerEngineTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.containerEngine';
|
||||
|
||||
constructor(public workspaceFolder: WorkspaceFolder, containerEngine: ContainerEngine) {
|
||||
super(containerEngine.key, TreeItemCollapsibleState.None);
|
||||
this.description = containerEngine.value;
|
||||
this.contextValue = ContainerEngineTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('code');
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||
import { act } from "../../extension";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
import ContainerEngineTreeItem from "./containerEngine";
|
||||
|
||||
export default class ContainerEnginesTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.containerEngines';
|
||||
|
||||
constructor(public workspaceFolder: WorkspaceFolder) {
|
||||
super('Container Engines', TreeItemCollapsibleState.Collapsed);
|
||||
this.contextValue = ContainerEnginesTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('server-process');
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
const items: GithubLocalActionsTreeItem[] = [];
|
||||
|
||||
const containerEngines = act.settingsManager.getSettings(this.workspaceFolder).containerEngines;
|
||||
for (const containerEngine of containerEngines) {
|
||||
items.push(new ContainerEngineTreeItem(this.workspaceFolder, containerEngine));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,11 @@ import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
|
||||
export default class EnvironmentTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.environment';
|
||||
environment: Environment;
|
||||
|
||||
constructor(public workspaceFolder: WorkspaceFolder, environment: Environment) {
|
||||
super(environment.name, TreeItemCollapsibleState.None);
|
||||
this.environment = environment;
|
||||
this.contextValue = EnvironmentTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('server');
|
||||
}
|
||||
|
||||
@@ -13,8 +13,13 @@ export default class EnvironmentsTreeItem extends TreeItem implements GithubLoca
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
const workflows = await act.workflowsManager.getWorkflows(this.workspaceFolder);
|
||||
const environments = [...new Set(workflows.map(workflow => act.settingsManager.getEnvironments(workflow)).flat())];
|
||||
return environments.map(environment => new EnvironmentTreeItem(this.workspaceFolder, environment));
|
||||
const items: GithubLocalActionsTreeItem[] = [];
|
||||
|
||||
const environments = await act.settingsManager.getEnvironments(this.workspaceFolder);
|
||||
for (const environment of environments) {
|
||||
items.push(new EnvironmentTreeItem(this.workspaceFolder, environment));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,15 @@ import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
|
||||
export default class InputTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.input';
|
||||
input: Input
|
||||
|
||||
constructor(public workspaceFolder: WorkspaceFolder, input: Input) {
|
||||
super(input.key, TreeItemCollapsibleState.None);
|
||||
this.input = input;
|
||||
this.description = input.value;
|
||||
this.contextValue = InputTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('symbol-parameter');
|
||||
this.checkboxState = TreeItemCheckboxState.Unchecked;
|
||||
this.checkboxState = input.selected ? TreeItemCheckboxState.Checked : TreeItemCheckboxState.Unchecked;
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||
import { act } from "../../extension";
|
||||
import { StorageKey } from "../../storageManager";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
import InputTreeItem from "./input";
|
||||
|
||||
@@ -13,8 +14,13 @@ export default class InputsTreeItem extends TreeItem implements GithubLocalActio
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
const workflows = await act.workflowsManager.getWorkflows(this.workspaceFolder);
|
||||
const inputs = [...new Set(workflows.map(workflow => act.settingsManager.getInputs(workflow)).flat())];
|
||||
return inputs.map(input => new InputTreeItem(this.workspaceFolder, input));
|
||||
const items: GithubLocalActionsTreeItem[] = [];
|
||||
|
||||
const inputs = await act.settingsManager.getSetting(this.workspaceFolder, /\${{\s*(?:inputs|github\.event\.inputs)\.(.*?)(?:\s*==\s*(.*?))?\s*}}/g, StorageKey.Inputs);
|
||||
for (const input of inputs) {
|
||||
items.push(new InputTreeItem(this.workspaceFolder, input));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,15 @@ import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
|
||||
export default class SecretTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.secret';
|
||||
secret: Secret;
|
||||
|
||||
constructor(public workspaceFolder: WorkspaceFolder, secret: Secret) {
|
||||
super(secret.key, TreeItemCollapsibleState.None);
|
||||
this.secret = secret;
|
||||
this.description = secret.value ? '••••••••' : '';
|
||||
this.contextValue = SecretTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('key');
|
||||
this.checkboxState = TreeItemCheckboxState.Unchecked;
|
||||
this.checkboxState = secret.selected ? TreeItemCheckboxState.Checked : TreeItemCheckboxState.Unchecked;
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||
import { act } from "../../extension";
|
||||
import { StorageKey } from "../../storageManager";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
import SecretTreeItem from "./secret";
|
||||
|
||||
@@ -13,8 +14,13 @@ export default class SecretsTreeItem extends TreeItem implements GithubLocalActi
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
const workflows = await act.workflowsManager.getWorkflows(this.workspaceFolder);
|
||||
const secrets = [...new Set(workflows.map(workflow => act.settingsManager.getSecrets(workflow)).flat())];
|
||||
return secrets.map(secret => new SecretTreeItem(this.workspaceFolder, secret));
|
||||
const items: GithubLocalActionsTreeItem[] = [];
|
||||
|
||||
const secrets = await act.settingsManager.getSetting(this.workspaceFolder, /\${{\s*secrets\.(.*?)\s*}}/g, StorageKey.Secrets);
|
||||
for (const secret of secrets) {
|
||||
items.push(new SecretTreeItem(this.workspaceFolder, secret));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { CancellationToken, commands, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, workspace } from "vscode";
|
||||
import { CancellationToken, commands, EventEmitter, ExtensionContext, TreeDataProvider, TreeItem, window, workspace } from "vscode";
|
||||
import { act } from "../../extension";
|
||||
import { StorageKey } from "../../storageManager";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
import ContainerEngineTreeItem from "./containerEngine";
|
||||
import InputTreeItem from "./input";
|
||||
import RunnersTreeItem from "./runners";
|
||||
import SecretTreeItem from "./secret";
|
||||
@@ -19,19 +19,44 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
|
||||
this.refresh();
|
||||
}),
|
||||
commands.registerCommand('githubLocalActions.editSecret', async (secretTreeItem: SecretTreeItem) => {
|
||||
//TODO: Implement
|
||||
const newValue = await window.showInputBox({
|
||||
prompt: `Enter the value for ${secretTreeItem.secret.value}`,
|
||||
placeHolder: `Secret value`,
|
||||
value: secretTreeItem.secret.value,
|
||||
password: true
|
||||
});
|
||||
|
||||
if (newValue) {
|
||||
act.settingsManager.editSetting(secretTreeItem.workspaceFolder, { key: secretTreeItem.secret.key, value: newValue, selected: secretTreeItem.secret.selected }, StorageKey.Secrets);
|
||||
this.refresh();
|
||||
}
|
||||
}),
|
||||
commands.registerCommand('githubLocalActions.editVariable', async (variableTreeItem: VariableTreeItem) => {
|
||||
//TODO: Implement
|
||||
const newValue = await window.showInputBox({
|
||||
prompt: `Enter the value for ${variableTreeItem.variable.value}`,
|
||||
placeHolder: `Variable value`,
|
||||
value: variableTreeItem.variable.value
|
||||
});
|
||||
|
||||
if (newValue) {
|
||||
act.settingsManager.editSetting(variableTreeItem.workspaceFolder, { key: variableTreeItem.variable.key, value: newValue, selected: variableTreeItem.variable.selected }, StorageKey.Variables);
|
||||
this.refresh();
|
||||
}
|
||||
}),
|
||||
commands.registerCommand('githubLocalActions.editInput', async (inputTreeItem: InputTreeItem) => {
|
||||
//TODO: Implement
|
||||
const newValue = await window.showInputBox({
|
||||
prompt: `Enter the value for ${inputTreeItem.input.value}`,
|
||||
placeHolder: `Input value`,
|
||||
value: inputTreeItem.input.value
|
||||
});
|
||||
|
||||
if (newValue) {
|
||||
act.settingsManager.editSetting(inputTreeItem.workspaceFolder, { key: inputTreeItem.input.key, value: newValue, selected: inputTreeItem.input.selected }, StorageKey.Inputs);
|
||||
this.refresh();
|
||||
}
|
||||
}),
|
||||
commands.registerCommand('githubLocalActions.addRunner', async (runnersTreeItem: RunnersTreeItem) => {
|
||||
//TODO: Implement
|
||||
}),
|
||||
commands.registerCommand('githubLocalActions.editContainerEngine', async (containerEngineTreeItem: ContainerEngineTreeItem) => {
|
||||
//TODO: Implement
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -62,7 +87,7 @@ export default class SettingsTreeDataProvider implements TreeDataProvider<Github
|
||||
const workspaceFolders = workspace.workspaceFolders;
|
||||
if (workspaceFolders) {
|
||||
if (workspaceFolders.length === 1) {
|
||||
return await new WorkspaceFolderSettingsTreeItem(workspaceFolders[0]).getChildren();
|
||||
items.push(...await new WorkspaceFolderSettingsTreeItem(workspaceFolders[0]).getChildren());
|
||||
} else if (workspaceFolders.length > 1) {
|
||||
for (const workspaceFolder of workspaceFolders) {
|
||||
items.push(new WorkspaceFolderSettingsTreeItem(workspaceFolder));
|
||||
|
||||
@@ -4,13 +4,15 @@ import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
|
||||
export default class VariableTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.variable';
|
||||
variable: Variable;
|
||||
|
||||
constructor(public workspaceFolder: WorkspaceFolder, variable: Variable) {
|
||||
super(variable.key, TreeItemCollapsibleState.None);
|
||||
this.variable = variable;
|
||||
this.description = variable.value;
|
||||
this.contextValue = VariableTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('symbol-variable');
|
||||
this.checkboxState = TreeItemCheckboxState.Unchecked;
|
||||
this.checkboxState = variable.selected ? TreeItemCheckboxState.Checked : TreeItemCheckboxState.Unchecked;
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "
|
||||
import { act } from "../../extension";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
import VariableTreeItem from "./variable";
|
||||
import { StorageKey } from "../../storageManager";
|
||||
|
||||
export default class VariablesTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
static contextValue = 'githubLocalActions.variables';
|
||||
@@ -13,8 +14,13 @@ export default class VariablesTreeItem extends TreeItem implements GithubLocalAc
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
const workflows = await act.workflowsManager.getWorkflows(this.workspaceFolder);
|
||||
const variables = [...new Set(workflows.map(workflow => act.settingsManager.getVariables(workflow)).flat())];
|
||||
return variables.map(variable => new VariableTreeItem(this.workspaceFolder, variable));
|
||||
const items: GithubLocalActionsTreeItem[] = [];
|
||||
|
||||
const variables = await act.settingsManager.getSetting(this.workspaceFolder, /\${{\s*vars\.(.*?)(?:\s*==\s*(.*?))?\s*}}/g, StorageKey.Variables);
|
||||
for (const variable of variables) {
|
||||
items.push(new VariableTreeItem(this.workspaceFolder, variable));
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
import ContainerEnginesTreeItem from "./containerEngines";
|
||||
import EnvironmentsTreeItem from "./environments";
|
||||
import InputsTreeItem from "./inputs";
|
||||
import RunnersTreeItem from "./runners";
|
||||
@@ -24,8 +23,7 @@ export default class WorkspaceFolderSettingsTreeItem extends TreeItem implements
|
||||
new SecretsTreeItem(this.workspaceFolder),
|
||||
new VariablesTreeItem(this.workspaceFolder),
|
||||
new InputsTreeItem(this.workspaceFolder),
|
||||
new RunnersTreeItem(this.workspaceFolder),
|
||||
new ContainerEnginesTreeItem(this.workspaceFolder)
|
||||
new RunnersTreeItem(this.workspaceFolder)
|
||||
]);
|
||||
|
||||
return items;
|
||||
|
||||
Reference in New Issue
Block a user