1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Build Badges View page into more of a profile

Summary: Ref T10798. Cleans up the UI a little and adds a sidenav.

Test Plan: Review badge and recipients in sandbox.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T10798

Differential Revision: https://secure.phabricator.com/D17358
This commit is contained in:
Chad Little 2017-02-15 11:32:08 -08:00
parent 2f69cb5fe7
commit 9716e83d60
9 changed files with 187 additions and 54 deletions

View file

@ -2027,8 +2027,10 @@ phutil_register_library_map(array(
'PhabricatorBadgesListController' => 'applications/badges/controller/PhabricatorBadgesListController.php', 'PhabricatorBadgesListController' => 'applications/badges/controller/PhabricatorBadgesListController.php',
'PhabricatorBadgesMailReceiver' => 'applications/badges/mail/PhabricatorBadgesMailReceiver.php', 'PhabricatorBadgesMailReceiver' => 'applications/badges/mail/PhabricatorBadgesMailReceiver.php',
'PhabricatorBadgesPHIDType' => 'applications/badges/phid/PhabricatorBadgesPHIDType.php', 'PhabricatorBadgesPHIDType' => 'applications/badges/phid/PhabricatorBadgesPHIDType.php',
'PhabricatorBadgesProfileController' => 'applications/badges/controller/PhabricatorBadgesProfileController.php',
'PhabricatorBadgesQuality' => 'applications/badges/constants/PhabricatorBadgesQuality.php', 'PhabricatorBadgesQuality' => 'applications/badges/constants/PhabricatorBadgesQuality.php',
'PhabricatorBadgesQuery' => 'applications/badges/query/PhabricatorBadgesQuery.php', 'PhabricatorBadgesQuery' => 'applications/badges/query/PhabricatorBadgesQuery.php',
'PhabricatorBadgesRecipientsController' => 'applications/badges/controller/PhabricatorBadgesRecipientsController.php',
'PhabricatorBadgesRecipientsListView' => 'applications/badges/view/PhabricatorBadgesRecipientsListView.php', 'PhabricatorBadgesRecipientsListView' => 'applications/badges/view/PhabricatorBadgesRecipientsListView.php',
'PhabricatorBadgesRemoveRecipientsController' => 'applications/badges/controller/PhabricatorBadgesRemoveRecipientsController.php', 'PhabricatorBadgesRemoveRecipientsController' => 'applications/badges/controller/PhabricatorBadgesRemoveRecipientsController.php',
'PhabricatorBadgesReplyHandler' => 'applications/badges/mail/PhabricatorBadgesReplyHandler.php', 'PhabricatorBadgesReplyHandler' => 'applications/badges/mail/PhabricatorBadgesReplyHandler.php',
@ -6942,7 +6944,6 @@ phutil_register_library_map(array(
'PhabricatorPolicyInterface', 'PhabricatorPolicyInterface',
'PhabricatorApplicationTransactionInterface', 'PhabricatorApplicationTransactionInterface',
'PhabricatorSubscribableInterface', 'PhabricatorSubscribableInterface',
'PhabricatorTokenReceiverInterface',
'PhabricatorFlaggableInterface', 'PhabricatorFlaggableInterface',
'PhabricatorDestructibleInterface', 'PhabricatorDestructibleInterface',
'PhabricatorConduitResultInterface', 'PhabricatorConduitResultInterface',
@ -6964,8 +6965,10 @@ phutil_register_library_map(array(
'PhabricatorBadgesListController' => 'PhabricatorBadgesController', 'PhabricatorBadgesListController' => 'PhabricatorBadgesController',
'PhabricatorBadgesMailReceiver' => 'PhabricatorObjectMailReceiver', 'PhabricatorBadgesMailReceiver' => 'PhabricatorObjectMailReceiver',
'PhabricatorBadgesPHIDType' => 'PhabricatorPHIDType', 'PhabricatorBadgesPHIDType' => 'PhabricatorPHIDType',
'PhabricatorBadgesProfileController' => 'PhabricatorController',
'PhabricatorBadgesQuality' => 'Phobject', 'PhabricatorBadgesQuality' => 'Phobject',
'PhabricatorBadgesQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorBadgesQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorBadgesRecipientsController' => 'PhabricatorBadgesProfileController',
'PhabricatorBadgesRecipientsListView' => 'AphrontView', 'PhabricatorBadgesRecipientsListView' => 'AphrontView',
'PhabricatorBadgesRemoveRecipientsController' => 'PhabricatorBadgesController', 'PhabricatorBadgesRemoveRecipientsController' => 'PhabricatorBadgesController',
'PhabricatorBadgesReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler', 'PhabricatorBadgesReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
@ -6975,7 +6978,7 @@ phutil_register_library_map(array(
'PhabricatorBadgesTransaction' => 'PhabricatorApplicationTransaction', 'PhabricatorBadgesTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorBadgesTransactionComment' => 'PhabricatorApplicationTransactionComment', 'PhabricatorBadgesTransactionComment' => 'PhabricatorApplicationTransactionComment',
'PhabricatorBadgesTransactionQuery' => 'PhabricatorApplicationTransactionQuery', 'PhabricatorBadgesTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
'PhabricatorBadgesViewController' => 'PhabricatorBadgesController', 'PhabricatorBadgesViewController' => 'PhabricatorBadgesProfileController',
'PhabricatorBarePageUIExample' => 'PhabricatorUIExample', 'PhabricatorBarePageUIExample' => 'PhabricatorUIExample',
'PhabricatorBarePageView' => 'AphrontPageView', 'PhabricatorBarePageView' => 'AphrontPageView',
'PhabricatorBaseURISetupCheck' => 'PhabricatorSetupCheck', 'PhabricatorBaseURISetupCheck' => 'PhabricatorSetupCheck',

View file

@ -47,11 +47,14 @@ final class PhabricatorBadgesApplication extends PhabricatorApplication {
=> 'PhabricatorBadgesArchiveController', => 'PhabricatorBadgesArchiveController',
'view/(?:(?P<id>\d+)/)?' 'view/(?:(?P<id>\d+)/)?'
=> 'PhabricatorBadgesViewController', => 'PhabricatorBadgesViewController',
'recipients/(?P<id>[1-9]\d*)/' 'recipients/' => array(
=> 'PhabricatorBadgesEditRecipientsController', '(?P<id>[1-9]\d*)/'
'recipients/(?P<id>[1-9]\d*)/remove/' => 'PhabricatorBadgesRecipientsController',
=> 'PhabricatorBadgesRemoveRecipientsController', '(?P<id>[1-9]\d*)/add/'
=> 'PhabricatorBadgesEditRecipientsController',
'(?P<id>[1-9]\d*)/remove/'
=> 'PhabricatorBadgesRemoveRecipientsController',
),
), ),
); );
} }

View file

@ -22,7 +22,7 @@ final class PhabricatorBadgesEditRecipientsController
return new Aphront404Response(); return new Aphront404Response();
} }
$view_uri = $this->getApplicationURI('view/'.$badge->getID().'/'); $view_uri = $this->getApplicationURI('recipients/'.$badge->getID().'/');
$awards = $badge->getAwards(); $awards = $badge->getAwards();
$recipient_phids = mpull($awards, 'getRecipientPHID'); $recipient_phids = mpull($awards, 'getRecipientPHID');
@ -79,13 +79,13 @@ final class PhabricatorBadgesEditRecipientsController
->appendControl( ->appendControl(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())
->setName('phids') ->setName('phids')
->setLabel(pht('Add Recipients')) ->setLabel(pht('Recipients'))
->setDatasource(new PhabricatorPeopleDatasource())); ->setDatasource(new PhabricatorPeopleDatasource()));
} }
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
->setUser($viewer) ->setUser($viewer)
->setTitle(pht('Award Badges')) ->setTitle(pht('Add Recipients'))
->appendForm($form) ->appendForm($form)
->addCancelButton($view_uri) ->addCancelButton($view_uri)
->addSubmitButton(pht('Add Recipients')); ->addSubmitButton(pht('Add Recipients'));

