Skip to content

Commit

Permalink
Merge branch 'master' of github.com:facebook/phabricator
Browse files Browse the repository at this point in the history
  • Loading branch information
AnhNhan committed Apr 6, 2013
2 parents 5d6045b + 3b1a1ae commit 1b27a80
Show file tree
Hide file tree
Showing 32 changed files with 703 additions and 84 deletions.
32 changes: 30 additions & 2 deletions src/__celerity_resource_map__.php
Expand Up @@ -1733,7 +1733,7 @@
),
'javelin-behavior-maniphest-batch-editor' =>
array(
'uri' => '/res/d22661be/rsrc/js/application/maniphest/behavior-batch-editor.js',
'uri' => '/res/00accaec/rsrc/js/application/maniphest/behavior-batch-editor.js',
'type' => 'js',
'requires' =>
array(
Expand Down Expand Up @@ -1903,6 +1903,20 @@
),
'disk' => '/rsrc/js/application/uiexample/gesture-example.js',
),
'javelin-behavior-phabricator-hovercards' =>
array(
'uri' => '/res/65824840/rsrc/js/application/core/behavior-hovercard.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-behavior',
1 => 'javelin-behavior-device',
2 => 'javelin-stratcom',
3 => 'javelin-vector',
4 => 'phabricator-hovercard',
),
'disk' => '/rsrc/js/application/core/behavior-hovercard.js',
),
'javelin-behavior-phabricator-keyboard-pager' =>
array(
'uri' => '/res/56d64eff/rsrc/js/application/core/behavior-keyboard-pager.js',
Expand Down Expand Up @@ -3027,9 +3041,23 @@
),
'disk' => '/rsrc/css/layout/phabricator-header-view.css',
),
'phabricator-hovercard' =>
array(
'uri' => '/res/345f3fca/rsrc/js/application/core/Hovercard.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-install',
1 => 'javelin-dom',
2 => 'javelin-vector',
3 => 'javelin-request',
4 => 'javelin-uri',
),
'disk' => '/rsrc/js/application/core/Hovercard.js',
),
'phabricator-hovercard-view-css' =>
array(
'uri' => '/res/68d69a87/rsrc/css/layout/phabricator-hovercard-view.css',
'uri' => '/res/ed56200c/rsrc/css/layout/phabricator-hovercard-view.css',
'type' => 'css',
'requires' =>
array(
Expand Down
10 changes: 10 additions & 0 deletions src/__phutil_library_map__.php
Expand Up @@ -233,6 +233,7 @@
'ConpherenceEditor' => 'applications/conpherence/editor/ConpherenceEditor.php',
'ConpherenceFileWidgetView' => 'applications/conpherence/view/ConpherenceFileWidgetView.php',
'ConpherenceFormDragAndDropUploadControl' => 'applications/conpherence/view/ConpherenceFormDragAndDropUploadControl.php',
'ConpherenceHovercardEventListener' => 'applications/conpherence/events/ConpherenceHovercardEventListener.php',
'ConpherenceImageData' => 'applications/conpherence/constants/ConpherenceImageData.php',
'ConpherenceLayoutView' => 'applications/conpherence/view/ConpherenceLayoutView.php',
'ConpherenceListController' => 'applications/conpherence/controller/ConpherenceListController.php',
Expand Down Expand Up @@ -332,6 +333,7 @@
'DifferentialFreeformFieldSpecification' => 'applications/differential/field/specification/DifferentialFreeformFieldSpecification.php',
'DifferentialGitSVNIDFieldSpecification' => 'applications/differential/field/specification/DifferentialGitSVNIDFieldSpecification.php',
'DifferentialHostFieldSpecification' => 'applications/differential/field/specification/DifferentialHostFieldSpecification.php',
'DifferentialHovercardEventListener' => 'applications/differential/events/DifferentialHovercardEventListener.php',
'DifferentialHunk' => 'applications/differential/storage/DifferentialHunk.php',
'DifferentialHunkParser' => 'applications/differential/parser/DifferentialHunkParser.php',
'DifferentialHunkParserTestCase' => 'applications/differential/parser/__tests__/DifferentialHunkParserTestCase.php',
Expand Down Expand Up @@ -439,6 +441,7 @@
'DiffusionHistoryQuery' => 'applications/diffusion/query/history/DiffusionHistoryQuery.php',
'DiffusionHistoryTableView' => 'applications/diffusion/view/DiffusionHistoryTableView.php',
'DiffusionHomeController' => 'applications/diffusion/controller/DiffusionHomeController.php',
'DiffusionHovercardEventListener' => 'applications/diffusion/events/DiffusionHovercardEventListener.php',
'DiffusionInlineCommentController' => 'applications/diffusion/controller/DiffusionInlineCommentController.php',
'DiffusionInlineCommentPreviewController' => 'applications/diffusion/controller/DiffusionInlineCommentPreviewController.php',
'DiffusionLastModifiedController' => 'applications/diffusion/controller/DiffusionLastModifiedController.php',
Expand Down Expand Up @@ -1213,6 +1216,7 @@
'PhabricatorPasteViewController' => 'applications/paste/controller/PhabricatorPasteViewController.php',
'PhabricatorPeopleController' => 'applications/people/controller/PhabricatorPeopleController.php',
'PhabricatorPeopleEditController' => 'applications/people/controller/PhabricatorPeopleEditController.php',
'PhabricatorPeopleHovercardEventListener' => 'applications/people/event/PhabricatorPeopleHovercardEventListener.php',
'PhabricatorPeopleLdapController' => 'applications/people/controller/PhabricatorPeopleLdapController.php',
'PhabricatorPeopleListController' => 'applications/people/controller/PhabricatorPeopleListController.php',
'PhabricatorPeopleLogsController' => 'applications/people/controller/PhabricatorPeopleLogsController.php',
Expand Down Expand Up @@ -1745,6 +1749,8 @@
'celerity_generate_unique_node_id' => 'infrastructure/celerity/api.php',
'celerity_get_resource_uri' => 'infrastructure/celerity/api.php',
'celerity_register_resource_map' => 'infrastructure/celerity/map.php',
'implode_handle_links' => 'applications/phid/handle/view/render.php',
'implode_selected_handle_links' => 'applications/phid/handle/view/render.php',
'javelin_render_tag' => 'infrastructure/javelin/markup.php',
'javelin_tag' => 'infrastructure/javelin/markup.php',
'phabricator_date' => 'view/viewutils.php',
Expand Down Expand Up @@ -1979,6 +1985,7 @@
'ConpherenceEditor' => 'PhabricatorApplicationTransactionEditor',
'ConpherenceFileWidgetView' => 'ConpherenceWidgetView',
'ConpherenceFormDragAndDropUploadControl' => 'AphrontFormControl',
'ConpherenceHovercardEventListener' => 'PhutilEventListener',
'ConpherenceImageData' => 'ConpherenceConstants',
'ConpherenceLayoutView' => 'AphrontView',
'ConpherenceListController' => 'ConpherenceController',
Expand Down Expand Up @@ -2074,6 +2081,7 @@
'DifferentialFreeformFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialGitSVNIDFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialHostFieldSpecification' => 'DifferentialFieldSpecification',
'DifferentialHovercardEventListener' => 'PhutilEventListener',
'DifferentialHunk' => 'DifferentialDAO',
'DifferentialHunkParserTestCase' => 'PhabricatorTestCase',
'DifferentialHunkTestCase' => 'ArcanistPhutilTestCase',
Expand Down Expand Up @@ -2175,6 +2183,7 @@
'DiffusionHistoryQuery' => 'DiffusionQuery',
'DiffusionHistoryTableView' => 'DiffusionView',
'DiffusionHomeController' => 'DiffusionController',
'DiffusionHovercardEventListener' => 'PhutilEventListener',
'DiffusionInlineCommentController' => 'PhabricatorInlineCommentController',
'DiffusionInlineCommentPreviewController' => 'PhabricatorInlineCommentPreviewController',
'DiffusionLastModifiedController' => 'DiffusionController',
Expand Down Expand Up @@ -2914,6 +2923,7 @@
'PhabricatorPasteViewController' => 'PhabricatorPasteController',
'PhabricatorPeopleController' => 'PhabricatorController',
'PhabricatorPeopleEditController' => 'PhabricatorPeopleController',
'PhabricatorPeopleHovercardEventListener' => 'PhutilEventListener',
'PhabricatorPeopleLdapController' => 'PhabricatorPeopleController',
'PhabricatorPeopleListController' => 'PhabricatorPeopleController',
'PhabricatorPeopleLogsController' => 'PhabricatorPeopleController',
Expand Down
9 changes: 3 additions & 6 deletions src/applications/base/controller/PhabricatorController.php
Expand Up @@ -278,12 +278,9 @@ protected function renderHandlesForPHIDs(array $phids, $style = "\n") {
throw new Exception("Unknown handle list style '{$style}'!");
}

$items = array();
foreach ($phids as $phid) {
$items[] = $this->getHandle($phid)->renderLink();
}

return phutil_implode_html($style_map[$style], $items);
return implode_selected_handle_links($style_map[$style],
$this->getLoadedHandles(),
$phids);
}

protected function buildApplicationMenu() {
Expand Down
Expand Up @@ -50,7 +50,7 @@ private function buildResources() {
$resources[] = phutil_tag(
'style',
array('type' => 'text/css'),
Filesystem::readFile($webroot.'/rsrc/css/'.$path));
phutil_safe_html(Filesystem::readFile($webroot.'/rsrc/css/'.$path)));
}
return phutil_implode_html("\n", $resources);
}
Expand Down
28 changes: 23 additions & 5 deletions src/applications/config/view/PhabricatorSetupIssueView.php
Expand Up @@ -132,13 +132,25 @@ private function renderPhabricatorConfig(array $configs) {
"The current Phabricator configuration has these %d value(s):",
count($configs)));

