@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator

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

authored by

lkassianik and committed by
epriestley
3d457a53 25f9facb

+107 -3
+5
resources/sql/autopatches/20140514.pholiomockclose.sql
··· 1 + ALTER TABLE {$NAMESPACE}_pholio.pholio_mock 2 + ADD COLUMN status VARCHAR(12) NOT NULL COLLATE utf8_bin; 3 + 4 + UPDATE {$NAMESPACE}_pholio.pholio_mock 5 + SET status = "open" WHERE status = "";
+1
src/applications/pholio/constants/PholioTransactionType.php
··· 8 8 /* edits to the high level mock */ 9 9 const TYPE_NAME = 'name'; 10 10 const TYPE_DESCRIPTION = 'description'; 11 + const TYPE_STATUS = 'status'; 11 12 12 13 /* edits to images within the mock */ 13 14 const TYPE_IMAGE_FILE = 'image-file';
+10
src/applications/pholio/controller/PholioMockEditController.php
··· 54 54 55 55 $v_name = $mock->getName(); 56 56 $v_desc = $mock->getDescription(); 57 + $v_status = $mock->getStatus(); 57 58 $v_view = $mock->getViewPolicy(); 58 59 $v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID( 59 60 $mock->getPHID()); ··· 63 64 64 65 $type_name = PholioTransactionType::TYPE_NAME; 65 66 $type_desc = PholioTransactionType::TYPE_DESCRIPTION; 67 + $type_status = PholioTransactionType::TYPE_STATUS; 66 68 $type_view = PhabricatorTransactions::TYPE_VIEW_POLICY; 67 69 $type_cc = PhabricatorTransactions::TYPE_SUBSCRIBERS; 68 70 69 71 $v_name = $request->getStr('name'); 70 72 $v_desc = $request->getStr('description'); 73 + $v_status = $request->getStr('status'); 71 74 $v_view = $request->getStr('can_view'); 72 75 $v_cc = $request->getArr('cc'); 73 76 74 77 $mock_xactions = array(); 75 78 $mock_xactions[$type_name] = $v_name; 76 79 $mock_xactions[$type_desc] = $v_desc; 80 + $mock_xactions[$type_status] = $v_status; 77 81 $mock_xactions[$type_view] = $v_view; 78 82 $mock_xactions[$type_cc] = array('=' => $v_cc); 79 83 ··· 298 302 ->setValue($v_desc) 299 303 ->setLabel(pht('Description')) 300 304 ->setUser($user)) 305 + ->appendChild( 306 + id(new AphrontFormSelectControl()) 307 + ->setLabel(pht('Status')) 308 + ->setName('status') 309 + ->setValue($mock->getStatus()) 310 + ->setOptions($mock->getStatuses())) 301 311 ->appendChild( 302 312 id(new AphrontFormTokenizerControl()) 303 313 ->setLabel(pht('CC'))
+9
src/applications/pholio/controller/PholioMockViewController.php
··· 67 67 68 68 $title = $mock->getName(); 69 69 70 + if ($mock->isClosed()) { 71 + $header_icon = 'oh-closed'; 72 + $header_name = pht('Closed'); 73 + } else { 74 + $header_icon = 'open'; 75 + $header_name = pht('Open'); 76 + } 77 + 70 78 $header = id(new PHUIHeaderView()) 71 79 ->setHeader($title) 72 80 ->setUser($user) 81 + ->setStatus($header_icon, '', $header_name) 73 82 ->setPolicyObject($mock); 74 83 75 84 $actions = $this->buildActionView($mock);
+8
src/applications/pholio/editor/PholioMockEditor.php
··· 25 25 26 26 $types[] = PholioTransactionType::TYPE_NAME; 27 27 $types[] = PholioTransactionType::TYPE_DESCRIPTION; 28 + $types[] = PholioTransactionType::TYPE_STATUS; 28 29 $types[] = PholioTransactionType::TYPE_INLINE; 29 30 30 31 $types[] = PholioTransactionType::TYPE_IMAGE_FILE; ··· 45 46 return $object->getName(); 46 47 case PholioTransactionType::TYPE_DESCRIPTION: 47 48 return $object->getDescription(); 49 + case PholioTransactionType::TYPE_STATUS: 50 + return $object->getStatus(); 48 51 case PholioTransactionType::TYPE_IMAGE_FILE: 49 52 $images = $object->getImages(); 50 53 return mpull($images, 'getPHID'); ··· 88 91 switch ($xaction->getTransactionType()) { 89 92 case PholioTransactionType::TYPE_NAME: 90 93 case PholioTransactionType::TYPE_DESCRIPTION: 94 + case PholioTransactionType::TYPE_STATUS: 91 95 case PholioTransactionType::TYPE_IMAGE_NAME: 92 96 case PholioTransactionType::TYPE_IMAGE_DESCRIPTION: 93 97 case PholioTransactionType::TYPE_IMAGE_SEQUENCE: ··· 196 200 case PholioTransactionType::TYPE_DESCRIPTION: 197 201 $object->setDescription($xaction->getNewValue()); 198 202 break; 203 + case PholioTransactionType::TYPE_STATUS: 204 + $object->setStatus($xaction->getNewValue()); 205 + break; 199 206 } 200 207 } 201 208 ··· 287 294 switch ($type) { 288 295 case PholioTransactionType::TYPE_NAME: 289 296 case PholioTransactionType::TYPE_DESCRIPTION: 297 + case PholioTransactionType::TYPE_STATUS: 290 298 return $v; 291 299 case PholioTransactionType::TYPE_IMAGE_REPLACE: 292 300 $u_img = $u->getNewValue();
+4
src/applications/pholio/phid/PholioPHIDTypeMock.php
··· 42 42 $handle->setURI("/M{$id}"); 43 43 $handle->setName("M{$id}"); 44 44 $handle->setFullName("M{$id}: {$name}"); 45 + 46 + if ($mock->isClosed()) { 47 + $handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED); 48 + } 45 49 } 46 50 } 47 51
+13
src/applications/pholio/query/PholioMockQuery.php
··· 9 9 private $ids; 10 10 private $phids; 11 11 private $authorPHIDs; 12 + private $statuses; 12 13 13 14 private $needCoverFiles; 14 15 private $needImages; ··· 27 28 28 29 public function withAuthorPHIDs(array $author_phids) { 29 30 $this->authorPHIDs = $author_phids; 31 + return $this; 32 + } 33 + 34 + public function withStatuses(array $statuses) { 35 + $this->statuses = $statuses; 30 36 return $this; 31 37 } 32 38 ··· 103 109 $conn_r, 104 110 'authorPHID in (%Ls)', 105 111 $this->authorPHIDs); 112 + } 113 + 114 + if ($this->statuses) { 115 + $where[] = qsprintf( 116 + $conn_r, 117 + 'status IN (%Ls)', 118 + $this->statuses); 106 119 } 107 120 108 121 return $this->formatWhereClause($where);
+32 -3
src/applications/pholio/query/PholioMockSearchEngine.php
··· 12 12 $saved->setParameter( 13 13 'authorPHIDs', 14 14 $this->readUsersFromRequest($request, 'authors')); 15 + $saved->setParameter( 16 + 'statuses', 17 + $request->getStrList('status')); 15 18 16 19 return $saved; 17 20 } ··· 21 24 ->needCoverFiles(true) 22 25 ->needImages(true) 23 26 ->needTokenCounts(true) 24 - ->withAuthorPHIDs($saved->getParameter('authorPHIDs', array())); 27 + ->withAuthorPHIDs($saved->getParameter('authorPHIDs', array())) 28 + ->withStatuses($saved->getParameter('statuses', array())); 25 29 26 30 return $query; 27 31 } ··· 36 40 ->withPHIDs($phids) 37 41 ->execute(); 38 42 43 + $statuses = array( 44 + ''=>pht('Any Status'), 45 + 'closed'=>pht('Closed'), 46 + 'open'=>pht('Open')); 47 + 48 + $status = $saved_query->getParameter('statuses', array()); 49 + $status = head($status); 50 + 39 51 $form 40 52 ->appendChild( 41 53 id(new AphrontFormTokenizerControl()) 42 54 ->setDatasource('/typeahead/common/users/') 43 55 ->setName('authors') 44 56 ->setLabel(pht('Authors')) 45 - ->setValue($author_handles)); 57 + ->setValue($author_handles)) 58 + ->appendChild( 59 + id(new AphrontFormSelectControl()) 60 + ->setLabel(pht('Status')) 61 + ->setName('status') 62 + ->setOptions($statuses) 63 + ->setValue($status)); 46 64 } 47 65 48 66 protected function getURI($path) { ··· 51 69 52 70 public function getBuiltinQueryNames() { 53 71 $names = array( 72 + 'open' => pht('Open Mocks'), 54 73 'all' => pht('All Mocks'), 55 74 ); 56 75 ··· 67 86 $query->setQueryKey($query_key); 68 87 69 88 switch ($query_key) { 89 + case 'open': 90 + return $query->setParameter( 91 + 'statuses', 92 + array('open')); 70 93 case 'all': 71 94 return $query; 72 95 case 'authored': ··· 94 117 95 118 $board = new PHUIPinboardView(); 96 119 foreach ($mocks as $mock) { 120 + 121 + $header = 'M'.$mock->getID().' '.$mock->getName(); 122 + if ($mock->isClosed()) { 123 + $header = pht('%s (Closed)', $header); 124 + } 125 + 97 126 $item = id(new PHUIPinboardItemView()) 98 - ->setHeader('M'.$mock->getID().' '.$mock->getName()) 127 + ->setHeader($header) 99 128 ->setURI('/M'.$mock->getID()) 100 129 ->setImageURI($mock->getCoverFile()->getThumb280x210URI()) 101 130 ->setImageSize(280, 210)
+12
src/applications/pholio/storage/PholioMock.php
··· 19 19 protected $description; 20 20 protected $coverPHID; 21 21 protected $mailKey; 22 + protected $status; 22 23 23 24 private $images = self::ATTACHABLE; 24 25 private $allImages = self::ATTACHABLE; ··· 127 128 } 128 129 129 130 return $history; 131 + } 132 + 133 + public function getStatuses() { 134 + $options = array(); 135 + $options['closed'] = 'Closed'; 136 + $options['open'] = 'Open'; 137 + return $options; 138 + } 139 + 140 + public function isClosed() { 141 + return ($this->getStatus() == 'closed'); 130 142 } 131 143 132 144
+13
src/applications/pholio/storage/PholioTransaction.php
··· 66 66 return 'fa-comment'; 67 67 case PholioTransactionType::TYPE_NAME: 68 68 case PholioTransactionType::TYPE_DESCRIPTION: 69 + case PholioTransactionType::TYPE_STATUS: 69 70 case PholioTransactionType::TYPE_IMAGE_NAME: 70 71 case PholioTransactionType::TYPE_IMAGE_DESCRIPTION: 71 72 case PholioTransactionType::TYPE_IMAGE_SEQUENCE: ··· 103 104 case PholioTransactionType::TYPE_DESCRIPTION: 104 105 return pht( 105 106 "%s updated the mock's description.", 107 + $this->renderHandleLink($author_phid)); 108 + break; 109 + case PholioTransactionType::TYPE_STATUS: 110 + return pht( 111 + "%s updated the mock's status.", 106 112 $this->renderHandleLink($author_phid)); 107 113 break; 108 114 case PholioTransactionType::TYPE_INLINE: ··· 207 213 $this->renderHandleLink($author_phid), 208 214 $this->renderHandleLink($object_phid)); 209 215 break; 216 + case PholioTransactionType::TYPE_STATUS: 217 + return pht( 218 + '%s updated the status for %s.', 219 + $this->renderHandleLink($author_phid), 220 + $this->renderHandleLink($object_phid)); 221 + break; 210 222 case PholioTransactionType::TYPE_INLINE: 211 223 return pht( 212 224 '%s added an inline comment to %s.', ··· 299 311 return PhabricatorTransactions::COLOR_GREEN; 300 312 } 301 313 case PholioTransactionType::TYPE_DESCRIPTION: 314 + case PholioTransactionType::TYPE_STATUS: 302 315 case PholioTransactionType::TYPE_IMAGE_NAME: 303 316 case PholioTransactionType::TYPE_IMAGE_DESCRIPTION: 304 317 case PholioTransactionType::TYPE_IMAGE_SEQUENCE: