Skip to content

Commit

Permalink
feat: Tag filtering
Browse files Browse the repository at this point in the history
Close #45
  • Loading branch information
mob-sakai committed Oct 28, 2019
1 parent 948ab67 commit a3b0104
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@
<ui:VisualElement name="controlContainer" class="horizontal v-spaced">
<ui:Button name="closeButton" text="Close" class="button" />
</ui:VisualElement>
<ui:VisualElement name="optionContainer" class="horizontal v-spaced">
<ui:Toggle name="showAllVersionsToggle" />
<ui:Label text="Show All Versions" />
</ui:VisualElement>
<!--</ui:VisualElement>-->
</UXML>
18 changes: 18 additions & 0 deletions Packages/UpmGitExtension/Editor/Scripts/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@ public static HostData GetHostData (string packageId)
? Instance.m_HostData.FirstOrDefault (x => packageId.Contains (x.Domain)) ?? s_EmptyHostData
: s_EmptyHostData;
}

public static bool? _showAllVersions = null;
public static bool showAllVersions
{
get
{
_showAllVersions = _showAllVersions ?? EditorPrefs.GetBool ("com.coffee.upm-git-extension/showAllVersions", false);
return (bool)_showAllVersions;
}
set
{
if(_showAllVersions != value)
{
_showAllVersions = value;
EditorPrefs.SetBool ("com.coffee.upm-git-extension/showAllVersions", value);
}
}
}
}

[System.Serializable]
Expand Down
21 changes: 18 additions & 3 deletions Packages/UpmGitExtension/Editor/Scripts/UI/InstallPackageWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public InstallPackageWindow ()

closeButton = root.Q<Button> ("closeButton");

showAllVersionsToggle = root.Q<Toggle> ("showAllVersionsToggle");

// Url container
#if UNITY_2019_1_OR_NEWER
repoUrlText.RegisterValueChangedCallback ((evt) => onChange_RepoUrl (evt.newValue));
Expand All @@ -83,6 +85,10 @@ public InstallPackageWindow ()
// Controll container
closeButton.clickable.clicked += onClick_Close;

// Show all version
showAllVersionsToggle.value = Settings.showAllVersions;
showAllVersionsToggle.OnValueChanged((evt) => Settings.showAllVersions = evt.newValue);

SetPhase (Phase.InputRepoUrl);
}

Expand All @@ -107,6 +113,7 @@ public void Open ()
readonly Button findVersionsButton;
readonly Button versionSelectButton;
readonly Button findPackageButton;
readonly Toggle showAllVersionsToggle;
readonly Label packageNameLabel;
readonly TextField repoUrlText;
IEnumerable<string> versions = new string [0];
Expand Down Expand Up @@ -199,9 +206,17 @@ void onClick_SelectVersions ()
menu.AddItem(new GUIContent(t), currentRefName == t, callback, t);

menu.AddDisabledItem(GUIContent.none);

foreach (var t in orderdVers.Where(x => !regSemVer.IsMatch(x)))
menu.AddItem(new GUIContent(t), currentRefName == t, callback, t);

if(Settings.showAllVersions)
{
foreach (var t in orderdVers.Where (x => !regSemVer.IsMatch (x)))
menu.AddItem (new GUIContent (t), currentRefName == t, callback, t);
}
else
{
foreach (var t in orderdVers.Where (x => !regSemVer.IsMatch (x) && x.Contains("upm")))
menu.AddItem (new GUIContent (t), currentRefName == t, callback, t);
}

menu.DropDown(versionSelectButton.worldBound);
}
Expand Down
1 change: 1 addition & 0 deletions Packages/UpmGitExtension/Editor/Scripts/UpmGitExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ void UpdateGitPackages(Queue<Expose> packagesToUpdate, Dictionary<string, IEnume
void UpdatePackageInfoVersions(Expose exPackage, IEnumerable<string> versions)
{
Expose vers = Expose.FromObject(versions
.Where(x=>Settings.showAllVersions || regVersionValid.IsMatch (x) || x.Contains("upm"))
.Select(x => regVersionValid.IsMatch(x) ? x : "0.0.0-" + x)
.Distinct()
.OrderBy(x => x)
Expand Down

0 comments on commit a3b0104

Please sign in to comment.