phorge/src/view/layout/PhabricatorActionListView.php
epriestley 90258ed491 Fix property shadowing on ActionListView after conversion to TagView
Summary:
See D17222. D17209 accidentally broke setting IDs on ActionListView by converting it into a TagView: TagView already has an `id` property, and this new `id` property on the subclass shadows it.

Materially, the "Actions" mobile button in the headers of objects (for example: Maniphest Task -> shrink browser window -> click "Actions" next to task name) relies on setting IDs on list views.

Test Plan:
  - Viewed a task.
  - Made browser window narrow.
  - Clicked `[= Actions]` button.
  - After patch: saw a dropdown menu.

Reviewers: chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D17223
2017-01-18 13:14:24 -08:00

71 lines
1.4 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() {
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);
}
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),
);
}
}