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