Skip to content

Commit c299f15

Browse files
author
Paul van Brenk
committed
Show the correct message when the local package is missing
Fixes #1043
1 parent c75b5d9 commit c299f15

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@
152152
x:Name="LocalInstallMissingMessage"
153153
Visibility="Collapsed"
154154
FontWeight="Bold"
155+
Foreground="Red"
155156
Text="{x:Static resx:NpmInstallWindowResources.MissingLocallyMessage}" />
156157

157158
<TextBlock Grid.Column="1"
@@ -177,6 +178,9 @@
177178
<DataTrigger Binding="{Binding IsInstalledLocally}" Value="true">
178179
<Setter TargetName="LocalInstallMessage" Property="Visibility" Value="Visible" />
179180
</DataTrigger>
181+
<DataTrigger Binding="{Binding IsLocalInstallMissing}" Value="true">
182+
<Setter TargetName="LocalInstallMissingMessage" Property="Visibility" Value="Visible" />
183+
</DataTrigger>
180184
<DataTrigger Binding="{Binding IsLocalInstallOutOfDate}" Value="true">
181185
<Setter TargetName="LocalInstallMessage" Property="Visibility" Value="Collapsed" />
182186
<Setter TargetName="LocalInstallOutOfDateMessage" Property="Visibility" Value="Visible" />

Nodejs/Product/Nodejs/NpmUI/PackageCatalogEntryViewModel.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
1+
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
22

33
using System;
44
using System.Collections.Generic;
@@ -12,6 +12,7 @@ internal abstract class PackageCatalogEntryViewModel
1212
{
1313
private readonly SemverVersion? version;
1414
private readonly SemverVersion? localVersion;
15+
private readonly bool? localInstallMissing;
1516

1617
protected PackageCatalogEntryViewModel(
1718
string name,
@@ -21,7 +22,8 @@ protected PackageCatalogEntryViewModel(
2122
string description,
2223
IEnumerable<string> homepages,
2324
string keywords,
24-
SemverVersion? localVersion
25+
SemverVersion? localVersion,
26+
bool? localInstallMissing
2527
)
2628
{
2729
this.Name = name;
@@ -32,6 +34,7 @@ protected PackageCatalogEntryViewModel(
3234
this.Homepages = homepages ?? Enumerable.Empty<string>();
3335
this.Keywords = keywords;
3436
this.localVersion = localVersion;
37+
this.localInstallMissing = localInstallMissing;
3538
}
3639

3740
public virtual string Name { get; }
@@ -51,8 +54,12 @@ protected PackageCatalogEntryViewModel(
5154

5255
public string Keywords { get; }
5356

54-
public bool IsInstalledLocally => this.localVersion.HasValue;
55-
public bool IsLocalInstallOutOfDate => this.localVersion.HasValue && this.localVersion < this.version;
57+
public bool IsInstalledLocally => !this.IsLocalInstallMissing && this.localVersion.HasValue;
58+
public bool IsLocalInstallOutOfDate => !this.IsLocalInstallMissing && this.localVersion.HasValue && this.localVersion < this.version;
59+
60+
// Local install is missing if we expect a local install, but it's not there.
61+
// This means that if a package is not in the package.json, we don't report it missing.
62+
public bool IsLocalInstallMissing => this.localInstallMissing.HasValue && this.localInstallMissing.Value;
5663
public string LocalVersion => this.localVersion?.ToString() ?? string.Empty;
5764

5865
public override string ToString()
@@ -74,7 +81,8 @@ public ReadOnlyPackageCatalogEntryViewModel(IPackage package, IPackage localInst
7481
(package.Keywords != null && package.Keywords.Any())
7582
? string.Join(", ", package.Keywords)
7683
: Resources.NoKeywordsInPackage,
77-
localInstall != null ? (SemverVersion?)localInstall.Version : null
84+
localInstall != null ? (SemverVersion?)localInstall.Version : null,
85+
localInstall?.IsMissing
7886
)
7987
{
8088
if (string.IsNullOrEmpty(this.Name))

0 commit comments

Comments
 (0)