mirror of
https://we.phorge.it/source/phorge.git
synced 2025-02-24 20:49:06 +01:00
Summary: Ref T13442. Ref T13157. There's a secret URI to look at an object's hovercard in a standalone view, but it's hard to remember and impossible to discover. In developer mode, add an action to "View Hovercard". Also add "View Handle", which primarily shows the object PHID. Test Plan: Viewed some objects, saw "Advanced/Developer...". Used "View Hovercard" to view hovercards and "View Handle" to view handles. Maniphest Tasks: T13442, T13157 Differential Revision: https://secure.phabricator.com/D20887
82 lines
1.7 KiB
PHP
82 lines
1.7 KiB
PHP
<?php
|
|
|
|
final class PhabricatorActionListView extends AphrontTagView {
|
|
|
|
private $actions = array();
|
|
private $object;
|
|
|
|
public function setObject(PhabricatorLiskDAO $object) {
|
|
$this->object = $object;
|
|
return $this;
|
|
}
|
|
|
|
public function addAction(PhabricatorActionView $view) {
|
|
$this->actions[] = $view;
|
|
return $this;
|
|
}
|
|
|
|
protected function getTagName() {
|
|
if (!$this->actions) {
|
|
return null;
|
|
}
|
|
|
|
return 'ul';
|
|
}
|
|
|
|
protected function getTagAttributes() {
|
|
$classes = array();
|
|
$classes[] = 'phabricator-action-list-view';
|
|
return array(
|
|
'class' => implode(' ', $classes),
|
|
);
|
|
}
|
|
|
|
protected function getTagContent() {
|
|
$viewer = $this->getViewer();
|
|
|
|
$event = new PhabricatorEvent(
|
|
PhabricatorEventType::TYPE_UI_DIDRENDERACTIONS,
|
|
array(
|
|
'object' => $this->object,
|
|
'actions' => $this->actions,
|
|
));
|
|
$event->setUser($viewer);
|
|
PhutilEventEngine::dispatchEvent($event);
|
|
|
|
$actions = $event->getValue('actions');
|
|
if (!$actions) {
|
|
return null;
|
|
}
|
|
|
|
foreach ($actions as $action) {
|
|
$action->setViewer($viewer);
|
|
}
|
|
|
|
$sort = array();
|
|
foreach ($actions as $key => $action) {
|
|
$sort[$key] = id(new PhutilSortVector())
|
|
->addInt($action->getOrder());
|
|
}
|
|
$sort = msortv($sort, 'getSelf');
|
|
$actions = array_select_keys($actions, array_keys($sort));
|
|
|
|
require_celerity_resource('phabricator-action-list-view-css');
|
|
|
|
$items = array();
|
|
foreach ($actions as $action) {
|
|
foreach ($action->getItems() as $item) {
|
|
$items[] = $item;
|
|
}
|
|
}
|
|
|
|
return $items;
|
|
}
|
|
|
|
public function getDropdownMenuMetadata() {
|
|
return array(
|
|
'items' => (string)hsprintf('%s', $this),
|
|
);
|
|
}
|
|
|
|
|
|
}
|