Add decoration in settings when setting, variable, input, or runner is selected but not set
Signed-off-by: Sanjula Ganepola <sanjulagane@gmail.com>
This commit is contained in:
@@ -287,7 +287,7 @@ export class Act {
|
||||
`${actCommand} ${commandArgs.options}` +
|
||||
(settings.secrets.length > 0 ? ` ${Option.Secret} ${settings.secrets.map(secret => secret.key).join(` ${Option.Secret} `)}` : ``) +
|
||||
(settings.secretFiles.length > 0 ? ` ${Option.SecretFile} "${settings.secretFiles[0].path}"` : ` ${Option.SecretFile} ""`) +
|
||||
(settings.variables.length > 0 ? ` ${Option.Variable} ${settings.variables.map(variable => (variable.value ? `${variable.key}=${variable.value}` : variable.key)).join(` ${Option.Variable} `)}` : ``) +
|
||||
(settings.variables.length > 0 ? ` ${Option.Variable} ${settings.variables.map(variable => `${variable.key}=${variable.value}`).join(` ${Option.Variable} `)}` : ``) +
|
||||
(settings.variableFiles.length > 0 ? ` ${Option.VariableFile} "${settings.variableFiles[0].path}"` : ` ${Option.VariableFile} ""`) +
|
||||
(settings.inputs.length > 0 ? ` ${Option.Input} ${settings.inputs.map(input => `${input.key}=${input.value}`).join(` ${Option.Input} `)}` : ``) +
|
||||
(settings.inputFiles.length > 0 ? ` ${Option.InputFile} "${settings.inputFiles[0].path}"` : ` ${Option.InputFile} ""`) +
|
||||
|
||||
@@ -59,9 +59,9 @@ export class SettingsManager {
|
||||
}
|
||||
|
||||
async getSettings(workspaceFolder: WorkspaceFolder, isUserSelected: boolean): Promise<Settings> {
|
||||
const secrets = (await this.getSetting(workspaceFolder, SettingsManager.secretsRegExp, StorageKey.Secrets, true, Visibility.hide)).filter(secret => !isUserSelected || secret.selected);
|
||||
const secrets = (await this.getSetting(workspaceFolder, SettingsManager.secretsRegExp, StorageKey.Secrets, true, Visibility.hide)).filter(secret => !isUserSelected || (secret.selected && secret.value));
|
||||
const secretFiles = (await this.getSettingFiles(workspaceFolder, StorageKey.SecretFiles)).filter(secretFile => !isUserSelected || secretFile.selected);
|
||||
const variables = (await this.getSetting(workspaceFolder, SettingsManager.variablesRegExp, StorageKey.Variables, false, Visibility.show)).filter(variable => !isUserSelected || variable.selected);
|
||||
const variables = (await this.getSetting(workspaceFolder, SettingsManager.variablesRegExp, StorageKey.Variables, false, Visibility.show)).filter(variable => !isUserSelected || (variable.selected && variable.value));
|
||||
const variableFiles = (await this.getSettingFiles(workspaceFolder, StorageKey.VariableFiles)).filter(variableFile => !isUserSelected || variableFile.selected);
|
||||
const inputs = (await this.getSetting(workspaceFolder, SettingsManager.inputsRegExp, StorageKey.Inputs, false, Visibility.show)).filter(input => !isUserSelected || (input.selected && input.value));
|
||||
const inputFiles = (await this.getSettingFiles(workspaceFolder, StorageKey.InputFiles)).filter(inputFile => !isUserSelected || inputFile.selected);
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import { CancellationToken, Event, FileDecoration, FileDecorationProvider, ProviderResult, ThemeColor, Uri } from "vscode";
|
||||
import { CliStatus, ExtensionStatus } from "../componentsManager";
|
||||
import ComponentTreeItem from "./components/component";
|
||||
import InputsTreeItem from "./settings/inputs";
|
||||
import RunnersTreeItem from "./settings/runners";
|
||||
import SecretsTreeItem from "./settings/secrets";
|
||||
import { SettingContextValue } from "./settings/setting";
|
||||
import VariablesTreeItem from "./settings/variables";
|
||||
import WorkflowTreeItem from "./workflows/workflow";
|
||||
|
||||
export class DecorationProvider implements FileDecorationProvider {
|
||||
@@ -37,14 +42,24 @@ export class DecorationProvider implements FileDecorationProvider {
|
||||
color: new ThemeColor('GitHubLocalActions.red')
|
||||
};
|
||||
}
|
||||
} else if ([SecretsTreeItem.contextValue, VariablesTreeItem.contextValue, InputsTreeItem.contextValue, RunnersTreeItem.contextValue].includes(uri.scheme)) {
|
||||
const hasAllValues = params.get('hasAllValues') === 'true';
|
||||
|
||||
if (!hasAllValues) {
|
||||
return {
|
||||
color: new ThemeColor('GitHubLocalActions.red')
|
||||
};
|
||||
}
|
||||
} else if (Object.values(SettingContextValue).includes(uri.scheme as any)) {
|
||||
const isSelected = params.get('isSelected') === 'true';
|
||||
const hasValue = params.get('hasValue') === 'true';
|
||||
|
||||
// else if (uri.scheme === SecretsTreeItem.contextValue || uri.scheme === VariablesTreeItem.contextValue || uri.scheme === InputsTreeItem.contextValue || uri.scheme === RunnersTreeItem.contextValue) {
|
||||
// const selected = params.get('selected');
|
||||
|
||||
// return {
|
||||
// badge: `${selected}`
|
||||
// };
|
||||
// }
|
||||
if (isSelected && !hasValue) {
|
||||
return {
|
||||
badge: '?',
|
||||
color: new ThemeColor('GitHubLocalActions.red')
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
|
||||
import { act } from "../../extension";
|
||||
import { Setting, SettingFile } from "../../settingsManager";
|
||||
import { StorageKey } from "../../storageManager";
|
||||
@@ -17,6 +17,8 @@ export default class InputsTreeItem extends TreeItem implements GithubLocalActio
|
||||
(selectedInputFiles.length > 0 ? ` + ${selectedInputFiles[0].name}` : ``);
|
||||
this.contextValue = InputsTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('record-keys');
|
||||
const hasAllValues = inputs.filter(input => input.selected && input.value === '').length === 0;
|
||||
this.resourceUri = Uri.parse(`${InputsTreeItem.contextValue}:Inputs?hasAllValues=${hasAllValues}`, true);
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
|
||||
import { act } from "../../extension";
|
||||
import { Setting } from "../../settingsManager";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
@@ -12,6 +12,8 @@ export default class RunnersTreeItem extends TreeItem implements GithubLocalActi
|
||||
this.description = `${runners.filter(runner => runner.selected).length}/${runners.length}`;
|
||||
this.contextValue = RunnersTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('server-environment');
|
||||
const hasAllValues = runners.filter(runner => runner.selected && runner.value === '').length === 0;
|
||||
this.resourceUri = Uri.parse(`${RunnersTreeItem.contextValue}:Runners?hasAllValues=${hasAllValues}`, true);
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
|
||||
import { act } from "../../extension";
|
||||
import { Setting, SettingFile } from "../../settingsManager";
|
||||
import { StorageKey } from "../../storageManager";
|
||||
@@ -17,6 +17,8 @@ export default class SecretsTreeItem extends TreeItem implements GithubLocalActi
|
||||
(selectedSecretFiles.length > 0 ? ` + ${selectedSecretFiles[0].name}` : ``);
|
||||
this.contextValue = SecretsTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('lock');
|
||||
const hasAllValues = secrets.filter(secret => secret.selected && secret.value === '').length === 0;
|
||||
this.resourceUri = Uri.parse(`${SecretsTreeItem.contextValue}:Secrets?hasAllValues=${hasAllValues}`, true);
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCheckboxState, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||
import { ThemeIcon, TreeItem, TreeItemCheckboxState, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
|
||||
import { Setting, Visibility } from "../../settingsManager";
|
||||
import { StorageKey } from "../../storageManager";
|
||||
import { GithubLocalActionsTreeItem } from "../githubLocalActionsTreeItem";
|
||||
|
||||
export enum SettingContextValue {
|
||||
secret = 'githubLocalActions.secret',
|
||||
variable = 'githubLocalActions.variable',
|
||||
input = 'githubLocalActions.input',
|
||||
runner = 'githubLocalActions.runner'
|
||||
}
|
||||
|
||||
export default class SettingTreeItem extends TreeItem implements GithubLocalActionsTreeItem {
|
||||
setting: Setting;
|
||||
storageKey: StorageKey;
|
||||
@@ -19,6 +26,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
|
||||
this.contextValue = `${treeItem.contextValue}_${setting.password ? setting.visible : ''}`;
|
||||
this.iconPath = treeItem.iconPath;
|
||||
this.checkboxState = setting.selected ? TreeItemCheckboxState.Checked : TreeItemCheckboxState.Unchecked;
|
||||
this.resourceUri = Uri.parse(`${treeItem.contextValue}:${setting.key}?isSelected=${setting.selected}&hasValue=${setting.value !== ''}`, true);
|
||||
}
|
||||
|
||||
static getSecretTreeItem(workspaceFolder: WorkspaceFolder, secret: Setting): SettingTreeItem {
|
||||
@@ -27,7 +35,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
|
||||
secret,
|
||||
StorageKey.Secrets,
|
||||
{
|
||||
contextValue: 'githubLocalActions.secret',
|
||||
contextValue: SettingContextValue.secret,
|
||||
iconPath: new ThemeIcon('key')
|
||||
}
|
||||
);
|
||||
@@ -39,7 +47,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
|
||||
variable,
|
||||
StorageKey.Variables,
|
||||
{
|
||||
contextValue: 'githubLocalActions.variable',
|
||||
contextValue: SettingContextValue.variable,
|
||||
iconPath: new ThemeIcon('symbol-variable')
|
||||
}
|
||||
);
|
||||
@@ -51,7 +59,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
|
||||
input,
|
||||
StorageKey.Inputs,
|
||||
{
|
||||
contextValue: 'githubLocalActions.input',
|
||||
contextValue: SettingContextValue.input,
|
||||
iconPath: new ThemeIcon('symbol-parameter')
|
||||
}
|
||||
);
|
||||
@@ -63,7 +71,7 @@ export default class SettingTreeItem extends TreeItem implements GithubLocalActi
|
||||
runner,
|
||||
StorageKey.Runners,
|
||||
{
|
||||
contextValue: 'githubLocalActions.runner',
|
||||
contextValue: SettingContextValue.runner,
|
||||
iconPath: new ThemeIcon('vm-connect')
|
||||
}
|
||||
);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, WorkspaceFolder } from "vscode";
|
||||
import { ThemeIcon, TreeItem, TreeItemCollapsibleState, Uri, WorkspaceFolder } from "vscode";
|
||||
import { act } from "../../extension";
|
||||
import { Setting, SettingFile } from "../../settingsManager";
|
||||
import { StorageKey } from "../../storageManager";
|
||||
@@ -17,6 +17,8 @@ export default class VariablesTreeItem extends TreeItem implements GithubLocalAc
|
||||
(selectedVariableFiles.length > 0 ? ` + ${selectedVariableFiles[0].name}` : ``);
|
||||
this.contextValue = VariablesTreeItem.contextValue;
|
||||
this.iconPath = new ThemeIcon('symbol-key');
|
||||
const hasAllValues = variables.filter(variable => variable.selected && variable.value === '').length === 0;
|
||||
this.resourceUri = Uri.parse(`${VariablesTreeItem.contextValue}:Variables?hasAllValues=${hasAllValues}`, true);
|
||||
}
|
||||
|
||||
async getChildren(): Promise<GithubLocalActionsTreeItem[]> {
|
||||
|
||||
Reference in New Issue
Block a user