Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14105539
D17358.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
14 KB
Referenced Files
None
Subscribers
None
D17358.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',
@@ -6942,7 +6944,6 @@
'PhabricatorPolicyInterface',
'PhabricatorApplicationTransactionInterface',
'PhabricatorSubscribableInterface',
- 'PhabricatorTokenReceiverInterface',
'PhabricatorFlaggableInterface',
'PhabricatorDestructibleInterface',
'PhabricatorConduitResultInterface',
@@ -6964,8 +6965,10 @@
'PhabricatorBadgesListController' => 'PhabricatorBadgesController',
'PhabricatorBadgesMailReceiver' => 'PhabricatorObjectMailReceiver',
'PhabricatorBadgesPHIDType' => 'PhabricatorPHIDType',
+ 'PhabricatorBadgesProfileController' => 'PhabricatorController',
'PhabricatorBadgesQuality' => 'Phobject',
'PhabricatorBadgesQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PhabricatorBadgesRecipientsController' => 'PhabricatorBadgesProfileController',
'PhabricatorBadgesRecipientsListView' => 'AphrontView',
'PhabricatorBadgesRemoveRecipientsController' => 'PhabricatorBadgesController',
'PhabricatorBadgesReplyHandler' => 'PhabricatorApplicationTransactionReplyHandler',
@@ -6975,7 +6978,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/PhabricatorBadgesEditRecipientsController.php b/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
--- a/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
+++ b/src/applications/badges/controller/PhabricatorBadgesEditRecipientsController.php
@@ -22,7 +22,7 @@
return new Aphront404Response();
}
- $view_uri = $this->getApplicationURI('view/'.$badge->getID().'/');
+ $view_uri = $this->getApplicationURI('recipients/'.$badge->getID().'/');
$awards = $badge->getAwards();
$recipient_phids = mpull($awards, 'getRecipientPHID');
@@ -79,13 +79,13 @@
->appendControl(
id(new AphrontFormTokenizerControl())
->setName('phids')
- ->setLabel(pht('Add Recipients'))
+ ->setLabel(pht('Recipients'))
->setDatasource(new PhabricatorPeopleDatasource()));
}
$dialog = id(new AphrontDialogView())
->setUser($viewer)
- ->setTitle(pht('Award Badges'))
+ ->setTitle(pht('Add Recipients'))
->appendForm($form)
->addCancelButton($view_uri)
->addSubmitButton(pht('Add Recipients'));
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/PhabricatorBadgesBadge.php b/src/applications/badges/storage/PhabricatorBadgesBadge.php
--- a/src/applications/badges/storage/PhabricatorBadgesBadge.php
+++ b/src/applications/badges/storage/PhabricatorBadgesBadge.php
@@ -5,7 +5,6 @@
PhabricatorPolicyInterface,
PhabricatorApplicationTransactionInterface,
PhabricatorSubscribableInterface,
- PhabricatorTokenReceiverInterface,
PhabricatorFlaggableInterface,
PhabricatorDestructibleInterface,
PhabricatorConduitResultInterface,
@@ -161,14 +160,6 @@
}
-/* -( PhabricatorTokenReceiverInterface )---------------------------------- */
-
-
- public function getUsersToNotifyOfTokenGiven() {
- return array($this->getCreatorPHID());
- }
-
-
/* -( PhabricatorDestructibleInterface )----------------------------------- */
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(
diff --git a/src/applications/badges/view/PhabricatorBadgesRecipientsListView.php b/src/applications/badges/view/PhabricatorBadgesRecipientsListView.php
--- a/src/applications/badges/view/PhabricatorBadgesRecipientsListView.php
+++ b/src/applications/badges/view/PhabricatorBadgesRecipientsListView.php
@@ -27,6 +27,18 @@
$badge,
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())
->setNoDataString(pht('This badge does not have any recipients.'))
->setFlush(true);
@@ -62,7 +74,7 @@
}
$box = id(new PHUIObjectBoxView())
- ->setHeaderText(pht('Recipients'))
+ ->setHeader($header)
->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)
->setObjectList($list);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 2:54 AM (20 h, 1 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6798041
Default Alt Text
D17358.diff (14 KB)
Attached To
Mode
D17358: Build Badges View page into more of a profile
Attached
Detach File
Event Timeline
Log In to Comment