Move the Cancel/Delete button logic into a partial.

This is already repeated once, so...