-
Notifications
You must be signed in to change notification settings - Fork 735
Package Source Mapping Options UI #4711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageItem.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageItem.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourceItem.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/AddMappingDialog.xaml.cs
Show resolved
Hide resolved
829a07d to
849bb52
Compare
donnie-msft
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Things are really coming along nicely! 🥳
Few considerations, nitpicks, and suggestions...
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageItem.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/AddMappingDialog.xaml
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/AddMappingDialog.xaml
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/AddMappingDialog.xaml
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/AddMappingDialog.xaml
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/ItemsChangeObservableCollectionBase.cs
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourceMappingOptionsControl.xaml.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageItem.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourceItem.cs
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| //converts from list of packagesourcemappingsourceItems to a dictonary that can be read by UI | ||
| private ItemsChangeObservableCollection<PackageItem> ReadMappingsFromConfigToUI(IReadOnlyList<PackageSourceMappingSourceItem> originalMappings) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this method be reduced? As another reviewer mentioned, I think more ideal would be using a more generic type than ObservableCollection, then interacting with the single SourceMappingsCollection directly.
| /// Source name to package patterns list. | ||
| /// </summary> | ||
| internal IReadOnlyDictionary<string, IReadOnlyList<string>> Patterns { get; } | ||
| public IReadOnlyDictionary<string, IReadOnlyList<string>> Patterns { get; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is not in draft mode, but this change (and others in src/NuGet.Core) are from this PR: #4709
Please focus one completing dependent PRs before marking new PRs that need the same change as "ready for review", to minimize workload on the rest of the team.
| using Microsoft.VisualStudio.Shell; | ||
|
|
||
|
|
||
| namespace NuGet.Options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This namespace doesn't feel right to me. Usually project default namespaces are the project name + folder within the project, so shouldn't the namespace be NuGet.PackageManagement.UI.Options?
Same question for the other new files in this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided not to change the namespace since the two existing options pages are in the NuGet.Options namespace.
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageItem.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageItem.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourceItem.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageItem.cs
Outdated
Show resolved
Hide resolved
2722c90 to
a907efa
Compare
dominoFire
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job. Some comments.
| @@ -0,0 +1,89 @@ | |||
| <Window x:Class="NuGet.Options.AddMappingDialog" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like, using our VsDialogWindow class?
| <Window x:Class="NuGet.Options.AddMappingDialog" | |
| <nuget:VsDialogWindow x:Class="NuGet.Options.AddMappingDialog" |
src/NuGet.Clients/NuGet.PackageManagement.UI/GlobalSuppressions.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/GlobalSuppressions.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourceMappingOptionsControl.xaml
Outdated
Show resolved
Hide resolved
src/NuGet.Core/NuGet.Configuration/PackageSourceMapping/PackageSourceMappingProvider.cs
Outdated
Show resolved
Hide resolved
1ad6fea to
a9ee7dc
Compare
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/MappingUIDisplay.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourceMappingOptionsControl.xaml.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourceMappingOptionsControl.xaml.cs
Outdated
Show resolved
Hide resolved
| IReadOnlyList<PackageSourceMappingSourceItem> packageSourceMappingsSourceItems = ReadMappingsFromUIToConfig(SourceMappingsCollection); | ||
| try | ||
| { | ||
| if (SourceMappingsChanged(_originalPackageSourceMappings, packageSourceMappingsSourceItems)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to call this method to find out if Source Mapping changed?
Doesn't packageSourceMappingProvider.SavePackageSourceMappings method only save if there is change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No SavePackageSourceMappings will go through all of the mappings and call AddOrUpdate even if nothing is changed (it won't modify the config file, though). It seems like it makes more sense to check if Save even needs to be called in the first place
|
Is edit button considered at this point? Currently remove button simply remove the patterns with all the sources. |
05d592e to
e91e3db
Compare
src/NuGet.Clients/NuGet.PackageManagement.UI/Models/ItemsChangeObservableCollectionBase.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another feedbacks, I believe your PR is very close. 🚀
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourceMappingOptionsControl.xaml.cs
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourceMappingOptionsControl.xaml.cs
Outdated
Show resolved
Hide resolved
| { | ||
| public class MappingUIDisplay | ||
| { | ||
| public string ID { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it just package Id or packagePattern? Maybe I rename to PackageId or PackagePattern, it's quite hard to remember it was packageId to begin.
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/MappingUIDisplay.cs
Outdated
Show resolved
Hide resolved
| mappingsDictonary[source.Name] = new List<PackagePatternItem>(); | ||
| } | ||
| PackagePatternItem tempID = new PackagePatternItem(mappingUIDisplay.ID); | ||
| bool newID = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe line 224-236 can be replaced with below, which is more readable.
PackagePatternItem tempID = new PackagePatternItem(mappingUIDisplay.ID);
if (!mappingsDictonary[source.Name].Any(id => id.Pattern == tempID.Pattern))
{
mappingsDictonary[source.Name].Add(tempID);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do. thanks
|
Team Triage: Work with @dominoFire regarding the localization of strings. |
dominoFire
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address button overflow. Keep up the good work!
| <Reference Include="System.Drawing" /> | ||
| <Reference Include="System.Runtime.Caching" /> | ||
| <Reference Include="System.Runtime.Serialization" /> | ||
| <Reference Include="System.ServiceProcess" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this namespace? I don't see any namespace reference to System.ServiceProcess
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/AddMappingDialog.xaml.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/AddMappingDialog.xaml.cs
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/MappingUIDisplay.cs
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourceMappingOptionsControl.xaml.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourceMappingOptionsControl.xaml.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourceMappingOptionsPage.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Clients/NuGet.PackageManagement.UI/Options/PackageSourceMappingOptionsPage.cs
Outdated
Show resolved
Hide resolved
|
|
||
| namespace NuGet.Options | ||
| { | ||
| internal class ButtonCommand : ICommand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I may be wrong but, I believe you can remove this class and achieve the same result using CommandBinding directly in XAML control.
Buttons in both dialogs (option dialog and add source mapping dialog) can map to method actions using XAML CommandBinding construc.
An example can be found in PackageManagerControl for search command:
NuGet.Client/src/NuGet.Clients/NuGet.PackageManagement.UI/Xamls/PackageManagerControl.xaml
Lines 34 to 36 in 3ec6f02
| <CommandBinding | |
| Command="{x:Static nuget:Commands.RestartSearchCommand}" | |
| Executed="ExecuteRestartSearchCommand"/> |
Ping me if you have more questions.
|
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
1 similar comment
|
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
@dominoFire - I decided to delete that class :) #4778 |
6ab4bae to
21f7a87
Compare
|
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
This reverts commit 9f30979.
21f7a87 to
95f3603
Compare
|
This PR has been automatically marked as stale because it has no activity for 7 days. It will be closed if no further activity occurs within another 7 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch. |
|
Decided to Sort the mappings by Package ID in the options page, since otherwise it's just a random order of how the IDs are read from the config. ff324ec Note that when adding new mappings, they appear initially at the bottom until "OK" is pressed. I think this is standard/expected behavior. |

Bug
Fixes: NuGet/Home#11362
Regression? Last working version:
Description
There is currently no support for package source mapping in the VS options UI. These changes allow the user to see all package source mappings in a new

Package Source Mappingoptions dialog, and toAdd,Remove, orClearmappings. Here is a screenshot of this dialog showing the mappings for NuGet.sln:When a user clicks

Add, a new window appears, and the user can type in a package namespace and select from all the previously configured sources for that project to map to. Here is a screenshot showing this window:There were some concerns about the modal dialog and the amount of whitespace in the
ListViewshowing package source mappings, but the UX Board checked it and said it was okay.PR Checklist
PR has a meaningful title
PR has a linked issue.
Described changes
Tests
ListViewshowing the package source mappings in thePackage Source Mappingsoptions dialog shows the wrong value for theIsOffScreenproperty for mappings not in view. This issue appears in other VS options dialogs that have aListViewand is mentioned in this issue: Inconsistent UIA IsOffscreen and ClickablePoint properties for WPF ListViewItems that are scrolled out of view dotnet/wpf#4631 , so I decided not to fix it.
- **OR** - [ ] Test exception - **OR** - [ ] N/A