Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14761095
D17358.id41744.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
11 KB
Referenced Files
None
Subscribers
None
D17358.id41744.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -2027,8 +2027,10 @@
'PhabricatorBadgesListController' => 'applications/badges/controller/PhabricatorBadgesListController.php',
'PhabricatorBadgesMailReceiver' => 'applications/badges/mail/PhabricatorBadgesMailReceiver.php',
'PhabricatorBadgesPHIDType' => 'applications/badges/phid/PhabricatorBadgesPHIDType.php',
+ 'PhabricatorBadgesProfileController' => 'applications/badges/controller/PhabricatorBadgesProfileController.php',
'PhabricatorBadgesQuality' => 'applications/badges/constants/PhabricatorBadgesQuality.php',
'PhabricatorBadgesQuery' => 'applications/badges/query/PhabricatorBadgesQuery.php',
+ 'PhabricatorBadgesRecipientsController' => 'applications/badges/controller/PhabricatorBadgesRecipientsController.php',
'PhabricatorBadgesRecipientsListView' => 'applications/badges/view/PhabricatorBadgesRecipientsListView.php',
'PhabricatorBadgesRemoveRecipientsController' => 'applications/badges/controller/PhabricatorBadgesRemoveRecipientsController.php',
'PhabricatorBadgesReplyHandler' => 'applications/badges/mail/PhabricatorBadgesReplyHandler.php',
@@ -6964,8 +6966,10 @@
'PhabricatorBadgesListController' => 'PhabricatorBadgesController',
'PhabricatorBadgesMailReceiver' => 'PhabricatorObjectMailReceiver',
'PhabricatorBadgesPHIDType' => 'PhabricatorPHIDType',
+ 'PhabricatorBadgesProfileController' => 'PhabricatorController',
'PhabricatorBadgesQuality' => 'Phobject',
'PhabricatorBadgesQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PhabricatorBadgesRecipientsController' => 'PhabricatorBadgesProfileController',
'PhabricatorBadgesRecipientsListView' => 'AphrontView',
'PhabricatorBadgesRemoveRecipientsController' => 'PhabricatorBadgesController',
'PhabricatorBadgesReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
@@ -6975,7 +6979,7 @@
'PhabricatorBadgesTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorBadgesTransactionComment' => 'PhabricatorApplicationTransactionComment',
'PhabricatorBadgesTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
- 'PhabricatorBadgesViewController' => 'PhabricatorBadgesController',
+ 'PhabricatorBadgesViewController' => 'PhabricatorBadgesProfileController',
'PhabricatorBarePageUIExample' => 'PhabricatorUIExample',
'PhabricatorBarePageView' => 'AphrontPageView',
'PhabricatorBaseURISetupCheck' => 'PhabricatorSetupCheck',
diff --git a/src/applications/badges/application/PhabricatorBadgesApplication.php b/src/applications/badges/application/PhabricatorBadgesApplication.php
--- a/src/applications/badges/application/PhabricatorBadgesApplication.php
+++ b/src/applications/badges/application/PhabricatorBadgesApplication.php
@@ -47,11 +47,14 @@
=> 'PhabricatorBadgesArchiveController',
'view/(?:(?P<id>\d+)/)?'
=> 'PhabricatorBadgesViewController',
- 'recipients/(?P<id>[1-9]\d*)/'
- => 'PhabricatorBadgesEditRecipientsController',
- 'recipients/(?P<id>[1-9]\d*)/remove/'
- => 'PhabricatorBadgesRemoveRecipientsController',
-
+ 'recipients/' => array(
+ '(?P<id>[1-9]\d*)/'
+ => 'PhabricatorBadgesRecipientsController',
+ '(?P<id>[1-9]\d*)/add/'
+ => 'PhabricatorBadgesEditRecipientsController',
+ '(?P<id>[1-9]\d*)/remove/'
+ => 'PhabricatorBadgesRemoveRecipientsController',
+ ),
),
);
}
diff --git a/src/applications/badges/controller/PhabricatorBadgesProfileController.php b/src/applications/badges/controller/PhabricatorBadgesProfileController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/badges/controller/PhabricatorBadgesProfileController.php
@@ -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;
+ }
+
+}
diff --git a/src/applications/badges/controller/PhabricatorBadgesRecipientsController.php b/src/applications/badges/controller/PhabricatorBadgesRecipientsController.php
new file mode 100644
--- /dev/null
+++ b/src/applications/badges/controller/PhabricatorBadgesRecipientsController.php
@@ -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);
+ }
+
+}
diff --git a/src/applications/badges/controller/PhabricatorBadgesViewController.php b/src/applications/badges/controller/PhabricatorBadgesViewController.php
--- a/src/applications/badges/controller/PhabricatorBadgesViewController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesViewController.php
@@ -1,7 +1,7 @@
<?php
final class PhabricatorBadgesViewController
- extends PhabricatorBadgesController {
+ extends PhabricatorBadgesProfileController {
public function shouldAllowPublic() {
return true;
@@ -14,35 +14,17 @@
$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($badge->getName());
- $crumbs->setBorder(true);
$title = $badge->getName();
- 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());
-
- $header = id(new PHUIHeaderView())
- ->setHeader($badge->getName())
- ->setUser($viewer)
- ->setPolicyObject($badge)
- ->setStatus($status_icon, $status_color, $status_name)
- ->setHeaderIcon('fa-trophy');
-
+ $header = $this->buildHeaderView();
$curtain = $this->buildCurtain($badge);
$details = $this->buildDetailsView($badge);
@@ -50,16 +32,6 @@
$badge,
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())
->setViewer($viewer)
->buildEditEngineCommentView($badge);
@@ -68,16 +40,18 @@
->setHeader($header)
->setCurtain($curtain)
->setMainColumn(array(
- $recipient_list,
$timeline,
$comment_view,
))
->addPropertySection(pht('Description'), $details);
+ $navigation = $this->buildSideNavView('view');
+
return $this->newPage()
->setTitle($title)
->setCrumbs($crumbs)
->setPageObjectPHIDs(array($badge->getPHID()))
+ ->setNavigation($navigation)
->appendChild($view);
}
@@ -116,7 +90,7 @@
$id = $badge->getID();
$edit_uri = $this->getApplicationURI("/edit/{$id}/");
$archive_uri = $this->getApplicationURI("/archive/{$id}/");
- $award_uri = $this->getApplicationURI("/recipients/{$id}/");
+ $award_uri = $this->getApplicationURI("/recipients/{$id}/add/");
$curtain = $this->newCurtainView($badge);
diff --git a/src/applications/badges/storage/PhabricatorBadgesTransaction.php b/src/applications/badges/storage/PhabricatorBadgesTransaction.php
--- a/src/applications/badges/storage/PhabricatorBadgesTransaction.php
+++ b/src/applications/badges/storage/PhabricatorBadgesTransaction.php
@@ -38,6 +38,10 @@
$type = $this->getTransactionType();
switch ($type) {
+ case PhabricatorTransactions::TYPE_CREATE:
+ return pht(
+ '%s created this badge.',
+ $this->renderHandleLink($author_phid));
case self::TYPE_NAME:
if ($old === null) {
return pht(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 23, 11:15 PM (19 h, 47 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7038198
Default Alt Text
D17358.id41744.diff (11 KB)
Attached To
Mode
D17358: Build Badges View page into more of a profile
Attached
Detach File
Event Timeline
Log In to Comment