Skip to content

Commit

Permalink
Unify package details across all views
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev committed Nov 18, 2024
1 parent 117ae11 commit 570c8ee
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
1 change: 0 additions & 1 deletion Bonsai.NuGet.Design/GalleryDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 7 additions & 11 deletions Bonsai.NuGet.Design/PackageDetails.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ public PackageDetails()
SetPackage(null);
}

public PackageOperationType Operation { get; set; }

[Category("Action")]
public event PackageViewEventHandler OperationClick
{
Expand All @@ -47,6 +45,10 @@ public event PackageSearchEventHandler PackageLinkClicked

public NuGetFramework ProjectFramework { get; set; }

private PackageOperationType Operation => installedVersionLayoutPanel.Visible
? PackageOperationType.Update
: PackageOperationType.Install;

private void OnOperationClick(PackageViewEventArgs e)
{
(Events[OperationClickEvent] as PackageViewEventHandler)?.Invoke(this, e);
Expand Down Expand Up @@ -90,19 +92,12 @@ public void SetPackage(PackageViewItem item)
packageIdLabel.Text = package.Identity.Id;
prefixReservedIcon.Visible = package.PrefixReserved;

installedVersionLayoutPanel.Visible =
(Operation == PackageOperationType.Install ||
Operation == PackageOperationType.Update) &&
selectedItem.LocalPackage != null;
installedVersionLayoutPanel.Visible = selectedItem.LocalPackage != null;
if (installedVersionLayoutPanel.Visible)
{
installedVersionTextBox.Text = selectedItem.LocalPackage.Identity.Version.ToString();
}

var operation = Operation == PackageOperationType.Install && selectedItem.LocalPackage != null
? PackageOperationType.Update
: Operation;
operationButton.Text = operation.ToString();
operationButton.Text = Operation.ToString();

versionComboBox.Items.Clear();
foreach (var version in item.PackageVersions
Expand All @@ -124,6 +119,7 @@ public void SetPackage(PackageViewItem item)
void SetPackageVersion(VersionInfo versionInfo)
{
var package = versionInfo.PackageSearchMetadata;
operationButton.Enabled = !(selectedItem.LocalPackage?.Identity.Version == versionInfo.Version);
createdByLabel.Text = string.Join(CultureInfo.CurrentCulture.TextInfo.ListSeparator, package.Authors);
SetLinkLabelUri(detailsLinkLabel, package.PackageDetailsUrl, true);
lastPublishedLabel.Text = package.Published.HasValue ? package.Published.Value.Date.ToShortDateString() : Resources.UnpublishedLabel;
Expand Down
1 change: 0 additions & 1 deletion Bonsai.NuGet.Design/PackageManagerDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions Bonsai.NuGet.Design/PackageViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public PackageViewController(
public PackageOperationType Operation
{
get => packageView.Operation;
set => packageView.Operation = packageDetails.Operation = value;
set => packageView.Operation = value;
}

public void ClearActiveRequests()
Expand Down Expand Up @@ -262,12 +262,7 @@ private void AddPackageRange(IList<IPackageSearchMetadata> packages)

private void AddPackage(IPackageSearchMetadata package)
{
LocalPackageInfo installedPackage = null;
if (SelectedRepository != PackageManager.LocalRepository)
{
installedPackage = PackageManager.LocalRepository.FindLocalPackage(package.Identity.Id);
}

var installedPackage = PackageManager.LocalRepository.FindLocalPackage(package.Identity.Id);
var nodeTitle = package.Identity.Id;
var nodeText = string.Join(
Environment.NewLine, nodeTitle,
Expand Down

0 comments on commit 570c8ee

Please sign in to comment.