Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 19 additions & 31 deletions src/ScriptRunner/ScriptRunner.GUI/Parameters/ParamsPanelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,15 @@ public ParamsPanel Create(ScriptConfig action, Dictionary<string, string> values
bool _isResizing = false;
Point _lastPointerPosition = default;

// Create toolbar
// Create toolbar for expand button only
var toolbar = new StackPanel()
{
Orientation = Orientation.Horizontal,
Height = 24,
HorizontalAlignment = HorizontalAlignment.Right,
//Background = new SolidColorBrush(Color.FromArgb(50, 128, 128, 128)),
Spacing = 5,
ZIndex = 1,
Margin = new Thickness(0,-25,0,0),
Margin = new Thickness(0,0,10,-35),
};

// Expand button to open overlay
Expand Down Expand Up @@ -133,15 +132,21 @@ public ParamsPanel Create(ScriptConfig action, Dictionary<string, string> values
}
};

// Resize handle
toolbar.Children.Add(expandButton);

// Create a grid to overlay the resize handle on the editor
var grid = new Grid();
grid.Children.Add(controlRecord.Control);

// Resize handle positioned at bottom right of editor
var resizeHandle = new Border()
{
Width = 24,
Height = 24,
Background = Brushes.Transparent,
Cursor = new Cursor(StandardCursorType.BottomRightCorner),
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(2,5,0,0),
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalAlignment = HorizontalAlignment.Right,
Margin = new Thickness(0,0,5,0),
ZIndex = 10
};

var resizeIcon = new Icon()
Expand Down Expand Up @@ -186,15 +191,14 @@ public ParamsPanel Create(ScriptConfig action, Dictionary<string, string> values
_isResizing = false;
};

toolbar.Children.Add(expandButton);
toolbar.Children.Add(resizeHandle);
grid.Children.Add(resizeHandle);

var panel = new StackPanel()
{
Orientation = Orientation.Vertical
};
panel.Children.Add(controlRecord.Control);
panel.Children.Add(toolbar);
panel.Children.Add(grid);
controlForEdit = panel;


Expand Down Expand Up @@ -535,35 +539,19 @@ private IControlRecord CreateControlRecord(ScriptParam p, string? value, int ind
UncheckedValue = p.GetPromptSettings("uncheckedValue", out var uncheckedValue)? uncheckedValue: defaultUnchecked,
};
case PromptType.Multilinetext:
if (p.GetPromptSettings("syntax", out var syntax) && !string.IsNullOrWhiteSpace(syntax))
{
return new TextControl
{
Control = CreateAvaloniaEdit(value, index, syntax)
};
}

// Use regular TextBox without syntax highlighting
p.GetPromptSettings("syntax", out var syntax);
syntax ??= "txt";
return new TextControl
{
Control = new TextBox
{
TextWrapping = TextWrapping.Wrap,
AcceptsReturn = true,
Height = 100,
Text = value,
TabIndex = index,
IsTabStop = true,
Width = 500,
}
Control = CreateAvaloniaEdit(value, index, syntax)
};

case PromptType.FileContent:
if (string.IsNullOrWhiteSpace(value) == false && Path.IsPathRooted(value) == false)
{
value = Path.GetFullPath(value, scriptConfig.WorkingDirectory);
}


var templateText = p.GetPromptSettings("templateText", out var rawTemplate)? rawTemplate: "";
var textForControl = File.Exists(value) ? File.ReadAllText(value) : templateText;

Expand Down
30 changes: 18 additions & 12 deletions src/ScriptRunner/ScriptRunner.GUI/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,20 +216,22 @@ public MainWindowViewModel(ParamsPanelFactory paramsPanelFactory, VaultProvider
this._configRepositoryUpdater = new ConfigRepositoryUpdater(new CliRepositoryClient(command =>
{
var tcs = new TaskCompletionSource<CliCommandOutputs>();

var job = new RunningJobViewModel
Dispatcher.UIThread.Post(() =>
{
Tile = $"Update repository",
ExecutedCommand = $"{command.Command} {command.Parameters}",
};
this.RunningJobs.Add(job);
SelectedRunningJob = job;
var job = new RunningJobViewModel
{
Tile = $"Update repository",
ExecutedCommand = $"{command.Command} {command.Parameters}",
};
this.RunningJobs.Add(job);
SelectedRunningJob = job;

job.ExecutionCompleted += (sender, args) =>
{
tcs.SetResult(new(job.RawOutput, job.RawErrorOutput));
};
job.RunJob(command.Command, command.Parameters, command.WorkingDirectory, Array.Empty<InteractiveInputDescription>(), Array.Empty<TroubleshootingItem>());
job.ExecutionCompleted += (sender, args) =>
{
tcs.SetResult(new(job.RawOutput, job.RawErrorOutput));
};
job.RunJob(command.Command, command.Parameters, command.WorkingDirectory, Array.Empty<InteractiveInputDescription>(), Array.Empty<TroubleshootingItem>());
});
return tcs.Task;
}));
IsScriptListVisible = true;
Expand Down Expand Up @@ -478,6 +480,10 @@ public void DismissNewVersionAvailable()
ShowNewVersionAvailable = false;
}

