diff --git a/src/NuGetGallery/Views/Packages/ManagePackageOwners.cshtml b/src/NuGetGallery/Views/Packages/ManagePackageOwners.cshtml
index 670013aa43..1a81e90262 100644
--- a/src/NuGetGallery/Views/Packages/ManagePackageOwners.cshtml
+++ b/src/NuGetGallery/Views/Packages/ManagePackageOwners.cshtml
@@ -12,7 +12,7 @@
(that’s you!)
(pending approval)
- Remove
+ Remove
@@ -58,6 +58,10 @@
message: ko.observable(''),
+ hasMoreThanOneOwner: function() {
+ return true;
+ },
+
addOwner: function () {
var newUsername = viewModel.newOwnerUsername();
var message = viewModel.newOwnerMessage();
@@ -117,6 +121,15 @@
var package = viewModel.package;
var headers = { '__RequestVerificationToken': $('input[name=""__RequestVerificationToken""]').val() };
+ var proceedToRemoveFunction = true;
+
+ if (item.current) {
+ proceedToRemoveFunction = confirm("Are you sure you want to remove yourself from the owners?");
+ }
+
+ if (proceedToRemoveFunction === false)
+ return;
+
$.ajax({
url: '@Url.Action("RemovePackageOwner", "JsonApi")?id=' + package.id + '&username=' + item.name(),
cache: false,
@@ -126,6 +139,10 @@
contentType: 'application/json; charset=utf-8',
success: function (data) {
if (data.success) {
+ if (item.current) {
+ window.location.href = '@Url.Package(Model.Id)';
+ }
+
viewModel.owners.remove(item);
// when an operation succeeds, always clear the error message
@@ -139,6 +156,24 @@
}
};
+ viewModel.hasMoreThanOneOwner = ko.computed(function () {
+
+ if (this.owners().length < 2)
+ return false;
+
+ var approvedOwner = 0;
+
+ ko.utils.arrayForEach(this.owners(), function (owner) {
+ if (owner.pending() === false)
+ approvedOwner++;
+ });
+
+ if (approvedOwner >= 2)
+ return true;
+
+ return false;
+ }, viewModel);
+
ko.applyBindings(viewModel);
// Load initial owners.