1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-28 16:30:59 +01:00

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
This commit is contained in:
lkassianik 2014-05-19 11:33:34 -07:00 committed by epriestley
parent 25f9facba6
commit 3d457a53be
10 changed files with 107 additions and 3 deletions

View file

@ -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 = "";

View file

@ -8,6 +8,7 @@ final class PholioTransactionType extends PholioConstants {
/* edits to the high level mock */ /* edits to the high level mock */
const TYPE_NAME = 'name'; const TYPE_NAME = 'name';
const TYPE_DESCRIPTION = 'description'; const TYPE_DESCRIPTION = 'description';
const TYPE_STATUS = 'status';
/* edits to images within the mock */ /* edits to images within the mock */
const TYPE_IMAGE_FILE = 'image-file'; const TYPE_IMAGE_FILE = 'image-file';

View file

@ -54,6 +54,7 @@ final class PholioMockEditController extends PholioController {
$v_name = $mock->getName(); $v_name = $mock->getName();
$v_desc = $mock->getDescription(); $v_desc = $mock->getDescription();
$v_status = $mock->getStatus();
$v_view = $mock->getViewPolicy(); $v_view = $mock->getViewPolicy();
$v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID( $v_cc = PhabricatorSubscribersQuery::loadSubscribersForPHID(
$mock->getPHID()); $mock->getPHID());
@ -63,17 +64,20 @@ final class PholioMockEditController extends PholioController {
$type_name = PholioTransactionType::TYPE_NAME; $type_name = PholioTransactionType::TYPE_NAME;
$type_desc = PholioTransactionType::TYPE_DESCRIPTION; $type_desc = PholioTransactionType::TYPE_DESCRIPTION;
$type_status = PholioTransactionType::TYPE_STATUS;
$type_view = PhabricatorTransactions::TYPE_VIEW_POLICY; $type_view = PhabricatorTransactions::TYPE_VIEW_POLICY;
$type_cc = PhabricatorTransactions::TYPE_SUBSCRIBERS; $type_cc = PhabricatorTransactions::TYPE_SUBSCRIBERS;
$v_name = $request->getStr('name'); $v_name = $request->getStr('name');
$v_desc = $request->getStr('description'); $v_desc = $request->getStr('description');
$v_status = $request->getStr('status');
$v_view = $request->getStr('can_view'); $v_view = $request->getStr('can_view');
$v_cc = $request->getArr('cc'); $v_cc = $request->getArr('cc');
$mock_xactions = array(); $mock_xactions = array();
$mock_xactions[$type_name] = $v_name; $mock_xactions[$type_name] = $v_name;
$mock_xactions[$type_desc] = $v_desc; $mock_xactions[$type_desc] = $v_desc;
$mock_xactions[$type_status] = $v_status;
$mock_xactions[$type_view] = $v_view; $mock_xactions[$type_view] = $v_view;
$mock_xactions[$type_cc] = array('=' => $v_cc); $mock_xactions[$type_cc] = array('=' => $v_cc);
@ -298,6 +302,12 @@ final class PholioMockEditController extends PholioController {
->setValue($v_desc) ->setValue($v_desc)
->setLabel(pht('Description')) ->setLabel(pht('Description'))
->setUser($user)) ->setUser($user))
->appendChild(
id(new AphrontFormSelectControl())
->setLabel(pht('Status'))
->setName('status')
->setValue($mock->getStatus())
->setOptions($mock->getStatuses()))
->appendChild( ->appendChild(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())
->setLabel(pht('CC')) ->setLabel(pht('CC'))

View file

@ -67,9 +67,18 @@ final class PholioMockViewController extends PholioController {
$title = $mock->getName(); $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()) $header = id(new PHUIHeaderView())
->setHeader($title) ->setHeader($title)
->setUser($user) ->setUser($user)
->setStatus($header_icon, '', $header_name)
->setPolicyObject($mock); ->setPolicyObject($mock);
$actions = $this->buildActionView($mock); $actions = $this->buildActionView($mock);

View file

@ -25,6 +25,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
$types[] = PholioTransactionType::TYPE_NAME; $types[] = PholioTransactionType::TYPE_NAME;
$types[] = PholioTransactionType::TYPE_DESCRIPTION; $types[] = PholioTransactionType::TYPE_DESCRIPTION;
$types[] = PholioTransactionType::TYPE_STATUS;
$types[] = PholioTransactionType::TYPE_INLINE; $types[] = PholioTransactionType::TYPE_INLINE;
$types[] = PholioTransactionType::TYPE_IMAGE_FILE; $types[] = PholioTransactionType::TYPE_IMAGE_FILE;
@ -45,6 +46,8 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
return $object->getName(); return $object->getName();
case PholioTransactionType::TYPE_DESCRIPTION: case PholioTransactionType::TYPE_DESCRIPTION:
return $object->getDescription(); return $object->getDescription();
case PholioTransactionType::TYPE_STATUS:
return $object->getStatus();
case PholioTransactionType::TYPE_IMAGE_FILE: case PholioTransactionType::TYPE_IMAGE_FILE:
$images = $object->getImages(); $images = $object->getImages();
return mpull($images, 'getPHID'); return mpull($images, 'getPHID');
@ -88,6 +91,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
switch ($xaction->getTransactionType()) { switch ($xaction->getTransactionType()) {
case PholioTransactionType::TYPE_NAME: case PholioTransactionType::TYPE_NAME:
case PholioTransactionType::TYPE_DESCRIPTION: case PholioTransactionType::TYPE_DESCRIPTION:
case PholioTransactionType::TYPE_STATUS:
case PholioTransactionType::TYPE_IMAGE_NAME: case PholioTransactionType::TYPE_IMAGE_NAME:
case PholioTransactionType::TYPE_IMAGE_DESCRIPTION: case PholioTransactionType::TYPE_IMAGE_DESCRIPTION:
case PholioTransactionType::TYPE_IMAGE_SEQUENCE: case PholioTransactionType::TYPE_IMAGE_SEQUENCE:
@ -196,6 +200,9 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
case PholioTransactionType::TYPE_DESCRIPTION: case PholioTransactionType::TYPE_DESCRIPTION:
$object->setDescription($xaction->getNewValue()); $object->setDescription($xaction->getNewValue());
break; break;
case PholioTransactionType::TYPE_STATUS:
$object->setStatus($xaction->getNewValue());
break;
} }
} }
@ -287,6 +294,7 @@ final class PholioMockEditor extends PhabricatorApplicationTransactionEditor {
switch ($type) { switch ($type) {
case PholioTransactionType::TYPE_NAME: case PholioTransactionType::TYPE_NAME:
case PholioTransactionType::TYPE_DESCRIPTION: case PholioTransactionType::TYPE_DESCRIPTION:
case PholioTransactionType::TYPE_STATUS:
return $v; return $v;
case PholioTransactionType::TYPE_IMAGE_REPLACE: case PholioTransactionType::TYPE_IMAGE_REPLACE:
$u_img = $u->getNewValue(); $u_img = $u->getNewValue();

View file

@ -42,6 +42,10 @@ final class PholioPHIDTypeMock extends PhabricatorPHIDType {
$handle->setURI("/M{$id}"); $handle->setURI("/M{$id}");
$handle->setName("M{$id}"); $handle->setName("M{$id}");
$handle->setFullName("M{$id}: {$name}"); $handle->setFullName("M{$id}: {$name}");
if ($mock->isClosed()) {
$handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED);
}
} }
} }

