From f92f5746b9b147c4bdb524039fc9a07db115e7cd Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 21 Aug 2023 20:33:41 +0800 Subject: [PATCH] feature: supports clear all stashes --- src/Resources/Locales/en_US.xaml | 1 + src/Resources/Locales/zh_CN.xaml | 1 + src/Views/Widgets/Stashes.xaml | 22 ++++++++++++++++++++-- src/Views/Widgets/Stashes.xaml.cs | 24 ++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/Resources/Locales/en_US.xaml b/src/Resources/Locales/en_US.xaml index da900303..30ea054c 100644 --- a/src/Resources/Locales/en_US.xaml +++ b/src/Resources/Locales/en_US.xaml @@ -542,4 +542,5 @@ Invalid path for archive file This field is required You are removing repository '{0}'. Are you sure to continue? + You are trying to clear all stashes. Are you sure to continue? \ No newline at end of file diff --git a/src/Resources/Locales/zh_CN.xaml b/src/Resources/Locales/zh_CN.xaml index 9eafebf9..e7a48dfc 100644 --- a/src/Resources/Locales/zh_CN.xaml +++ b/src/Resources/Locales/zh_CN.xaml @@ -541,4 +541,5 @@ 非法的存档文件路径! 内容未填写! 正在将 '{0}' 从列表中移除,是否要继续? + 您正在丢弃所有的贮藏,一经操作,无法回退,是否继续? \ No newline at end of file diff --git a/src/Views/Widgets/Stashes.xaml b/src/Views/Widgets/Stashes.xaml index d83b3715..6faf5a6c 100644 --- a/src/Views/Widgets/Stashes.xaml +++ b/src/Views/Widgets/Stashes.xaml @@ -26,25 +26,43 @@ - + + + + + + + + + - + + + diff --git a/src/Views/Widgets/Stashes.xaml.cs b/src/Views/Widgets/Stashes.xaml.cs index 118436d9..a7dac347 100644 --- a/src/Views/Widgets/Stashes.xaml.cs +++ b/src/Views/Widgets/Stashes.xaml.cs @@ -25,6 +25,30 @@ namespace SourceGit.Views.Widgets { changeList.ItemsSource = null; } + private void ClearAll(object sender, RoutedEventArgs e) { + var confirmDialog = new ConfirmDialog( + App.Text("Apply.Warn"), + App.Text("ConfirmClearStashes"), + async () => { + waiting.Visibility = Visibility.Visible; + waiting.IsAnimating = true; + Models.Watcher.SetEnabled(repo, false); + await Task.Run(() => { + new Commands.Command() { + Cwd = repo, + Args = "stash clear", + }.Exec(); + }); + Models.Watcher.SetEnabled(repo, true); + waiting.Visibility = Visibility.Collapsed; + waiting.IsAnimating = false; + }); + + confirmDialog.Owner = App.Current.MainWindow; + confirmDialog.ShowDialog(); + e.Handled = true; + } + private async void OnStashSelectionChanged(object sender, SelectionChangedEventArgs e) { changeList.ItemsSource = null; selected = null;