Skip to content

Commit

Permalink
Hide Parameters panel if no params in config
Browse files Browse the repository at this point in the history
  • Loading branch information
gosukretess authored and cezarypiatek committed May 12, 2023
1 parent 7ac087d commit f4197b7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 44 deletions.
66 changes: 32 additions & 34 deletions ConfigDraft/Proposal_1.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
]
]
}
]
}

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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
{
Expand All @@ -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;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ScriptRunner/ScriptRunner.GUI/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
<Button Margin="5,5,5,15" IsVisible="{Binding !SelectedActionInstalled}" Command="{Binding InstallScript}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center">Install</Button>
</StackPanel>
<StackPanel IsEnabled="{Binding SelectedActionInstalled}">
<StackPanel>
<StackPanel IsVisible="{Binding HasParams}">
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<TextBlock Classes="h2" Text="Parameters: "></TextBlock>
<ComboBox Margin="20,0,0,5" Items="{Binding SelectedAction.PredefinedArgumentSets}" SelectedItem="{Binding SelectedArgumentSet, Mode=TwoWay}" MinWidth="200">
Expand Down

0 comments on commit f4197b7

Please sign in to comment.