From cf346d3c8152dbf5dac26faf0f4b76d42df7ef32 Mon Sep 17 00:00:00 2001 From: Vedha Sayyaparaju Date: Thu, 24 Jan 2013 21:26:40 -0800 Subject: [PATCH] T2385: Add "Delete Document" action to Phriction pages Summary: If a page has not been deleted, this adds an action button to delete the document in the menu on the Phriction Page. Test Plan: 1. Created a document, checked whether "Delete Document" button was visible. 2. Clicked on "Delete Document" button, checked that the document had been deleted. 3. Went back to document page, checked that the "Delete Document" button no longer existed. Reviewers: epriestley CC: aran, Korvin Maniphest Tasks: T2385 Differential Revision: https://secure.phabricator.com/D4636 --- .../PhrictionDocumentController.php | 23 ++++++++++++++----- .../controller/PhrictionEditController.php | 14 ----------- 2 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/applications/phriction/controller/PhrictionDocumentController.php b/src/applications/phriction/controller/PhrictionDocumentController.php index 7b7a88fd98..97b328bd67 100644 --- a/src/applications/phriction/controller/PhrictionDocumentController.php +++ b/src/applications/phriction/controller/PhrictionDocumentController.php @@ -215,19 +215,30 @@ final class PhrictionDocumentController $slug = PhabricatorSlug::normalize($this->slug); - return id(new PhabricatorActionListView()) + $action_view = id(new PhabricatorActionListView()) ->setUser($user) ->setObject($document) ->addAction( id(new PhabricatorActionView()) ->setName(pht('Edit Document')) ->setIcon('edit') - ->setHref('/phriction/edit/'.$document->getID().'/')) - ->addAction( + ->setHref('/phriction/edit/'.$document->getID().'/')); + + if ($document->getStatus() == PhrictionDocumentStatus::STATUS_EXISTS) { + $action_view->addAction( id(new PhabricatorActionView()) - ->setName(pht('View History')) - ->setIcon('history') - ->setHref(PhrictionDocument::getSlugURI($slug, 'history'))); + ->setName(pht('Delete Document')) + ->setIcon('delete') + ->setHref('/phriction/delete/'.$document->getID().'/') + ->setWorkflow(true)); + } + + return + $action_view->addAction( + id(new PhabricatorActionView()) + ->setName(pht('View History')) + ->setIcon('history') + ->setHref(PhrictionDocument::getSlugURI($slug, 'history'))); } private function renderChildren($slug) { diff --git a/src/applications/phriction/controller/PhrictionEditController.php b/src/applications/phriction/controller/PhrictionEditController.php index e5ebe1bf11..2c35ce4bed 100644 --- a/src/applications/phriction/controller/PhrictionEditController.php +++ b/src/applications/phriction/controller/PhrictionEditController.php @@ -154,19 +154,9 @@ final class PhrictionEditController ->setErrors($errors); } - $delete_button = null; if ($document->getID()) { $panel_header = 'Edit Phriction Document'; $submit_button = 'Save Changes'; - if ($document->getStatus() != PhrictionDocumentStatus::STATUS_DELETED) { - $delete_button = phutil_render_tag( - 'a', - array( - 'href' => '/phriction/delete/'.$document->getID().'/', - 'class' => 'grey button', - ), - 'Delete Document'); - } } else { $panel_header = 'Create New Phriction Document'; $submit_button = 'Create Document'; @@ -240,10 +230,6 @@ final class PhrictionEditController ->setHeader($panel_header) ->appendChild($form); - if ($delete_button) { - $panel->addButton($delete_button); - } - $preview_panel = '