View file

@ -9,6 +9,7 @@ final class PholioMockQuery
private $ids; private $ids;
private $phids; private $phids;
private $authorPHIDs; private $authorPHIDs;
private $statuses;
private $needCoverFiles; private $needCoverFiles;
private $needImages; private $needImages;
@ -30,6 +31,11 @@ final class PholioMockQuery
return $this; return $this;
} }
public function withStatuses(array $statuses) {
$this->statuses = $statuses;
return $this;
}
public function needCoverFiles($need_cover_files) { public function needCoverFiles($need_cover_files) {
$this->needCoverFiles = $need_cover_files; $this->needCoverFiles = $need_cover_files;
return $this; return $this;
@ -105,6 +111,13 @@ final class PholioMockQuery
$this->authorPHIDs); $this->authorPHIDs);
} }
if ($this->statuses) {
$where[] = qsprintf(
$conn_r,
'status IN (%Ls)',
$this->statuses);
}
return $this->formatWhereClause($where); return $this->formatWhereClause($where);
} }

View file

@ -12,6 +12,9 @@ final class PholioMockSearchEngine
$saved->setParameter( $saved->setParameter(
'authorPHIDs', 'authorPHIDs',
$this->readUsersFromRequest($request, 'authors')); $this->readUsersFromRequest($request, 'authors'));
$saved->setParameter(
'statuses',
$request->getStrList('status'));
return $saved; return $saved;
} }
@ -21,7 +24,8 @@ final class PholioMockSearchEngine
->needCoverFiles(true) ->needCoverFiles(true)
->needImages(true) ->needImages(true)
->needTokenCounts(true) ->needTokenCounts(true)
->withAuthorPHIDs($saved->getParameter('authorPHIDs', array())); ->withAuthorPHIDs($saved->getParameter('authorPHIDs', array()))
->withStatuses($saved->getParameter('statuses', array()));
return $query; return $query;
} }
@ -36,13 +40,27 @@ final class PholioMockSearchEngine
->withPHIDs($phids) ->withPHIDs($phids)
->execute(); ->execute();
$statuses = array(
''=>pht('Any Status'),
'closed'=>pht('Closed'),
'open'=>pht('Open'));
$status = $saved_query->getParameter('statuses', array());
$status = head($status);
$form $form
->appendChild( ->appendChild(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/users/') ->setDatasource('/typeahead/common/users/')
->setName('authors') ->setName('authors')
->setLabel(pht('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) { protected function getURI($path) {
@ -51,6 +69,7 @@ final class PholioMockSearchEngine
public function getBuiltinQueryNames() { public function getBuiltinQueryNames() {
$names = array( $names = array(
'open' => pht('Open Mocks'),
'all' => pht('All Mocks'), 'all' => pht('All Mocks'),
); );
@ -67,6 +86,10 @@ final class PholioMockSearchEngine
$query->setQueryKey($query_key); $query->setQueryKey($query_key);
switch ($query_key) { switch ($query_key) {
case 'open':
return $query->setParameter(
'statuses',
array('open'));
case 'all': case 'all':
return $query; return $query;
case 'authored': case 'authored':
@ -94,8 +117,14 @@ final class PholioMockSearchEngine
$board = new PHUIPinboardView(); $board = new PHUIPinboardView();
foreach ($mocks as $mock) { foreach ($mocks as $mock) {
$header = 'M'.$mock->getID().' '.$mock->getName();
if ($mock->isClosed()) {
$header = pht('%s (Closed)', $header);
}
$item = id(new PHUIPinboardItemView()) $item = id(new PHUIPinboardItemView())
->setHeader('M'.$mock->getID().' '.$mock->getName()) ->setHeader($header)
->setURI('/M'.$mock->getID()) ->setURI('/M'.$mock->getID())
->setImageURI($mock->getCoverFile()->getThumb280x210URI()) ->setImageURI($mock->getCoverFile()->getThumb280x210URI())
->setImageSize(280, 210) ->setImageSize(280, 210)

View file

@ -19,6 +19,7 @@ final class PholioMock extends PholioDAO
protected $description; protected $description;
protected $coverPHID; protected $coverPHID;
protected $mailKey; protected $mailKey;
protected $status;
private $images = self::ATTACHABLE; private $images = self::ATTACHABLE;
private $allImages = self::ATTACHABLE; private $allImages = self::ATTACHABLE;
@ -129,6 +130,17 @@ final class PholioMock extends PholioDAO
return $history; return $history;
} }
public function getStatuses() {
$options = array();
$options['closed'] = 'Closed';
$options['open'] = 'Open';
return $options;
}
public function isClosed() {
return ($this->getStatus() == 'closed');
}
/* -( PhabricatorSubscribableInterface Implementation )-------------------- */ /* -( PhabricatorSubscribableInterface Implementation )-------------------- */

View file

@ -66,6 +66,7 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
return 'fa-comment'; return 'fa-comment';
case PholioTransactionType::TYPE_NAME: case PholioTransactionType::TYPE_NAME:
case PholioTransactionType::TYPE_DESCRIPTION: case PholioTransactionType::TYPE_DESCRIPTION:
case PholioTransactionType::TYPE_STATUS:
case PholioTransactionType::TYPE_IMAGE_NAME: case PholioTransactionType::TYPE_IMAGE_NAME:
case PholioTransactionType::TYPE_IMAGE_DESCRIPTION: case PholioTransactionType::TYPE_IMAGE_DESCRIPTION:
case PholioTransactionType::TYPE_IMAGE_SEQUENCE: case PholioTransactionType::TYPE_IMAGE_SEQUENCE:
@ -105,6 +106,11 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
"%s updated the mock's description.", "%s updated the mock's description.",
$this->renderHandleLink($author_phid)); $this->renderHandleLink($author_phid));
break; break;
case PholioTransactionType::TYPE_STATUS:
return pht(
"%s updated the mock's status.",
$this->renderHandleLink($author_phid));
break;
case PholioTransactionType::TYPE_INLINE: case PholioTransactionType::TYPE_INLINE:
$count = 1; $count = 1;
foreach ($this->getTransactionGroup() as $xaction) { foreach ($this->getTransactionGroup() as $xaction) {
@ -207,6 +213,12 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
$this->renderHandleLink($author_phid), $this->renderHandleLink($author_phid),
$this->renderHandleLink($object_phid)); $this->renderHandleLink($object_phid));
break; 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: case PholioTransactionType::TYPE_INLINE:
return pht( return pht(
'%s added an inline comment to %s.', '%s added an inline comment to %s.',
@ -299,6 +311,7 @@ final class PholioTransaction extends PhabricatorApplicationTransaction {
return PhabricatorTransactions::COLOR_GREEN; return PhabricatorTransactions::COLOR_GREEN;
} }
case PholioTransactionType::TYPE_DESCRIPTION: case PholioTransactionType::TYPE_DESCRIPTION:
case PholioTransactionType::TYPE_STATUS:
case PholioTransactionType::TYPE_IMAGE_NAME: case PholioTransactionType::TYPE_IMAGE_NAME:
case PholioTransactionType::TYPE_IMAGE_DESCRIPTION: case PholioTransactionType::TYPE_IMAGE_DESCRIPTION:
case PholioTransactionType::TYPE_IMAGE_SEQUENCE: case PholioTransactionType::TYPE_IMAGE_SEQUENCE: