Skip to content

Commit cdbfae0

Browse files
authored
Symbols UI Fixes (#6576)
1 parent 0e244f8 commit cdbfae0

7 files changed

Lines changed: 51 additions & 13 deletions

File tree

src/NuGetGallery.Core/Extensions/PackageExtensions.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,16 @@ public static SymbolPackage LatestSymbolPackage(this Package package)
1919
.OrderByDescending(sp => sp.Created)
2020
.FirstOrDefault();
2121
}
22+
23+
/// <summary>
24+
/// Returns true if there exists a symbol package which is latest and is in
25+
/// available state, false otherwise.
26+
/// </summary>
27+
public static bool IsLatestSymbolPackageAvailable(this Package package)
28+
{
29+
var latestSymbolPackage = package.LatestSymbolPackage();
30+
return latestSymbolPackage != null
31+
&& latestSymbolPackage.StatusKey == PackageStatus.Available;
32+
}
2233
}
2334
}

src/NuGetGallery/Controllers/PackagesController.cs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ private async Task<ActionResult> UploadSymbolsPackageInternal(SubmitPackageReque
237237

238238
var verifyRequest = new VerifyPackageRequest(packageMetadata, accountsAllowedOnBehalfOf, existingPackageRegistration);
239239
verifyRequest.IsSymbolsPackage = true;
240+
verifyRequest.HasExistingAvailableSymbols = packageForUploadingSymbols.IsLatestSymbolPackageAvailable();
241+
240242
model.InProgressUpload = verifyRequest;
241243

242244
return View(model);
@@ -386,7 +388,12 @@ private async Task<JsonResult> UploadSymbolsPackageInternal(PackageArchiveReader
386388
// Save the uploaded file
387389
await _uploadFileService.SaveUploadFileAsync(currentUser.Key, uploadStream);
388390

389-
return await GetVerifyPackageView(currentUser, packageMetadata, accountsAllowedOnBehalfOf, existingPackageRegistration, isSymbolsPackageUpload: true);
391+
return await GetVerifyPackageView(currentUser,
392+
packageMetadata,
393+
accountsAllowedOnBehalfOf,
394+
existingPackageRegistration,
395+
isSymbolsPackageUpload: true,
396+
hasExistingSymbolsPackageAvailable: packageForUploadingSymbols.IsLatestSymbolPackageAvailable());
390397
}
391398

392399
private async Task<JsonResult> UploadPackageInternal(PackageArchiveReader packageArchiveReader, Stream uploadStream, NuspecReader nuspec, PackageMetadata packageMetadata)
@@ -495,14 +502,22 @@ await _packageDeleteService.HardDeletePackagesAsync(
495502

496503
await _uploadFileService.SaveUploadFileAsync(currentUser.Key, uploadStream);
497504

498-
return await GetVerifyPackageView(currentUser, packageMetadata, accountsAllowedOnBehalfOf, existingPackageRegistration, isSymbolsPackageUpload: false);
505+
var hasExistingSymbolsPackageAvailable = existingPackage != null && existingPackage.IsLatestSymbolPackageAvailable();
506+
507+
return await GetVerifyPackageView(currentUser,
508+
packageMetadata,
509+
accountsAllowedOnBehalfOf,
510+
existingPackageRegistration,
511+
isSymbolsPackageUpload: false,
512+
hasExistingSymbolsPackageAvailable: hasExistingSymbolsPackageAvailable);
499513
}
500514

501515
private async Task<JsonResult> GetVerifyPackageView(User currentUser,
502516
PackageMetadata packageMetadata,
503517
IEnumerable<User> accountsAllowedOnBehalfOf,
504518
PackageRegistration existingPackageRegistration,
505-
bool isSymbolsPackageUpload)
519+
bool isSymbolsPackageUpload,
520+
bool hasExistingSymbolsPackageAvailable)
506521
{
507522
IReadOnlyList<string> warnings = new List<string>();
508523
using (Stream uploadedFile = await _uploadFileService.GetUploadFileAsync(currentUser.Key))
@@ -546,8 +561,8 @@ private async Task<JsonResult> GetVerifyPackageView(User currentUser,
546561

547562
var model = new VerifyPackageRequest(packageMetadata, accountsAllowedOnBehalfOf, existingPackageRegistration);
548563
model.IsSymbolsPackage = isSymbolsPackageUpload;
564+
model.HasExistingAvailableSymbols = hasExistingSymbolsPackageAvailable;
549565
model.Warnings.AddRange(warnings);
550-
551566
return Json(model);
552567
}
553568

src/NuGetGallery/RequestModels/VerifyPackageRequest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public VerifyPackageRequest(PackageMetadata packageMetadata, IEnumerable<User> p
117117
public string Tags { get; set; }
118118
public string Title { get; set; }
119119
public bool IsSymbolsPackage { get; set; }
120+
public bool HasExistingAvailableSymbols { get; set; }
120121

121122
public List<string> Warnings { get; set; } = new List<string>();
122123

src/NuGetGallery/Scripts/gallery/async-file-upload.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
};
8585

8686
function resetFileSelectFeedback() {
87-
$('#file-select-feedback').attr('value', 'Browse or Drop files to select a package or symbols package...');
87+
$('#file-select-feedback').attr('value', 'Browse or Drop files to select a package (.nupkg) or symbols package (.snupkg)...');
8888
}
8989

9090
function prepareUploadFormData() {
@@ -232,6 +232,7 @@
232232
function clearErrors() {
233233
$("#validation-failure-container").addClass("hidden");
234234
$("#validation-failure-list").remove();
235+
$('#symbols-replace-warning-container').addClass('hidden');
235236

236237
var warnings = $('#warning-container');
237238
warnings.addClass("hidden");
@@ -271,6 +272,12 @@
271272
cancelUploadAsync();
272273
});
273274

275+
if (model.IsSymbolsPackage && model.HasExistingAvailableSymbols) {
276+
$('#symbols-replace-warning-container').removeClass('hidden');
277+
} else {
278+
$('#symbols-replace-warning-container').addClass('hidden');
279+
}
280+
274281
$('#verify-submit-button').on('click', function () {
275282
$('#verify-cancel-button').attr('disabled', 'disabled');
276283
$('#verify-submit-button').attr('disabled', 'disabled');

src/NuGetGallery/Views/Packages/DeleteSymbols.cshtml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,15 @@
6161
</div>
6262

6363
<h2>
64-
<a href="#" role="button" data-toggle="collapse" data-target="#delete-package"
65-
aria-expanded="false" aria-controls="delete-package" id="show-delete-package">
66-
<i class="ms-Icon ms-Icon--ChevronRight" aria-hidden="true"></i>
64+
<a href="#" role="button" data-toggle="collapse" data-target="#delete-package" aria-expanded="true" aria-controls="delete-package" id="show-delete-package">
65+
<i class="ms-Icon ms-Icon--ChevronDown" aria-hidden="true"></i>
6766
<span>Delete Symbols Package Version</span>
6867
</a>
6968
</h2>
70-
<div class="list-unstyled panel-collapse collapse" id="delete-package">
69+
<div class="list-unstyled panel-collapse collapse in" id="delete-package">
7170
@ViewHelpers.AlertDanger(
7271
@<text>
73-
<strong>Deleting this symbols package will remove all the symbols from the symbol server and make them unavailable.</strong><br />
72+
<strong>Deleting this symbols package will remove all symbols in this package from the symbol server and make them unavailable.</strong><br />
7473
</text>)
7574

7675
@using (Html.BeginForm("DeleteSymbolsPackage", "Packages", FormMethod.Post, new { id = "delete-symbols-form" }))

src/NuGetGallery/Views/Packages/UploadPackage.cshtml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
ViewBag.Title = "Upload Package";
44
ViewBag.Tab = "Upload";
55
var placeholder = Model.IsSymbolsUploadEnabled
6-
? "Browse or Drop files to select a package or symbols package..."
7-
: "Browse or Drop files to select a package";
6+
? "Browse or Drop files to select a package (.nupkg) or symbols package (.snupkg)..."
7+
: "Browse or Drop files to select a package (.nupkg)";
88
var acceptExtensions = Model.IsSymbolsUploadEnabled
99
? ".nupkg,.snupkg"
1010
: ".nupkg";
@@ -58,6 +58,11 @@
5858
</div>
5959
}
6060

61+
<div id="symbols-replace-warning-container" class="hidden">
62+
@ViewHelpers.AlertWarning(@<text>There is an existing symbols package (.snupkg) for the below package ID and version.
63+
Submitting this request will replace the previously uploaded symbols package as well as the corresponding symbol files from the symbol server.</text>)
64+
</div>
65+
6166
@Html.Partial("_VerifyForm")
6267
</div>
6368
</div>

src/NuGetGallery/Views/Packages/_VerifyMetadata.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
</div>
122122
<!-- /ko -->
123123

124+
<!-- ko ifnot: $data.IsSymbolsPackage -->
124125
<div class="verify-package-field">
125126
<label class="verify-package-field-heading">Title</label>
126127
<div data-bind="template: { name: 'display-data-or-default', data: { DisplayText: $data.Title }}"></div>
@@ -136,7 +137,6 @@
136137
<div data-bind="template: { name: 'display-data-or-default', data: { DisplayText: $data.Summary }}"></div>
137138
</div>
138139

139-
<!-- ko ifnot: $data.IsSymbolsPackage -->
140140
<div class="verify-package-field">
141141
<div class="verify-package-field-heading"><label>Release Notes</label> (for this version)</div>
142142
<div data-bind="template: { name: 'display-data-or-default', data: { DisplayText: $data.ReleaseNotes }}"></div>

0 commit comments

Comments
 (0)