mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
feature<Dashboard>: show waiting panel while staging objects
This commit is contained in:
parent
5bc7f9021b
commit
c1b9fbaddd
7 changed files with 59 additions and 29 deletions
|
@ -655,16 +655,25 @@ namespace SourceGit.Git {
|
|||
public void Stage(params string[] files) {
|
||||
isWatcherDisabled = true;
|
||||
|
||||
var args = "add";
|
||||
if (files == null || files.Length == 0) {
|
||||
args += " .";
|
||||
var errs = RunCommand("add .", null);
|
||||
if (errs != null) App.RaiseError(errs);
|
||||
} else {
|
||||
args += " --";
|
||||
foreach (var file in files) args += $" \"{file}\"";
|
||||
for (int i = 0; i < files.Length; i += 10) {
|
||||
var args = "add --";
|
||||
var maxIdx = i + 10;
|
||||
|
||||
for (int j = i; j < files.Length && j < maxIdx; j++) {
|
||||
args += $" \"{files[j]}\"";
|
||||
}
|
||||
|
||||
var errs = RunCommand(args, null);
|
||||
if (errs != null) App.RaiseError(errs);
|
||||
if (errs != null) {
|
||||
App.RaiseError(errs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OnWorkingCopyChanged?.Invoke();
|
||||
isWatcherDisabled = false;
|
||||
|
@ -677,14 +686,25 @@ namespace SourceGit.Git {
|
|||
public void Unstage(params string[] files) {
|
||||
isWatcherDisabled = true;
|
||||
|
||||
var args = "reset";
|
||||
if (files != null && files.Length > 0) {
|
||||
args += " --";
|
||||
foreach (var file in files) args += $" \"{file}\"";
|
||||
if (files == null || files.Length == 0) {
|
||||
var errs = RunCommand("reset", null);
|
||||
if (errs != null) App.RaiseError(errs);
|
||||
} else {
|
||||
for (int i = 0; i < files.Length; i += 10) {
|
||||
var args = "reset --";
|
||||
var maxIdx = i + 10;
|
||||
|
||||
for (int j = i; j < files.Length && j < maxIdx; j++) {
|
||||
args += $" \"{files[j]}\"";
|
||||
}
|
||||
|
||||
var errs = RunCommand(args, null);
|
||||
if (errs != null) App.RaiseError(errs);
|
||||
if (errs != null) {
|
||||
App.RaiseError(errs);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OnWorkingCopyChanged?.Invoke();
|
||||
isWatcherDisabled = false;
|
||||
|
|
|
@ -411,6 +411,9 @@
|
|||
<sys:String x:Key="Text.Conflict.Revert">Revert merge request detected! Press 'Abort' to restore original HEAD</sys:String>
|
||||
<sys:String x:Key="Text.Conflict.Merge">Merge request detected! Press 'Abort' to restore original HEAD</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.Waiting.UpdateSubmodule">WAITING SUBMOUDLE UPDATE COMPLETE...</sys:String>
|
||||
<sys:String x:Key="Text.Waiting.Staging">WAITING STAGE COMPLETE...</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.NotConfigured">Git has NOT been configured.\nPlease to go [Preference] and configure it first.</sys:String>
|
||||
<sys:String x:Key="Text.PathNotFound">Path[{0}] not exists!</sys:String>
|
||||
<sys:String x:Key="Text.MissingBash">Can NOT locate bash.exe. Make sure bash.exe exists under the same folder with git.exe</sys:String>
|
||||
|
|
|
@ -411,6 +411,9 @@
|
|||
<sys:String x:Key="Text.Conflict.Revert">检测到回滚提交冲突!</sys:String>
|
||||
<sys:String x:Key="Text.Conflict.Merge">检测到分支合并冲突!</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.Waiting.UpdateSubmodule">等待子模块更新完成...</sys:String>
|
||||
<sys:String x:Key="Text.Waiting.Staging">等待暂存完成 ...</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.NotConfigured">GIT尚未配置。请打开【偏好设置】配置GIT路径。</sys:String>
|
||||
<sys:String x:Key="Text.PathNotFound">路径({0})不存在或不可读取!</sys:String>
|
||||
<sys:String x:Key="Text.MissingBash">无法找到bash.exe,请确保其在git.exe同目录中!</sys:String>
|
||||
|
|
|
@ -991,7 +991,7 @@ namespace SourceGit.UI {
|
|||
}
|
||||
|
||||
private void UpdateSubmodule(object sender, RoutedEventArgs e) {
|
||||
Waiting.Show(repo, () => repo.UpdateSubmodule());
|
||||
Waiting.Show(repo, "Text.Waiting.UpdateSubmodule", () => repo.UpdateSubmodule());
|
||||
}
|
||||
|
||||
private void SubmoduleLostFocus(object sender, RoutedEventArgs e) {
|
||||
|
|
|
@ -5,4 +5,5 @@
|
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="160" d:DesignWidth="500" Height="200" Width="500">
|
||||
<TextBlock x:Name="txtTip" Text="WAITING ..." HorizontalAlignment="Center" VerticalAlignment="Center" FontFamily="Consolas" FontWeight="Bold" FontSize="16" Foreground="{StaticResource Brush.FG1}"/>
|
||||
</UserControl>
|
||||
|
|
|
@ -20,11 +20,14 @@ namespace SourceGit.UI {
|
|||
/// Show this dialog.
|
||||
/// </summary>
|
||||
/// <param name="repo"></param>
|
||||
/// <param name="tip"></param>
|
||||
/// <param name="job"></param>
|
||||
public static void Show(Git.Repository repo, Action job) {
|
||||
public static void Show(Git.Repository repo, string tipKey, Action job) {
|
||||
var dialog = new Waiting();
|
||||
var popup = repo.GetPopupManager();
|
||||
var tip = dialog.FindResource(tipKey) as string;
|
||||
if (tip != null) dialog.txtTip.Text = tip;
|
||||
|
||||
var popup = repo.GetPopupManager();
|
||||
popup?.Show(dialog);
|
||||
popup?.Lock();
|
||||
Task.Run(() => {
|
||||
|
|
|
@ -336,8 +336,8 @@ namespace SourceGit.UI {
|
|||
|
||||
var stage = new MenuItem();
|
||||
stage.Header = App.Text("FileCM.Stage");
|
||||
stage.Click += async (o, e) => {
|
||||
await Task.Run(() => Repo.Stage(node.FilePath));
|
||||
stage.Click += (o, e) => {
|
||||
Waiting.Show(Repo, "Text.Waiting.Staging", () => Repo.Stage(node.FilePath));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
|
@ -408,8 +408,8 @@ namespace SourceGit.UI {
|
|||
|
||||
var stage = new MenuItem();
|
||||
stage.Header = App.Format("FileCM.StageMulti", changes.Count);
|
||||
stage.Click += async (o, e) => {
|
||||
await Task.Run(() => Repo.Stage(files.ToArray()));
|
||||
stage.Click += (o, e) => {
|
||||
Waiting.Show(Repo, "Text.Waiting.Staging", () => Repo.Stage(files.ToArray()));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
|
@ -478,8 +478,8 @@ namespace SourceGit.UI {
|
|||
|
||||
var stage = new MenuItem();
|
||||
stage.Header = App.Text("FileCM.Stage");
|
||||
stage.Click += async (o, e) => {
|
||||
await Task.Run(() => Repo.Stage(change.Path));
|
||||
stage.Click += (o, e) => {
|
||||
Waiting.Show(Repo, "Text.Waiting.Staging", () => Repo.Stage(change.Path));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
|
@ -551,8 +551,8 @@ namespace SourceGit.UI {
|
|||
|
||||
var stage = new MenuItem();
|
||||
stage.Header = App.Format("FileCM.StageMulti", changes.Count);
|
||||
stage.Click += async (o, e) => {
|
||||
await Task.Run(() => Repo.Stage(files.ToArray()));
|
||||
stage.Click += (o, e) => {
|
||||
Waiting.Show(Repo, "Text.Waiting.Staging", () => Repo.Stage(files.ToArray()));
|
||||
e.Handled = true;
|
||||
};
|
||||
|
||||
|
@ -596,7 +596,7 @@ namespace SourceGit.UI {
|
|||
ev.Handled = true;
|
||||
}
|
||||
|
||||
private async void Stage(object sender, RoutedEventArgs e) {
|
||||
private void Stage(object sender, RoutedEventArgs e) {
|
||||
var files = new List<string>();
|
||||
|
||||
if (App.Setting.UI.UnstageFileDisplayMode != Preference.FilesDisplayMode.Tree) {
|
||||
|
@ -614,11 +614,11 @@ namespace SourceGit.UI {
|
|||
}
|
||||
|
||||
if (files.Count == 0) return;
|
||||
await Task.Run(() => Repo.Stage(files.ToArray()));
|
||||
Waiting.Show(Repo, "Text.Waiting.Staging", () => Repo.Stage(files.ToArray()));
|
||||
}
|
||||
|
||||
private async void StageAll(object sender, RoutedEventArgs e) {
|
||||
await Task.Run(() => Repo.Stage());
|
||||
private void StageAll(object sender, RoutedEventArgs e) {
|
||||
Waiting.Show(Repo, "Text.Waiting.Staging", () => Repo.Stage());
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
Loading…
Reference in a new issue