public void DismissOutdatedRepositories()
{
OutOfDateConfigRepositories.Clear();
}
private IEnumerable<IControlRecord> _controlRecords;

//private ActionsConfig config;
Expand Down
187 changes: 157 additions & 30 deletions src/ScriptRunner/ScriptRunner.GUI/Views/NotificationSection.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,170 @@
xmlns:viewModels="clr-namespace:ScriptRunner.GUI.ViewModels"
xmlns:converters="clr-namespace:ScriptRunner.GUI.Converters"
xmlns:avalonia="clr-namespace:LoadingIndicators.Avalonia;assembly=LoadingIndicators.Avalonia"
xmlns:icons="https://github.com/projektanker/icons.avalonia"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:DataType="viewModels:MainWindowViewModel"
x:Class="ScriptRunner.GUI.Views.NotificationSection">
<UserControl.Resources>
<converters:CountToVisibilityConverter x:Key="CountToVisibilityConverter"/>
</UserControl.Resources>
<StackPanel Orientation="Vertical">
<StackPanel IsVisible="{Binding ShowNewVersionAvailable}" Height="75">
<Border BorderBrush="#FF0000" BorderThickness="1" >
<StackPanel Orientation="Horizontal" Margin="20" VerticalAlignment="Center">
<TextBlock VerticalAlignment="Center" Text="A newer version is available"></TextBlock>
<Button Margin="20,0,0,0" VerticalAlignment="Center" Command="{Binding CheckForUpdates}">Check release log</Button>
<Button Margin="20,0,0,0" VerticalAlignment="Center" Command="{Binding InstallUpdate}">Install update</Button>
<Button Margin="20,0,0,0" VerticalAlignment="Center" Command="{Binding DismissNewVersionAvailable}">Dismiss</Button>
<StackPanel Orientation="Vertical" Margin="10,5">
<!-- New Version Available Notification -->
<Border IsVisible="{Binding ShowNewVersionAvailable}"
Background="#2B2B2B"
BorderBrush="#3baced"
BorderThickness="1"
CornerRadius="5"
Padding="15,12"
Margin="0,5">
<Grid ColumnDefinitions="Auto,Auto,Auto,*">
<Border Grid.Column="0"
Background="#3baced"
CornerRadius="3"
Width="32"
Height="32"
Margin="0,0,12,0"
VerticalAlignment="Center">
<icons:Icon Value="fas fa-download"
FontSize="16"
Foreground="White"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<StackPanel Grid.Column="1"
VerticalAlignment="Center"
Margin="0,0,15,0">
<TextBlock Text="A newer version is available"
FontWeight="SemiBold"
FontSize="14"/>
<TextBlock Text="Update to get the latest features and improvements"
FontSize="12"
Foreground="#B0B0B0"
Margin="0,2,0,0"/>
</StackPanel>
</Border>
</StackPanel>
<StackPanel IsVisible="{Binding OutOfDateConfigRepositories.Count, Converter={StaticResource CountToVisibilityConverter}}">
<Border BorderBrush="#FF0000" BorderThickness="1" >
<StackPanel Orientation="Vertical" Margin="20" VerticalAlignment="Center">
<TextBlock VerticalAlignment="Center" Text="You have some outdated repositories with script configuration files:"></TextBlock>
<ItemsControl ItemsSource="{Binding OutOfDateConfigRepositories}">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="backgroundTasks:OutdatedRepositoryModel">
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
<TextBlock VerticalAlignment="Center" Text="{Binding Path}"></TextBlock>
<TextBlock VerticalAlignment="Center" Margin="5,0" Text="{Binding BranchName, StringFormat='(branch: {0})'}"></TextBlock>
<Button Margin="20,0,0,0" VerticalAlignment="Center" IsEnabled="{Binding !IsPulling}"
Command="{Binding DataContext.PullRepoChanges, RelativeSource={RelativeSource AncestorType={x:Type views:MainWindow}}}"
CommandParameter="{Binding}">Pull</Button>
<avalonia:LoadingIndicator IsActive="{Binding IsPulling}" Mode="Arc" SpeedRatio="1.2" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<StackPanel Grid.Column="2"
Orientation="Horizontal"
VerticalAlignment="Center">
<Button Classes="primary"
Margin="0,0,8,0"
Command="{Binding InstallUpdate}"
ToolTip.Tip="Download and install the update">
<StackPanel Orientation="Horizontal">
<icons:Icon Value="fas fa-rocket" FontSize="12" Margin="0,0,5,0"/>
<TextBlock Text="Install Update"/>
</StackPanel>
</Button>
<Button Margin="0,0,8,0"
Command="{Binding CheckForUpdates}"
ToolTip.Tip="View the release notes">
<StackPanel Orientation="Horizontal">
<icons:Icon Value="fas fa-file-alt" FontSize="12" Margin="0,0,5,0"/>
<TextBlock Text="Release Notes"/>
</StackPanel>
</Button>
<Button Command="{Binding DismissNewVersionAvailable}"
ToolTip.Tip="Dismiss this notification">
<TextBlock Text="Dismiss"/>
</Button>
</StackPanel>
</Border>
</StackPanel>
</Grid>
</Border>

