From f4197b7999e854be4177ceb917de64b10c89d848 Mon Sep 17 00:00:00 2001 From: Kapu Date: Fri, 12 May 2023 14:46:33 +0200 Subject: [PATCH] Hide Parameters panel if no params in config --- ConfigDraft/Proposal_1.json | 66 +++++++++---------- .../ViewModels/MainWindowViewModel.cs | 19 +++--- .../ScriptRunner.GUI/Views/MainWindow.axaml | 2 +- 3 files changed, 43 insertions(+), 44 deletions(-) diff --git a/ConfigDraft/Proposal_1.json b/ConfigDraft/Proposal_1.json index bd21168..32e9cf8 100644 --- a/ConfigDraft/Proposal_1.json +++ b/ConfigDraft/Proposal_1.json @@ -1,40 +1,38 @@ { - "dependencies":[ + "dependencies": [ + { + "name": "", + "install": "", + "exists": "" + } + ], + "actions": [ + { + "name": "", + "categories": [""], + "description": "", + "dependencies": [ { - "name":"", - "install":"", - "exists":"" + "name": "", + "version": "" } - ], - "actions":[ + ], + "command": "sample.ps1 -p1 {parameter1}", + "params": [ { - "name":"", - "category":"", - "description":"", - "dependencies":[ - { - "name":"", - "version":"" - } - ], - "command":"sample.ps1 -p1 {parameter1}", - "params":[ - { - "name":"parameter1", - "description":"", - "type":"", - "default":"", - "prompt":"text|password|dropdown|multiselect|datepicker|checkbox|multilinetext|filepicker|directorypicker", - "mandatory":"true", - "promptSettings": - { - "p1":"v1", - "p2":"v2", - "p3":"v3" - } - } - ] + "name": "parameter1", + "description": "", + "type": "", + "default": "", + "prompt": "text|password|dropdown|multiselect|datepicker|checkbox|multilinetext|filepicker|directorypicker", + "mandatory": "true", + "promptSettings": { + "p1": "v1", + "p2": "v2", + "p3": "v3" + } } - ] + ] + } + ] } - diff --git a/src/ScriptRunner/ScriptRunner.GUI/ViewModels/MainWindowViewModel.cs b/src/ScriptRunner/ScriptRunner.GUI/ViewModels/MainWindowViewModel.cs index a460589..e307043 100644 --- a/src/ScriptRunner/ScriptRunner.GUI/ViewModels/MainWindowViewModel.cs +++ b/src/ScriptRunner/ScriptRunner.GUI/ViewModels/MainWindowViewModel.cs @@ -6,15 +6,10 @@ using System.Reactive.Linq; using System.Security.Principal; using System.Text.Json; -using System.Text.Json.Serialization; using System.Threading.Tasks; using Avalonia; using Avalonia.Controls; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Controls.Metadata; -using Avalonia.Interactivity; using Avalonia.Threading; -using Avalonia.VisualTree; using DynamicData; using MessageBox.Avalonia.Enums; using ReactiveUI; @@ -25,7 +20,6 @@ using ScriptRunner.GUI.ScriptReader; using ScriptRunner.GUI.Settings; using ScriptRunner.GUI.Views; -using static ScriptRunner.GUI.Views.PasswordBox; namespace ScriptRunner.GUI.ViewModels; @@ -76,21 +70,26 @@ public RunningJobViewModel SelectedRunningJob set => this.RaiseAndSetIfChanged(ref _selectedRunningJob, value); } + private bool _isActionSelected; public bool IsActionSelected { get => _isActionSelected; set => this.RaiseAndSetIfChanged(ref _isActionSelected, value); } - private bool _isActionSelected; - + private bool _installAvailable; public bool InstallAvailable { get => _installAvailable; set => this.RaiseAndSetIfChanged(ref _installAvailable, value); } - private bool _installAvailable; + private bool _hasParams; + public bool HasParams + { + get => _hasParams; + private set => this.RaiseAndSetIfChanged(ref _hasParams, value); + } public ScriptConfig? SelectedAction { @@ -116,12 +115,14 @@ public ScriptConfig? SelectedAction InstallAvailable = string.IsNullOrWhiteSpace(value.InstallCommand) == false; SelectedActionInstalled = InstallAvailable ? IsActionInstalled(value.Name): true; IsActionSelected = true; + HasParams = value.Params.Any(); } else { SelectedArgumentSet = null; SelectedActionInstalled = false; IsActionSelected = false; + HasParams = false; } } } diff --git a/src/ScriptRunner/ScriptRunner.GUI/Views/MainWindow.axaml b/src/ScriptRunner/ScriptRunner.GUI/Views/MainWindow.axaml index 40844a7..a84d0f5 100644 --- a/src/ScriptRunner/ScriptRunner.GUI/Views/MainWindow.axaml +++ b/src/ScriptRunner/ScriptRunner.GUI/Views/MainWindow.axaml @@ -136,7 +136,7 @@ - +