Skip to content

Commit d405677

Browse files
authored
Merge pull request #10 from frosch95/pr-9
Refresh button for the file list
2 parents 6754210 + 0e979fa commit d405677

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

K8sFileBrowser/ViewModels/MainWindowViewModel.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public class MainWindowViewModel : ViewModelBase
6767

6868
public ReactiveCommand<Unit, Unit> DownloadCommand { get; private set; } = null!;
6969
public ReactiveCommand<Unit, Unit> DownloadLogCommand { get; private set; } = null!;
70+
public ReactiveCommand<Unit, Unit> RefreshCommand { get; private set; } = null!;
7071
public ReactiveCommand<Unit, Unit> ParentCommand { get; private set; } = null!;
7172
public ReactiveCommand<Unit, Unit> OpenCommand { get; private set; } = null!;
7273
private ReactiveCommand<Namespace, IEnumerable<Pod>> GetPodsForNamespace { get; set; } = null!;
@@ -82,6 +83,7 @@ public MainWindowViewModel()
8283
// commands
8384
ConfigureOpenDirectoryCommand();
8485
ConfigureDownloadFileCommand(kubernetesService);
86+
ConfigureRefreshCommand(kubernetesService);
8587
ConfigureDownloadLogCommand(kubernetesService);
8688
ConfigureParentDirectoryCommand();
8789
ConfigureGetPodsForNamespaceCommand(kubernetesService);
@@ -248,6 +250,24 @@ await Observable.StartAsync(async () =>
248250
DownloadLogCommand.ThrownExceptions.ObserveOn(RxApp.MainThreadScheduler)
249251
.Subscribe(ShowErrorMessage);
250252
}
253+
254+
private void ConfigureRefreshCommand(IKubernetesService kubernetesService)
255+
{
256+
var isSelectedContainer = this
257+
.WhenAnyValue(x => x.SelectedContainer)
258+
.Select(x => x != null);
259+
260+
RefreshCommand = ReactiveCommand.CreateFromTask(async () =>
261+
{
262+
await Observable.Start(() =>
263+
{
264+
FileInformation = GetFileInformation(kubernetesService, SelectedPath!, SelectedPod!, SelectedNamespace!, SelectedContainer!);
265+
}, RxApp.TaskpoolScheduler);
266+
}, isSelectedContainer, RxApp.MainThreadScheduler);
267+
268+
RefreshCommand.ThrownExceptions.ObserveOn(RxApp.MainThreadScheduler)
269+
.Subscribe(ShowErrorMessage);
270+
}
251271

252272
private void ConfigureDownloadFileCommand(IKubernetesService kubernetesService)
253273
{

K8sFileBrowser/Views/MainWindow.axaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@
9494
<Button Command="{Binding DownloadLogCommand}" VerticalAlignment="Center" ToolTip.Tip="Download Container Log" Margin="0 0 48 0 ">
9595
<PathIcon Data="{StaticResource document_one_page_regular}"></PathIcon>
9696
</Button>
97+
<Button Command="{Binding RefreshCommand}" VerticalAlignment="Center" ToolTip.Tip="Refresh Directory">
98+
<PathIcon Data="{StaticResource arrow_sync_circle_regular}"></PathIcon>
99+
</Button>
97100
<Button Command="{Binding ParentCommand}" VerticalAlignment="Center" ToolTip.Tip="Go To Parent Directory">
98101
<PathIcon Data="{StaticResource arrow_curve_up_left_regular}"></PathIcon>
99102
</Button>

0 commit comments

Comments
 (0)