mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
refactor: merge sourcegit.issuetracker.setting to sourcegit.settings.
This commit is contained in:
parent
f754b2c63a
commit
dfd098e131
15 changed files with 100 additions and 122 deletions
|
@ -64,6 +64,5 @@ namespace SourceGit
|
||||||
[JsonSerializable(typeof(Models.Version))]
|
[JsonSerializable(typeof(Models.Version))]
|
||||||
[JsonSerializable(typeof(Models.RepositorySettings))]
|
[JsonSerializable(typeof(Models.RepositorySettings))]
|
||||||
[JsonSerializable(typeof(ViewModels.Preference))]
|
[JsonSerializable(typeof(ViewModels.Preference))]
|
||||||
[JsonSerializable(typeof(ViewModels.IssueTrackerRuleSetting))]
|
|
||||||
internal partial class JsonCodeGen : JsonSerializerContext { }
|
internal partial class JsonCodeGen : JsonSerializerContext { }
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ using Avalonia.Collections;
|
||||||
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
namespace SourceGit.ViewModels
|
namespace SourceGit.Models
|
||||||
{
|
{
|
||||||
public class IssueTrackerMatch
|
public class IssueTrackerMatch
|
||||||
{
|
{
|
||||||
|
@ -72,7 +72,7 @@ namespace SourceGit.ViewModels
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var matches = _regex.Matches(message);
|
var matches = _regex.Matches(message);
|
||||||
for (int i = 0; i < matches.Count; i++)
|
for (var i = 0; i < matches.Count; i++)
|
||||||
{
|
{
|
||||||
var match = matches[i];
|
var match = matches[i];
|
||||||
if (!match.Success)
|
if (!match.Success)
|
||||||
|
@ -97,7 +97,7 @@ namespace SourceGit.ViewModels
|
||||||
range.Start = start;
|
range.Start = start;
|
||||||
range.Length = len;
|
range.Length = len;
|
||||||
range.URL = _urlTemplate;
|
range.URL = _urlTemplate;
|
||||||
for (int j = 1; j < match.Groups.Count; j++)
|
for (var j = 1; j < match.Groups.Count; j++)
|
||||||
{
|
{
|
||||||
var group = match.Groups[j];
|
var group = match.Groups[j];
|
||||||
if (group.Success)
|
if (group.Success)
|
||||||
|
@ -113,52 +113,4 @@ namespace SourceGit.ViewModels
|
||||||
private string _urlTemplate;
|
private string _urlTemplate;
|
||||||
private Regex _regex = null;
|
private Regex _regex = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class IssueTrackerRuleSetting
|
|
||||||
{
|
|
||||||
public AvaloniaList<IssueTrackerRule> Rules
|
|
||||||
{
|
|
||||||
get;
|
|
||||||
set;
|
|
||||||
} = new AvaloniaList<IssueTrackerRule>();
|
|
||||||
|
|
||||||
public IssueTrackerRule Add()
|
|
||||||
{
|
|
||||||
var rule = new IssueTrackerRule()
|
|
||||||
{
|
|
||||||
Name = "New Issue Tracker",
|
|
||||||
RegexString = "#(\\d+)",
|
|
||||||
URLTemplate = "https://xxx/$1",
|
|
||||||
};
|
|
||||||
|
|
||||||
Rules.Add(rule);
|
|
||||||
return rule;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IssueTrackerRule AddGithub(string repoURL)
|
|
||||||
{
|
|
||||||
var rule = new IssueTrackerRule()
|
|
||||||
{
|
|
||||||
Name = "Github ISSUE",
|
|
||||||
RegexString = "#(\\d+)",
|
|
||||||
URLTemplate = string.IsNullOrEmpty(repoURL) ? "https://github.com/username/repository/issues/$1" : $"{repoURL}/issues/$1",
|
|
||||||
};
|
|
||||||
|
|
||||||
Rules.Add(rule);
|
|
||||||
return rule;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IssueTrackerRule AddJira()
|
|
||||||
{
|
|
||||||
var rule = new IssueTrackerRule()
|
|
||||||
{
|
|
||||||
Name = "Jira Tracker",
|
|
||||||
RegexString = "PROJ-(\\d+)",
|
|
||||||
URLTemplate = "https://jira.yourcompany.com/browse/PROJ-$1",
|
|
||||||
};
|
|
||||||
|
|
||||||
Rules.Add(rule);
|
|
||||||
return rule;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -76,6 +76,12 @@ namespace SourceGit.Models
|
||||||
set;
|
set;
|
||||||
} = new AvaloniaList<string>();
|
} = new AvaloniaList<string>();
|
||||||
|
|
||||||
|
public AvaloniaList<IssueTrackerRule> IssueTrackerRules
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
set;
|
||||||
|
} = new AvaloniaList<IssueTrackerRule>();
|
||||||
|
|
||||||
public void PushCommitMessage(string message)
|
public void PushCommitMessage(string message)
|
||||||
{
|
{
|
||||||
var existIdx = CommitMessages.IndexOf(message);
|
var existIdx = CommitMessages.IndexOf(message);
|
||||||
|
@ -93,5 +99,50 @@ namespace SourceGit.Models
|
||||||
|
|
||||||
CommitMessages.Insert(0, message);
|
CommitMessages.Insert(0, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IssueTrackerRule AddNewIssueTracker()
|
||||||
|
{
|
||||||
|
var rule = new IssueTrackerRule()
|
||||||
|
{
|
||||||
|
Name = "New Issue Tracker",
|
||||||
|
RegexString = "#(\\d+)",
|
||||||
|
URLTemplate = "https://xxx/$1",
|
||||||
|
};
|
||||||
|
|
||||||
|
IssueTrackerRules.Add(rule);
|
||||||
|
return rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IssueTrackerRule AddGithubIssueTracker(string repoURL)
|
||||||
|
{
|
||||||
|
var rule = new IssueTrackerRule()
|
||||||
|
{
|
||||||
|
Name = "Github ISSUE",
|
||||||
|
RegexString = "#(\\d+)",
|
||||||
|
URLTemplate = string.IsNullOrEmpty(repoURL) ? "https://github.com/username/repository/issues/$1" : $"{repoURL}/issues/$1",
|
||||||
|
};
|
||||||
|
|
||||||
|
IssueTrackerRules.Add(rule);
|
||||||
|
return rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IssueTrackerRule AddJiraIssueTracker()
|
||||||
|
{
|
||||||
|
var rule = new IssueTrackerRule()
|
||||||
|
{
|
||||||
|
Name = "Jira Tracker",
|
||||||
|
RegexString = "PROJ-(\\d+)",
|
||||||
|
URLTemplate = "https://jira.yourcompany.com/browse/PROJ-$1",
|
||||||
|
};
|
||||||
|
|
||||||
|
IssueTrackerRules.Add(rule);
|
||||||
|
return rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveIssueTracker(IssueTrackerRule rule)
|
||||||
|
{
|
||||||
|
if (rule != null)
|
||||||
|
IssueTrackerRules.Remove(rule);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
using Avalonia.Collections;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Media.Imaging;
|
using Avalonia.Media.Imaging;
|
||||||
using Avalonia.Platform.Storage;
|
using Avalonia.Platform.Storage;
|
||||||
|
@ -88,15 +89,15 @@ namespace SourceGit.ViewModels
|
||||||
set => SetProperty(ref _viewRevisionFileContent, value);
|
set => SetProperty(ref _viewRevisionFileContent, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IssueTrackerRuleSetting IssueTrackerSetting
|
public AvaloniaList<Models.IssueTrackerRule> IssueTrackerRules
|
||||||
{
|
{
|
||||||
get => _issueTrackerSetting;
|
get => _issueTrackerRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommitDetail(string repo, IssueTrackerRuleSetting issueTrackerSetting)
|
public CommitDetail(string repo, AvaloniaList<Models.IssueTrackerRule> issueTrackerRules)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_issueTrackerSetting = issueTrackerSetting;
|
_issueTrackerRules = issueTrackerRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Cleanup()
|
public void Cleanup()
|
||||||
|
@ -248,7 +249,7 @@ namespace SourceGit.ViewModels
|
||||||
history.Icon = App.CreateMenuIcon("Icons.Histories");
|
history.Icon = App.CreateMenuIcon("Icons.Histories");
|
||||||
history.Click += (_, ev) =>
|
history.Click += (_, ev) =>
|
||||||
{
|
{
|
||||||
var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, change.Path, _issueTrackerSetting) };
|
var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, change.Path, _issueTrackerRules) };
|
||||||
window.Show();
|
window.Show();
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
@ -311,7 +312,7 @@ namespace SourceGit.ViewModels
|
||||||
history.Icon = App.CreateMenuIcon("Icons.Histories");
|
history.Icon = App.CreateMenuIcon("Icons.Histories");
|
||||||
history.Click += (_, ev) =>
|
history.Click += (_, ev) =>
|
||||||
{
|
{
|
||||||
var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, file.Path, _issueTrackerSetting) };
|
var window = new Views.FileHistories() { DataContext = new FileHistories(_repo, file.Path, _issueTrackerRules) };
|
||||||
window.Show();
|
window.Show();
|
||||||
ev.Handled = true;
|
ev.Handled = true;
|
||||||
};
|
};
|
||||||
|
@ -463,7 +464,7 @@ namespace SourceGit.ViewModels
|
||||||
};
|
};
|
||||||
|
|
||||||
private string _repo;
|
private string _repo;
|
||||||
private IssueTrackerRuleSetting _issueTrackerSetting = null;
|
private AvaloniaList<Models.IssueTrackerRule> _issueTrackerRules = null;
|
||||||
private int _activePageIndex = 0;
|
private int _activePageIndex = 0;
|
||||||
private Models.Commit _commit = null;
|
private Models.Commit _commit = null;
|
||||||
private string _fullMessage = string.Empty;
|
private string _fullMessage = string.Empty;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Avalonia.Collections;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
@ -54,11 +54,11 @@ namespace SourceGit.ViewModels
|
||||||
set => SetProperty(ref _detailContext, value);
|
set => SetProperty(ref _detailContext, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileHistories(string repo, string file, IssueTrackerRuleSetting issueTrackerSetting)
|
public FileHistories(string repo, string file, AvaloniaList<Models.IssueTrackerRule> issueTrackerRules)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
_file = file;
|
_file = file;
|
||||||
_detailContext = new CommitDetail(repo, issueTrackerSetting);
|
_detailContext = new CommitDetail(repo, issueTrackerRules);
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,7 +94,7 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var commitDetail = new CommitDetail(_repo.FullPath, _repo.IssueTrackerSetting);
|
var commitDetail = new CommitDetail(_repo.FullPath, _repo.Settings.IssueTrackerRules);
|
||||||
commitDetail.Commit = commit;
|
commitDetail.Commit = commit;
|
||||||
DetailContext = commitDetail;
|
DetailContext = commitDetail;
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ namespace SourceGit.ViewModels
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var commitDetail = new CommitDetail(_repo.FullPath, _repo.IssueTrackerSetting);
|
var commitDetail = new CommitDetail(_repo.FullPath, _repo.Settings.IssueTrackerRules);
|
||||||
commitDetail.Commit = commit;
|
commitDetail.Commit = commit;
|
||||||
DetailContext = commitDetail;
|
DetailContext = commitDetail;
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,7 +114,7 @@ namespace SourceGit.ViewModels
|
||||||
Current = current;
|
Current = current;
|
||||||
On = on;
|
On = on;
|
||||||
IsLoading = true;
|
IsLoading = true;
|
||||||
DetailContext = new CommitDetail(repoPath, repo.IssueTrackerSetting);
|
DetailContext = new CommitDetail(repoPath, repo.Settings.IssueTrackerRules);
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,11 +44,6 @@ namespace SourceGit.ViewModels
|
||||||
get => _settings;
|
get => _settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IssueTrackerRuleSetting IssueTrackerSetting
|
|
||||||
{
|
|
||||||
get => _issueTrackerSetting;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int SelectedViewIndex
|
public int SelectedViewIndex
|
||||||
{
|
{
|
||||||
get => _selectedViewIndex;
|
get => _selectedViewIndex;
|
||||||
|
@ -324,23 +319,6 @@ namespace SourceGit.ViewModels
|
||||||
_settings = new Models.RepositorySettings();
|
_settings = new Models.RepositorySettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
var issueTrackerSettingsFile = Path.Combine(_gitDir, "sourcegit.issuetracker.settings");
|
|
||||||
if (File.Exists(issueTrackerSettingsFile))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_issueTrackerSetting = JsonSerializer.Deserialize(File.ReadAllText(issueTrackerSettingsFile), JsonCodeGen.Default.IssueTrackerRuleSetting);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
_issueTrackerSetting = new IssueTrackerRuleSetting();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_issueTrackerSetting = new IssueTrackerRuleSetting();
|
|
||||||
}
|
|
||||||
|
|
||||||
_watcher = new Models.Watcher(this);
|
_watcher = new Models.Watcher(this);
|
||||||
_histories = new Histories(this);
|
_histories = new Histories(this);
|
||||||
_workingCopy = new WorkingCopy(this);
|
_workingCopy = new WorkingCopy(this);
|
||||||
|
@ -361,10 +339,6 @@ namespace SourceGit.ViewModels
|
||||||
File.WriteAllText(Path.Combine(_gitDir, "sourcegit.settings"), settingsSerialized);
|
File.WriteAllText(Path.Combine(_gitDir, "sourcegit.settings"), settingsSerialized);
|
||||||
_settings = null;
|
_settings = null;
|
||||||
|
|
||||||
var issueTrackerSerialized = JsonSerializer.Serialize(_issueTrackerSetting, JsonCodeGen.Default.IssueTrackerRuleSetting);
|
|
||||||
File.WriteAllText(Path.Combine(_gitDir, "sourcegit.issuetracker.settings"), issueTrackerSerialized);
|
|
||||||
_issueTrackerSetting = null;
|
|
||||||
|
|
||||||
_watcher.Dispose();
|
_watcher.Dispose();
|
||||||
_histories.Cleanup();
|
_histories.Cleanup();
|
||||||
_workingCopy.Cleanup();
|
_workingCopy.Cleanup();
|
||||||
|
@ -1986,7 +1960,6 @@ namespace SourceGit.ViewModels
|
||||||
private string _fullpath = string.Empty;
|
private string _fullpath = string.Empty;
|
||||||
private string _gitDir = string.Empty;
|
private string _gitDir = string.Empty;
|
||||||
private Models.RepositorySettings _settings = null;
|
private Models.RepositorySettings _settings = null;
|
||||||
private IssueTrackerRuleSetting _issueTrackerSetting = null;
|
|
||||||
|
|
||||||
private Models.Watcher _watcher = null;
|
private Models.Watcher _watcher = null;
|
||||||
private Histories _histories = null;
|
private Histories _histories = null;
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Avalonia.Collections;
|
using Avalonia.Collections;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
|
|
||||||
|
@ -43,12 +42,12 @@ namespace SourceGit.ViewModels
|
||||||
set => SetProperty(ref _httpProxy, value);
|
set => SetProperty(ref _httpProxy, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AvaloniaList<IssueTrackerRule> IssueTrackerRules
|
public AvaloniaList<Models.IssueTrackerRule> IssueTrackerRules
|
||||||
{
|
{
|
||||||
get => _repo.IssueTrackerSetting.Rules;
|
get => _repo.Settings.IssueTrackerRules;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IssueTrackerRule SelectedIssueTrackerRule
|
public Models.IssueTrackerRule SelectedIssueTrackerRule
|
||||||
{
|
{
|
||||||
get => _selectedIssueTrackerRule;
|
get => _selectedIssueTrackerRule;
|
||||||
set => SetProperty(ref _selectedIssueTrackerRule, value);
|
set => SetProperty(ref _selectedIssueTrackerRule, value);
|
||||||
|
@ -86,29 +85,29 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
if (remote.TryGetVisitURL(out string url))
|
if (remote.TryGetVisitURL(out string url))
|
||||||
{
|
{
|
||||||
SelectedIssueTrackerRule = _repo.IssueTrackerSetting.AddGithub(url);
|
SelectedIssueTrackerRule = _repo.Settings.AddGithubIssueTracker(url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectedIssueTrackerRule = _repo.IssueTrackerSetting.AddGithub(null);
|
SelectedIssueTrackerRule = _repo.Settings.AddGithubIssueTracker(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddSampleJiraIssueTracker()
|
public void AddSampleJiraIssueTracker()
|
||||||
{
|
{
|
||||||
SelectedIssueTrackerRule = _repo.IssueTrackerSetting.AddJira();
|
SelectedIssueTrackerRule = _repo.Settings.AddJiraIssueTracker();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void NewIssueTracker()
|
public void NewIssueTracker()
|
||||||
{
|
{
|
||||||
SelectedIssueTrackerRule = _repo.IssueTrackerSetting.Add();
|
SelectedIssueTrackerRule = _repo.Settings.AddNewIssueTracker();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveSelectedIssueTracker()
|
public void RemoveSelectedIssueTracker()
|
||||||
{
|
{
|
||||||
if (_selectedIssueTrackerRule != null)
|
_repo.Settings.RemoveIssueTracker(_selectedIssueTrackerRule);
|
||||||
_repo.IssueTrackerSetting.Rules.Remove(_selectedIssueTrackerRule);
|
SelectedIssueTrackerRule = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Save()
|
public void Save()
|
||||||
|
@ -142,6 +141,6 @@ namespace SourceGit.ViewModels
|
||||||
private readonly Repository _repo = null;
|
private readonly Repository _repo = null;
|
||||||
private readonly Dictionary<string, string> _cached = null;
|
private readonly Dictionary<string, string> _cached = null;
|
||||||
private string _httpProxy;
|
private string _httpProxy;
|
||||||
private IssueTrackerRule _selectedIssueTrackerRule = null;
|
private Models.IssueTrackerRule _selectedIssueTrackerRule = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -541,7 +541,7 @@ namespace SourceGit.ViewModels
|
||||||
history.Icon = App.CreateMenuIcon("Icons.Histories");
|
history.Icon = App.CreateMenuIcon("Icons.Histories");
|
||||||
history.Click += (_, e) =>
|
history.Click += (_, e) =>
|
||||||
{
|
{
|
||||||
var window = new Views.FileHistories() { DataContext = new FileHistories(_repo.FullPath, change.Path, _repo.IssueTrackerSetting) };
|
var window = new Views.FileHistories() { DataContext = new FileHistories(_repo.FullPath, change.Path, _repo.Settings.IssueTrackerRules) };
|
||||||
window.Show();
|
window.Show();
|
||||||
e.Handled = true;
|
e.Handled = true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
Margin="12,5,8,0"
|
Margin="12,5,8,0"
|
||||||
Classes="primary"
|
Classes="primary"
|
||||||
Message="{Binding #ThisControl.Message}"
|
Message="{Binding #ThisControl.Message}"
|
||||||
IssueTrackerSetting="{Binding #ThisControl.IssueTrackerSetting}"
|
IssueTrackerRules="{Binding #ThisControl.IssueTrackerRules}"
|
||||||
TextWrapping="Wrap"/>
|
TextWrapping="Wrap"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
using Avalonia.Collections;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
|
|
||||||
|
@ -24,13 +25,13 @@ namespace SourceGit.Views
|
||||||
set => SetValue(MessageProperty, value);
|
set => SetValue(MessageProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<ViewModels.IssueTrackerRuleSetting> IssueTrackerSettingProperty =
|
public static readonly StyledProperty<AvaloniaList<Models.IssueTrackerRule>> IssueTrackerRulesProperty =
|
||||||
AvaloniaProperty.Register<CommitBaseInfo, ViewModels.IssueTrackerRuleSetting>(nameof(IssueTrackerSetting));
|
AvaloniaProperty.Register<CommitBaseInfo, AvaloniaList<Models.IssueTrackerRule>>(nameof(IssueTrackerRules));
|
||||||
|
|
||||||
public ViewModels.IssueTrackerRuleSetting IssueTrackerSetting
|
public AvaloniaList<Models.IssueTrackerRule> IssueTrackerRules
|
||||||
{
|
{
|
||||||
get => GetValue(IssueTrackerSettingProperty);
|
get => GetValue(IssueTrackerRulesProperty);
|
||||||
set => SetValue(IssueTrackerSettingProperty, value);
|
set => SetValue(IssueTrackerRulesProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommitBaseInfo()
|
public CommitBaseInfo()
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<!-- Base Information -->
|
<!-- Base Information -->
|
||||||
<v:CommitBaseInfo Content="{Binding Commit}"
|
<v:CommitBaseInfo Content="{Binding Commit}"
|
||||||
Message="{Binding FullMessage}"
|
Message="{Binding FullMessage}"
|
||||||
IssueTrackerSetting="{Binding IssueTrackerSetting}"/>
|
IssueTrackerRules="{Binding IssueTrackerRules}"/>
|
||||||
|
|
||||||
<!-- Line -->
|
<!-- Line -->
|
||||||
<Rectangle Height=".65" Margin="8" Fill="{DynamicResource Brush.Border2}"/>
|
<Rectangle Height=".65" Margin="8" Fill="{DynamicResource Brush.Border2}"/>
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
|
using Avalonia.Collections;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Controls.Documents;
|
using Avalonia.Controls.Documents;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
|
@ -19,13 +20,13 @@ namespace SourceGit.Views
|
||||||
set => SetValue(MessageProperty, value);
|
set => SetValue(MessageProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<ViewModels.IssueTrackerRuleSetting> IssueTrackerSettingProperty =
|
public static readonly StyledProperty<AvaloniaList<Models.IssueTrackerRule>> IssueTrackerRulesProperty =
|
||||||
AvaloniaProperty.Register<CommitMessagePresenter, ViewModels.IssueTrackerRuleSetting>(nameof(IssueTrackerSetting));
|
AvaloniaProperty.Register<CommitMessagePresenter, AvaloniaList<Models.IssueTrackerRule>>(nameof(IssueTrackerRules));
|
||||||
|
|
||||||
public ViewModels.IssueTrackerRuleSetting IssueTrackerSetting
|
public AvaloniaList<Models.IssueTrackerRule> IssueTrackerRules
|
||||||
{
|
{
|
||||||
get => GetValue(IssueTrackerSettingProperty);
|
get => GetValue(IssueTrackerRulesProperty);
|
||||||
set => SetValue(IssueTrackerSettingProperty, value);
|
set => SetValue(IssueTrackerRulesProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Type StyleKeyOverride => typeof(SelectableTextBlock);
|
protected override Type StyleKeyOverride => typeof(SelectableTextBlock);
|
||||||
|
@ -34,7 +35,7 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
base.OnPropertyChanged(change);
|
base.OnPropertyChanged(change);
|
||||||
|
|
||||||
if (change.Property == MessageProperty || change.Property == IssueTrackerSettingProperty)
|
if (change.Property == MessageProperty || change.Property == IssueTrackerRulesProperty)
|
||||||
{
|
{
|
||||||
Inlines.Clear();
|
Inlines.Clear();
|
||||||
|
|
||||||
|
@ -42,14 +43,14 @@ namespace SourceGit.Views
|
||||||
if (string.IsNullOrEmpty(message))
|
if (string.IsNullOrEmpty(message))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var rules = IssueTrackerSetting?.Rules;
|
var rules = IssueTrackerRules;
|
||||||
if (rules == null || rules.Count == 0)
|
if (rules == null || rules.Count == 0)
|
||||||
{
|
{
|
||||||
Inlines.Add(new Run(message));
|
Inlines.Add(new Run(message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var matches = new List<ViewModels.IssueTrackerMatch>();
|
var matches = new List<Models.IssueTrackerMatch>();
|
||||||
foreach (var rule in rules)
|
foreach (var rule in rules)
|
||||||
rule.Matches(matches, message);
|
rule.Matches(matches, message);
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:m="using:SourceGit.Models"
|
||||||
xmlns:vm="using:SourceGit.ViewModels"
|
xmlns:vm="using:SourceGit.ViewModels"
|
||||||
xmlns:v="using:SourceGit.Views"
|
xmlns:v="using:SourceGit.Views"
|
||||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||||
|
@ -141,7 +142,7 @@
|
||||||
</ListBox.ItemsPanel>
|
</ListBox.ItemsPanel>
|
||||||
|
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate DataType="vm:IssueTrackerRule">
|
<DataTemplate DataType="m:IssueTrackerRule">
|
||||||
<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="8,0" TextTrimming="CharacterEllipsis"/>
|
<TextBlock Grid.Column="1" Text="{Binding Name}" Margin="8,0" TextTrimming="CharacterEllipsis"/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
|
@ -187,7 +188,7 @@
|
||||||
</ContentControl.Content>
|
</ContentControl.Content>
|
||||||
|
|
||||||
<ContentControl.DataTemplates>
|
<ContentControl.DataTemplates>
|
||||||
<DataTemplate DataType="vm:IssueTrackerRule">
|
<DataTemplate DataType="m:IssueTrackerRule">
|
||||||
<Grid Grid.Column="1" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto">
|
<Grid Grid.Column="1" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto">
|
||||||
<TextBlock Grid.Row="0" Text="{DynamicResource Text.Configure.IssueTracker.RuleName}"/>
|
<TextBlock Grid.Row="0" Text="{DynamicResource Text.Configure.IssueTracker.RuleName}"/>
|
||||||
<TextBox Grid.Row="1" CornerRadius="3" Height="28" Text="{Binding Name, Mode=TwoWay}"/>
|
<TextBox Grid.Row="1" CornerRadius="3" Height="28" Text="{Binding Name, Mode=TwoWay}"/>
|
||||||
|
|
Loading…
Reference in a new issue