Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge branch "dev" into main #9210

Merged
merged 11 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# on specific relative paths.
**/Scripts/gallery/jquery-3.4.1.js
**/Scripts/gallery/knockout-3.5.1.js
**/Scripts/gallery/moment-2.29.2.js
**/Scripts/gallery/moment-2.29.4.js
5 changes: 0 additions & 5 deletions NuGetGallery.sln.DotSettings

This file was deleted.

6 changes: 3 additions & 3 deletions src/Bootstrap/dist/css/bootstrap-theme.css

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

39 changes: 20 additions & 19 deletions src/Bootstrap/less/theme/page-display-package.less
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,28 @@
margin-right: 12px;
}

.prefix-reserve-title {
background-color: #F3F2F1;
display: inline-flex;
align-items: center;
border-radius: 100px;
vertical-align: middle;
}

.reserved-indicator {
width: 18px;
margin-right: 5px;
margin-left: 2px;
}
.prefix-reserve-title {
background-color: #F3F2F1;
display: inline-flex;
align-items: center;
border-radius: 100px;
vertical-align: middle;

.prefix-reserve-label {
font-size: 14px;
font-weight: 400;
color: #2F6FA7;
margin-top: 2px;
margin-bottom: 2px;
margin-right: 10px;
}
.reserved-indicator {
width: 18px;
margin-right: 5px;
margin-left: 2px;
}

.prefix-reserve-label {
font-size: 14px;
font-weight: 400;
color: #2F6FA7;
margin-top: 2px;
margin-bottom: 2px;
margin-right: 10px;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/DatabaseMigrationTools/DatabaseMigrationTools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="NuGet.Services.Validation">
<Version>2.104.0</Version>
<Version>2.105.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
<Version>4.3.0-dev-5590084</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.Cursor">
<Version>2.104.0</Version>
<Version>2.105.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/NuGetGallery.Core/NuGetGallery.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.FeatureFlags">
<Version>2.104.0</Version>
<Version>2.105.0</Version>
</PackageReference>
<PackageReference Include="WindowsAzure.Storage">
<Version>9.3.3</Version>
Expand All @@ -59,13 +59,13 @@

<ItemGroup Condition="'$(TargetFramework)' == 'net472'">
<PackageReference Include="NuGet.Services.Messaging.Email">
<Version>2.104.0</Version>
<Version>2.105.0</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.Validation">
<Version>2.104.0</Version>
<Version>2.105.0</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.Validation.Issues">
<Version>2.104.0</Version>
<Version>2.105.0</Version>
</PackageReference>
<PackageReference Include="NuGet.StrongName.elmah.corelibrary">
<Version>1.2.2</Version>
Expand Down
7 changes: 2 additions & 5 deletions src/NuGetGallery.Services/NuGetGallery.Services.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,14 @@
<PackageReference Include="Microsoft.Owin.Security.OpenIdConnect">
<Version>4.1.0</Version>
</PackageReference>
<PackageReference Include="NuGet.Packaging">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="NuGet.Protocol">
<Version>6.0.0</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.Configuration">
<Version>2.104.0</Version>
<Version>2.105.0</Version>
</PackageReference>
<PackageReference Include="NuGet.Services.Logging">
<Version>2.104.0</Version>
<Version>2.105.0</Version>
</PackageReference>
<PackageReference Include="NuGet.StrongName.WebBackgrounder">
<Version>0.2.0</Version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"api.dependabot.com",
"api.travis-ci.com",
"api.travis-ci.org",
"api.reuse.software",
"app.fossa.io",
"app.fossa.com",
"badge.fury.io",
Expand Down
2 changes: 1 addition & 1 deletion src/NuGetGallery/App_Start/AppActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private static void BundlingPostStart()
.Include("~/Scripts/gallery/jquery.validate.unobtrusive-3.2.6.js")
.Include("~/Scripts/gallery/knockout-3.5.1.js")
.Include("~/Scripts/gallery/bootstrap.js")
.Include("~/Scripts/gallery/moment-2.29.2.js")
.Include("~/Scripts/gallery/moment-2.29.4.js")
.Include("~/Scripts/gallery/common.js")
.Include("~/Scripts/gallery/autocomplete.js");
BundleTable.Bundles.Add(scriptBundle);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,28 @@ public JsonResult SearchPrefix(string query)
var prefixQueries = GetPrefixesFromQuery(query);

var foundPrefixes = _reservedNamespaceService.FindReservedNamespacesForPrefixList(prefixQueries);
var valueToNamespace = foundPrefixes.ToDictionary(x => x.Value, StringComparer.OrdinalIgnoreCase);

var notFoundPrefixQueries = prefixQueries.Except(foundPrefixes.Select(p => p.Value), StringComparer.OrdinalIgnoreCase);
var notFoundPrefixes = notFoundPrefixQueries.Select(q => new ReservedNamespace(value: q, isSharedNamespace: false, isPrefix: true));

var resultModel = foundPrefixes.Select(fp => new ReservedNamespaceResultModel(fp, isExisting: true));
resultModel = resultModel.Concat(notFoundPrefixes.Select(nfp => new ReservedNamespaceResultModel(nfp, isExisting: false)).ToList());
var resultModel = new List<ReservedNamespaceResultModel>();
foreach (var value in prefixQueries)
{
bool isExisting = valueToNamespace.TryGetValue(value, out var ns);
if (!isExisting)
{
ns = new ReservedNamespace(value: value, isSharedNamespace: false, isPrefix: true);
}

var existingPrefixes = _reservedNamespaceService.GetReservedNamespacesForId(value);

var parents = existingPrefixes
.Where(x => value.StartsWith(x.Value, StringComparison.OrdinalIgnoreCase)
&& value.Length > x.Value.Length)
.Select(x => x.Value + (x.IsPrefix ? "*" : string.Empty))
.OrderBy(x => x.Length)
.ToArray();

resultModel.Add(new ReservedNamespaceResultModel(ns, isExisting, parents));
}

var results = new ReservedNamespaceSearchResult
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ public sealed class ReservedNamespaceResultModel

public string[] owners { get; }

public string[] parents { get; }

public ReservedNamespaceResultModel() { }

public ReservedNamespaceResultModel(ReservedNamespace reservedNamespace, bool isExisting)
public ReservedNamespaceResultModel(ReservedNamespace reservedNamespace, bool isExisting, string[] parents)
{
if (reservedNamespace == null)
{
Expand All @@ -31,6 +33,7 @@ public ReservedNamespaceResultModel(ReservedNamespace reservedNamespace, bool is
registrations = reservedNamespace.PackageRegistrations?.Select(pr => pr.Id).ToArray();
owners = reservedNamespace.Owners?.Select(u => u.Username).ToArray();
this.isExisting = isExisting;
this.parents = parents;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,23 @@
<span style="font-weight: bold">Matching Pattern: </span>
<span data-bind="text: $data.pattern" />
</div>
<!-- ko if: $data.parents.length > 0 -->
<div>
<span style="font-weight: bold">⚠ Parent namespaces:</span>
<ul>
<!-- ko foreach: $data.parents -->
<li data-bind="text: $data"></li>
<!-- /ko -->
</ul>
</div>
<!-- /ko -->
<!-- ko if: $data.isExisting -->
<input style="margin-top: 5px" type="submit" value="Deallocate Namespace" title="Delete this namespace"
data-bind="click: $parent.managePrefix.bind(this, $data.prefix, false)" />
data-bind="click: $parent.managePrefix.bind(this, $data.prefix, false, $data.parents)" />
<!-- /ko -->
<!-- ko ifnot: $data.isExisting -->
<input style="margin-top: 5px" type="submit" value="Reserve Namespace" title="Add this namespace"
data-bind="click: $parent.managePrefix.bind(this, $data.prefix, true)" />
data-bind="click: $parent.managePrefix.bind(this, $data.prefix, true, $data.parents)" />
<!-- /ko -->
</div>
</td>
Expand Down Expand Up @@ -243,12 +253,19 @@
});
};

this.managePrefix = function (data, addPrefix) {
this.managePrefix = function (prefixToModify, addPrefix, parents, model, e) {
if (!addPrefix && !confirm('Are you sure you want to delete this namespace?')) {
e.preventDefault();
return;
}

if (addPrefix
&& parents.length > 0
&& !confirm("At least one parent namespace exists. Ensure the owners of the parent namespaces have approved of the new child namespace. Press 'OK' to continue. Existing parent(s):\n" + parents.join("\n"))) {
e.preventDefault();
return;
}

var prefixToModify = data;
var url = addPrefix
? '@Url.Action("AddNamespace", "ReservedNamespace", new { area = "Admin" })'
: '@Url.Action("RemoveNamespace", "ReservedNamespace", new { area = "Admin" })';
Expand Down
Loading