View file

@ -0,0 +1,88 @@
<?php
abstract class PhabricatorBadgesProfileController
extends PhabricatorController {
private $badge;
public function setBadge(PhabricatorBadgesBadge $badge) {
$this->badge = $badge;
return $this;
}
public function getBadge() {
return $this->badge;
}
public function buildApplicationMenu() {
return $this->buildSideNavView()->getMenu();
}
protected function buildHeaderView() {
$viewer = $this->getViewer();
$badge = $this->getBadge();
$id = $badge->getID();
if ($badge->isArchived()) {
$status_icon = 'fa-ban';
$status_color = 'dark';
} else {
$status_icon = 'fa-check';
$status_color = 'bluegrey';
}
$status_name = idx(
PhabricatorBadgesBadge::getStatusNameMap(),
$badge->getStatus());
return id(new PHUIHeaderView())
->setHeader($badge->getName())
->setUser($viewer)
->setPolicyObject($badge)
->setStatus($status_icon, $status_color, $status_name)
->setHeaderIcon('fa-trophy');
}
protected function buildApplicationCrumbs() {
$badge = $this->getBadge();
$id = $badge->getID();
$badge_uri = $this->getApplicationURI("/view/{$id}/");
$crumbs = parent::buildApplicationCrumbs();
$crumbs->addTextCrumb($badge->getName(), $badge_uri);
$crumbs->setBorder(true);
return $crumbs;
}
protected function buildSideNavView($filter = null) {
$viewer = $this->getViewer();
$badge = $this->getBadge();
$id = $badge->getID();
$can_edit = PhabricatorPolicyFilter::hasCapability(
$viewer,
$badge,
PhabricatorPolicyCapability::CAN_EDIT);
$nav = id(new AphrontSideNavFilterView())
->setBaseURI(new PhutilURI($this->getApplicationURI()));
$nav->addLabel(pht('Badge'));
$nav->addFilter(
'view',
pht('View Badge'),
$this->getApplicationURI("/view/{$id}/"),
'fa-trophy');
$nav->addFilter(
'recipients',
pht('View Recipients'),
$this->getApplicationURI("/recipients/{$id}/"),
'fa-group');
$nav->selectFilter($filter);
return $nav;
}
}