$options = PhabricatorApplicationConfigOptions::loadAllOptions();
$hidden = array();
foreach ($options as $key => $option) {
if ($option->getHidden()) {
$hidden[$key] = true;
}
}

$table = null;
$dict = array();
foreach ($configs as $key) {
$dict[$key] = PhabricatorEnv::getUnrepairedEnvConfig($key);
if (isset($hidden[$key])) {
$dict[$key] = null;
} else {
$dict[$key] = PhabricatorEnv::getUnrepairedEnvConfig($key);
}
}
$table = $this->renderValueTable($dict);

$options = PhabricatorApplicationConfigOptions::loadAllOptions();
$table = $this->renderValueTable($dict, $hidden);

if ($this->getIssue()->getIsFatal()) {
$update_info = phutil_tag(
Expand Down Expand Up @@ -299,12 +311,18 @@ private function renderPHPConfig(array $configs) {
));
}

private function renderValueTable(array $dict) {
private function renderValueTable(array $dict, array $hidden = array()) {
$rows = array();
foreach ($dict as $key => $value) {
if (isset($hidden[$key])) {
$value = phutil_tag('em', array(), 'hidden');
} else {
$value = $this->renderValueForDisplay($value);
}

$cols = array(
phutil_tag('th', array(), $key),
phutil_tag('td', array(), $this->renderValueForDisplay($value)),
phutil_tag('td', array(), $value),
);
$rows[] = phutil_tag('tr', array(), $cols);
}
Expand Down
Expand Up @@ -36,6 +36,7 @@ public function getApplicationGroup() {
public function getEventListeners() {
return array(
new ConpherencePeopleMenuEventListener(),
new ConpherenceHovercardEventListener(),
);
}

Expand Down
@@ -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);
}

}

