feature(Submodule): add button to do submodule update

This commit is contained in:
leo 2020-07-24 17:17:53 +08:00
parent 1896ae1daf
commit 0e9b1574a8
5 changed files with 62 additions and 7 deletions

View file

@ -26,27 +26,27 @@ namespace SourceGit.Git {
/// <summary>
/// Branch name
/// </summary>
public string Name { get; set; }
public string Name { get; set; } = "";
/// <summary>
/// Full name.
/// </summary>
public string FullName { get; set; }
public string FullName { get; set; } = "";
/// <summary>
/// Head ref
/// </summary>
public string Head { get; set; }
public string Head { get; set; } = "";
/// <summary>
/// Subject for head ref.
/// </summary>
public string HeadSubject { get; set; }
public string HeadSubject { get; set; } = "";
/// <summary>
/// Is local branch
/// </summary>
public bool IsLocal { get; set; }
public bool IsLocal { get; set; } = false;
/// <summary>
/// Branch type.
@ -56,7 +56,7 @@ namespace SourceGit.Git {
/// <summary>
/// Remote name. Only used for remote branch
/// </summary>
public string Remote { get; set; }
public string Remote { get; set; } = "";
/// <summary>
/// Upstream. Only used for local branches.

View file

@ -445,12 +445,17 @@
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="16"/>
<ColumnDefinition Width="8"/>
<ColumnDefinition Width="16"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" x:Name="submoduleCount" Content="SUBMODULES" Style="{StaticResource Style.Label.GroupHeader}"/>
<Button Grid.Column="1" Click="OpenAddSubmodule" ToolTip="ADD SUBMODULE">
<Path Width="14" Height="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Submodule}"/>
</Button>
<Button Grid.Column="3" Click="UpdateSubmodule" ToolTip="UPDATE SUBMODULE">
<Path Width="14" Height="14" Style="{StaticResource Style.Icon}" Data="{StaticResource Icon.Loading}"/>
</Button>
</Grid>
</ToggleButton>
<DataGrid

View file

@ -223,7 +223,7 @@ namespace SourceGit.UI {
foreach (var b in branches) {
if (b.IsLocal) {
MakeBranchNode(b, localBranchNodes, folders, states, "locals");
} else {
} else if (!string.IsNullOrEmpty(b.Remote)) {
RemoteNode remote = null;
if (!remoteMap.ContainsKey(b.Remote)) {
@ -926,6 +926,13 @@ namespace SourceGit.UI {
AddSubmodule.Show(repo);
}
private void UpdateSubmodule(object sender, RoutedEventArgs e) {
Waiting.Show(() => {
var errs = repo.RunCommand("submodule update", PopupManager.UpdateStatus, true);
if (errs != null) App.RaiseError(errs);
});
}
private void SubmoduleLostFocus(object sender, RoutedEventArgs e) {
(sender as DataGrid).UnselectAll();
}

View file

@ -0,0 +1,8 @@
<UserControl x:Class="SourceGit.UI.Waiting"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="160" d:DesignWidth="500" Height="200" Width="500">
</UserControl>

View file

@ -0,0 +1,35 @@
using System;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace SourceGit.UI {
/// <summary>
/// General waiting dialog.
/// </summary>
public partial class Waiting : UserControl {
/// <summary>
/// Constructor.
/// </summary>
public Waiting() {
InitializeComponent();
}
/// <summary>
/// Show this dialog.
/// </summary>
/// <param name="job"></param>
public static void Show(Action job) {
var dialog = new Waiting();
PopupManager.Show(dialog);
PopupManager.Lock();
Task.Run(() => {
job.Invoke();
dialog.Dispatcher.Invoke(() => {
PopupManager.Close(true);
});
});
}
}
}