Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:facebook/phabricator
- Loading branch information
Showing
32 changed files
with
703 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/applications/conpherence/events/ConpherenceHovercardEventListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
/** | ||
* This event listener is tasked with probably one of the most important | ||
* missions in this world: Adding a Conpherence button to a hovercard. | ||
* | ||
* Handle with care when modifying! | ||
* | ||
* @task event | ||
*/ | ||
final class ConpherenceHovercardEventListener extends PhutilEventListener { | ||
|
||
public function register() { | ||
$this->listen(PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD); | ||
} | ||
|
||
public function handleEvent(PhutilEvent $event) { | ||
switch ($event->getType()) { | ||
case PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD: | ||
$this->handleHovercardEvent($event); | ||
break; | ||
} | ||
} | ||
|
||
private function handleHovercardEvent($event) { | ||
$hovercard = $event->getValue('hovercard'); | ||
$user = $event->getValue('object'); | ||
|
||
if (!($user instanceof PhabricatorUser)) { | ||
return; | ||
} | ||
|
||
$conpherence_uri = new PhutilURI( | ||
'/conpherence/new/?participant='.$user->getPHID()); | ||
$name = pht('Start a Conpherence'); | ||
$hovercard->addAction($name, $conpherence_uri, true); | ||
|
||
$event->setValue('hovercard', $hovercard); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
src/applications/differential/events/DifferentialHovercardEventListener.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php | ||
|
||
final class DifferentialHovercardEventListener extends PhutilEventListener { | ||
|
||
public function register() { | ||
$this->listen(PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD); | ||
} | ||
|
||
public function handleEvent(PhutilEvent $event) { | ||
switch ($event->getType()) { | ||
case PhabricatorEventType::TYPE_UI_DIDRENDERHOVERCARD: | ||
$this->handleHovercardEvent($event); | ||
break; | ||
} | ||
} | ||
|
||
private function handleHovercardEvent($event) { | ||
$viewer = $event->getUser(); | ||
$hovercard = $event->getValue('hovercard'); | ||
$object_handle = $event->getValue('handle'); | ||
$phid = $object_handle->getPHID(); | ||
$rev = $event->getValue('object'); | ||
|
||
if (!($rev instanceof DifferentialRevision)) { | ||
return; | ||
} | ||
|
||
$rev->loadRelationships(); | ||
$reviewer_phids = $rev->getReviewers(); | ||
$e_task = PhabricatorEdgeConfig::TYPE_DREV_HAS_RELATED_TASK; | ||
$edge_query = id(new PhabricatorEdgeQuery()) | ||
->withSourcePHIDs(array($phid)) | ||
->withEdgeTypes( | ||
array( | ||
$e_task, | ||
)); | ||
$edge_query->execute(); | ||
$tasks = $edge_query->getDestinationPHIDs(); | ||
|
||
$phids = array_merge( | ||
array( | ||
$rev->getAuthorPHID(), | ||
), | ||
$reviewer_phids, | ||
$tasks); | ||
|
||
$handles = id(new PhabricatorObjectHandleData($phids)) | ||
->setViewer($viewer) | ||
->loadHandles(); | ||
|
||
$hovercard->setTitle('D'.$rev->getID()); | ||
$hovercard->setDetail($rev->getTitle()); | ||
|
||
$hovercard->addField(pht('Author'), | ||
$handles[$rev->getAuthorPHID()]->renderLink()); | ||
|
||
$hovercard->addField(pht('Date'), | ||
phabricator_datetime($rev->getDateModified(), $viewer)); | ||
|
||
$hovercard->addField(pht('Reviewers'), | ||
implode_selected_handle_links(', ', $handles, $reviewer_phids)); | ||
|
||
if ($tasks) { | ||
$hovercard->addField(pht('Task(s)', count($tasks)), | ||
implode_selected_handle_links(', ', $handles, $tasks)); | ||
} | ||
|
||
if ($rev->getSummary()) { | ||
$hovercard->addField(pht('Summary'), | ||
phutil_utf8_shorten($rev->getSummary(), 120)); | ||
} | ||
|
||
$hovercard->addTag( | ||
DifferentialRevisionDetailView::renderTagForRevision($rev)); | ||
$hovercard->setColor(PhabricatorActionHeaderView::HEADER_BLUE); | ||
|
||
$event->setValue('hovercard', $hovercard); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.