Expand Up @@ -30,7 +30,8 @@ public function getTitleGlyph() {

public function getEventListeners() {
return array(
new DifferentialPeopleMenuEventListener()
new DifferentialPeopleMenuEventListener(),
new DifferentialHovercardEventListener(),
);
}

Expand Down
@@ -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);
}

}

Expand Up @@ -277,13 +277,8 @@ public function renderUserList(array $user_phids) {
return phutil_tag('em', array(), pht('None'));
}

$links = array();
foreach ($user_phids as $user_phid) {
$handle = $this->getHandle($user_phid);
$links[] = $handle->renderLink();
}

return phutil_implode_html(', ', $links);
return implode_selected_handle_links(', ',
$this->getLoadedHandles(), $user_phids);
}


Expand Down Expand Up @@ -988,6 +983,14 @@ final protected function getHandle($phid) {
return $this->handles[$phid];
}

final protected function getLoadedHandles() {
if ($this->handles === null) {
throw new DifferentialFieldDataNotAvailableException($this);
}

return $this->handles;
}

/**
* Get the list of properties for a diff set by @{method:setManualDiff}.
*
Expand Down
Expand Up @@ -26,7 +26,8 @@ public function getFactObjectsForAnalysis() {

public function getEventListeners() {
return array(
new DiffusionPeopleMenuEventListener()
new DiffusionPeopleMenuEventListener(),
new DiffusionHovercardEventListener(),
);
}

Expand Down

0 comments on commit 1b27a80

Please sign in to comment.