View file

@ -0,0 +1,58 @@
<?php
final class PhabricatorBadgesRecipientsController
extends PhabricatorBadgesProfileController {
public function shouldAllowPublic() {
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$id = $request->getURIData('id');
$badge = id(new PhabricatorBadgesQuery())
->setViewer($viewer)
->withIDs(array($id))
->needRecipients(true)
->executeOne();
if (!$badge) {
return new Aphront404Response();
}
$this->setBadge($badge);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Recipients'));
$crumbs->setBorder(true);
$title = $badge->getName();
$header = $this->buildHeaderView();
$awards = $badge->getAwards();
$recipient_phids = mpull($awards, 'getRecipientPHID');
$recipient_phids = array_reverse($recipient_phids);
$handles = $this->loadViewerHandles($recipient_phids);
$recipient_list = id(new PhabricatorBadgesRecipientsListView())
->setBadge($badge)
->setHandles($handles)
->setUser($viewer);
$view = id(new PHUITwoColumnView())
->setHeader($header)
->setFooter(array(
$recipient_list,
));
$navigation = $this->buildSideNavView('recipients');
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setPageObjectPHIDs(array($badge->getPHID()))
->setNavigation($navigation)
->appendChild($view);
}
}

View file

@ -1,7 +1,7 @@
<?php <?php
final class PhabricatorBadgesViewController final class PhabricatorBadgesViewController
extends PhabricatorBadgesController { extends PhabricatorBadgesProfileController {
public function shouldAllowPublic() { public function shouldAllowPublic() {
return true; return true;
@ -14,35 +14,17 @@ final class PhabricatorBadgesViewController
$badge = id(new PhabricatorBadgesQuery()) $badge = id(new PhabricatorBadgesQuery())
->setViewer($viewer) ->setViewer($viewer)
->withIDs(array($id)) ->withIDs(array($id))
->needRecipients(true)
->executeOne(); ->executeOne();
if (!$badge) { if (!$badge) {
return new Aphront404Response(); return new Aphront404Response();
} }
$this->setBadge($badge);
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb($badge->getName());
$crumbs->setBorder(true);
$title = $badge->getName(); $title = $badge->getName();
if ($badge->isArchived()) { $header = $this->buildHeaderView();
$status_icon = 'fa-ban';
$status_color = 'dark';
} else {
$status_icon = 'fa-check';
$status_color = 'bluegrey';
}
$status_name = idx(
PhabricatorBadgesBadge::getStatusNameMap(),
$badge->getStatus());
$header = id(new PHUIHeaderView())
->setHeader($badge->getName())
->setUser($viewer)
->setPolicyObject($badge)
->setStatus($status_icon, $status_color, $status_name)
->setHeaderIcon('fa-trophy');
$curtain = $this->buildCurtain($badge); $curtain = $this->buildCurtain($badge);
$details = $this->buildDetailsView($badge); $details = $this->buildDetailsView($badge);
@ -50,16 +32,6 @@ final class PhabricatorBadgesViewController
$badge, $badge,
new PhabricatorBadgesTransactionQuery()); new PhabricatorBadgesTransactionQuery());
$awards = $badge->getAwards();
$recipient_phids = mpull($awards, 'getRecipientPHID');
$recipient_phids = array_reverse($recipient_phids);
$handles = $this->loadViewerHandles($recipient_phids);
$recipient_list = id(new PhabricatorBadgesRecipientsListView())
->setBadge($badge)
->setHandles($handles)
->setUser($viewer);
$comment_view = id(new PhabricatorBadgesEditEngine()) $comment_view = id(new PhabricatorBadgesEditEngine())
->setViewer($viewer) ->setViewer($viewer)
->buildEditEngineCommentView($badge); ->buildEditEngineCommentView($badge);
@ -68,16 +40,18 @@ final class PhabricatorBadgesViewController
->setHeader($header) ->setHeader($header)
->setCurtain($curtain) ->setCurtain($curtain)
->setMainColumn(array( ->setMainColumn(array(
$recipient_list,
$timeline, $timeline,
$comment_view, $comment_view,
)) ))
->addPropertySection(pht('Description'), $details); ->addPropertySection(pht('Description'), $details);
$navigation = $this->buildSideNavView('view');
return $this->newPage() return $this->newPage()
->setTitle($title) ->setTitle($title)
->setCrumbs($crumbs) ->setCrumbs($crumbs)
->setPageObjectPHIDs(array($badge->getPHID())) ->setPageObjectPHIDs(array($badge->getPHID()))
->setNavigation($navigation)
->appendChild($view); ->appendChild($view);
} }
@ -116,7 +90,7 @@ final class PhabricatorBadgesViewController
$id = $badge->getID(); $id = $badge->getID();
$edit_uri = $this->getApplicationURI("/edit/{$id}/"); $edit_uri = $this->getApplicationURI("/edit/{$id}/");
$archive_uri = $this->getApplicationURI("/archive/{$id}/"); $archive_uri = $this->getApplicationURI("/archive/{$id}/");
$award_uri = $this->getApplicationURI("/recipients/{$id}/"); $award_uri = $this->getApplicationURI("/recipients/{$id}/add/");
$curtain = $this->newCurtainView($badge); $curtain = $this->newCurtainView($badge);

