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

Add ability to reflow hard-deletes from Admin area #4899

Merged
merged 8 commits into from
Oct 30, 2017

Conversation

scottbommarito
Copy link
Contributor

@scottbommarito scottbommarito commented Oct 24, 2017

#4876

Existing delete page:
image

New page (just for reflowing hard deletes):
image

@@ -165,6 +168,30 @@ public class PackageDeleteService
UpdateSearchIndex();
}

public Task ReflowHardDeletedPackagesAsync(string id, string version, User deletedBy)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deletedBy does not seem used.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it reflows a hard-deleted package


[HttpPost]
[ValidateAntiForgeryToken]
public virtual async Task<ActionResult> Reflow(HardDeleteReflowViewModel model)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should support bulk by splitting lines, ID Version. Similar to the delete UI.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, will add

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joelverhagen just pushed this change

@joelverhagen
Copy link
Member

Screenshot plz

}
}

var auditRecord = new PackageAuditRecord(normalizedId, normalizedVersion, string.Empty, null, null, AuditedPackageAction.Delete, "reflow hard-deleted package");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

label null and string.Empty parameters

Copy link
Member

@joelverhagen joelverhagen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⌚️

@joelverhagen
Copy link
Member

Related: #4876


if (existingPackage != null)
{
throw new ArgumentException("The package exists! You can only reflow hard-deleted packages that do not exist.");
Copy link
Contributor

@loic-sharma loic-sharma Oct 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider throwing a UserSafeException instead of an ArgumentException so that the Reflow admin action gets a real error message using e.GetUserSafeMessage(). Also, consider adding the normalizedId and normalizedVersion to the exception message just for convenience's sake.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, looks nice

@@ -156,8 +155,81 @@ public virtual ActionResult Reflow()

TempData["Message"] = e.GetUserSafeMessage();

return Reflow();
return View("Reflow");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nameof(Reflow). The view name in general should match the method name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this is an MVC convention)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!


<div class="form-field">
@Html.LabelFor(m => m.BulkList)
@Html.TextAreaFor(m => m.BulkList, 10, 50, null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spoke offline about this, need width: 100% i think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it was form-field!!!


@if (Model == null)
{
@Html.Partial("_ReflowSingle")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spoke offline, I don't think we need the single if we have the bulk.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

return View("Reflow");
}

var lines = request.BulkList.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super nit: I personally like to use StringReader for this so you don't have the ugly \r \n` constant in your code. But this is totally fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future I will use StringReader.

Copy link
Member

@joelverhagen joelverhagen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to carefully test all the code paths of this UI in DEV/INT. We need to be really sure these fake entries don't block feed2catalog.

{
if (string.IsNullOrEmpty(id))
{
throw new UserSafeException($"Must supply an ID for the hard-deleted package to reflow.");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ [](start = 44, length = 1)

Nit, unused $ on this exception and the one on line 180.

Copy link
Contributor

@loic-sharma loic-sharma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@scottbommarito scottbommarito merged commit 5c8184f into dev Oct 30, 2017
@scottbommarito scottbommarito deleted the sb-harddeletereflow branch October 30, 2017 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants