mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 03:50:54 +01:00
Put Spaces on Hovercards and ObjectItemLists
Summary: Ref T8449. Test Plan: {F474186} {F474187} Reviewers: btrahan Reviewed By: btrahan Subscribers: chad, epriestley Maniphest Tasks: T8449 Differential Revision: https://secure.phabricator.com/D13173
This commit is contained in:
parent
4f0d61436b
commit
1e4e121956
8 changed files with 125 additions and 52 deletions
|
@ -1228,6 +1228,7 @@ phutil_register_library_map(array(
|
||||||
'PHUIPropertyListExample' => 'applications/uiexample/examples/PHUIPropertyListExample.php',
|
'PHUIPropertyListExample' => 'applications/uiexample/examples/PHUIPropertyListExample.php',
|
||||||
'PHUIPropertyListView' => 'view/phui/PHUIPropertyListView.php',
|
'PHUIPropertyListView' => 'view/phui/PHUIPropertyListView.php',
|
||||||
'PHUIRemarkupPreviewPanel' => 'view/phui/PHUIRemarkupPreviewPanel.php',
|
'PHUIRemarkupPreviewPanel' => 'view/phui/PHUIRemarkupPreviewPanel.php',
|
||||||
|
'PHUISpacesNamespaceContextView' => 'applications/spaces/view/PHUISpacesNamespaceContextView.php',
|
||||||
'PHUIStatusItemView' => 'view/phui/PHUIStatusItemView.php',
|
'PHUIStatusItemView' => 'view/phui/PHUIStatusItemView.php',
|
||||||
'PHUIStatusListView' => 'view/phui/PHUIStatusListView.php',
|
'PHUIStatusListView' => 'view/phui/PHUIStatusListView.php',
|
||||||
'PHUITagExample' => 'applications/uiexample/examples/PHUITagExample.php',
|
'PHUITagExample' => 'applications/uiexample/examples/PHUITagExample.php',
|
||||||
|
@ -4589,6 +4590,7 @@ phutil_register_library_map(array(
|
||||||
'PHUIPropertyListExample' => 'PhabricatorUIExample',
|
'PHUIPropertyListExample' => 'PhabricatorUIExample',
|
||||||
'PHUIPropertyListView' => 'AphrontView',
|
'PHUIPropertyListView' => 'AphrontView',
|
||||||
'PHUIRemarkupPreviewPanel' => 'AphrontTagView',
|
'PHUIRemarkupPreviewPanel' => 'AphrontTagView',
|
||||||
|
'PHUISpacesNamespaceContextView' => 'AphrontView',
|
||||||
'PHUIStatusItemView' => 'AphrontTagView',
|
'PHUIStatusItemView' => 'AphrontTagView',
|
||||||
'PHUIStatusListView' => 'AphrontTagView',
|
'PHUIStatusListView' => 'AphrontTagView',
|
||||||
'PHUITagExample' => 'PhabricatorUIExample',
|
'PHUITagExample' => 'PhabricatorUIExample',
|
||||||
|
|
|
@ -7,18 +7,17 @@ final class PhabricatorSearchHovercardController
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function processRequest() {
|
public function handleRequest(AphrontRequest $request) {
|
||||||
$request = $this->getRequest();
|
$viewer = $this->getViewer();
|
||||||
$user = $request->getUser();
|
|
||||||
|
|
||||||
$phids = $request->getArr('phids');
|
$phids = $request->getArr('phids');
|
||||||
|
|
||||||
$handles = id(new PhabricatorHandleQuery())
|
$handles = id(new PhabricatorHandleQuery())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->withPHIDs($phids)
|
->withPHIDs($phids)
|
||||||
->execute();
|
->execute();
|
||||||
$objects = id(new PhabricatorObjectQuery())
|
$objects = id(new PhabricatorObjectQuery())
|
||||||
->setViewer($user)
|
->setViewer($viewer)
|
||||||
->withPHIDs($phids)
|
->withPHIDs($phids)
|
||||||
->execute();
|
->execute();
|
||||||
|
|
||||||
|
@ -26,9 +25,15 @@ final class PhabricatorSearchHovercardController
|
||||||
|
|
||||||
foreach ($phids as $phid) {
|
foreach ($phids as $phid) {
|
||||||
$handle = $handles[$phid];
|
$handle = $handles[$phid];
|
||||||
|
$object = $objects[$phid];
|
||||||
|
|
||||||
$hovercard = new PhabricatorHovercardView();
|
$hovercard = id(new PhabricatorHovercardView())
|
||||||
$hovercard->setObjectHandle($handle);
|
->setUser($viewer)
|
||||||
|
->setObjectHandle($handle);
|
||||||
|
|
||||||
|
if ($object) {
|
||||||
|
$hovercard->setObject($object);
|
||||||
|
}
|
||||||
|
|
||||||
// Send it to the other side of the world, thanks to PhutilEventEngine
|
// Send it to the other side of the world, thanks to PhutilEventEngine
|
||||||
$event = new PhabricatorEvent(
|
$event = new PhabricatorEvent(
|
||||||
|
@ -36,9 +41,9 @@ final class PhabricatorSearchHovercardController
|
||||||
array(
|
array(
|
||||||
'hovercard' => $hovercard,
|
'hovercard' => $hovercard,
|
||||||
'handle' => $handle,
|
'handle' => $handle,
|
||||||
'object' => idx($objects, $phid),
|
'object' => $object,
|
||||||
));
|
));
|
||||||
$event->setUser($user);
|
$event->setUser($viewer);
|
||||||
PhutilEventEngine::dispatchEvent($event);
|
PhutilEventEngine::dispatchEvent($event);
|
||||||
|
|
||||||
$cards[$phid] = $hovercard;
|
$cards[$phid] = $hovercard;
|
||||||
|
|
|
@ -145,4 +145,33 @@ final class PhabricatorSpacesNamespaceQuery
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the Space PHID for an object, if one exists.
|
||||||
|
*
|
||||||
|
* This is intended to simplify performing a bunch of redundant checks; you
|
||||||
|
* can intentionally pass any value in (including `null`).
|
||||||
|
*
|
||||||
|
* @param wild
|
||||||
|
* @return phid|null
|
||||||
|
*/
|
||||||
|
public static function getObjectSpacePHID($object) {
|
||||||
|
if (!$object) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!($object instanceof PhabricatorSpacesInterface)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$space_phid = $object->getSpacePHID();
|
||||||
|
if ($space_phid === null) {
|
||||||
|
$default_space = self::getDefaultSpace();
|
||||||
|
if ($default_space) {
|
||||||
|
$space_phid = $default_space->getPHID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $space_phid;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
final class PHUISpacesNamespaceContextView extends AphrontView {
|
||||||
|
|
||||||
|
private $object;
|
||||||
|
|
||||||
|
public function setObject($object) {
|
||||||
|
$this->object = $object;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getObject() {
|
||||||
|
return $this->object;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render() {
|
||||||
|
$object = $this->getObject();
|
||||||
|
|
||||||
|
$space_phid = PhabricatorSpacesNamespaceQuery::getObjectSpacePHID($object);
|
||||||
|
if (!$space_phid) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$viewer = $this->getUser();
|
||||||
|
return phutil_tag(
|
||||||
|
'span',
|
||||||
|
array(
|
||||||
|
'class' => 'spaces-name',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
$viewer->renderHandle($space_phid),
|
||||||
|
' | ',
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -172,9 +172,14 @@ final class PHUIHeaderView extends AphrontTagView {
|
||||||
' ');
|
' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
$header = array();
|
$viewer = $this->getUser();
|
||||||
|
|
||||||
$header[] = $this->renderObjectSpaceInformation();
|
$header = array();
|
||||||
|
if ($viewer) {
|
||||||
|
$header[] = id(new PHUISpacesNamespaceContextView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setObject($this->policyObject);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->objectName) {
|
if ($this->objectName) {
|
||||||
$header[] = array(
|
$header[] = array(
|
||||||
|
@ -297,40 +302,4 @@ final class PHUIHeaderView extends AphrontTagView {
|
||||||
return array($icon, $link);
|
return array($icon, $link);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderObjectSpaceInformation() {
|
|
||||||
$viewer = $this->getUser();
|
|
||||||
|
|
||||||
$object = $this->policyObject;
|
|
||||||
if (!$object) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!($object instanceof PhabricatorSpacesInterface)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$space_phid = $object->getSpacePHID();
|
|
||||||
if ($space_phid === null) {
|
|
||||||
$default_space = PhabricatorSpacesNamespaceQuery::getDefaultSpace();
|
|
||||||
if ($default_space) {
|
|
||||||
$space_phid = $default_space->getPHID();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($space_phid === null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return phutil_tag(
|
|
||||||
'span',
|
|
||||||
array(
|
|
||||||
'class' => 'spaces-name',
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
$viewer->renderHandle($space_phid),
|
|
||||||
' | ',
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,7 @@ final class PHUIObjectItemListView extends AphrontTagView {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTagContent() {
|
protected function getTagContent() {
|
||||||
|
$viewer = $this->getUser();
|
||||||
require_celerity_resource('phui-object-item-list-view-css');
|
require_celerity_resource('phui-object-item-list-view-css');
|
||||||
|
|
||||||
$header = null;
|
$header = null;
|
||||||
|
@ -103,6 +104,11 @@ final class PHUIObjectItemListView extends AphrontTagView {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->items) {
|
if ($this->items) {
|
||||||
|
if ($viewer) {
|
||||||
|
foreach ($this->items as $item) {
|
||||||
|
$item->setUser($viewer);
|
||||||
|
}
|
||||||
|
}
|
||||||
$items = $this->items;
|
$items = $this->items;
|
||||||
} else if ($this->allowEmptyList) {
|
} else if ($this->allowEmptyList) {
|
||||||
$items = null;
|
$items = null;
|
||||||
|
|
|
@ -323,12 +323,21 @@ final class PHUIObjectItemView extends AphrontTagView {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTagContent() {
|
protected function getTagContent() {
|
||||||
|
$viewer = $this->getUser();
|
||||||
|
|
||||||
$content_classes = array();
|
$content_classes = array();
|
||||||
$content_classes[] = 'phui-object-item-content';
|
$content_classes[] = 'phui-object-item-content';
|
||||||
|
|
||||||
$header_name = null;
|
$header_name = array();
|
||||||
|
|
||||||
|
if ($viewer) {
|
||||||
|
$header_name[] = id(new PHUISpacesNamespaceContextView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setObject($this->object);
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->objectName) {
|
if ($this->objectName) {
|
||||||
$header_name = array(
|
$header_name[] = array(
|
||||||
phutil_tag(
|
phutil_tag(
|
||||||
'span',
|
'span',
|
||||||
array(
|
array(
|
||||||
|
|
|
@ -10,6 +10,7 @@ final class PhabricatorHovercardView extends AphrontView {
|
||||||
* @var PhabricatorObjectHandle
|
* @var PhabricatorObjectHandle
|
||||||
*/
|
*/
|
||||||
private $handle;
|
private $handle;
|
||||||
|
private $object;
|
||||||
|
|
||||||
private $title = array();
|
private $title = array();
|
||||||
private $detail;
|
private $detail;
|
||||||
|
@ -23,6 +24,15 @@ final class PhabricatorHovercardView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function setObject($object) {
|
||||||
|
$this->object = $object;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getObject() {
|
||||||
|
return $this->object;
|
||||||
|
}
|
||||||
|
|
||||||
public function setTitle($title) {
|
public function setTitle($title) {
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -65,13 +75,20 @@ final class PhabricatorHovercardView extends AphrontView {
|
||||||
throw new PhutilInvalidStateException('setObjectHandle');
|
throw new PhutilInvalidStateException('setObjectHandle');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$viewer = $this->getUser();
|
||||||
$handle = $this->handle;
|
$handle = $this->handle;
|
||||||
|
|
||||||
require_celerity_resource('phabricator-hovercard-view-css');
|
require_celerity_resource('phabricator-hovercard-view-css');
|
||||||
|
|
||||||
$title = pht('%s: %s',
|
$title = array(
|
||||||
|
id(new PHUISpacesNamespaceContextView())
|
||||||
|
->setUser($viewer)
|
||||||
|
->setObject($this->getObject()),
|
||||||
|
pht(
|
||||||
|
'%s: %s',
|
||||||
$handle->getTypeName(),
|
$handle->getTypeName(),
|
||||||
$this->title ? $this->title : $handle->getName());
|
$this->title ? $this->title : $handle->getName()),
|
||||||
|
);
|
||||||
|
|
||||||
$header = new PHUIActionHeaderView();
|
$header = new PHUIActionHeaderView();
|
||||||
$header->setHeaderColor($this->color);
|
$header->setHeaderColor($this->color);
|
||||||
|
|
Loading…
Reference in a new issue