View file

@ -5,7 +5,6 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO
PhabricatorPolicyInterface, PhabricatorPolicyInterface,
PhabricatorApplicationTransactionInterface, PhabricatorApplicationTransactionInterface,
PhabricatorSubscribableInterface, PhabricatorSubscribableInterface,
PhabricatorTokenReceiverInterface,
PhabricatorFlaggableInterface, PhabricatorFlaggableInterface,
PhabricatorDestructibleInterface, PhabricatorDestructibleInterface,
PhabricatorConduitResultInterface, PhabricatorConduitResultInterface,
@ -161,14 +160,6 @@ final class PhabricatorBadgesBadge extends PhabricatorBadgesDAO
} }
/* -( PhabricatorTokenReceiverInterface )---------------------------------- */
public function getUsersToNotifyOfTokenGiven() {
return array($this->getCreatorPHID());
}
/* -( PhabricatorDestructibleInterface )----------------------------------- */ /* -( PhabricatorDestructibleInterface )----------------------------------- */

View file

@ -38,6 +38,10 @@ final class PhabricatorBadgesTransaction
$type = $this->getTransactionType(); $type = $this->getTransactionType();
switch ($type) { switch ($type) {
case PhabricatorTransactions::TYPE_CREATE:
return pht(
'%s created this badge.',
$this->renderHandleLink($author_phid));
case self::TYPE_NAME: case self::TYPE_NAME:
if ($old === null) { if ($old === null) {
return pht( return pht(

View file

@ -27,6 +27,18 @@ final class PhabricatorBadgesRecipientsListView extends AphrontView {
$badge, $badge,
PhabricatorPolicyCapability::CAN_EDIT); PhabricatorPolicyCapability::CAN_EDIT);
$award_button = id(new PHUIButtonView())
->setTag('a')
->setIcon('fa-plus')
->setText(pht('Add Recipents'))
->setWorkflow(true)
->setDisabled(!$can_edit)
->setHref('/badges/recipients/'.$badge->getID().'/add/');
$header = id(new PHUIHeaderView())
->setHeader(pht('Recipients'))
->addActionLink($award_button);
$list = id(new PHUIObjectItemListView()) $list = id(new PHUIObjectItemListView())
->setNoDataString(pht('This badge does not have any recipients.')) ->setNoDataString(pht('This badge does not have any recipients.'))
->setFlush(true); ->setFlush(true);
@ -62,7 +74,7 @@ final class PhabricatorBadgesRecipientsListView extends AphrontView {
} }
$box = id(new PHUIObjectBoxView()) $box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Recipients')) ->setHeader($header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setObjectList($list); ->setObjectList($list);