зеркало из https://github.com/DeGsoft/maui-linux.git
Add filter toggles for the various issue trackers
This commit is contained in:
Родитель
0d199d1515
Коммит
9a8c3e7825
|
@ -1,13 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using Xamarin.Forms.Controls.TestCasesPages;
|
||||
using Xamarin.Forms.CustomAttributes;
|
||||
using Xamarin.Forms.Internals;
|
||||
|
||||
namespace Xamarin.Forms.Controls
|
||||
{
|
||||
|
@ -17,6 +12,11 @@ namespace Xamarin.Forms.Controls
|
|||
{
|
||||
public static Dictionary<string, Action> PageToAction = new Dictionary<string, Action> ();
|
||||
|
||||
bool _filterBugzilla;
|
||||
bool _filterNone;
|
||||
bool _filterGitHub;
|
||||
string _filter;
|
||||
|
||||
static TextCell MakeIssueCell (string text, string detail, Action tapped)
|
||||
{
|
||||
PageToAction[text] = tapped;
|
||||
|
@ -103,6 +103,8 @@ namespace Xamarin.Forms.Controls
|
|||
return true;
|
||||
}
|
||||
|
||||
// If the user has typed something which looks like part of a short issue name
|
||||
// (e.g. 'B605' or 'G13'), make sure we match that
|
||||
if (string.Compare(Name, 0, filter, 0, filter.Length, StringComparison.OrdinalIgnoreCase) == 0)
|
||||
{
|
||||
return true;
|
||||
|
@ -131,7 +133,7 @@ namespace Xamarin.Forms.Controls
|
|||
{
|
||||
if (duplicates.Contains (im.Name) && !IsExempt (im.Name)) {
|
||||
throw new NotSupportedException ("Please provide unique tracker + issue number combo: "
|
||||
+ im.IssueTracker.ToString () + im.IssueNumber.ToString () + im.IssueTestNumber.ToString());
|
||||
+ im.IssueTracker.ToString () + im.IssueNumber.ToString () + im.IssueTestNumber.ToString());
|
||||
}
|
||||
|
||||
duplicates.Add (im.Name);
|
||||
|
@ -144,7 +146,7 @@ namespace Xamarin.Forms.Controls
|
|||
|
||||
Intent = TableIntent.Settings;
|
||||
|
||||
var assembly = typeof (TestCases).GetTypeInfo ().Assembly;
|
||||
var assembly = typeof(TestCases).GetTypeInfo().Assembly;
|
||||
|
||||
_issues =
|
||||
(from typeInfo in assembly.DefinedTypes.Select (o => o.AsType ().GetTypeInfo ())
|
||||
|
@ -168,33 +170,70 @@ namespace Xamarin.Forms.Controls
|
|||
FilterIssues();
|
||||
}
|
||||
|
||||
public void FilterTracker(IssueTracker tracker)
|
||||
{
|
||||
switch (tracker)
|
||||
{
|
||||
case IssueTracker.Github:
|
||||
_filterGitHub = !_filterGitHub;
|
||||
break;
|
||||
case IssueTracker.Bugzilla:
|
||||
_filterBugzilla = !_filterBugzilla;
|
||||
break;
|
||||
case IssueTracker.None:
|
||||
_filterNone = !_filterNone;
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(tracker), tracker, null);
|
||||
}
|
||||
|
||||
FilterIssues(_filter);
|
||||
}
|
||||
|
||||
public void FilterIssues(string filter = null)
|
||||
{
|
||||
_filter = filter;
|
||||
|
||||
PageToAction.Clear();
|
||||
|
||||
var root = new TableRoot ();
|
||||
var section = new TableSection ("Bug Repro");
|
||||
root.Add (section);
|
||||
|
||||
var githubIssueCells =
|
||||
from issueModel in _issues
|
||||
where issueModel.IssueTracker == IssueTracker.Github && issueModel.Matches(filter)
|
||||
orderby issueModel.IssueNumber descending
|
||||
select MakeIssueCell (issueModel.Name, issueModel.Description, issueModel.Action);
|
||||
var issueCells = Enumerable.Empty<TextCell>();
|
||||
|
||||
var bugzillaIssueCells =
|
||||
from issueModel in _issues
|
||||
where issueModel.IssueTracker == IssueTracker.Bugzilla && issueModel.Matches(filter)
|
||||
orderby issueModel.IssueNumber descending
|
||||
select MakeIssueCell (issueModel.Name, issueModel.Description, issueModel.Action);
|
||||
if (!_filterBugzilla)
|
||||
{
|
||||
var bugzillaIssueCells =
|
||||
from issueModel in _issues
|
||||
where issueModel.IssueTracker == IssueTracker.Bugzilla && issueModel.Matches(filter)
|
||||
orderby issueModel.IssueNumber descending
|
||||
select MakeIssueCell(issueModel.Name, issueModel.Description, issueModel.Action);
|
||||
|
||||
var untrackedIssueCells =
|
||||
from issueModel in _issues
|
||||
where issueModel.IssueTracker == IssueTracker.None && issueModel.Matches(filter)
|
||||
orderby issueModel.IssueNumber descending, issueModel.Description
|
||||
select MakeIssueCell (issueModel.Name, issueModel.Description, issueModel.Action);
|
||||
issueCells = issueCells.Concat(bugzillaIssueCells);
|
||||
}
|
||||
|
||||
var issueCells = bugzillaIssueCells.Concat (githubIssueCells).Concat (untrackedIssueCells);
|
||||
if (!_filterGitHub)
|
||||
{
|
||||
var githubIssueCells =
|
||||
from issueModel in _issues
|
||||
where issueModel.IssueTracker == IssueTracker.Github && issueModel.Matches(filter)
|
||||
orderby issueModel.IssueNumber descending
|
||||
select MakeIssueCell(issueModel.Name, issueModel.Description, issueModel.Action);
|
||||
|
||||
issueCells = issueCells.Concat(githubIssueCells);
|
||||
}
|
||||
|
||||
if (!_filterNone)
|
||||
{
|
||||
var untrackedIssueCells =
|
||||
from issueModel in _issues
|
||||
where issueModel.IssueTracker == IssueTracker.None && issueModel.Matches(filter)
|
||||
orderby issueModel.IssueNumber descending, issueModel.Description
|
||||
select MakeIssueCell(issueModel.Name, issueModel.Description, issueModel.Action);
|
||||
|
||||
issueCells = issueCells.Concat(untrackedIssueCells);
|
||||
}
|
||||
|
||||
foreach (var issueCell in issueCells) {
|
||||
section.Add (issueCell);
|
||||
|
@ -228,7 +267,7 @@ namespace Xamarin.Forms.Controls
|
|||
};
|
||||
|
||||
var searchBar = new SearchBar() {
|
||||
HeightRequest = 42,
|
||||
HeightRequest = 42, // Need this for Android N, see https://bugzilla.xamarin.com/show_bug.cgi?id=43975
|
||||
AutomationId = "SearchBarGo"
|
||||
};
|
||||
|
||||
|
@ -257,6 +296,8 @@ namespace Xamarin.Forms.Controls
|
|||
|
||||
var testCaseScreen = new TestCaseScreen();
|
||||
|
||||
rootLayout.Children.Add(CreateTrackerFilter(testCaseScreen));
|
||||
|
||||
rootLayout.Children.Add(testCaseScreen);
|
||||
|
||||
searchBar.TextChanged += (sender, args) => SearchBarOnTextChanged(sender, args, testCaseScreen);
|
||||
|
@ -275,6 +316,32 @@ namespace Xamarin.Forms.Controls
|
|||
return page;
|
||||
}
|
||||
|
||||
static Layout CreateTrackerFilter(TestCaseScreen testCaseScreen)
|
||||
{
|
||||
var trackerFilterLayout = new StackLayout
|
||||
{
|
||||
Orientation = StackOrientation.Horizontal,
|
||||
HorizontalOptions = LayoutOptions.Fill
|
||||
};
|
||||
|
||||
var bzSwitch = new Switch { IsToggled = true };
|
||||
trackerFilterLayout.Children.Add(new Label { Text = "Bugzilla" });
|
||||
trackerFilterLayout.Children.Add(bzSwitch);
|
||||
bzSwitch.Toggled += (sender, args) => testCaseScreen.FilterTracker(IssueTracker.Bugzilla);
|
||||
|
||||
var ghSwitch = new Switch { IsToggled = true };
|
||||
trackerFilterLayout.Children.Add(new Label { Text = "GitHub" });
|
||||
trackerFilterLayout.Children.Add(ghSwitch);
|
||||
ghSwitch.Toggled += (sender, args) => testCaseScreen.FilterTracker(IssueTracker.Github);
|
||||
|
||||
var noneSwitch = new Switch { IsToggled = true };
|
||||
trackerFilterLayout.Children.Add(new Label { Text = "None" });
|
||||
trackerFilterLayout.Children.Add(noneSwitch);
|
||||
noneSwitch.Toggled += (sender, args) => testCaseScreen.FilterTracker(IssueTracker.None);
|
||||
|
||||
return trackerFilterLayout;
|
||||
}
|
||||
|
||||
static void SearchBarOnTextChanged(object sender, TextChangedEventArgs textChangedEventArgs, TestCaseScreen cases)
|
||||
{
|
||||
var filter = textChangedEventArgs.NewTextValue;
|
||||
|
|
Загрузка…
Ссылка в новой задаче