From dabc7ea28dec523bb00ed7438ec2b40f88f3095c Mon Sep 17 00:00:00 2001 From: James Rhodes Date: Mon, 9 Dec 2013 07:52:24 +1100 Subject: [PATCH] Render deleted files in Phragment as disabled Summary: This updates Phragment so that fragments that are currently considered deleted have a disabled status and have an additional attribute 'Deleted'. It also places this effect on versions (in the history controller) that actually involve deleting the file. Test Plan: Viewed deleted fragments and versions. Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley CC: Korvin, epriestley, aran Maniphest Tasks: T4205 Differential Revision: https://secure.phabricator.com/D7737 --- .../controller/PhragmentBrowseController.php | 4 ++++ .../phragment/controller/PhragmentController.php | 12 +++++++++--- .../controller/PhragmentHistoryController.php | 5 +++++ .../phragment/storage/PhragmentFragment.php | 4 ++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/applications/phragment/controller/PhragmentBrowseController.php b/src/applications/phragment/controller/PhragmentBrowseController.php index adb4c0d796..852f1e8644 100644 --- a/src/applications/phragment/controller/PhragmentBrowseController.php +++ b/src/applications/phragment/controller/PhragmentBrowseController.php @@ -66,6 +66,10 @@ final class PhragmentBrowseController extends PhragmentController { $item->addAttribute(pht( 'Latest Version %s', $fragment->getLatestVersion()->getSequence())); + if ($fragment->isDeleted()) { + $item->setDisabled(true); + $item->addAttribute(pht('Deleted')); + } } else { $item->addAttribute('Directory'); } diff --git a/src/applications/phragment/controller/PhragmentController.php b/src/applications/phragment/controller/PhragmentController.php index d156745f4b..ac5d43c032 100644 --- a/src/applications/phragment/controller/PhragmentController.php +++ b/src/applications/phragment/controller/PhragmentController.php @@ -134,9 +134,15 @@ abstract class PhragmentController extends PhabricatorController { ->setActionList($actions); if (!$fragment->isDirectory()) { - $properties->addProperty( - pht('Type'), - pht('File')); + if ($fragment->isDeleted()) { + $properties->addProperty( + pht('Type'), + pht('File (Deleted)')); + } else { + $properties->addProperty( + pht('Type'), + pht('File')); + } $properties->addProperty( pht('Latest Version'), $this->renderHandlesForPHIDs(array($fragment->getLatestVersionPHID()))); diff --git a/src/applications/phragment/controller/PhragmentHistoryController.php b/src/applications/phragment/controller/PhragmentHistoryController.php index 4ca50c0f3a..53cac0c360 100644 --- a/src/applications/phragment/controller/PhragmentHistoryController.php +++ b/src/applications/phragment/controller/PhragmentHistoryController.php @@ -52,6 +52,11 @@ final class PhragmentHistoryController extends PhragmentController { $version->getDateCreated(), $viewer)); + if ($version->getFilePHID() === null) { + $item->setDisabled(true); + $item->addAttribute('Deletion'); + } + $disabled = !isset($files[$version->getFilePHID()]); $action = id(new PHUIListItemView()) ->setIcon('download') diff --git a/src/applications/phragment/storage/PhragmentFragment.php b/src/applications/phragment/storage/PhragmentFragment.php index 87caf483e3..446c306acd 100644 --- a/src/applications/phragment/storage/PhragmentFragment.php +++ b/src/applications/phragment/storage/PhragmentFragment.php @@ -42,6 +42,10 @@ final class PhragmentFragment extends PhragmentDAO return $this->latestVersionPHID === null; } + public function isDeleted() { + return $this->getLatestVersion()->getFilePHID() === null; + } + public function getLatestVersion() { if ($this->latestVersionPHID === null) { return null;