From 3d457a53be60db07f5946f626fd47fe64c985774 Mon Sep 17 00:00:00 2001 From: lkassianik Date: Mon, 19 May 2014 11:33:34 -0700 Subject: [PATCH] Close pholio mocks Summary: Fixes T4299, Add status dropdown to mock edit view Test Plan: Edit mock, close mock, thumbnail title should read (Disabled). Default mocks list should show only open mocks. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: chad, epriestley, Korvin Maniphest Tasks: T4299 Differential Revision: https://secure.phabricator.com/D9145 --- .../autopatches/20140514.pholiomockclose.sql | 5 +++ .../constants/PholioTransactionType.php | 1 + .../controller/PholioMockEditController.php | 10 ++++++ .../controller/PholioMockViewController.php | 9 +++++ .../pholio/editor/PholioMockEditor.php | 8 +++++ .../pholio/phid/PholioPHIDTypeMock.php | 4 +++ .../pholio/query/PholioMockQuery.php | 13 +++++++ .../pholio/query/PholioMockSearchEngine.php | 35 +++++++++++++++++-- .../pholio/storage/PholioMock.php | 12 +++++++ .../pholio/storage/PholioTransaction.php | 13 +++++++ 10 files changed, 107 insertions(+), 3 deletions(-) create mode 100644 resources/sql/autopatches/20140514.pholiomockclose.sql diff --git a/resources/sql/autopatches/20140514.pholiomockclose.sql b/resources/sql/autopatches/20140514.pholiomockclose.sql new file mode 100644 index 0000000000..2a4c2768f7 --- /dev/null +++ b/resources/sql/autopatches/20140514.pholiomockclose.sql @@ -0,0 +1,5 @@ +ALTER TABLE {$NAMESPACE}_pholio.pholio_mock + ADD COLUMN status VARCHAR(12) NOT NULL COLLATE utf8_bin; + +UPDATE {$NAMESPACE}_pholio.pholio_mock + SET status = "open" WHERE status = ""; diff --git a/src/applications/pholio/constants/PholioTransactionType.php b/src/applications/pholio/constants/PholioTransactionType.php index e106628636..50ab8fe942 100644 --- a/src/applications/pholio/constants/PholioTransactionType.php +++ b/src/applications/pholio/constants/PholioTransactionType.php @@ -8,6 +8,7 @@ final class PholioTransactionType extends PholioConstants { /* edits to the high level mock */ const TYPE_NAME = 'name'; const TYPE_DESCRIPTION = 'description'; + const TYPE_STATUS = 'status'; /* edits to images within the mock */ const TYPE_IMAGE_FILE = 'image-file'; diff --git a/src/applications/pholio/controller/PholioMockEditController.php b/src/applications/pholio/controller/PholioMockEditController.php index c46df1b5a1..195aa3170e 100644 --- a/src/applications/pholio/controller/PholioMockEditController.php +++ b/src/applications/pholio/controller/PholioMockEditController.php @@ -54,6 +54,7 @@ final class PholioMockEditController extends PholioController { $v_name = $mock->getName(); $v_desc = $mock->getDescription(); + $v_status = $mock->getStatus(); $v_view = $mock->getViewPolicy(); $v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID( $mock->getPHID()); @@ -63,17 +64,20 @@ final class PholioMockEditController extends PholioController { $type_name = PholioTransactionType::TYPE_NAME; $type_desc = PholioTransactionType::TYPE_DESCRIPTION; + $type_status = PholioTransactionType::TYPE_STATUS; $type_view = PhabricatorTransactions::TYPE_VIEW_POLICY; $type_cc = PhabricatorTransactions::TYPE_SUBSCRIBERS; $v_name = $request->getStr('name'); $v_desc = $request->getStr('description'); + $v_status = $request->getStr('status'); $v_view = $request->getStr('can_view'); $v_cc = $request->getArr('cc'); $mock_xactions = array(); $mock_xactions[$type_name] = $v_name; $mock_xactions[$type_desc] = $v_desc; + $mock_xactions[$type_status] = $v_status; $mock_xactions[$type_view] = $v_view; $mock_xactions[$type_cc] = array('=' => $v_cc); @@ -298,6 +302,12 @@ final class PholioMockEditController extends PholioController { ->setValue($v_desc) ->setLabel(pht('Description')) ->setUser($user)) + ->appendChild( + id(new AphrontFormSelectControl()) + ->setLabel(pht('Status')) + ->setName('status') + ->setValue($mock->getStatus()) + ->setOptions($mock->getStatuses())) ->appendChild( id(new AphrontFormTokenizerControl()) ->setLabel(pht('CC')) diff --git a/src/applications/pholio/controller/PholioMockViewController.php b/src/applications/pholio/controller/PholioMockViewController.php index 4ce1be6472..0388791529 100644 --- a/src/applications/pholio/controller/PholioMockViewController.php +++ b/src/applications/pholio/controller/PholioMockViewController.php @@ -67,9 +67,18 @@ final class PholioMockViewController extends PholioController { $title = $mock->getName(); + if ($mock->isClosed()) { + $header_icon = 'oh-closed'; + $header_name = pht('Closed'); + } else { + $header_icon = 'open'; + $header_name = pht('Open'); + } + $header = id(new PHUIHeaderView()) ->setHeader($title) ->setUser($user) + ->setStatus($header_icon, '', $header_name) ->setPolicyObject($mock); $actions = $this->buildActionView($mock); diff --git a/src/applications/pholio/editor/PholioMockEditor.php b/src/applications/pholio/editor/PholioMockEditor.php index 6b6b9c8425..c39b8caf05 100644 --- a/src/applications/pholio/editor/PholioMockEditor.php +++ b/src/applications/pholio/editor/PholioMockEditor.php @@ -25,6 +25,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor { $types[] = PholioTransactionType::TYPE_NAME; $types[] = PholioTransactionType::TYPE_DESCRIPTION; + $types[] = PholioTransactionType::TYPE_STATUS; $types[] = PholioTransactionType::TYPE_INLINE; $types[] = PholioTransactionType::TYPE_IMAGE_FILE; @@ -45,6 +46,8 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor { return $object->getName(); case PholioTransactionType::TYPE_DESCRIPTION: return $object->getDescription(); + case PholioTransactionType::TYPE_STATUS: + return $object->getStatus(); case PholioTransactionType::TYPE_IMAGE_FILE: $images = $object->getImages(); return mpull($images, 'getPHID'); @@ -88,6 +91,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor { switch ($xaction->getTransactionType()) { case PholioTransactionType::TYPE_NAME: case PholioTransactionType::TYPE_DESCRIPTION: + case PholioTransactionType::TYPE_STATUS: case PholioTransactionType::TYPE_IMAGE_NAME: case PholioTransactionType::TYPE_IMAGE_DESCRIPTION: case PholioTransactionType::TYPE_IMAGE_SEQUENCE: @@ -196,6 +200,9 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor { case PholioTransactionType::TYPE_DESCRIPTION: $object->setDescription($xaction->getNewValue()); break; + case PholioTransactionType::TYPE_STATUS: + $object->setStatus($xaction->getNewValue()); + break; } } @@ -287,6 +294,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor { switch ($type) { case PholioTransactionType::TYPE_NAME: case PholioTransactionType::TYPE_DESCRIPTION: + case PholioTransactionType::TYPE_STATUS: return $v; case PholioTransactionType::TYPE_IMAGE_REPLACE: $u_img = $u->getNewValue(); diff --git a/src/applications/pholio/phid/PholioPHIDTypeMock.php b/src/applications/pholio/phid/PholioPHIDTypeMock.php index d0567db1cd..39025fcfd8 100644 --- a/src/applications/pholio/phid/PholioPHIDTypeMock.php +++ b/src/applications/pholio/phid/PholioPHIDTypeMock.php @@ -42,6 +42,10 @@ final class PholioPHIDTypeMock extends PhabricatorPHIDType { $handle->setURI("/M{$id}"); $handle->setName("M{$id}"); $handle->setFullName("M{$id}: {$name}"); + + if ($mock->isClosed()) { + $handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED); + } } } diff --git a/src/applications/pholio/query/PholioMockQuery.php b/src/applications/pholio/query/PholioMockQuery.php index 3b9a40fa9a..dbe8334193 100644 --- a/src/applications/pholio/query/PholioMockQuery.php +++ b/src/applications/pholio/query/PholioMockQuery.php @@ -9,6 +9,7 @@ final class PholioMockQuery private $ids; private $phids; private $authorPHIDs; + private $statuses; private $needCoverFiles; private $needImages; @@ -30,6 +31,11 @@ final class PholioMockQuery return $this; } + public function withStatuses(array $statuses) { + $this->statuses = $statuses; + return $this; + } + public function needCoverFiles($need_cover_files) { $this->needCoverFiles = $need_cover_files; return $this; @@ -105,6 +111,13 @@ final class PholioMockQuery $this->authorPHIDs); } + if ($this->statuses) { + $where[] = qsprintf( + $conn_r, + 'status IN (%Ls)', + $this->statuses); + } + return $this->formatWhereClause($where); } diff --git a/src/applications/pholio/query/PholioMockSearchEngine.php b/src/applications/pholio/query/PholioMockSearchEngine.php index 5c46243693..96b546160e 100644 --- a/src/applications/pholio/query/PholioMockSearchEngine.php +++ b/src/applications/pholio/query/PholioMockSearchEngine.php @@ -12,6 +12,9 @@ final class PholioMockSearchEngine $saved->setParameter( 'authorPHIDs', $this->readUsersFromRequest($request, 'authors')); + $saved->setParameter( + 'statuses', + $request->getStrList('status')); return $saved; } @@ -21,7 +24,8 @@ final class PholioMockSearchEngine ->needCoverFiles(true) ->needImages(true) ->needTokenCounts(true) - ->withAuthorPHIDs($saved->getParameter('authorPHIDs', array())); + ->withAuthorPHIDs($saved->getParameter('authorPHIDs', array())) + ->withStatuses($saved->getParameter('statuses', array())); return $query; } @@ -36,13 +40,27 @@ final class PholioMockSearchEngine ->withPHIDs($phids) ->execute(); + $statuses = array( + ''=>pht('Any Status'), + 'closed'=>pht('Closed'), + 'open'=>pht('Open')); + + $status = $saved_query->getParameter('statuses', array()); + $status = head($status); + $form ->appendChild( id(new AphrontFormTokenizerControl()) ->setDatasource('/typeahead/common/users/') ->setName('authors') ->setLabel(pht('Authors')) - ->setValue($author_handles)); + ->setValue($author_handles)) + ->appendChild( + id(new AphrontFormSelectControl()) + ->setLabel(pht('Status')) + ->setName('status') + ->setOptions($statuses) + ->setValue($status)); } protected function getURI($path) { @@ -51,6 +69,7 @@ final class PholioMockSearchEngine public function getBuiltinQueryNames() { $names = array( + 'open' => pht('Open Mocks'), 'all' => pht('All Mocks'), ); @@ -67,6 +86,10 @@ final class PholioMockSearchEngine $query->setQueryKey($query_key); switch ($query_key) { + case 'open': + return $query->setParameter( + 'statuses', + array('open')); case 'all': return $query; case 'authored': @@ -94,8 +117,14 @@ final class PholioMockSearchEngine $board = new PHUIPinboardView(); foreach ($mocks as $mock) { + + $header = 'M'.$mock->getID().' '.$mock->getName(); + if ($mock->isClosed()) { + $header = pht('%s (Closed)', $header); + } + $item = id(new PHUIPinboardItemView()) - ->setHeader('M'.$mock->getID().' '.$mock->getName()) + ->setHeader($header) ->setURI('/M'.$mock->getID()) ->setImageURI($mock->getCoverFile()->getThumb280x210URI()) ->setImageSize(280, 210) diff --git a/src/applications/pholio/storage/PholioMock.php b/src/applications/pholio/storage/PholioMock.php index 0504dd6dff..a6adb26e69 100644 --- a/src/applications/pholio/storage/PholioMock.php +++ b/src/applications/pholio/storage/PholioMock.php @@ -19,6 +19,7 @@ final class PholioMock extends PholioDAO protected $description; protected $coverPHID; protected $mailKey; + protected $status; private $images = self::ATTACHABLE; private $allImages = self::ATTACHABLE; @@ -129,6 +130,17 @@ final class PholioMock extends PholioDAO return $history; } + public function getStatuses() { + $options = array(); + $options['closed'] = 'Closed'; + $options['open'] = 'Open'; + return $options; + } + + public function isClosed() { + return ($this->getStatus() == 'closed'); + } + /* -( PhabricatorSubscribableInterface Implementation )-------------------- */ diff --git a/src/applications/pholio/storage/PholioTransaction.php b/src/applications/pholio/storage/PholioTransaction.php index c2e6c415fa..bee7340cd9 100644 --- a/src/applications/pholio/storage/PholioTransaction.php +++ b/src/applications/pholio/storage/PholioTransaction.php @@ -66,6 +66,7 @@ final class PholioTransaction extends PhabricatorApplicationTransaction { return 'fa-comment'; case PholioTransactionType::TYPE_NAME: case PholioTransactionType::TYPE_DESCRIPTION: + case PholioTransactionType::TYPE_STATUS: case PholioTransactionType::TYPE_IMAGE_NAME: case PholioTransactionType::TYPE_IMAGE_DESCRIPTION: case PholioTransactionType::TYPE_IMAGE_SEQUENCE: @@ -105,6 +106,11 @@ final class PholioTransaction extends PhabricatorApplicationTransaction { "%s updated the mock's description.", $this->renderHandleLink($author_phid)); break; + case PholioTransactionType::TYPE_STATUS: + return pht( + "%s updated the mock's status.", + $this->renderHandleLink($author_phid)); + break; case PholioTransactionType::TYPE_INLINE: $count = 1; foreach ($this->getTransactionGroup() as $xaction) { @@ -207,6 +213,12 @@ final class PholioTransaction extends PhabricatorApplicationTransaction { $this->renderHandleLink($author_phid), $this->renderHandleLink($object_phid)); break; + case PholioTransactionType::TYPE_STATUS: + return pht( + '%s updated the status for %s.', + $this->renderHandleLink($author_phid), + $this->renderHandleLink($object_phid)); + break; case PholioTransactionType::TYPE_INLINE: return pht( '%s added an inline comment to %s.', @@ -299,6 +311,7 @@ final class PholioTransaction extends PhabricatorApplicationTransaction { return PhabricatorTransactions::COLOR_GREEN; } case PholioTransactionType::TYPE_DESCRIPTION: + case PholioTransactionType::TYPE_STATUS: case PholioTransactionType::TYPE_IMAGE_NAME: case PholioTransactionType::TYPE_IMAGE_DESCRIPTION: case PholioTransactionType::TYPE_IMAGE_SEQUENCE: