Skip to content

Commit f45e233

Browse files
authored
UI symbol server changes behind the flag (#6571)
1 parent 62d038d commit f45e233

4 files changed

Lines changed: 20 additions & 4 deletions

File tree

src/NuGetGallery/Controllers/PackagesController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ public virtual async Task<ActionResult> UploadPackage()
169169
{
170170
var currentUser = GetCurrentUser();
171171
var model = new SubmitPackageRequest();
172+
model.IsSymbolsUploadEnabled = _contentObjectService.SymbolsConfiguration.IsSymbolsUploadEnabledForUser(currentUser);
172173
PackageMetadata packageMetadata;
173174

174175
using (var uploadedFile = await _uploadFileService.GetUploadFileAsync(currentUser.Key))

src/NuGetGallery/RequestModels/SubmitPackageRequest.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ public class SubmitPackageRequest
88
public bool IsUploadInProgress => InProgressUpload != null;
99

1010
public VerifyPackageRequest InProgressUpload { get; set; }
11+
12+
public bool IsSymbolsUploadEnabled { get; set; }
1113
}
1214
}

src/NuGetGallery/Views/Packages/UploadPackage.cshtml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
@{
33
ViewBag.Title = "Upload Package";
44
ViewBag.Tab = "Upload";
5+
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";
8+
var acceptExtensions = Model.IsSymbolsUploadEnabled
9+
? ".nupkg,.snupkg"
10+
: ".nupkg";
511
}
612

713
<section role="main" class="container main-container page-upload">
@@ -27,10 +33,10 @@
2733
@Html.AntiForgeryToken()
2834

2935
<div class="input-group">
30-
<input type="text" class="form-control" id="file-select-feedback" value="Browse or Drop files to select a package or symbols package..." aria-label="Upload Your Package" readonly />
36+
<input type="text" class="form-control" id="file-select-feedback" value="@placeholder" aria-label="Upload Your Package" readonly />
3137
<label for="input-select-file" id="PackageFileLabel" class="input-group-btn">
3238
<span id="browse-for-package-button" class="btn btn-primary form-control" tabindex="0" aria-label="Browse for package" role="button">
33-
Browse&hellip;<input type="file" name="UploadFile" accept=".nupkg,.snupkg" aria-labelledby="PackageFileLabel" id="input-select-file" style="display:none;" />
39+
Browse&hellip;<input type="file" name="UploadFile" accept="@acceptExtensions" aria-labelledby="PackageFileLabel" id="input-select-file" style="display:none;" />
3440
</span>
3541
</label>
3642
</div>

tests/NuGetGallery.Facts/Controllers/PackagesControllerFacts.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,13 @@ private static PackagesController CreateController(
142142

143143
readMeService = readMeService ?? new ReadMeService(packageFileService.Object, entitiesContext.Object);
144144

145-
contentObjectService = contentObjectService ?? new Mock<IContentObjectService>();
145+
if (contentObjectService == null)
146+
{
147+
contentObjectService = new Mock<IContentObjectService>();
148+
contentObjectService
149+
.Setup(x => x.SymbolsConfiguration.IsSymbolsUploadEnabledForUser(It.IsAny<User>()))
150+
.Returns(false);
151+
}
146152

147153
if (symbolPackageUploadService == null)
148154
{
@@ -4016,9 +4022,10 @@ public async Task WillShowTheViewWhenThereIsNoUploadInProgress()
40164022
uploadFileService: fakeUploadFileService);
40174023
controller.SetCurrentUser(TestUtility.FakeUser);
40184024

4019-
var result = await controller.UploadPackage() as ViewResult;
4025+
var result = (await controller.UploadPackage() as ViewResult).Model as SubmitPackageRequest;
40204026

40214027
Assert.NotNull(result);
4028+
Assert.False(result.IsSymbolsUploadEnabled);
40224029
}
40234030

40244031
[Fact]

0 commit comments

Comments
 (0)