mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-11-01 13:13:21 -07:00
fix<Manager>: refresh home page when successfully clone/init a repository
This commit is contained in:
parent
00214fe0ab
commit
4600d46328
3 changed files with 31 additions and 9 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
@ -10,6 +11,7 @@ namespace SourceGit.UI {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Clone : UserControl {
|
public partial class Clone : UserControl {
|
||||||
private PopupManager popup = null;
|
private PopupManager popup = null;
|
||||||
|
private Action cb = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Remote repository
|
/// Remote repository
|
||||||
|
@ -34,9 +36,10 @@ namespace SourceGit.UI {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Clone(PopupManager mgr) {
|
public Clone(PopupManager mgr, Action success) {
|
||||||
ParentFolder = App.Setting.Tools.GitDefaultCloneDir;
|
ParentFolder = App.Setting.Tools.GitDefaultCloneDir;
|
||||||
popup = mgr;
|
popup = mgr;
|
||||||
|
cb = success;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +93,9 @@ namespace SourceGit.UI {
|
||||||
if (succ) {
|
if (succ) {
|
||||||
var path = new DirectoryInfo(ParentFolder + "/" + repoName).FullName;
|
var path = new DirectoryInfo(ParentFolder + "/" + repoName).FullName;
|
||||||
var repo = App.Setting.AddRepository(path, "");
|
var repo = App.Setting.AddRepository(path, "");
|
||||||
repo.Open();
|
App.Open(repo);
|
||||||
|
cb?.Invoke();
|
||||||
|
popup.Close(true);
|
||||||
} else {
|
} else {
|
||||||
popup.Unlock();
|
popup.Unlock();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
@ -10,15 +11,17 @@ namespace SourceGit.UI {
|
||||||
public partial class Init : UserControl {
|
public partial class Init : UserControl {
|
||||||
private PopupManager popup = null;
|
private PopupManager popup = null;
|
||||||
private string workingDir = null;
|
private string workingDir = null;
|
||||||
|
private Action onSuccess = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor.
|
/// Constructor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mgr"></param>
|
/// <param name="mgr"></param>
|
||||||
/// <param name="path"></param>
|
/// <param name="path"></param>
|
||||||
public Init(PopupManager mgr, string path) {
|
public Init(PopupManager mgr, string path, Action success) {
|
||||||
popup = mgr;
|
popup = mgr;
|
||||||
workingDir = path;
|
workingDir = path;
|
||||||
|
onSuccess = success;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
txtPath.Content = path;
|
txtPath.Content = path;
|
||||||
}
|
}
|
||||||
|
@ -40,10 +43,13 @@ namespace SourceGit.UI {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
popup.Close(true);
|
|
||||||
|
|
||||||
var repo = App.Setting.FindRepository(workingDir);
|
var repo = App.Setting.FindRepository(workingDir);
|
||||||
if (repo != null) repo.Open();
|
if (repo != null) {
|
||||||
|
App.Open(repo);
|
||||||
|
onSuccess?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
popup.Close(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -57,7 +57,12 @@ namespace SourceGit.UI {
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void CloneRepo(object sender, RoutedEventArgs e) {
|
private void CloneRepo(object sender, RoutedEventArgs e) {
|
||||||
if (MakeSureReady()) popupManager.Show(new Clone(popupManager));
|
if (MakeSureReady()) {
|
||||||
|
popupManager.Show(new Clone(popupManager, () => {
|
||||||
|
UpdateRecentOpened();
|
||||||
|
UpdateTree();
|
||||||
|
}));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -401,7 +406,10 @@ namespace SourceGit.UI {
|
||||||
private void ShowBrief(Git.Repository repo) {
|
private void ShowBrief(Git.Repository repo) {
|
||||||
if (repo == null || !Git.Repository.IsValid(repo.Path)) {
|
if (repo == null || !Git.Repository.IsValid(repo.Path)) {
|
||||||
if (Directory.Exists(repo.Path)) {
|
if (Directory.Exists(repo.Path)) {
|
||||||
popupManager.Show(new Init(popupManager, repo.Path));
|
popupManager.Show(new Init(popupManager, repo.Path, () => {
|
||||||
|
UpdateRecentOpened();
|
||||||
|
UpdateTree();
|
||||||
|
}));
|
||||||
} else {
|
} else {
|
||||||
App.RaiseError("Path is NOT valid git repository or has been removed.");
|
App.RaiseError("Path is NOT valid git repository or has been removed.");
|
||||||
App.Setting.RemoveRepository(repo.Path);
|
App.Setting.RemoveRepository(repo.Path);
|
||||||
|
@ -477,7 +485,10 @@ namespace SourceGit.UI {
|
||||||
|
|
||||||
if (!Git.Repository.IsValid(path)) {
|
if (!Git.Repository.IsValid(path)) {
|
||||||
if (Directory.Exists(path)) {
|
if (Directory.Exists(path)) {
|
||||||
popupManager.Show(new Init(popupManager, path));
|
popupManager.Show(new Init(popupManager, path, () => {
|
||||||
|
UpdateRecentOpened();
|
||||||
|
UpdateTree();
|
||||||
|
}));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue