Skip to content

Commit d0df204

Browse files
authored
Merge pull request #1709 from paulvanbrenk/npmUiMissingPackage
Npm ui missing package
2 parents b039087 + 01c2562 commit d0df204

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.Designer.cs

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Nodejs/Product/Nodejs/NpmUI/NpmInstallWindowResources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,4 +186,7 @@
186186
<data name="WindowTitle" xml:space="preserve">
187187
<value>Install New npm Packages</value>
188188
</data>
189+
<data name="MissingLocallyMessage" xml:space="preserve">
190+
<value>Package missing</value>
191+
</data>
189192
</root>

Nodejs/Product/Nodejs/NpmUI/NpmPackageInstallWindow.xaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,13 @@
148148
FontWeight="Bold"
149149
Text="{x:Static resx:NpmInstallWindowResources.InstalledLocallyMessage}" />
150150

151+
<TextBlock Grid.Column="1"
152+
x:Name="LocalInstallMissingMessage"
153+
Visibility="Collapsed"
154+
FontWeight="Bold"
155+
Foreground="Red"
156+
Text="{x:Static resx:NpmInstallWindowResources.MissingLocallyMessage}" />
157+
151158
<TextBlock Grid.Column="1"
152159
x:Name="LocalInstallOutOfDateMessage"
153160
Visibility="Collapsed"
@@ -171,6 +178,9 @@
171178
<DataTrigger Binding="{Binding IsInstalledLocally}" Value="true">
172179
<Setter TargetName="LocalInstallMessage" Property="Visibility" Value="Visible" />
173180
</DataTrigger>
181+
<DataTrigger Binding="{Binding IsLocalInstallMissing}" Value="true">
182+
<Setter TargetName="LocalInstallMissingMessage" Property="Visibility" Value="Visible" />
183+
</DataTrigger>
174184
<DataTrigger Binding="{Binding IsLocalInstallOutOfDate}" Value="true">
175185
<Setter TargetName="LocalInstallMessage" Property="Visibility" Value="Collapsed" />
176186
<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.IsInstalledLocally && 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 == true;
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?.Version,
85+
localInstall?.IsMissing
7886
)
7987
{
8088
if (string.IsNullOrEmpty(this.Name))

0 commit comments

Comments
 (0)