<!-- Outdated Repositories Notification -->
<Border IsVisible="{Binding OutOfDateConfigRepositories.Count, Converter={StaticResource CountToVisibilityConverter}}"
Background="#2B2B2B"
BorderBrush="#FF9800"
BorderThickness="1"
CornerRadius="5"
Padding="15,12"
Margin="0,5">
<StackPanel Orientation="Vertical">
<!-- Header -->
<Grid ColumnDefinitions="Auto,Auto,Auto,*" Margin="0,0,0,10">
<Border Grid.Column="0"
Background="#FF9800"
CornerRadius="3"
Width="32"
Height="32"
Margin="0,0,12,0"
VerticalAlignment="Center">
<icons:Icon Value="fas fa-exclamation-triangle"
FontSize="16"
Foreground="White"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>
</Border>
<StackPanel Grid.Column="1"
VerticalAlignment="Center"
Margin="0,0,15,0">
<TextBlock Text="Outdated Script Repositories"
FontWeight="SemiBold"
FontSize="14"/>
<TextBlock Text="Updates are available for your script configuration repositories"
FontSize="12"
Foreground="#B0B0B0"
Margin="0,2,0,0"/>
</StackPanel>
<Button Grid.Column="2"
VerticalAlignment="Center"
Command="{Binding DismissOutdatedRepositories}"
ToolTip.Tip="Dismiss all outdated repository notifications">
<TextBlock Text="Dismiss"/>
</Button>
</Grid>

<!-- Repository List -->
<ItemsControl ItemsSource="{Binding OutOfDateConfigRepositories}">
<ItemsControl.ItemTemplate>
<DataTemplate x:DataType="backgroundTasks:OutdatedRepositoryModel">
<Border Background="#1e1f22"
BorderBrush="#4E4E4E"
BorderThickness="1"
CornerRadius="3"
Padding="12,10"
Margin="0,0,0,8">
<Grid ColumnDefinitions="Auto,*,Auto">
<icons:Icon Grid.Column="0"
Value="fab fa-git-alt"
FontSize="20"
Foreground="#FF9800"
VerticalAlignment="Center"
Margin="0,0,12,0"/>
<StackPanel Grid.Column="1" VerticalAlignment="Center">
<TextBlock Text="{Binding Path}"
FontWeight="Medium"
FontSize="13"/>
<TextBlock Text="{Binding BranchName, StringFormat='Branch: {0}'}"
FontSize="11"
Foreground="#B0B0B0"
Margin="0,2,0,0"/>
</StackPanel>
<StackPanel Grid.Column="2"
Orientation="Horizontal"
VerticalAlignment="Center">
<Button Classes="primary"
IsEnabled="{Binding !IsPulling}"
Command="{Binding DataContext.PullRepoChanges, RelativeSource={RelativeSource AncestorType={x:Type views:MainWindow}}}"
CommandParameter="{Binding}"
ToolTip.Tip="Pull the latest changes from this repository">
<StackPanel Orientation="Horizontal">
<icons:Icon Value="fas fa-sync-alt" FontSize="12" Margin="0,0,5,0"/>
<TextBlock Text="Pull Changes"/>
</StackPanel>
</Button>
<avalonia:LoadingIndicator IsActive="{Binding IsPulling}"
Mode="Arc"
SpeedRatio="1.2"
Width="24"
Height="24"
Margin="8,0,0,0"/>
</StackPanel>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</Border>
</StackPanel>
</UserControl>
Loading
Loading