-
Notifications
You must be signed in to change notification settings - Fork 677
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show Package Source Mapping Status in Details Pane
- Loading branch information
1 parent
ac6b25a
commit ed4afa3
Showing
24 changed files
with
476 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/NuGet.Clients/NuGet.PackageManagement.UI/Resources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
...uGet.Clients/NuGet.PackageManagement.UI/ViewModels/PackageSourceMappingActionViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
#nullable enable | ||
|
||
using System; | ||
using System.Linq; | ||
|
||
namespace NuGet.PackageManagement.UI.ViewModels | ||
{ | ||
public sealed class PackageSourceMappingActionViewModel : ViewModelBase | ||
{ | ||
internal INuGetUI UIController { get; } | ||
|
||
private PackageSourceMappingActionViewModel(INuGetUI uiController) | ||
{ | ||
UIController = uiController ?? throw new ArgumentNullException(nameof(uiController)); | ||
} | ||
|
||
public bool IsPackageSourceMappingEnabled => UIController.UIContext?.PackageSourceMapping?.IsEnabled == true; | ||
|
||
private string? _packageId; | ||
|
||
internal string? PackageId | ||
{ | ||
get { return _packageId; } | ||
set | ||
{ | ||
if (_packageId == value) | ||
{ | ||
return; | ||
} | ||
|
||
_packageId = value; | ||
|
||
RaisePropertyChanged(nameof(IsPackageMapped)); | ||
RaisePropertyChanged(nameof(MappingStatus)); | ||
} | ||
} | ||
|
||
public bool IsPackageMapped | ||
{ | ||
get | ||
{ | ||
if (string.IsNullOrWhiteSpace(PackageId)) | ||
{ | ||
return false; | ||
} | ||
|
||
var packageSourceMapping = UIController.UIContext.PackageSourceMapping; | ||
return packageSourceMapping?.GetConfiguredPackageSources(PackageId)?.Any() == true; | ||
} | ||
} | ||
|
||
public string MappingStatus | ||
{ | ||
get | ||
{ | ||
if (IsPackageSourceMappingEnabled) | ||
{ | ||
if (IsPackageMapped) | ||
{ | ||
return Resources.Text_PackageMappingsFound; | ||
} | ||
else | ||
{ | ||
return Resources.Text_PackageMappingsNotFound; | ||
} | ||
} | ||
else | ||
{ | ||
return Resources.Text_PackageMappingsDisabled; | ||
} | ||
} | ||
} | ||
|
||
public void SettingsChanged() | ||
{ | ||
RaisePropertyChanged(nameof(IsPackageSourceMappingEnabled)); | ||
RaisePropertyChanged(nameof(IsPackageMapped)); | ||
RaisePropertyChanged(nameof(MappingStatus)); | ||
} | ||
|
||
public static PackageSourceMappingActionViewModel Create(INuGetUI uiController) | ||
{ | ||
return new PackageSourceMappingActionViewModel(uiController); | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/NuGet.Clients/NuGet.PackageManagement.UI/ViewModels/ViewModelBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.ComponentModel; | ||
using System.Runtime.CompilerServices; | ||
|
||
namespace NuGet.PackageManagement.UI.ViewModels | ||
{ | ||
public abstract class ViewModelBase : INotifyPropertyChanged | ||
{ | ||
public virtual event PropertyChangedEventHandler PropertyChanged; | ||
|
||
public void RaisePropertyChanged([CallerMemberName] string propertyName = "") | ||
{ | ||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); | ||
} | ||
} | ||
} |
Oops, something went wrong.