mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
refactor: add a popup panel to show submodule updating status
This commit is contained in:
parent
069c78f213
commit
d0edc09b2e
8 changed files with 71 additions and 9 deletions
|
@ -29,9 +29,10 @@ namespace SourceGit.Commands
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Update()
|
public bool Update(Action<string> outputHandler)
|
||||||
{
|
{
|
||||||
Args = $"submodule update --rebase --remote";
|
Args = $"submodule update --rebase --remote";
|
||||||
|
_outputHandler = outputHandler;
|
||||||
return Exec();
|
return Exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -458,6 +458,8 @@
|
||||||
<x:String x:Key="Text.TagCM.Delete" xml:space="preserve">Delete${0}$</x:String>
|
<x:String x:Key="Text.TagCM.Delete" xml:space="preserve">Delete${0}$</x:String>
|
||||||
<x:String x:Key="Text.TagCM.Push" xml:space="preserve">Push${0}$</x:String>
|
<x:String x:Key="Text.TagCM.Push" xml:space="preserve">Push${0}$</x:String>
|
||||||
<x:String x:Key="Text.URL" xml:space="preserve">URL :</x:String>
|
<x:String x:Key="Text.URL" xml:space="preserve">URL :</x:String>
|
||||||
|
<x:String x:Key="Text.UpdateSubmodules" xml:space="preserve">Update Submodules</x:String>
|
||||||
|
<x:String x:Key="Text.UpdateSubmodules.Tip" xml:space="preserve">Run `submodule update` command for this repository.</x:String>
|
||||||
<x:String x:Key="Text.Warn" xml:space="preserve">Warning</x:String>
|
<x:String x:Key="Text.Warn" xml:space="preserve">Warning</x:String>
|
||||||
<x:String x:Key="Text.Welcome.AddRootFolder" xml:space="preserve">Create Group</x:String>
|
<x:String x:Key="Text.Welcome.AddRootFolder" xml:space="preserve">Create Group</x:String>
|
||||||
<x:String x:Key="Text.Welcome.AddSubFolder" xml:space="preserve">Create Sub-Group</x:String>
|
<x:String x:Key="Text.Welcome.AddSubFolder" xml:space="preserve">Create Sub-Group</x:String>
|
||||||
|
|
|
@ -461,6 +461,8 @@
|
||||||
<x:String x:Key="Text.TagCM.Delete" xml:space="preserve">删除${0}$</x:String>
|
<x:String x:Key="Text.TagCM.Delete" xml:space="preserve">删除${0}$</x:String>
|
||||||
<x:String x:Key="Text.TagCM.Push" xml:space="preserve">推送${0}$</x:String>
|
<x:String x:Key="Text.TagCM.Push" xml:space="preserve">推送${0}$</x:String>
|
||||||
<x:String x:Key="Text.URL" xml:space="preserve">仓库地址 :</x:String>
|
<x:String x:Key="Text.URL" xml:space="preserve">仓库地址 :</x:String>
|
||||||
|
<x:String x:Key="Text.UpdateSubmodules" xml:space="preserve">更新子模块</x:String>
|
||||||
|
<x:String x:Key="Text.UpdateSubmodules.Tip" xml:space="preserve">为此仓库执行`submodule update`命令,更新所有的子模块。</x:String>
|
||||||
<x:String x:Key="Text.Warn" xml:space="preserve">警告</x:String>
|
<x:String x:Key="Text.Warn" xml:space="preserve">警告</x:String>
|
||||||
<x:String x:Key="Text.Welcome.AddRootFolder" xml:space="preserve">新建分组</x:String>
|
<x:String x:Key="Text.Welcome.AddRootFolder" xml:space="preserve">新建分组</x:String>
|
||||||
<x:String x:Key="Text.Welcome.AddSubFolder" xml:space="preserve">新建子分组</x:String>
|
<x:String x:Key="Text.Welcome.AddSubFolder" xml:space="preserve">新建子分组</x:String>
|
||||||
|
|
|
@ -769,6 +769,12 @@ namespace SourceGit.ViewModels
|
||||||
PopupHost.ShowPopup(new AddSubmodule(this));
|
PopupHost.ShowPopup(new AddSubmodule(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateSubmodules()
|
||||||
|
{
|
||||||
|
if (PopupHost.CanCreatePopup())
|
||||||
|
PopupHost.ShowAndStartPopup(new UpdateSubmodules(this));
|
||||||
|
}
|
||||||
|
|
||||||
public ContextMenu CreateContextMenuForGitFlow()
|
public ContextMenu CreateContextMenuForGitFlow()
|
||||||
{
|
{
|
||||||
var menu = new ContextMenu();
|
var menu = new ContextMenu();
|
||||||
|
|
28
src/ViewModels/UpdateSubmodules.cs
Normal file
28
src/ViewModels/UpdateSubmodules.cs
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SourceGit.ViewModels
|
||||||
|
{
|
||||||
|
public class UpdateSubmodules : Popup
|
||||||
|
{
|
||||||
|
public UpdateSubmodules(Repository repo)
|
||||||
|
{
|
||||||
|
_repo = repo;
|
||||||
|
View = new Views.UpdateSubmodules() { DataContext = this };
|
||||||
|
}
|
||||||
|
|
||||||
|
public override Task<bool> Sure()
|
||||||
|
{
|
||||||
|
_repo.SetWatcherEnabled(false);
|
||||||
|
ProgressDescription = "Updating submodules ...";
|
||||||
|
|
||||||
|
return Task.Run(() =>
|
||||||
|
{
|
||||||
|
new Commands.Submodule(_repo.FullPath).Update(SetProgressDescription);
|
||||||
|
CallUIThread(() => _repo.SetWatcherEnabled(true));
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly Repository _repo = null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -306,16 +306,10 @@ namespace SourceGit.Views
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void UpdateSubmodules(object sender, RoutedEventArgs e)
|
private void UpdateSubmodules(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (DataContext is ViewModels.Repository repo)
|
if (DataContext is ViewModels.Repository repo)
|
||||||
{
|
repo.UpdateSubmodules();
|
||||||
repo.SetWatcherEnabled(false);
|
|
||||||
iconSubmoduleUpdate.Classes.Add("rotating");
|
|
||||||
await Task.Run(() => new Commands.Submodule(repo.FullPath).Update());
|
|
||||||
iconSubmoduleUpdate.Classes.Remove("rotating");
|
|
||||||
repo.SetWatcherEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
}
|
}
|
||||||
|
|
17
src/Views/UpdateSubmodules.axaml
Normal file
17
src/Views/UpdateSubmodules.axaml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<UserControl xmlns="https://github.com/avaloniaui"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:vm="using:SourceGit.ViewModels"
|
||||||
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
x:Class="SourceGit.Views.UpdateSubmodules"
|
||||||
|
x:DataType="vm:UpdateSubmodules">
|
||||||
|
<StackPanel Orientation="Vertical" Margin="8,0">
|
||||||
|
<TextBlock FontSize="18"
|
||||||
|
Classes="bold"
|
||||||
|
Text="{DynamicResource Text.UpdateSubmodules}"/>
|
||||||
|
<TextBlock Text="{DynamicResource Text.UpdateSubmodules.Tip}"
|
||||||
|
Margin="0,16,0,0"
|
||||||
|
HorizontalAlignment="Center"/>
|
||||||
|
</StackPanel>
|
||||||
|
</UserControl>
|
12
src/Views/UpdateSubmodules.axaml.cs
Normal file
12
src/Views/UpdateSubmodules.axaml.cs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace SourceGit.Views
|
||||||
|
{
|
||||||
|
public partial class UpdateSubmodules : UserControl
|
||||||
|
{
|
||||||
|
public UpdateSubmodules()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue